/
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/
#pragma save_binary
#include "monster.h"
mixed  *spells;

void    create()
{
    spells = ({ });
}

void    do_shadow()
{
    int     i, num;
    object  ob;
    string  fname;

/* do we wint the sleaze of the year award????  */
    this_object()->shadow_death();
    fname = (string)MONSTER_HAND->query_shadow_name();
    rm( fname + ".c" );
    for( i = 0; i < sizeof( spells ); i += 2 )
	write_file( fname + ".c", "inherit \"/std/trigger/" + spells[ i ] + "\";\n" );
    write_file( fname + ".c", read_file( "/std/living/mon-shadow.c" ) );
    ob = clone_object( fname );
    ob->setup_shadow( this_object() );
    rm( fname + ".c" );

}

int     add_triggered_action( string name, string trigger, mixed ob,
			      string func )
{
    int     i, j;

    if( (i = member_array( trigger, spells )) == -1 )
    {
	spells += ({ trigger, ({ name, ({ ob, func }) }) });
	do_shadow();
    }
    else
	if( (j = member_array( name, spells[ i + 1 ] )) == -1 )
	    spells[ i + 1 ] += ({ name, ({ ob, func }) });
	else
	    spells[ i + 1 ][ j + 1 ] = ({ ob, func });
}

int     remove_trigger( string name )
{
    int     i;

    if( (i = member_array( name, spells )) == -1 )
	return 0;
    spells = delete( spells, i, 2 );
    if( !sizeof( spells ) )
	this_object()->shadow_death();
    else
	do_shadow();
    return 1;
}

int     remove_triggered_action( string trigger, string name )
{
    int     i, j;

    if( (i = member_array( trigger, spells )) == -1 )
	return 0;
    if( (j = member_array( name, spells[ i + 1 ] )) == -1 )
	return 0;
    spells[ i + 1 ] = delete( spells[ i + 1 ], i, 2 );
    if( !sizeof( spells[ i + 1 ] ) )
	remove_trigger( trigger );
    return 1;
}

mixed * query_actions( string trigger )
{
    int     i;

    if( (i = member_array( trigger, spells )) == -1 )
	return({ });
    return spells[ i + 1 ];
}

mixed * query_spells()
{
    return spells;
}