Fishing Snippet for Dawn of Time MUDs

This fishing snippet offers a simple but expandible form of entertainment
for players that also provides them with a food source that can be
sold. If your mud uses cooking to cook raw meats, make sure to make
the fishcatch object with a raw flag.

Players have to have a fishing pole and hold it to fish. They also
need to have bait in their inv. They must be standing in a room of
sector type WATER_SWIM or WATER_NOSWIM (adjust to fit your code) to
fish.

You will need to create the following:
Skills:
fish

Object Types:
pole
bait

Specific Objects:
fishcatch – declared in your game as a specific vnum

/*fish.cpp
Upon not being able to find a snippet being publicly shared to do this,
I decided to try to write something simple myself.
Feel free to use as you see fit and alter as needed.
All of the rom/diku/dot/merc/oblivian anyhthing you can think of type licenses
forbidding profit made from this code apply.
Please just keep this tag in the file if you're going to redistribute.
- Hera, of Athens - The Mud athens.boue.ca port 9000
hera_of_athens@yahoo.com
*/

#include "include.h"
void fish_start( char_data *ch );

void do_fish( char_data *ch, char * )
{
OBJ_DATA *obj;
int chance;

chance = get_skill( ch, gsn_fish )+10;

if ( chance < 11) { ch->println("You couldn't catch a cold, much less a fish.");
return;
}

// make it easier for newbies
/* if (ch->level<30) chance+=ch->level;
*/
/* if (chancewrapln("You attempt to fish for a while, not getting a single nibble.");
return;
}
*/
if ( ch->in_room->sector_type == SECT_WATER_SWIM
|| ch->in_room->sector_type == SECT_WATER_NOSWIM)
{

if (chancewrapln("You attempt to fish for a while, not getting a single nibble.");
return;
}

if (!IS_NPC(ch))
{
for ( obj = ch->carrying; obj; obj = obj->next_content )
{
if ( obj->item_type == ITEM_POLE && obj->wear_loc == WEAR_HOLD )
break;
}

if ( !obj )
{
ch->println("`cYou are not holding a fishing pole.`x");
return;
}
}else{
ch->println( "Mobiles don't need to fish." );
return;
}

fish_start( ch );
return;

}else{
ch->println( "You can't fish here." );
return;
}

}

void fish_start( char_data *ch )
{
OBJ_INDEX_DATA *pObjIndex;
OBJ_DATA *pObj;
OBJ_DATA *bait;
int fishevent;
bool foundbait = false;

if (!IS_NPC(ch))
{

for ( bait = ch->carrying; bait; bait = bait->next_content )
{

if ( bait->item_type == ITEM_BAIT )
{
foundbait = true;
break;
}
}

if ( !foundbait )
{
ch->println("`cYou don't have any bait.`x");
return;
}
}

if (( pObjIndex = get_obj_index( OBJ_VNUM_FISHCATCH )) == NULL ) {
ch->println("catch 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 random luck

fishevent = dice(1,6);
switch(fishevent)
{ case 1:
ch->println("`cYou get a nibble but the fish leaves without taking the bait.`x\n\r");
return;

case 2:
ch->println("`cA fish steals your bait without getting hooked!`x\n\r");
extract_obj( bait );
return;

case 3:
pObj->description = str_dup( "A freshly caught tuna fish lies here." );
pObj->short_descr = str_dup( "a tuna fish" );
pObj->name = str_dup( "tuna fish" );
pObj->cost = 300;
extract_obj( bait );
// Send the message to the world!
obj_to_char( pObj, ch );
ch->println("You caught something!");
act( "$n caught a fish!", ch, NULL, NULL, TO_ROOM );
check_improve( ch, gsn_fish, true, 2 );
break;
case 4:
pObj->description = str_dup( "A freshly caught large mouth bass lies here." );
pObj->short_descr = str_dup( "a large mouth bass" );
pObj->name = str_dup( "bass" );
pObj->cost = 200;
extract_obj( bait );
// Send the message to the world!
obj_to_char( pObj, ch );
ch->println("You caught something!");
act( "$n caught a fish!", ch, NULL, NULL, TO_ROOM );
check_improve( ch, gsn_fish, true, 2 );
break;
case 5:
pObj->description = str_dup( "A freshly caught minnow lies here." );
pObj->short_descr = str_dup( "a minnow" );
pObj->name = str_dup( "minnow" );
pObj->cost = 50;
extract_obj( bait );
// Send the message to the world!
obj_to_char( pObj, ch );
ch->println("You caught something!");
act( "$n caught a fish!", ch, NULL, NULL, TO_ROOM );
check_improve( ch, gsn_fish, true, 2 );
break;
case 6:
pObj->description = str_dup( "A freshly caught bullhead lies here." );
pObj->short_descr = str_dup( "A bullhead" );
pObj->name = str_dup( "bullhead" );
pObj->cost = 100;
extract_obj( bait );
break;
// Send the message to the world!
obj_to_char( pObj, ch );
ch->println("You caught something!");
act( "$n caught a fish!", ch, NULL, NULL, TO_ROOM );
check_improve( ch, gsn_fish, true, 2 );
break;

}

}