Welcome to the Builder Academy

Question autoassist not working to assist charmies in group

More
15 Apr 2023 18:06 #10313 by Nero
Player A has a charmie both grouped with Player B
Player B has auto assist on.
Player A orders charmie to attack a mob
Player B is not autoassisting the charmie it keeps saying No on here by that name.
How do I fix this?
Code:
ACMD(do_assist) {   char arg[MAX_INPUT_LENGTH];   struct char_data *helpee, *opponent;   if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL)) {     send_to_char(ch, "%s", PEACE_ROOM_WARNING);     return;   }   if (FIGHTING(ch)) {     send_to_char(ch, "You're already fighting!  How can you assist someone else?\r\n");     return;   }   one_argument(argument, arg);   if (!*arg)     send_to_char(ch, "Whom do you wish to assist?\r\n");   else if (!(helpee = get_char_room_vis(ch, arg)))     send_to_char(ch, "%s", CONFIG_NOPERSON);   else if (helpee == ch)     send_to_char(ch, "You can't help yourself any more than this!\r\n");   else if (GET_POS(helpee) != POS_FIGHTING)     act("But nobody is fighting $M!", FALSE, ch, 0, helpee, TO_CHAR);   else {     /*      * Hit the same enemy the person you're helping is.      */     if (FIGHTING(helpee))       opponent = FIGHTING(helpee);     else       for (opponent = world[IN_ROOM(ch)].people; opponent && (FIGHTING(opponent) != helpee);            opponent = opponent->next_in_room)         ;     if (!opponent)       act("But nobody is fighting $M!", FALSE, ch, 0, helpee, TO_CHAR);     else if (!CAN_SEE(ch, opponent))       act("You can't see who is fighting $M!", FALSE, ch, 0, helpee, TO_CHAR);          /* prevent accidental pkill */          else if (IS_PC(opponent) && IS_PC(ch) && !ROOM_FLAGGED(IN_ROOM(ch), ROOM_ARENA))       act("Go to the Arena if you really want to attack $N.", FALSE,             (AFF_FLAGGED(ch, AFF_CHARM) ? ch->master : ch), 0, opponent, TO_CHAR);     else if (GET_POS(opponent) == POS_DEAD)       return;     else if (IN_ROOM(ch) != IN_ROOM(opponent))       return;     else {       send_to_char(ch, "Banzai! You join in the fight...\r\n");       act("$N assists you!", 0, helpee, 0, ch, TO_CHAR);       act("$n assists $N.", FALSE, ch, 0, helpee, TO_NOTVICT);       hit_with_wielded_weapon(ch, opponent, TYPE_UNDEFINED);     }   }   return; }
Code:
    /* auto-assist */  if (GROUP(ch) && GROUP(ch)->members && GROUP(ch)->members->iSize) {       struct iterator_data Iterator;       tch = (struct char_data *) merge_iterator(&Iterator, GROUP(ch)->members);     for (; tch ; tch = next_in_list(&Iterator)) {         if (tch == ch)           continue;         if (!IS_NPC(tch) && !PRF_FLAGGED(tch, PRF_AUTOASSIST))           continue;         if (IN_ROOM(ch) != IN_ROOM(tch))           continue;         if (FIGHTING(tch))           continue;         if (GET_POS(tch) != POS_STANDING)           continue;         if (!CAN_SEE(tch, ch))           continue;                do_assist(tch, GET_NAME(ch), 0, 0);                         }     }     if (!IS_NPC(ch) && GROUP(ch)) {       for (struct follow_type *k = ch->followers; k; k = k->next) {         /* should followers auto-assist master? */         /* New Method, check made on if a mobile or player is attempting an auto-assist.           Created to address SYSERR: Mob using           '((k->follower)->player_specials->saved.pref)' at fight.c:2598. Jason Phillips           3/29/2020 */         if (!IS_NPC(k->follower) && !FIGHTING(k->follower)             && AFF_FLAGGED(k->follower, AFF_GROUP) && PRF_FLAGGED(k->follower, PRF_AUTOASSIST)             && (k->follower->in_room == ch->in_room) && (GET_POS(k->follower) == POS_STANDING))           do_assist(k->follower, GET_NAME(ch), 0, 0);       }       /* should master auto-assist followers?  */       if (ch->master && !IS_NPC(ch->master) && FIGHTING(ch) && !FIGHTING(ch->master)           && AFF_FLAGGED(ch->master, AFF_GROUP) && PRF_FLAGGED(ch->master, PRF_AUTOASSIST)           && (ch->master->in_room == ch->in_room) && (GET_POS(ch->master) == POS_STANDING))         do_assist(ch->master, GET_NAME(ch), 0, 0);     }

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

More
19 Apr 2023 00:03 #10315 by Nero
I think I may have gotten this working
My get_char_room_vis is heavily modified and may be the issue
I discovered that when a player tries to auto assist a mob its looking for the first letter in its short description instead of its alias
for example if the mob's alias is janitor but the short description is a janitor, it will try to assist a and not find the mob in the room.
it seems to be working using this modification which searches for the short description as well. Hopefully no other issues arise from this:
Code:
struct char_data *get_num_char_room_vis(struct char_data *ch, const char *name, int *number) {   /* JE 7/18/94 :-) :-) */   if (!str_cmp(name, "self") || !str_cmp(name, "me"))     return (ch);   /* 0.<name> means PC with name */   if (number && *number == 0)     return get_player_vis(ch, name, 0, FIND_CHAR_ROOM); // room limited   for (struct char_data *i = world[IN_ROOM(ch)].people; i; i = i->next_in_room)     if (CAN_SEE(ch, i) && isname(name, i->player.name) || isname(name, i->player.short_descr))       if (!number || --(*number) <= 0)         return i;   return NULL; }
The following user(s) said Thank You: doogie

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

Time to create page: 0.287 seconds