17 Mar, 2010, garumike wrote in the 1st comment:
Votes: 0
I am trying to do a couple of things with this… I ripped this from some forage code I have in my mud and just messed with it a little to simulate fishing. What I would like to do:
1.Have a few lines when the command is entered stating something like: 1a.You cast your line out. 2b.Something jostles your line. 3c. You feel a tug on your line and set your hook! Each a few pulses apart, and that can be interupted by the player being attacked.
2. (MORE IMPORTANT) Make it so an object: ITEM_TYPE_BAIT has to be in the player inventory, and when they use the command, the obj is automatically removed from inventory without the player actually having to use an argument (like: fish <item_type_bait name>).

I hope this is appropriate to post… Thanks for your help in advance.

THE CODE:

void do_fish (CHAR_DATA *ch)
{
OBJ_DATA *obj, *pole;
ROOM_INDEX_DATA *in_room;

int chance = 0;

in_room = ch->in_room;
obj = create_object(get_obj_index(OBJ_VNUM_FISH2), 0);
// initialized, whiny compiler
pole = get_eq_char(ch, WEAR_HOLD);

if (!IS_IMMORTAL(ch)
&& (pole == NULL || pole->item_type != ITEM_FISHING_ROD)) {
send_to_char("You need a fishing pole to fish.\n\r", ch);
return;
}

if((in_room->sector_type != SECT_OCEAN) &&
(in_room->sector_type != SECT_WATER_SWIM) &&
(in_room->sector_type != SECT_WATER_NOSWIM) &&
(in_room->sector_type != SECT_WHIRLPOOL))
{
stc("You can only fish near a body of water.\n\r", ch);
return;
}

//Commented because it will not be a learned skill.
// if (get_skill(ch,gsn_forage) < 1 && !IS_IMMORTAL(ch)) {
// stc("You know nothing about foraging.\n\r",ch);
// return;
// }

if (ch->move < 10)
{
stc("You need at least 10 moves to use this skill!\n\r",ch);
return;
}

if (number_range(1,100) > 50) {
stc("You failed to catch anything.\n\r",ch);
WAIT_STATE(ch, 3 * PULSE_VIOLENCE);
// check_improve(ch, gsn_forage, FALSE, 1);
return;
}

if (!IS_IMMORTAL(ch))
WAIT_STATE(ch, PULSE_VIOLENCE*3/4);

stc("You feel a tug on your line and set your hook!\n\r",ch);
chance = number_range(0,30);
if (chance <= 5)
obj = create_object(get_obj_index(OBJ_VNUM_FISH7), 0);
else if (chance <= 10)
obj = create_object(get_obj_index(OBJ_VNUM_FISH2), 0);
else if (chance <= 15)
obj = create_object(get_obj_index(OBJ_VNUM_FISH3), 0);
else if (chance <= 20)
obj = create_object(get_obj_index(OBJ_VNUM_FISH4), 0);
else if (chance <= 25)
obj = create_object(get_obj_index(OBJ_VNUM_FISH5), 0);
else if (chance <= 27)
obj = create_object(get_obj_index(OBJ_VNUM_FISH6), 0);
else if (chance <= 30)
obj = create_object(get_obj_index(OBJ_VNUM_FISH1), 0);

obj_to_char(obj,ch);
// check_improve(ch, gsn_forage, TRUE, 2);

ch->move -= 10;

return;
}
17 Mar, 2010, jurdendurden wrote in the 2nd comment:
Votes: 0
1. You will need to set up some sort of event system for fishing then. What I did was create an enum for several 'fishing states', i.e casting, waiting, reeling, etc.. You will then need to make a call in update.c under the update_handler function to a fishing_update function or something like that. Once your fishing_update function is called, set a variable in CHAR_DATA for fishing_state (as an int), and update it according (incrementing from casting to catching to reeling).

2. Your bait issue could be handled so:

a) create ITEM_TYPE_BAIT.
b) iterate through inventory to make sure it's there:

OBJ_DATA *bait;
for ( bait = ch->carrying; bait; bait = bait->next_content )
{
if (bait->item_type == ITEM_TYPE_BAIT)
break;
}

if (!bait)
{
stc("You need some sort of bait to catch any fish!\r\n",ch);
return;
}
else
{
extract_obj(bait);
//do fishing stuff.
}
17 Mar, 2010, garumike wrote in the 3rd comment:
Votes: 0
Second part worked like a charm… havent tackled the first. Appreciate the speedy response man.
0.0/3