bool is_safe (CHAR_DATA * victim)
{
CHAR_DATA * ch;
if (victim->in_room == NULL || ch->in_room == NULL)
return TRUE;
if (victim->fighting == ch || victim == ch)
return FALSE;
if (IS_IMMORTAL (ch) && ch->level > LEVEL_IMMORTAL)
return FALSE;
/* killing mobiles */
if (IS_NPC (victim))
{
/* safe room? */
if (IS_SET (victim->in_room->room_flags, ROOM_SAFE))
{
send_to_char ("Not in this room.\n\r", ch);
return TRUE;
}
if (victim->pIndexData->pShop != NULL)
{
send_to_char ("The shopkeeper wouldn't like that.\n\r", ch);
return TRUE;
}
/* no killing healers, trainers, etc */
if (IS_SET (victim->act, ACT_TRAIN)
|| IS_SET (victim->act, ACT_IS_HEALER)
|| IS_SET (victim->act, ACT_IS_CHANGER))
{
send_to_char ("I don't think Mota would approve.\n\r", ch);
return TRUE;
}
if (!IS_NPC (ch))
{
/* no pets */
if (IS_SET (victim->act, ACT_PET))
{
act ("But $N looks so cute and cuddly…",
ch, NULL, victim, TO_CHAR);
return TRUE;
}
/* no charmed creatures unless owner */
if (IS_AFFECTED (victim, AFF_CHARM) && ch != victim->master)
{
send_to_char ("You don't own that monster.\n\r", ch);
return TRUE;
}
}
}
/* killing players */
else
{
/* NPC doing the killing */
if (IS_NPC (ch))
{
/* safe room check */
if (IS_SET (victim->in_room->room_flags, ROOM_SAFE))
{
send_to_char ("Not in this room.\n\r", ch);
return TRUE;
}
/* charmed mobs and pets cannot attack players while owned */
if (IS_AFFECTED (ch, AFF_CHARM) && ch->master != NULL
&& ch->master->fighting != victim)
{
send_to_char ("Players are your friends!\n\r", ch);
return TRUE;
}
}
/* player doing the killing */
else
{
if (IS_SET (victim->in_room->room_flags, ROOM_SAFE))
{
if (IS_SET (victim->act, PLR_KILLER)
|| IS_SET (victim->act, PLR_THIEF)
|| IS_SET (victim->act, PLR_VIOLENT))
return FALSE;
else
{
send_to_char ("Not in this room.\n\r", ch);
return TRUE;
}
}
if (ch->level > victim->level + 8)
{
send_to_char ("Pick on someone your own size.\n\r", ch);
return TRUE;
}
}
}
return FALSE;
}
bool is_safe (CHAR_DATA *ch, CHAR_DATA * victim)
bool is_safe (CHAR_DATA * victim)
{
if ( victim->in_room == NULL )
return TRUE;
@@ if ( IS_IMMORTAL( victim ) ) //<— I assume you have that defined?
return TRUE;
/* killing mobiles */
if ( IS_NPC( victim ) )
{
/* safe room? */
if ( IS_SET( victim->in_room->room_flags, ROOM_SAFE ) )
{
// send_to_char ( "Not in this room.\r\n", ch );
return TRUE;
}
if ( victim->pIndexData->pShop != NULL )
{
// send_to_char ( "The shopkeeper wouldn't like that.\r\n", ch );
return TRUE;
}
/* no killing healers, trainers, etc */
if ( IS_SET( victim->act, ACT_TRAIN )
|| IS_SET( victim->act, ACT_IS_HEALER )
|| IS_SET( victim->act, ACT_IS_CHANGER ) )
{
// send_to_char ( "I don't think Mota would approve.\r\n", ch );
return TRUE;
}
}
/* killing players */
else
{
if ( IS_SET( victim->in_room->room_flags, ROOM_SAFE ) )
{
if ( IS_SET ( victim->act, PLR_KILLER )
|| IS_SET ( victim->act, PLR_THIEF )
|| IS_SET ( victim->act, PLR_VIOLENT ) )
return FALSE;
else
{
// send_to_char ( "Not in this room.\r\n", ch );
return TRUE;
}
}
}
return FALSE;
}
bool is_safe (CHAR_DATA * victim)
{
CHAR_DATA * ch; //See here? ch is defined, but nothing is assigned to it, and there's no way to.
if (victim->in_room == NULL || ch->in_room == NULL) //Uh oh. ch->in_room is NULL. because ch is NULL.
return TRUE;
if (victim->fighting == ch || victim == ch) //This isn't going to work either, because again, ch is NULL.
return FALSE;
if (IS_IMMORTAL (ch) && ch->level > LEVEL_IMMORTAL) //Yep, more checking against a NULL value.
return FALSE;
/* killing mobiles */
if (IS_NPC (victim))
{
/* safe room? */
if (IS_SET (victim->in_room->room_flags, ROOM_SAFE))
{
send_to_char ("Not in this room.\n\r", ch); //sending the message to ch?
return TRUE;
}
if (victim->pIndexData->pShop != NULL)
{
send_to_char ("The shopkeeper wouldn't like that.\n\r", ch); //Again with the sending to ch…
return TRUE;
}
/* no killing healers, trainers, etc */
if (IS_SET (victim->act, ACT_TRAIN)
|| IS_SET (victim->act, ACT_IS_HEALER)
|| IS_SET (victim->act, ACT_IS_CHANGER))
{
send_to_char ("I don't think Mota would approve.\n\r", ch); //Again…
return TRUE;
}
if (!IS_NPC (ch)) //Yep, this isn't going to work either. ch doesn't have a value.
{
/* no pets */
if (IS_SET (victim->act, ACT_PET))
{
act ("But $N looks so cute and cuddly…",
ch, NULL, victim, TO_CHAR);
return TRUE;
}
/* no charmed creatures unless owner */
if (IS_AFFECTED (victim, AFF_CHARM) && ch != victim->master) //Again…
{
send_to_char ("You don't own that monster.\n\r", ch); //And again…
return TRUE;
}
}
}
/* killing players */
else
{
/* NPC doing the killing */
if (IS_NPC (ch)) //Nope, not gonna work here either.
{
/* safe room check */
if (IS_SET (victim->in_room->room_flags, ROOM_SAFE))
{
send_to_char ("Not in this room.\n\r", ch); //I suppose this works if you don't want anyone to ever see it…
return TRUE;
}
/* charmed mobs and pets cannot attack players while owned */
if (IS_AFFECTED (ch, AFF_CHARM) && ch->master != NULL
&& ch->master->fighting != victim) //Yeah.. about that… There is no ch.
{
send_to_char ("Players are your friends!\n\r", ch);
return TRUE;
}
}
/* player doing the killing */
else
{
if (IS_SET (victim->in_room->room_flags, ROOM_SAFE))
{
if (IS_SET (victim->act, PLR_KILLER)
|| IS_SET (victim->act, PLR_THIEF)
|| IS_SET (victim->act, PLR_VIOLENT))
return FALSE;
else
{
send_to_char ("Not in this room.\n\r", ch);
return TRUE;
}
}
if (ch->level > victim->level + 8)
{
send_to_char ("Pick on someone your own size.\n\r", ch);
return TRUE;
}
}
}
return FALSE;
}
I decided to only have it check if the victim was safe, as in all cases it is the victim being attacked etc. Now of
course I do CHAR_DATA * ch; at the start of is safe and is safe spell and it all compiles etc but with the uninitialized
errors in those two. I can post it if you want, but its just the regular bool is_safe with just (CHAR_DATA * victim)
and the CHAR_DATA * ch; is called inside, the rest is mostly stock cept at the end I added to see if victm->violent
but when i ran it just to see no one is ever safe… basically :P If someone would help me i can PM you the code if
this is too vague, I just didnt wanna post all that in here as its mainly stock. Im starving to death and super tired
so hopefully this is something silly I can fix.