diff options
Diffstat (limited to 'npc/functions')
-rw-r--r-- | npc/functions/fishing.txt | 143 |
1 files changed, 80 insertions, 63 deletions
diff --git a/npc/functions/fishing.txt b/npc/functions/fishing.txt index f2a1fd20..c2b4fda2 100644 --- a/npc/functions/fishing.txt +++ b/npc/functions/fishing.txt @@ -1,22 +1,44 @@ // Evol functions. // Authors: +// Omatt // Travolta // Description: // Fishing functions. +// Variable +// .dir +// DOWN Never try or pulled too late +// UP Bait dropped +// LEFT Fish bite bait +// +// player log on .dir is DOWN, start by choose bait menu +// player choose bait, script addtimer in npc .dir is UP +// if player pull before signal npc, bait is lose, set .bait to DOWN goto choose bait +// if player pull after pull delay max, bait is lose, set .bait to DOWN goto choose bait +// npc signal .dir is LEFT +// player pull between npc signal and pull delay max, got the fish, set .dir to DOWN goto choose bait + +function script fishingspot { + + if (getnpcdir(getarg(0)) != DOWN && @occupy == false) + { + npctalkonce l("This fishing spot is already being used!"); + close; + } -// player log on @pull is 0, start by choose bait menu -// player choose bait, script addtimer in npc @pull is 1 -// if player pull before signal npc, bait is lose, set @pull 3 goto choose bait -// if player pull after pull delay max, bait is lose, set @pull 3 goto choose bait -// npc signal @pull 2 -// player pull between npc signal and pull delay max, got the fish, set @pull 3 goto choose bait + // Skip the narator when we are in fishing + if (getnpcdir(getarg(0)) == DOWN) + { + narrator 4, l("You see some fish reflecting the sun on the surface of the water."); + } + return; +} function script fishing { - .@wait_time_min = 8000; - .@wait_time_max = 35000; - .@pull_rand_max = 800; + .@wait_time_min = 4000; + .@wait_time_max = 18000; + .@pull_rand_max = 500; .@fish_id = CommonCarp; .@rare_fish_chance = 25; @@ -28,71 +50,59 @@ function script fishing { return -1; } -// @pull : -// 0 = never try (goto choose bait) -// 1 = bait done -// 2 = fish bite bait -// 3 = pull too late or soon, Leave the spot, or already pulled a carp ( goto choose bait) - - switch (@pull) + switch (getnpcdir(getarg(0))) { - case 1: - { - narrator 5, - l("You pulled too soon and lost the bait."); - // @pull is 1 and the player talk to npc too late - // delete the timer for pull, and set 3 cancel the bait - @pull = 3; - // delete the timer, the bait is lost, no need to tease the player with a useless signal :3 - deltimer "" + getarg(0) + "::OnPull"; - close; - } - case 2: - // with this new system of pull i think this check become useless - // but that can prevent the player to start a fishing in one spot and complete in another + case UP: + @occupy = false; + setnpcdir getarg(0), DOWN; + + deltimer getarg(0) + "::OnBiteBait"; + narrator l("You pulled too soon and lost the bait."); + + close; + case LEFT: + @occupy = false; + setnpcdir getarg(0), DOWN; + getmapxy (.@mapbis$, .@xbis, .@ybis, 0); + + // Leave spot, lost the bait if (.@xbis != @x || .@ybis != @y || !compare (@map$, .@mapbis$)) { - narrator - l("You left your fishing spot!"); - // Leave spot, lost the bait, set @pull 3 - @pull = 3; + narrator l("You left your fishing spot!"); close; } + + // RNG to obtain a rare fish .@timediff = gettimetick(0) - @tick; - .@rnd = rand(.@timediff); if (rand(.@rare_fish_chance) == 0) + { .@fish_id = GrassCarp; - // debugmes "timediff = " + .@timediff; + } - if (.@rnd <= .@pull_rand_max) + // RNG to obtain a fish + if (rand(.@timediff) <= .@pull_rand_max) { - getitem .@fish_id, 1; + narrator l("You caught a @@!", getitemname(.@fish_id)); - narrator 1, - l("You caught a @@!", getitemname(.@fish_id)); - // player got the fish, done, set @pull 3 - @pull = 3; - close; + inventoryplace .@fish_id, 1; + getitem .@fish_id, 1; } else { - narrator 5, - l("You pulled too late and lost the bait."); - // the player pull to late, set @pull 3 - @pull = 3; - close; - } - case 3: - { - break; + narrator l("You pulled too late and lost a @@...", getitemname(.@fish_id)); } + + close; + + default: + break; } -L_ChooseBait: +OnChooseBait: if (Fishing_Tick > gettimetick(2) - 20) { - mes "Busy, please, wait few seconds."; + narrator l("This fishing spot has just been used, give it a rest."); close; } @@ -136,23 +146,30 @@ L_ChooseBait: return 0; } + if (@occupy == true) + { + narrator 1, + l("Somebody took your place on this spot!"), + l("You take your fishing rod and leave."); + return 0; + } + @occupy = true; + + // The player occupy this spot, his bait is ready, he just have to wait the signal. + closedialog; + + setnpcdir getarg(0), UP; + Fishing_Tick = gettimetick(2); .@bait = .@user_items[.@idx - 1]; delitem .@bait, 1; - narrator 3, - l("You use a @@ as bait.", getitemname(.@bait)), - l("You patiently wait..."); // maybe adding here informatiopn about effect - // because the player don't know he need to wait the signal effect + npctalk3 l("Wait for the bait to sink underwater."); getmapxy (@map$, @x, @y, 0); .@delay = rand(.@wait_time_min, .@wait_time_max); - // set 1 the @pull, the bait is ready, player need to wait the signal - @pull = 1; - // @spot$ is set by the spot npc - addtimer .@delay, "" + getarg(0) + "::OnPull"; + addtimer .@delay, getarg(0) + "::OnBiteBait"; close; - } |