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;
}
|