#include "weather.h" #define SPLASH_AMOUNT 10 + random( 10 ) static int current_thing, light; int wetness; int query_wetness() { return wetness; } void add_wetness( int arg ) { wetness += arg; } void create() { this_object()->add_alias( "weather" ); this_object()->add_alias( "moon" ); this_object()->add_alias( "sun" ); } void weather_commands() { add_action( "make", "make" ); add_action( "splash", "splash" ); } string weather_extra_look() { string prn; prn = capitalize( (string)this_object()->query_pronoun() ); if( wetness > 300 ) return prn + " is soaked to the bone.\n"; switch( wetness ) { case 200..300: return prn + " is soaked right through, and dripping everywhere.\n"; case 150..199: return prn + " is soaked through.\n"; case 100..149: return prn + " looks extremely wet and bedraggled.\n"; case 70..99: return prn + " looks wet and bedraggled.\n"; case 40..69: return prn + " is rather wet.\n"; case 20..39: return prn + " looks a bit wet and bedraggled.\n"; case 10..19: return prn + " is moderately damp-looking.\n"; case 1..9: return prn + " looks slightly damp.\n"; default: return ""; } } string weather_long( string str ) { object env; string temp; if( !(env = environment()) ) return ""; if( (string)env->query_property( "location" ) == "inside" ) return "You are not outside.\n"; if( str == "sun" ) if( WEATHER->query_day( env ) ) return "Ouch that hurts your eyes!\n"; else return "The sun is not up.\n"; if( str == "moon" ) if( WEATHER->query_day( env ) ) return "The moon is not up, try at night.\n"; else if( temp = (string)WEATHER->query_moon_string( env ) ) return temp + ".\n"; else return "The moon is not up at the moment, try again later.\n"; if( str != "weather" ) return ""; if( pointerp( env->query_co_ord() ) ) return "The weather is currently " + WEATHER->weather_string( env ) + ".\n"; else return "There is no weather here right now.\n"; } void event_weather() { call_out( "check_it", 0 ); } void check_it() { object env; int *type; string loc; if( !(env = environment()) ) return; loc = (string)env->query_property( "location" ); if( !WEATHER->query_day( env ) ) if( light && (loc != "inside") ) { tell_object( this_object(), "The sun sets slowly on the horizon.\n" ); light = 0; } else if( !light && (loc != "inside") ) { tell_object( this_object(), "Dawn breaks as the sun rises above the horizon.\n" ); light = 1; } if( env->query_co_ord() ) { type = (int *)WEATHER->query_type_rain( env ); if( current_thing != type[ 0 ] && loc != "inside" ) if( current_thing && type[ 0 ] ) tell_object( this_object(), "It has stopped " + ({ "raining", "hailing", "snowing" })[ current_thing - 1 ] + " and started " + ({ "raining", "hailing", "snowing" })[ type[ 0 ] - 1 ] + ".\n" ); else if( current_thing ) tell_object( this_object(), "It has stopped " + ({ "raining", "hailing", "snowing" })[ current_thing - 1 ] + ".\n" ); else if( type[ 0 ] ) tell_object( this_object(), "It has started " + ({ "raining", "hailing", "snowing" })[ type[ 0 ] - 1 ] + ".\n" ); current_thing = type[ 0 ]; if( type[ 1 ] > 0 && loc == "outside" ) { if( !sizeof( filter_array( all_inventory( this_object() ), "check_umbrella", this_object() ) ) ) if( type[ 0 ] == 1 ) wetness += type[ 1 ]; else wetness += type[ 1 ] / 2; } else if( wetness > 0 ) { type[ 1 ] = WEATHER->temperature_index( env ) + env->query_property( "warmth" ); if( type[ 1 ] < 0 ) wetness += type[ 1 ]; else wetness--; } } if( wetness > 100 && random( 10 ) < 4 ) tell_object( this_object(), "You are soaked.\n" ); } int check_umbrella( object ob ) { return( int ) ob->query_property( "umbrella" ); } int make( string str ) { object env; if( !(env = environment()) ) return 0; if( (string)env->query_property( "location" ) == "inside" ) { notify_fail( "You must be outside to do that.\n" ); return 0; } if( !pointerp( env->query_co_ord() ) ) { notify_fail( "This room has no co-ordinates... Arggghhh.\n" ); return 0; } if( !WEATHER->query_snowing( env ) ) { notify_fail( "It must be snowing to make a snowball.\n" ); return 0; } if( str == "snowball" ) { clone_object( "/std/environ/snowball" )->move( this_player() ); write( "You make a lovely big snowball. Have fun with it!\n" ); say( this_player()->query_cap_name() + " grabs a handful of snow, and forms it into a snowball.\n" ); return 1; } if( str == "snowman" ) { clone_object( "/std/environ/snowman" )->move( env ); write( "You make a snowman that will make others marvel.\n" ); say( this_player()->query_cap_name() + " gathers up a big heap of snow and makes a snowman.\n" ); return 1; } notify_fail( "Make what?\n" ); return 0; } int splash( string str ) { object *obs, weath, env; int * co_ords, i; if( !(env = environment()) ) return 0; if( (string)environment()->query_property( "location" ) == "inside" ) { notify_fail( "You must be outside to do that.\n" ); return 0; } if( !WEATHER->query_raining( env ) ) { notify_fail( "It must be raining to splash someone.\n" ); return 0; } if( !str ) { write( "You splash about in the puddles.\n" ); say( this_player()->query_cap_name() + " splashes about in the puddles. Mmmm, that looks fun!\n" ); wetness += SPLASH_AMOUNT; return 1; } if( !sizeof( obs = find_match( str, environment() ) ) ) { notify_fail( "You cannot see " + str + " here.\n" ); return 0; } for( i = 0; i < sizeof( obs ); i++ ) { obs[ i ]->add_wetness( SPLASH_AMOUNT ); tell_object( obs[ i ], ( string ) this_player()->query_cap_name() + " splashes " + query_multiple_short( obs - ({ obs[ i ] }) + ({ "you" }) ) + ".\n" ); } str = query_multiple_short( obs ); write( "You splash " + str + ".\n" ); say( this_object()->query_cap_name() + " splashes " + str + ".\n", obs ); return 1; }