/* mine.cpp Upon not being able to find a snippet being publicly shared to do this, I decided to try to write something simple myself. - Hera, of Athens - The Mud athens.boue.ca port 9000 hera_of_athens@yahoo.com */ #include "include.h" void mine_gems( char_data *ch ); void mine_silver( char_data *ch ); void mine_gold( char_data *ch ); void do_mine( char_data *ch, char *argument ) { if ( IS_NULLSTR( argument )) { ch->println( "Syntax: mine (type)" ); ch->println( "Types availabile: gems, gold, silver" ); return; } if ( !str_prefix( argument, "gems" )) { mine_gems( ch ); return; } if ( !str_prefix( argument, "gold" )) { mine_gold( ch ); return; } if ( !str_prefix( argument, "silver" )) { mine_silver( ch ); return; } ch->println( "Syntax: mine (type)" ); ch->println( "Types availabile: gems, gold, silver" ); return; } void mine_gems( char_data *ch ) { OBJ_INDEX_DATA *pObjIndex; OBJ_DATA *pObj; int chance; int gemevent; OBJ_DATA *obj; chance = get_skill( ch, gsn_mine )+10; if ( chance < 11){ ch->println("You don't know how to mine for gemstones."); return; } // make it easier for newbies if (ch->level<30) chance+=ch->level; if(!IS_SET(ch->in_room->room2_flags, ROOM2_MINE )) { ch->println("You are not in a gemstone mine."); return; } if (!IS_NPC(ch)) { for ( obj = ch->carrying; obj; obj = obj->next_content ) { if ( obj->item_type == ITEM_PICK && obj->wear_loc == WEAR_HOLD ) break; } if ( !obj ) { ch->println("You are not holding a pick."); return; }else{ for ( obj = ch->in_room->contents; obj; obj = obj->next_content ) { if ( obj->item_type == ITEM_GEMVEIN ) extract_obj( obj ); break; } if ( obj == NULL ) { ch->println( "There are no exposed gemstones to mine right now." ); return; } } if (chancewrapln("You attempt to mine for a while, not aquiring anything."); #ifdef unix WAIT_STATE( ch, PULSE_PER_SECOND *number_range(3,5)); #endif return; } if (( pObjIndex = get_obj_index( OBJ_VNUM_GEMSTONE )) == NULL ) { ch->println("gemstone item non-existant, please report this with a note to admin."); return; } pObj = create_object( pObjIndex); // Free up old object names and descriptions free_string( pObj->description ); free_string( pObj->name ); free_string( pObj->short_descr ); // Change food desc according to terrain type gemevent = dice(1,6); switch ( gemevent ) { case 1: pObj->description = str_dup( "A spotted, amber-colored agate gemstone lies here." ); pObj->short_descr = str_dup( "a spotted agate gemstone" ); pObj->name = str_dup( "agate gemstone" ); pObj->cost = 400; break; case 2: pObj->description = str_dup( "A dark red garnet gemstone lies here." ); pObj->short_descr = str_dup( "a dark red garnet gemstone" ); pObj->name = str_dup( "garnet gemstone" ); pObj->cost = 800; break; case 3: pObj->description = str_dup( "A light purple amethyst gemstone lies here." ); pObj->short_descr = str_dup( "a light purple amethyst gemstone" ); pObj->name = str_dup( "amethyst gemstone" ); pObj->cost = 1200; break; case 4: pObj->description = str_dup( "A deeply green emerald gemstone lies here." ); pObj->short_descr = str_dup( "a deeply green emerald gemstone" ); pObj->name = str_dup( "emerald gemstone" ); pObj->cost = 1600; break; case 5: pObj->description = str_dup( "A very blue sapphire gemstone lies here." ); pObj->short_descr = str_dup( "a very blue sapphire gemstone" ); pObj->name = str_dup( "sapphire gemstone" ); pObj->cost = 2000; break; case 6: pObj->description = str_dup( "A clear diamond gemstone lies here." ); pObj->short_descr = str_dup( "a clear diamond gemstone" ); pObj->name = str_dup( "diamond gemstone" ); pObj->cost = 2400; break; } // Send the message to the world! obj_to_room( pObj, ch->in_room ); ch->println("You found a gemstone."); act( "$n is mining for something.", ch, NULL, NULL, TO_ROOM ); check_improve( ch, gsn_mine, true, 2 ); return; } } void mine_silver( char_data *ch ) { OBJ_DATA *obj; int silverevent; int chance; if(!IS_SET(ch->in_room->room2_flags, ROOM2_SILVERMINE)) { ch->println("You are not in a silver mine."); return; } if (!IS_NPC(ch)) { for ( obj = ch->carrying; obj; obj = obj->next_content ) { if ( obj->item_type == ITEM_PICK && obj->wear_loc == WEAR_HOLD ) break; } if ( !obj ) { ch->println("You are not holding a pick."); return; }else{ for ( obj = ch->in_room->contents; obj; obj = obj->next_content ) { if ( obj->item_type == ITEM_SILVERVEIN ) extract_obj( obj ); break; } if ( obj == NULL ) { ch->println( "There is no exposed silver vein to mine." ); return; } chance = get_skill( ch, gsn_mine )+10; if ( chance < 11){ ch->println("You don't know how to mine for silver."); return; } if (chancewrapln("You attempt to mine for a while, not aquiring anything."); return; } silverevent = dice(1,9); switch(silverevent) { case 1: ch->println("Your pick strikes a soft ore. It is silver!\n\r"); ch->silver=ch->silver+1; ch->println("1 silver has been added to your score.\n\r"); break; case 2: ch->println("Your pick strikes a soft ore. It is silver!\n\r"); ch->silver=ch->silver+50; ch->println("50 silver have been added to your score.\n\r"); break; case 3: ch->println("Your pick strikes a soft ore. It is silver!\n\r"); ch->silver=ch->silver+2; ch->println("2 silver have been added to your score.\n\r"); break; case 4: ch->println("Your pick strikes a soft ore. It is silver!\n\r"); ch->silver=ch->silver+25; ch->println("25 silver have been added to your score.\n\r"); break; case 5: ch->println("Your pick strikes a soft ore. It is silver!\n\r"); ch->silver=ch->gold+3; ch->println("3 silver have been added to your score.\n\r"); break; case 6: ch->println("Your pick strikes a soft ore. It is silver!\n\r"); ch->silver=ch->silver+75; ch->println("75 silver have been added to your score.\n\r"); break; case 7: ch->println("Your pick strikes a soft stone. It contains nothing of value.\n\r"); break; case 8: ch->println("Your pick strikes a hard stone. It contains nothing of value.\n\r"); break; case 9: ch->println("Your pick strikes a hard stone. It contains nothing of value.\n\r"); return; } check_improve( ch, gsn_mine, true, 2 ); return; } } else ch->println( "Mobiles don't need to mine." ); } void mine_gold( char_data *ch ) { OBJ_DATA *obj; int goldevent; int chance; if(!IS_SET(ch->in_room->room2_flags, ROOM2_GOLDMINE)) { ch->println("You are not in a gold mine."); return; } if (!IS_NPC(ch)) { for ( obj = ch->carrying; obj; obj = obj->next_content ) { if ( obj->item_type == ITEM_PICK && obj->wear_loc == WEAR_HOLD ) break; } if ( !obj ) { ch->println("You are not holding a pick."); return; }else{ for ( obj = ch->in_room->contents; obj; obj = obj->next_content ) { if ( obj->item_type == ITEM_GOLDVEIN ) extract_obj( obj ); break; } if ( obj == NULL ) { ch->println( "There is no exposed gold vein to mine." ); return; } chance = get_skill( ch, gsn_mine )+10; if ( chance < 11){ ch->println("You don't know how to mine for gold."); return; } if (chancewrapln("You attempt to mine for a while, not aquiring anything."); return; } goldevent = dice(1,9); switch(goldevent) { case 1: ch->println("Your pick strikes a soft ore. It is gold!\n\r"); ch->gold=ch->gold+1; ch->println("1 gold has been added to your score.\n\r"); break; case 2: ch->println("Your pick strikes a soft ore. It is gold!\n\r"); ch->gold=ch->gold+10; ch->println("10 gold have been added to your score.\n\r"); break; case 3: ch->println("Your pick strikes a soft ore. It is gold!\n\r"); ch->gold=ch->gold+15; ch->println("15 gold have been added to your score.\n\r"); break; case 4: ch->println("Your pick strikes a soft ore. It is gold!\n\r"); ch->gold=ch->gold+5; ch->println("5 gold have been added to your score.\n\r"); break; case 5: ch->println("Your pick strikes a soft ore. It is gold!\n\r"); ch->gold=ch->gold+3; ch->println("3 gold have been added to your score.\n\r"); break; case 6: ch->println("Your pick strikes a soft ore. It is gold!\n\r"); ch->gold=ch->gold+20; ch->println("20 gold have been added to your score.\n\r"); break; case 7: ch->println("Your pick strikes a soft stone. It contains nothing of value.\n\r"); break; case 8: ch->println("Your pick strikes a hard stone. It contains nothing of value.\n\r"); break; case 9: ch->println("Your pick strikes a hard stone. It contains nothing of value.\n\r"); return; } check_improve( ch, gsn_mine, true, 2 ); return; } } else ch->println( "Mobiles don't need to mine." ); }