From c811ec5446242bcb2ecb60e0c454dc0a2419b60d Mon Sep 17 00:00:00 2001
From: Reid <reidyaro@gmail.com>
Date: Sat, 6 Aug 2016 07:01:59 +0200
Subject: Update the fishing support with the new animation.

---
 npc/001-1/wateranimation.txt | 343 ++++++++++++++++++++++++-------------------
 npc/functions/fishing.txt    | 143 ++++++++++--------
 2 files changed, 273 insertions(+), 213 deletions(-)

(limited to 'npc')

diff --git a/npc/001-1/wateranimation.txt b/npc/001-1/wateranimation.txt
index ad409d1a..fda5f23e 100644
--- a/npc/001-1/wateranimation.txt
+++ b/npc/001-1/wateranimation.txt
@@ -5,23 +5,23 @@
 //    Water animations, splash, fishes, etc...
 
 001-1,116,123,0	script	#water_animation0	NPC_WATER_SPLASH,{
-    // skip the narator when we are in fishing
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
-    fishing strnpcinfo(3); // give the name of npc for set the addtimer.
+
+    fishingspot strnpcinfo(3);
+    fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106; // here the effect, emote is just for try :3
-    if (@pull == 3) // is too late or too soon, don't set the @pull 2
-                    // useless for now, because if you fail that delete the timer
-                    // just a security
-        end;
-    else
-        @pull = 2; // set 2, the fish bite the bait
-        @tick = gettimetick(0); // the tick required for the pull_max 
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -29,20 +29,23 @@ OnInit:
 }
 
 001-1,119,102,0	script	#water_animation1	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -50,20 +53,23 @@ OnInit:
 }
 
 001-1,167,82,0	script	#water_animation2	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -71,20 +77,23 @@ OnInit:
 }
 
 001-1,167,40,0	script	#water_animation3	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -92,20 +101,23 @@ OnInit:
 }
 
 001-1,104,127,0	script	#water_animation4	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -113,20 +125,23 @@ OnInit:
 }
 
 001-1,166,123,0	script	#water_animation5	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -134,20 +149,23 @@ OnInit:
 }
 
 001-1,181,119,0	script	#water_animation6	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -155,20 +173,23 @@ OnInit:
 }
 
 001-1,202,114,0	script	#water_animation7	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -176,20 +197,23 @@ OnInit:
 }
 
 001-1,187,86,0	script	#water_animation8	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -197,20 +221,23 @@ OnInit:
 }
 
 001-1,32,57,0	script	#water_animation9	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -218,20 +245,23 @@ OnInit:
 }
 
 001-1,40,144,0	script	#water_animation10	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -239,20 +269,23 @@ OnInit:
 }
 
 001-1,58,131,0	script	#water_animation11	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -260,20 +293,23 @@ OnInit:
 }
 
 001-1,76,137,0	script	#water_animation12	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -281,20 +317,23 @@ OnInit:
 }
 
 001-1,109,132,0	script	#water_animation13	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -302,20 +341,23 @@ OnInit:
 }
 
 001-1,141,93,0	script	#water_animation14	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water.");
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
@@ -323,22 +365,23 @@ OnInit:
 }
 
 001-1,168,57,0	script	#water_animation15	NPC_WATER_SPLASH,{
-    if (@pull != 1 && @pull != 2)
-    {
-        narrator 4, l("You see some fish reflecting the sun on the surface of the water. " + @pull + "");
-    }
+
+    fishingspot strnpcinfo(3);
     fishing strnpcinfo(3);
     close;
 
-OnPull:
-    emotion 106;
-    if (@pull == 3)
-        end;
-    else
-        @pull = 2;
-        @tick = gettimetick(0);
+OnBiteBait:
+    .dir = LEFT;
+    @tick = gettimetick(0);
+
     end;
 
+OnTimer35000:
+    .dir = DOWN;
+    @occupy = false;
+
+    close;
+
 OnInit:
     .sex = G_OTHER;
     .distance = 5;
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;
-
 }
-- 
cgit v1.2.3-70-g09d2