summaryrefslogtreecommitdiff
path: root/npc/functions/fishing.txt
blob: 3445c1256f31be7a06e7813d8ee06490d272d9bb (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
// Evol functions.
// Authors:
//    Travolta
// Description:
//    Fishing functions.


function	script	fishing	{

    .@wait_time_min = 5000;
    .@wait_time_max = 30000;
    .@pull_rand_max = 800;
    .@pull_timeout = 1500;
    .@fish_id = CommonCarp;
    .@max_wait_times = 3;
    .@rare_fish_chance = 2500;

    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 0,
        l("What will be the bait for the fish?");
    .@idx = select(.@sel$);

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

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

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

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


    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))
                .@fish_id = GrassCarp;
            // debugmes "timediff = " + .@timediff;

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

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

                return 1;
            }
            else
            {
                narrator
                    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
                    l("The fish ate all your bait.");
                goto L_ChooseBait;
            }
            else
            {
                narrator l("The fish ate small part of your bait.");
                mes col(l("But you decide to patiently wait."), 9);

                goto L_Wait;
            }
            break;

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

    return;
}