/
LIB3/
LIB3/D/ADMIN/
LIB3/D/ADMIN/OBJ/
LIB3/D/ADMIN/ROOM/W/
LIB3/D/HOME/
LIB3/D/HOME/CITY/ARENA/
LIB3/D/HOME/CITY/ITEMS/
LIB3/D/HOME/CITY/POSTOFFI/
LIB3/DOC/
LIB3/GLOBAL/SPECIAL/
LIB3/GLOBAL/VIRTUAL/
LIB3/NET/
LIB3/NET/CONFIG/
LIB3/NET/DAEMON/CHARS/
LIB3/NET/GOPHER/
LIB3/NET/INHERIT/
LIB3/NET/OBJ/
LIB3/NET/SAVE/
LIB3/NET/VIRTUAL/
LIB3/OBJ/B_DAY/
LIB3/OBJ/HANDLERS/TERM_TYP/
LIB3/PLAYERS/B/
LIB3/PLAYERS/N/
LIB3/ROOM/
LIB3/SAVE/
LIB3/SAVE/BOARDS/
LIB3/SAVE/ENVIRON/
LIB3/SAVE/POST/
LIB3/STD/COMMANDS/SHADOWS/
LIB3/STD/CREATOR/
LIB3/STD/DOM/
LIB3/STD/EFFECTS/
LIB3/STD/EFFECTS/HEALING/
LIB3/STD/EFFECTS/OTHER/
LIB3/STD/EFFECTS/POISONS/
LIB3/STD/ENVIRON/
LIB3/STD/GUILDS/
LIB3/STD/LIQUIDS/
LIB3/STD/ROOM/
LIB3/STD/TRIGGER/SHADOW/
LIB3/W/
LIB3/W/BANNOR/
LIB3/W/NEWSTYLE/
/* /obj/handlers/monster-handler.c */

/* Keeps track of monsters that need desting, as well as shadow_names
 * (don't ask me what shadow_names are for though) - Bannor
 *
 * When a room unloads, it should call zap_monster() on each monster
 * that it's cloned.  Zap_monster() will dest the monster if it's
 * no being attacked and is not in a room where interactive folk
 * might see it go bye-bye.
 *
 */


/* prototypes */
void    zap_monster( object monster );
object *query_destable_monsters();
int     check_for_interactive( object *obj_list );



int     num;
object *destable_monsters;



void    create()
{
    seteuid( "Root" );
    restore_object( "/save/monster-handler" );
    destable_monsters = ({ });
}				/* create() */


void    reset()
{
    int     count;

    /* dest any idle monsters that are on our list. */
    for( count = 0; count < sizeof( destable_monsters ); count++ )
	zap_monster( destable_monsters[ count ] );

}				/* reset() */


string  query_shadow_name()
{
    num++;
    save_object( "/save/monster-handler" );
    return( "/tmp/mon-shad/frog-" + num );
}				/* query_shadow_name() */


void    zap_monster( object monster )
{
    object *room_obs;


    if( !monster )
	return 0;
    if( monster->query_attacker_list() )
    {
	/* no one is attacking it, check to see if anyone will see */
	/* it getting zapped */
	if( !objectp( monster ) )
	    return;
	room_obs = all_inventory( environment( monster ) );
	if( !check_for_interactive( room_obs ) )
	{
	    monster->dest_me();
	    if( member_array( monster, destable_monsters ) != -1 )
		destable_monsters -= monster;
	}
    }
    if( monster )
    {
	/* didn't dest, so make sure it's in the 'to-dest' list. */
	if( member_array( monster, destable_monsters ) != -1 )
	    destable_monsters += monster;
    }

}				/* dest_monster() */


int     check_for_interactive( object *obj_list )
{
    int     count, return_value;

    return_value = 0;		/* no interactives in the room */
    for( count = 0; count < sizeof( obj_list ); count++ )
    {
	if( interactive( obj_list[ count ] ) )
	{
	    return_value = 1;
	    break;
	}
    }
    return return_value;

}				/* check_for_interactive() */


object *query_destable_monsters()
{
    return destable_monsters;
}				/* query_destable_monsters() */