Welcome to the Builder Academy

Question re: scatter equipment across a zone on death

More
19 Mar 2025 00:41 - 19 Mar 2025 01:40 #10600 by zi
so... now don't get mad... but I DID have it in my original iteration, just at the end, which was wrong, so thank you!

For future generations: The nowhere check has to be first as does the real_room to convert to a rnum before the while.
Code:
  /* transfer NPC's equipment to corpse */   if (IS_NPC(ch)) {     for (i = 0; i < NUM_WEARS; i++)     if (GET_EQ(ch, i)) {       remove_otrigger(GET_EQ(ch, i), ch);       obj_to_obj(unequip_char(ch, i), corpse);     }   } else {   /* scatter player's equipment randomly across zone */    int top, bot, z, sendit;    z = world[IN_ROOM(ch)].zone;    bot = zone_table[z].bot;    top = zone_table[z].top;    for (i = 0; i < NUM_WEARS; i++)      if (GET_EQ(ch, i)) {      do {         sendit = real_room(rand_number(bot, top));         } while (sendit == NOWHERE || ROOM_FLAGGED(sendit, ROOM_DEATH) ||       ROOM_FLAGGED(sendit, ROOM_GODROOM) || ROOM_FLAGGED(sendit, ROOM_PRIVATE));       obj_to_room(unequip_char(ch, i), sendit);    } }

@thomas - does C work from interior parenthesis... out? For instance: my sendit calculation it looks like it grabs the random number FIRST and then pipes it through real_room. This would be helpful in thinking how to construct solutions with multiple functions.

and thanks as always for your help and patience!
Last edit: 19 Mar 2025 01:40 by zi.

Please Log in or Create an account to join the conversation.

More
19 Mar 2025 20:11 #10601 by thomas
Indeed - in this code, you're first generating a random room vnum in the range, then piping it through real_room, which will try to find a matching real room number, or NOWHERE, if the room isn't actually in the mud.

I'd add another guard to the else statement. Instead of just } else {, I'd check if the character is in a room.
Code:
} else if (IN_ROOM(ch) != NOWHERE) {
I can't remember if this check is done earlier in the function.

Please Log in or Create an account to join the conversation.

Time to create page: 0.283 seconds