STATS.C
LIB3/STD/LIVING/STATS.C · 7.2 KB
From the archive nm4dos.zip
Download the archive « Back to the archive contents
#pragma save_binary
static int intbon, dexbon, conbon, strbon, wisbon;
int Dex, Int, Con, Str, Wis, inttmp, dextmp, contmp, wistmp, strtmp;
static int no_check;
int query_no_check()
{
return no_check;
}
void set_no_check( int i )
{
no_check = i;
}
int check( int i )
{
if( i > 28 )
return 0;
return 1;
}
void reset_hp()
{
if( no_check )
return;
this_object()->set_max_hp(
500 + (int)this_object()->query_skill_bonus( "combat.stamina" ) * 10 );
}
void reset_gp()
{
object guild_ob;
if( no_check )
return;
guild_ob = (object)this_object()->query_guild_ob();
if( !guild_ob )
this_object()->set_max_gp(
50 + (int)this_object()->query_skill_bonus( "general.points" ) );
else
guild_ob->set_gp( this_object() );
}
void reset_carry_cap()
{
int old_cap, cap, st;
object ob1, ob2;
if( no_check )
return;
old_cap = (int)this_object()->query_loc_weight();
st = Str + strtmp + strbon;
cap = 6 * st * st;
if( cap < 500 )
cap = 500;
this_object()->set_max_weight( cap );
if( cap >= old_cap )
return;
ob1 = first_inventory( this_object() );
while( ob1 )
{
ob2 = next_inventory( ob1 );
if( ob1->query_weight() )
if( ob1->move( environment() ) )
{
old_cap -= (int)ob1->query_weight();
say( this_object()->query_cap_name() + " drops " + ob1->short() +
", looking strained.\n" );
write( "In your weakness you drop " + ob1->short() + ".\n" );
}
if( cap >= old_cap )
return;
ob1 = ob2;
}
}
void reset_all()
{
call_out( "zap_stat_cache", 0, "SDIWC" );
call_out( "reset_all2", 0 );
}
void reset_all2()
{
no_check = 0;
reset_hp();
reset_gp();
reset_carry_cap();
}
int set_str( int i )
{
if( i > 28 )
i = 28;
if( Str != i )
call_out( "zap_stat_cache", 0, "S" );
Str = i;
reset_carry_cap();
return 1;
}
int set_con( int i )
{
if( i > 28 )
i = 28;
if( Con != i )
call_out( "zap_stat_cache", 0, "C" );
Con = i;
call_out( "reset_hp", 2 );
return 1;
}
int set_int( int i )
{
if( i > 28 )
i = 28;
if( Int != i )
call_out( "zap_stat_cache", 0, "I" );
Int = i;
call_out( "reset_gp", 2 );
return 1;
}
int set_dex( int i )
{
if( i > 28 )
i = 28;
if( Dex != i )
call_out( "zap_stat_cache", 0, "D" );
Dex = i;
return 1;
}
int set_wis( int i )
{
if( i > 28 )
i = 28;
if( Wis != i )
call_out( "zap_stat_cache", 0, "W" );
Wis = i;
call_out( "reset_gp", 2 );
return 1;
}
int query_str()
{
return Str + strtmp + strbon;
}
int query_int()
{
return Int + inttmp + intbon;
}
int query_dex()
{
return Dex + dextmp + dexbon;
}
int query_wis()
{
return Wis + wistmp + wisbon;
}
int query_con()
{
return Con + contmp + conbon;
}
int query_real_str()
{
return Str;
}
int query_real_int()
{
return Int;
}
int query_real_dex()
{
return Dex;
}
int query_real_wis()
{
return Wis;
}
int query_real_con()
{
return Con;
}
int query_tmp_str()
{
return strtmp;
}
int query_tmp_int()
{
return inttmp;
}
int query_tmp_dex()
{
return dextmp;
}
int query_tmp_wis()
{
return wistmp;
}
int query_tmp_con()
{
return contmp;
}
int query_bonus_str()
{
return strbon;
}
int query_bonus_int()
{
return intbon;
}
int query_bonus_dex()
{
return dexbon;
}
int query_bonus_wis()
{
return wisbon;
}
int query_bonus_con()
{
return conbon;
}
int adjust_dex( int i )
{
Dex += i;
if( Dex > 28 )
Dex = 28;
if( i )
call_out( "zap_stat_cache", 0, "D" );
return Dex;
}
int adjust_con( int i )
{
Con += i;
if( Con > 28 )
Con = 28;
if( i )
call_out( "zap_stat_cache", 0, "C" );
call_out( "reset_hp", 2 );
return Con;
}
int adjust_str( int i )
{
Str += i;
if( Str > 28 )
Str = 28;
if( i )
call_out( "zap_stat_cache", 0, "S" );
reset_carry_cap();
return Str;
}
int adjust_wis( int i )
{
Wis += i;
if( Wis > 28 )
Wis = 28;
if( i )
call_out( "zap_stat_cache", 0, "W" );
call_out( "reset_gp", 2 );
return Wis;
}
int adjust_int( int i )
{
Int += i;
if( Int > 28 )
Int = 28;
if( i )
call_out( "zap_stat_cache", 0, "I" );
call_out( "reset_gp", 2 );
return Int;
}
int adjust_tmp_int( int i )
{
inttmp += i;
if( i )
call_out( "zap_stat_cache", 0, "I" );
call_out( "reset_gp", 2 );
return inttmp;
}
int adjust_tmp_dex( int i )
{
dextmp += i;
if( i )
call_out( "zap_stat_cache", 0, "D" );
return dextmp;
}
int adjust_tmp_wis( int i )
{
wistmp += i;
if( i )
call_out( "zap_stat_cache", 0, "W" );
call_out( "reset_gp", 2 );
return wistmp;
}
int adjust_tmp_str( int i )
{
strtmp += i;
if( i )
call_out( "zap_stat_cache", 0, "S" );
reset_carry_cap();
return strtmp;
}
int adjust_tmp_con( int i )
{
contmp += i;
if( i )
call_out( "zap_stat_cache", 0, "C" );
call_out( "reset_hp", 2 );
return contmp;
}
int adjust_bonus_int( int i )
{
intbon += i;
if( i )
call_out( "zap_stat_cache", 0, "I" );
call_out( "reset_gp", 2 );
return intbon;
}
int adjust_bonus_dex( int i )
{
dexbon += i;
if( i )
call_out( "zap_stat_cache", 0, "D" );
return dexbon;
}
int adjust_bonus_wis( int i )
{
wisbon += i;
if( i )
call_out( "zap_stat_cache", 0, "W" );
call_out( "reset_gp", 2 );
return wisbon;
}
int adjust_bonus_str( int i )
{
strbon += i;
if( i )
call_out( "zap_stat_cache", 0, "S" );
reset_carry_cap();
return strbon;
}
int adjust_bonus_con( int i )
{
conbon += i;
if( i )
call_out( "zap_stat_cache", 0, "C" );
call_out( "reset_hp", 2 );
return conbon;
}
int set_bonus_int( int i )
{
intbon = i;
if( i )
call_out( "zap_stat_cache", 0, "I" );
call_out( "reset_gp", 2 );
return intbon;
}
int set_bonus_dex( int i )
{
dexbon = i;
if( i )
call_out( "zap_stat_cache", 0, "D" );
return dexbon;
}
int set_bonus_wis( int i )
{
wisbon = i;
if( i )
call_out( "zap_stat_cache", 0, "W" );
call_out( "reset_gp", 2 );
return wisbon;
}
int set_bonus_str( int i )
{
strbon = i;
if( i )
call_out( "zap_stat_cache", 0, "S" );
reset_carry_cap();
return strbon;
}
int set_bonus_con( int i )
{
conbon = i;
if( i )
call_out( "zap_stat_cache", 0, "C" );
call_out( "reset_hp", 2 );
return conbon;
}
void update_tmps()
{
if( strtmp )
{
call_out( "zap_stat_cache", 0, "S" );
strtmp = strtmp / 2;
reset_carry_cap();
}
if( contmp )
{
call_out( "zap_stat_cache", 0, "C" );
contmp = contmp / 2;
call_out( "reset_hp", 2 );
}
if( wistmp )
{
call_out( "zap_stat_cache", 0, "W" );
wistmp = wistmp / 2;
call_out( "reset_gp", 2 );
}
if( inttmp )
{
call_out( "zap_stat_cache", 0, "I" );
inttmp = inttmp / 2;
call_out( "reset_gp", 2 );
}
if( dextmp )
{
call_out( "zap_stat_cache", 0, "D" );
dextmp = dextmp / 2;
}
}
string stat_string( int i )
{
if( i < 19 )
return i + "";
if( i > 28 )
return( i - 10 ) + "";
if( i == 28 )
return "18/00";
return "18/" + (i - 18) + "0";
}