/* fear - scared mobs fight or flee - Fallon 01.09 */
void fear_update( void )
{
CHAR_DATA *ch;
CHAR_DATA *ch_next;
CHAR_DATA *rch;
CHAR_DATA *rch_next;
CHAR_DATA *victim;
EXIT_DATA *pexit;
OBJ_DATA *obj;
OBJ_DATA *obj_next;
int door;
/* examine all mobs */
for ( ch = char_list; ch != NULL; ch = ch_next )
{
ch_next = ch->next;
if ( !IS_NPC(ch) || ch->in_room == NULL || ch->in_room->area->empty
|| ch->position != POS_STANDING || IS_AFFECTED(ch, AFF_CHARM) )
continue;
/* see if there's scary stuff around */
for ( obj = ch->in_room->contents; obj; obj = obj_next )
{
obj_next = obj->next_content;
if ( obj->item_type == ITEM_CORPSE_PC
|| obj->item_type == ITEM_CORPSE_NPC )
{
/* bodies that look like your own, very scary! */
if ( obj->race == ch->race )
{
ch->fear += 40;
}
else
ch->fear += 20;
}
/* body parts (food on the ground tends to be legs) */
if ( obj->item_type == ITEM_FOOD )
{
ch->fear += 10;
}
}
for ( rch = ch->in_room->people; rch != NULL; rch = rch_next )
{
rch_next = rch->next_in_room;
if ( (victim = rch->fighting) != NULL && can_see(ch, victim) )
{
/* big mobs scare little ones */
if ( victim->level > ch->level + 5 )
ch->fear += 35;
else
ch->fear += 20;
/* fight (check for assist) */
if ( ch->fear > 110 && number_range(1, 6) < 2
&& !IS_SET(ch->act, ACT_WIMPY)
&& victim->level < ch->level + 2
&& victim->level > ch->level - 4 )
{
do_function(ch, &do_emote,
"`Yshrieks in anger and joins the fight!`x");
multi_hit(ch, victim, TYPE_UNDEFINED);
break;
}
}
}
/* flee (based on wander_flag_update) */
if ( !IS_SET(ch->act, ACT_SENTINEL) && ch->position == POS_STANDING
&& ch->fear > 80 )
{
door = ch->door;
if ( door )
{
if ( (pexit = ch->in_room->exit[door]) != NULL
&& pexit->u1.to_room != NULL
&& !IS_SET(pexit->exit_info, EX_CLOSED)
&& !IS_SET(pexit->u1.to_room->room_flags, ROOM_NO_MOB)
&& ( !IS_SET(ch->act, ACT_STAY_AREA)
|| pexit->u1.to_room->area == ch->in_room->area )
&& ( !IS_SET(ch->act, ACT_OUTDOORS)
|| !IS_SET(pexit->u1.to_room->room_flags, ROOM_INDOORS) )
&& ( !IS_SET(ch->act, ACT_INDOORS)
|| IS_SET(pexit->u1.to_room->room_flags, ROOM_INDOORS) ) )
{
move_char( ch, door, FALSE );
}
else
ch->door = number_range( 0, 5 );
}
else
ch->door = number_range( 0, 5 );
}
ch->fear = ch->fear * 2 / 3;
}
return;
}
Hey, this is why I do what I do. I really believe games to be the ultimate art form. I stand up on my pedestal and laugh at all the other arts. Possibly throw things at them.
I blame the Tanqueray. I get rambly. You can tell how sober I am now, though, given how I'm cutting this post sho