CARRYING.C
LIB3/STD/LIVING/CARRYING.C · 2.0 KB
From the archive nm4dos.zip
Download the archive « Back to the archive contents
#pragma save_binary
/* formatting inventories for player, monster and corpse contents */
/* self true if inventory, else an examine. */
string query_living_contents( int self )
{
string s, t, *strs;
object obj, *objs, *conts;
int i, col;
strs = ({ });
conts = all_inventory( this_object() );
for( i = 0; i < sizeof( conts ); i++ )
if( !conts[ i ] || !(s = (string)conts[ i ]->short())||(s == "") )
conts -= ({ conts[ i ] });
obj = (object)this_object()->query_weapon();
if( obj )
{
strs += ({ "Wielding: ", ( string ) obj->short( 0 ) + ".\n" });
conts -= ({ obj });
}
obj = (object)this_object()->query_held_ob();
if( obj )
{
strs += ({ "Holding : ", ( string ) obj->short( 0 ) + ".\n" });
conts -= ({ obj });
}
objs = (object *)this_object()->query_armours();
if( sizeof( objs ) )
if( s = query_multiple_short( objs ) )
strs += ({ "Wearing : ", s + ".\n" });
obj = present( "Some Money For Me", this_object() );
conts -= objs + ({ obj }) +
(object *)this_object()->query_labels();
if( sizeof( conts ) )
if( s = (string)this_object()->query_contents( 0, conts ) )
strs += ({ "Carrying: ", s });
s = "";
col = (int)this_player()->query_cols() - 11;
for( i = 0; i < sizeof( strs ); i += 2 )
s += sprintf( "%s%-=*s", strs[ i ], col, strs[ i + 1 ] );
if( self )
{
if( obj )
t = (string)obj->short( 0 );
else
t = 0;
if( !sizeof( strs ) )
s = "You are empty handed.\n";
s += "Your purse contains " + (t ? t : "only moths") + ".\n";
}
else
if( obj )
{
i = (int)obj->query_number_coins();
s += capitalize( (string)this_object()->query_possessive() ) + " purse is ";
switch( i )
{
case 0..10:
s += "home to only moths!\n";
break;
case 11..100:
s += "tinkling with coins.\n";
break;
case 101..300:
s += "bulging with coins.\n";
break;
default:
s += "fit to burst!\n";
}
}
return s;
}