inherit "/std/object"; #define RACES ({ "human", "dwarf", "elf", "half-elf",\ "hobbit", "gnome", "orc", "troll" }) setup() { set_name( "disc" ); set_short( "%^YELLOW%^A small golden disc%^RESET%^" ); add_adjective( ({ "small", "golden" }) ); set_main_plural( "Error, please contact Newstyle" ); set_long( "The %^YELLOW%^small golden disc%^RESET%^ is embossed with " + "a stylised image of the new moon. It is about 3 inches " + "across and the reverse side of it bears images of " + sizeof( RACES ) + " different races." ); set_read_mess( "Race changer : Type 'race' to begin.\n" + "%^RED%^%^FLASH%^WARNING : Only useable once.%^RESET%^\n" ); set_value( 0 ); set_weight( 1 ); reset_drop(); } void init() { ::init(); add_action( "sure1", "race" ); } string help() { return "This object can be used to change your race. " + "To do this, simply type 'race', and answer the " "questions put to you appropriately."; } int do_race() { write( "Choose your race from any of :-\n%^GREEN%^" + implode( RACES, ", " ) + "\n\n%^RESET%^Or type help <race> for more information" + ".\n> " ); input_to( "do_race2" ); return 1; } int sure1() { write( "Are you sure you wish to set your race now?\n" + "You will only get one chance to set it!\n" + " (yes/no) > " ); input_to( "sure2" ); return 1; } void sure2( string str ) { str = lower_case( str ); if( str == "y" | str == "yes" ) { do_race(); return; } if( str == "n" | str == "no" ) { write( "Okay, race-choosing cancelled.\n" ); return; } write( "%^WHITE%^Answer yes or no!%^RESET%^\n\n>" ); input_to( "sure2" ); return; } string get_race_ob( string str ) { int i; for( i = 0; i < sizeof( RACES ); i++ ) if( str == RACES[ i ] ) return "/std/races/" + str; return "nada"; } void race_help( string str ) { string obj; obj = get_race_ob( str ); if( obj == "nada" ) { write( "Unknown race : " + str + ".\n" ); do_race(); return; } write( obj->query_long() + "\n" ); do_race(); return; } /* Surely this is written elsewhere .... */ string add_pronoun( string str ) { string *letters; int i; letters = explode( str, "" ); for( i = 0; i < 5; i++ ) if( letters[ 0 ] == ({ "a", "e", "i", "o", "u" })[ i ] ) return "an " + str; return "a " + str; } void do_race2( string str ) { string obj; str = lower_case( str ); if( sscanf( str, "%s %s", obj, str ) == 2 ) { sscanf( str, "%s %s", obj, str ); if( obj == "help" ) { race_help( str ); return; } write( "Unknown command :" + obj + ".\n" ); do_race(); return; } obj = get_race_ob( str ); if( obj == "nada" ) { write( "Unknown race : " + str + ".\n" ); do_race(); return; } this_player()->set_race_ob( obj ); write( "You are now " + add_pronoun( str ) + ".\n" ); this_player()->query_race_ob()->set_stats( this_player() ); say( this_player()->query_cap_name() + " transforms into " + add_pronoun( str ) + ".\n" ); write( "Your %^YELLOW%^small golden disc%^RESET%^ vanishes " + "in a puff of smoke.\n" ); call_out( "dest_me", 1 ); return; }