summaryrefslogtreecommitdiff
path: root/npc/functions/fishing.txt
blob: 8083e3753ef99f5a730743042e9413cc86d7f406 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Evol functions.
// Authors:
//    Travolta
// Description:
//    Fishing functions.

function	script	fishing	{

    .@wait_time_min = 8000;
    .@wait_time_max = 35000;
    .@pull_rand_max = 800;
    .@pull_timeout = 1500;
    .@fish_id = CommonCarp;
    .@max_wait_times = 3;
    .@rare_fish_chance = 25;

    setarray .@bait_ids[0], SmallTentacles, Bread, Aquada,
                            UrchinMeat, TortugaTongue,
                            Tentacles;
    if (countitem(FishingRod) < 1)
    {
        narrator
            l("You don't have a @@.", getitemlink(FishingRod));
        return -1;
    }

L_ChooseBait:
    .@curr_wait_times = 0;
    .@sel$ = "";
    .@cnt = 0;

    for (.@i = 0; .@i < getarraysize(.@bait_ids); .@i++)
        if (countitem(.@bait_ids[.@i]) > 0)
        {
            setarray .@user_items[.@cnt], .@bait_ids[.@i];
            .@sel$ = .@sel$ + getitemname(.@bait_ids[.@i]) + ":";
            .@cnt += 1;
        }
    .@sel$ = .@sel$ + l("Nothing, I changed my mind.");

    if (!.@cnt)
    {
        .@bait_names$ = getitemlink(.@bait_ids[0]);
        for (.@i = 1; .@i < getarraysize(.@bait_ids); .@i++)
            .@bait_names$ = .@bait_names$ + ", " + getitemlink(.@bait_ids[.@i]);
        narrator
            l("You don't have any food suitable for bait."),
            l("You need one of these: ") + .@bait_names$;
            return -2;
    }

    narrator 2,
        l("What will be the bait for the fish?");
    .@idx = select(.@sel$);

    if (.@idx == .@cnt + 1)
    {
        narrator 1,
            l("You take your fishing rod and leave.");
        return 0;
    }

    .@bait = .@user_items[.@idx - 1];
    delitem .@bait, 1;

    narrator 3,
        l("You use a @@ as a bait.", getitemname(.@bait)),
        l("You patiently wait...");

L_Wait:
    getmapxy (.@map$, .@x, .@y, 0);

    sleep2 rand(.@wait_time_min, .@wait_time_max);
    .@tick = gettimetick(0);

    getmapxy (.@mapbis$, .@xbis, .@ybis, 0);
    if (.@xbis != .@x || .@ybis != .@y || !compare (.@map$, .@mapbis$))
    {
        narrator
            l("You left your fishing spot!");
        close;
    }

    mes col(l("Splash!"), 9);
    mes "";

    menuint
        l("Pull!"), 1,
        l("Wait..."), 2,
        l("Give up."), 3;

    switch (@menuret)
    {
        case 1:
            .@timediff = gettimetick(0) - .@tick;
            .@rnd = rand(.@timediff);
            if (rand(.@rare_fish_chance) == 0)
                .@fish_id = GrassCarp;
            // debugmes "timediff = " + .@timediff;

            if (.@rnd <= .@pull_rand_max)
            {
                getitem .@fish_id, 1;

                narrator 1,
                    l("You caught a @@!", getitemname(.@fish_id));

                return 1;
            }
            else
            {
                narrator 5,
                    l("You pulled too late and lost the bait.");

                goto L_ChooseBait;
            }

        case 2:
            .@curr_wait_times += 1;

            if (.@curr_wait_times > .@max_wait_times)
            {
                narrator 5,
                    l("The fish ate all your bait.");
                goto L_ChooseBait;
            }
            else
            {
                narrator 3,
                    l("The fish ate small part of your bait."),
                    l("But you decide to patiently wait.");

                goto L_Wait;
            }
            break;

        case 3:
            narrator 1,
                l("You take your fishing rod and leave.");
            return 0;
    }

    return;
}