Hiya. The way mobs are aggie now is the first person in the rooms people list. I'd like to make the aggression fo the mob random and have it attack from anyone it can see in the room. So far, I've set things up like so int can_hit(struct char_data *ch, struct char_data *vict) { if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE)) return 0; if (vict->in_room == ch->in_room) return 0; if (MOB_FLAGGED(ch, MOB_WIMPY) && AWAKE(vict)) return 0; if (!MOB_FLAGGED(ch, MOB_AGGR_TO_ALIGN) || (MOB_FLAGGED(ch, MOB_AGGR_EVIL) && IS_EVIL(vict)) || (MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) || (MOB_FLAGGED(ch, MOB_AGGR_GOOD) && IS_GOOD(vict))) return 1; return 0; } struct char_data *random_target(struct char_data *ch, int num) { struct char_data *pos[num]; struct char_data *temp, *vict; int i = 0; if(num <= 0) return NULL; for(vict = world[ch->in_room].people; vict; vict = vict->next_in_room) if(can_hit(ch, vict) && i <= num) { pos[i] = vict; i++; } temp = pos[number(0,num)]; if(!temp) return NULL; return temp; } Then, in mobile_activity I replaced the stock aggressive code with this: /* Aggressive Mobs */ if (MOB_FLAGGED(ch, MOB_AGGRESSIVE | MOB_AGGR_TO_ALIGN)) { for(vict = world[ch->in_room].people; vict; vict = vict->next_in_room) count++; vict = random_target(ch, count); if(vict && ch && ch->in_room == vict->in_room) hit(ch, vict, TYPE_UNDEFINED); } However, it crashes soon after I reboot and gives me the gdb output of: #0 0x8079ef7 in mobile_activity () at mobact.c:231 Source file is more recent than executable. 231 if (names->id == GET_IDNUM(vict)) { (gdb) bt #0 0x8079ef7 in mobile_activity () at mobact.c:231 Cannot access memory at address 0xbffff798. (gdb) list 226 found = FALSE; 227 for (vict = world[ch->in_room].people; vict && !found; vict = vict ->next_in_room) { 228 if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE)) 229 continue; 230 for (names = MEMORY(ch); names && !found; names = names->next) 231 if (names->id == GET_IDNUM(vict)) { 232 found = TRUE; 233 act("'Hey! You're the fiend that attacked me!!!', exclaims $n.", 234 FALSE, ch, 0, 0, TO_ROOM); 235 hit(ch, vict, TYPE_UNDEFINED); Now, I'm guessing the aggression code nulls the vict pointer up half the time, but it is re-defined on line 227. Any ideas on what the heck could be happening? Chuck --------------------------------------- Chuck Reed | Ash of Dark Horizon | master@i-55.com | dh.gator.net 6001 | --------------------------------------- +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST