[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  Programming
. -> [Folder]  General
. . -> [Subject]  Fishing Code Snippet Help
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

Fishing Code Snippet Help

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Posted by Garumike   (1 post)  [Biography] bio
Date Wed 17 Mar 2010 09:01 PM (UTC)
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.


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

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

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

//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);

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

if (!IS_IMMORTAL(ch))

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

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

ch->move -= 10;

[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Wed 17 Mar 2010 11:05 PM (UTC)
Template:codetag To make your code more readable please use [code] tags as described here.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Conner   USA  (381 posts)  [Biography] bio
Date Reply #2 on Fri 19 Mar 2010 12:19 AM (UTC)
It'd also probably be helpful to mention what codebase you're working with and what portion of what you're trying to do isn't working along with what it is doing instead. I'm guessing, based upon what you did tell us, the problem is that you're not sure how to have the code do the two things you've mentioned, but it does appear, from the code you've provided, that you already know how to add pulse waits and send messages, so I'm thinking that your real question is about how to make it check for the bait in their inventory and remove it from their inventory when they use the command.

Come test your mettle in the Land of Legends at telnet://tcdbbs.zapto.org:4000
or, for a little family oriented medieval fun, come join us at The Castle's Dungeon BBS at telnet://tcdbbs.zapto.org
or, if you just want information about either, check our web page at http://tcdbbs.zapto.org
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #3 on Fri 19 Mar 2010 03:06 AM (UTC)
This was crossposted to MB:
and apparently a solution to part of it was given and accepted by the poster. (Didn't read it thoroughly, though.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]