[CODE] - need a little help

From: Tom Dailey (tomd@waymark.net)
Date: 04/02/99

Hello,  the following code is supposed to let one player "guard" another
And if the second player gets attacked, the first player will come to their
But for some reason, when the player gets attacked, the "guard" gets a
"Use murder if you want to become a player-killer".

        struct char_data *vict;
        struct obj_data *found_obj = NULL;
        struct char_datat *found_char=NULL;
        int bits;

        one_argument(argument, arg);

   if (!has_skill(ch, SKILL_GUARD)) {
      send_to_char("You do not know how to guard anyone.\r\n", ch);

        if(!*arg) {
                send_to_char("Usage: guard <target>\r\n", ch);

        bits = generic_find(arg, FIND_CHAR_ROOM, ch, &found_char,

                vict = found_char;
        else {
                send_to_char("Guard whom?\r\n", ch);
        if(IS_NPC(vict)) {
                send_to_char("Guard a mobile? Huh-uh.\r\n", ch);

        if(ch->player_specials->guarding == vict) {
                ch->player_specials->guarding = NULL;
                vict->player_specials->guarded_by = NULL;
                sprintf(buf, "You stop guarding %s.\r\n", GET_NAME(vict));
                send_to_char(buf, ch);
                sprintf(buf, "%s stops guarding you.\r\n", GET_NAME(ch));
                send_to_char(buf, vict);
        } else {
                ch->player_specials->guarding = vict;
                vict->player_specials->guarded_by = ch;
                sprintf(buf,"You begin guarding %s.\r\n", GET_NAME(vict));
                send_to_char(buf, ch);
                sprintf(buf,"%s begins guarding you.\r\n", GET_NAME(ch));
                send_to_char(buf, vict);

and in fight.c where "we start one char fighting another.."

if(GET_GUARDIAN(vict)) {
          if(GET_GUARDIAN(vict)->in_room == vict->in_room) {
                  set_fighting(ch, GET_GUARDIAN(vict));
          } else {
                  sprintf(buf, "%s is being attacked!\r\n", GET_NAME(vict));
                  send_to_char(buf, GET_GUARDIAN(vict));

and in utils.h

#define GET_GUARDIAN(ch)        ((ch)->player_specials->guarded_by)
#define GET_GUARDING(ch)        ((ch)->player_specials->guarding)

and in structs.h in struct player_special_data

 struct char_data *guarding;
 struct char_data *guarded_by;

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |

This archive was generated by hypermail 2b30 : 12/15/00 PST