STANDARD.C
LIB3/STD/GUILDS/STANDARD.C · 3.7 KB
From the archive nm4dos.zip
Download the archive « Back to the archive contents
inherit "/std/object";
#include "skills.h"
#include "commands.h"
#include "tune.h"
string *commands;
mixed spells;
int heal_loop;
string start_pos;
void create()
{
commands = ({ });
spells = ({ });
start_pos = "/d/home/city/newbiepub1";
::create();
}
void set_start_pos( string str )
{
start_pos = str;
}
string query_start_pos()
{
return start_pos;
}
int add_command( string name, int add_if_player )
{
if( member_array( name, commands ) != -1 )
return 0;
commands += ({ name, ({ add_if_player }) });
return 1;
}
int remove_command( string name )
{
int i;
if( (i = member_array( name, commands )) == -1 )
return 0;
commands = delete( commands, i, 1 );
return 1;
}
int do_command( string name, mixed param )
{
mixed * tmp;
if( member_array( name, commands ) )
return 0;
tmp = (mixed *)COMMAND_SERVER->query_command( name );
return( int ) call_other( tmp[ 0 ], tmp[ 1 ], param );
}
int add_spell( string name, object ob, string func_name, int add_if_player )
{
if( member_array( name, spells ) != -1 )
return 0;
spells += ({ name, ({ ob, func_name, add_if_player }), });
return 1;
}
int remove_spell( string name )
{
int i;
if( (i = member_array( name, spells )) == -1 )
return 0;
spells = delete( spells, i, 2 );
return 1;
}
int cast_spell( string name, mixed bing )
{
int i;
if( (i = member_array( name, spells )) == -1 )
return 0;
return( int ) call_other( spells[ i + 1 ][ 0 ], spells[ i + 1 ][ 1 ], bing );
}
mixed query_spells()
{
return spells;
}
string *query_commands()
{
return commands;
}
/* These 4 should be redefined in the guild object */
int query_skill_cost( string skill )
{
return 10;
}
int query_skill_max_level( string skill )
{
return 10;
}
string query_title( object player )
{
return "Ack! How the hell should I know?";
}
int query_level( object ob )
{
return( int ) ob->query_skill( "other" );
}
void start_player( object pl )
{
int i;
if( !spells )
spells = ({ });
for( i = 0; i < sizeof( spells ); i += 2 )
if( spells[ i + 1 ][ 2 ] || !interactive( pl ) )
pl->add_spell( spells[ i ], spells[ i + 1 ][ 0 ], spells[ i + 1 ][ 1 ] );
if( !commands )
commands = ({ });
for( i = 0; i < sizeof( commands ); i += 2 )
if( commands[ i + 1 ][ 0 ] || !interactive( pl ) )
pl->add_known_command( commands[ i ] );
}
/* Are these 3 hooked up? */
void leave_guild()
{
}
void player_quit()
{
}
void player_save()
{
}
/* Added by Newstyle, 28/10/93 */
string new_mail_messages()
{
}
void player_heart_beat()
{
int bon;
bon = (int)this_player()->query_con() * 5;
if( (int)this_player()->query_hp() < 0 )
this_player()->set_hp( 1 );
if( bon < 40 )
this_player()->adjust_hp( 1 );
else
this_player()->adjust_hp( bon / 40 );
/* Ack! This should refernce the primary stat, not Int! */
bon = (int)this_player()->query_int() * 5;
if( bon < 40 )
this_player()->adjust_gp( 1 );
else
this_player()->adjust_gp( bon / 40 );
}
void set_level( object ob, int lvl, string class )
{
call_out( "set_new_level", 0, ({ ob, lvl, class }) );
}
void set_new_level( mixed *arr )
{
object ob;
int lvl;
ob = arr[ 0 ];
lvl = arr[ 1 ];
if( !ob )
return;
ob->add_skill_level( "fighting", lvl );
ob->add_skill_level( "other", lvl );
ob->add_skill_level( "magic", lvl );
ob->add_skill_level( "faith", lvl );
ob->add_skill_level( "occult", lvl );
ob->set_int( 13 );
ob->set_dex( 13 );
ob->set_wis( 13 );
ob->set_con( 13 );
ob->set_str( 13 );
ob->set_hp( 100000 );
ob->set_gp( 100000 );
ob->reset_all();
}