CURSES.C
LIB3/STD/LIVING/CURSES.C · 2.6 KB
From the archive nm4dos.zip
Download the archive « Back to the archive contents
#pragma save_binary
/* the standard curses/diseases stuff to be inherited into the
* living object.
*
* Should be pretty easy stuff.
* Some of these functions are player specific... But the remove
* stuff can be done on npcs too.
*
* Curses/diseases objects to interface with this...
* The object should have some
* functions defined on it called player_quit, query_remove and
* player_start.
* The player_quit function is called when the player quits. This is
* used to clean up anthing that might need cleaning up.
* The query_remove function checks to see if the caller can remove it.
* this should be used by the clerics remove curse to check this. Should
* be pased the skill bonus in the appropriate skill.
* The player_start will be called when the player logs on.
*/
mapping curses, diseases;
void create()
{
curses = ([ ]);
diseases = ([ ]);
}
string query_curse( string name )
{
if( !curses )
curses = ([ ]);
return curses[ name ];
}
string query_disease( string name )
{
if( !diseases )
diseases = ([ ]);
return diseases[ name ];
}
mapping query_curses()
{
return curses;
}
mapping query_diseases()
{
return diseases;
}
int add_disease( string name, string ob )
{
if( !diseases )
diseases = ([ ]);
diseases[ name ] = ob;
return 1;
}
int remove_disease( string name )
{
if( !diseases )
diseases = ([ ]);
if( !diseases[ name ] )
return 0;
this_player()->destruct_disease( name );
diseases = m_delete( diseases, name );
return 1;
}
int remove_curse( string name )
{
if( !curses )
curses = ([ ]);
if( !curses[ name ] )
return 0;
this_player()->destruct_curse( name );
curses = m_delete( curses, name );
return 1;
}
int add_curse( string name, string ob )
{
if( !curses )
curses = ([ ]);
if( curses[ name ] )
remove_curse( name );
curses[ name ] = ob;
return 1;
}
void curses_quit()
{
if( !diseases )
diseases = ([ ]);
if( !curses )
curses = ([ ]);
filter_mapping( curses, "player_curses_quit", this_object() );
filter_mapping( diseases, "player_curses_quit", this_object() );
}
void player_curses_quit( object ob )
{
ob->player_quit();
}
void reset_curses()
{
curses = ([ ]);
}
void reset_diseases()
{
diseases = ([ ]);
}
void curses_start()
{
int i;
if( !diseases )
diseases = ([ ]);
if( !curses )
curses = ([ ]);
filter_mapping( curses, "player_curses_start", this_object() );
filter_mapping( diseases, "player_curses_start", this_object() );
}
int player_curses_start( object ob )
{
ob->player_start();
}