fish.cpp
Fishing/fish.cpp · 4.6 KB
From the archive Fishing.zip
Download the archive « Back to the archive contents
/*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 (chance<number_range(0,105))
{
ch->wrapln("You attempt to fish but the fish aren't biting.");
return;
}
if ( ch->in_room->sector_type == SECT_WATER_SWIM
|| ch->in_room->sector_type == SECT_WATER_NOSWIM)
{
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;
}
}
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 need 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");
break;
case 2:
ch->println("`cA fish steals your bait without getting hooked!`x\n\r");
extract_obj( bait );
break;
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;
}
}