Hi all,
I’m making a fishing mechanic and would welcome some pointers about how you would approach this. Essentially:
- Different fish exist, belonging to different species.
- Different fish live in different locations.
- Fish have a rarity, affecting the likelihood of being caught.
- A player can fish with the combination of a fishing rod and bait.
- Bait comes in different forms (worms, grasshoppers etc.). Different baits attract different fish.
- Fish vary in size when caught (e.g. small, medium, large) with value increasing for larger fish.
So far I have a skeleton for 1-3, but I’m struggling with how to get bait to work with influencing fish capture with the rarity mechanic - e.g. ‘fish with bait A’ can result in catching fish B or C, while ‘fish with bait D’ can catch fish E, F or G. Any ideas how to approach this?
Also, any suggestions how you might approach step 6 as well to handle the size of the fish once caught? I’m imagining that this size value could be randomly made upon capture but perhaps there’s a better way.
Here’s the code I have so far for reference:
The Lake is a room. The Pond is north of the Lake. The Mountain Stream is west of the Lake. The River is south of the Lake. The Swamp is east of the Lake.
A fish is a kind of thing. A fish is always scenery.
Instead of taking a fish:
say "You can't just grab fish out of the water! Try fishing instead."
Carp are a kind of fish. Trout are a kind of fish. Catfish are a kind of fish. Perch are a kind of fish. Pike are a kind of fish.
The Common Carp is a carp. The Mirror Carp is a carp. The Koi Carp is a carp.
The Brown Trout is a trout. The Rainbow Trout is a trout. The Brook Trout is a trout.
The Channel Catfish is a catfish. The Blue Catfish is a catfish. The Flathead Catfish is a catfish.
The European Perch is a perch. The Yellow Perch is a perch. The Balkhash Perch is a perch.
The Northern Pike is a pike. The Muskellunge is a pike. The Chain Pickerel is a pike.
The Common Carp is in the Lake. The Mirror Carp is in the Lake. The Koi Carp is in the Pond.
The Brown Trout is in the River. The Rainbow Trout is in the River. The Brook Trout is in the Mountain Stream.
The Channel Catfish is in the River. The Blue Catfish is in the Lake. The Flathead Catfish is in the Swamp.
The European Perch is in the River. The Yellow Perch is in the Lake. The Balkhash Perch is in the Pond.
The Northern Pike is in the River. The Muskellunge is in the Lake. The Chain Pickerel is in the Swamp.
The player carries a fishing rod.
A fish has a number called rarity.
The Common Carp has rarity 1. The Mirror Carp has rarity 2. The Koi Carp has rarity 3.
The Brown Trout has rarity 2. The Rainbow Trout has rarity 1. The Brook Trout has rarity 3.
The Channel Catfish has rarity 1. The Blue Catfish has rarity 2. The Flathead Catfish has rarity 3.
The European Perch has rarity 1. The Yellow Perch has rarity 1. The Balkhash Perch has rarity 2.
The Northern Pike has rarity 3. The Muskellunge has rarity 3. The Chain Pickerel has rarity 2.
Fishing is an action applying to nothing.
Understand "fish" or "cast rod" as fishing.
Check fishing:
if the player does not carry a fishing rod:
say "You don't have anything to fish with!" instead;
if there is no fish in the location:
say "There don't seem to be any fish here." instead.
Carry out fishing:
let possible catches be the list of fish in the location;
if the number of entries in possible catches is 0:
say "You cast your line, but nothing bites.";
otherwise:
let chosen fish be a random entry in possible catches weighted by rarity;
say "You cast your line and wait... You feel a tug! You reel in a [chosen fish]!";
now the player carries the chosen fish.
To decide which object is a random entry in (L - a list of things) weighted by rarity:
let best choice be nothing;
repeat with item running through L:
if best choice is nothing or a random number between 1 and the rarity of best choice is less than a random number between 1 and the rarity of item:
now best choice is item;
decide on best choice.
Any pointers appreciated - thanks!