I’ve been coding for my MUD game, Athens and wrote up the following hash of code that could be altered for fishing, hunting (as in game animals), panning for gold, ect. It’s basically a hack of a lot of things that I dug around in.
Code Snippet and Instructions
Make sure to add an object type for PICK and to add mine.o to your makefile.
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
void do_mine( char_data *ch, char * )
ch->println("You are not in a mine.");
for ( obj = ch->carrying; obj; obj = obj->next_content )
if ( obj->item_type == ITEM_PICK && obj->wear_loc == WEAR_HOLD )
if ( !obj )
ch->println("You are not holding a pick.");
for ( obj = ch->in_room->contents; obj; obj = obj->next_content )
if ( obj->item_type == ITEM_ORE )
extract_obj( obj );
if ( obj == NULL )
ch->println( "This is not a suitable place to mine." );
mineevent = dice(1,2);
ch->println("Your pick strikes a soft ore. It is gold!\n\r");
ch->println("Your pick strikes a soft ore. It is silver!\n\r");
ch->println( "Mobiles don't need to mine." );
You can add more cases to give different amounts of gold or silver, or perhaps objects such as gems. I just put up two as an example.
To make this work, you’d have a mine shaft or cave or some other area, and flag the rooms ROOM2_MINE. You’d also have to have objects of type ORE reset into the room. I suggest making them not takable.
When a player walks into the mine and sees some ore in the room, he’ll know he can mine (if he’s got a pick). When he types MINE, one of the ore type objects in the room is purged. This prevents someone from simply typing MINE 200 times and getting a lot of money. When the area resets, more ore will show up and another player who comes along can mine again.