summaryrefslogtreecommitdiff
path: root/npc/008-1/annualeaster.txt
blob: 618a0956a25bb5b475474c4bb937e9b92db3d69f (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
008-1,0,0,0	script	Easter Eggs	NPC32767,{


    if (strnpcinfo(2) == "") end;
    if (get(.disabled, "Easter Eggs") || $@isEaster < 1) goto L_Destroy;
    @npc_distance = 1;
    callfunc "PCtoNPCRange";
    if(@npc_check) end;
    if ((gettimetick(2)-TUT_var < 5*7*86400) || (BaseLevel < 40)) //player must be created at least 5 weeks ago
        goto L_EndTooYoung;

    @easter_year = (Annual_Quest & BYTE_1_MASK) >> BYTE_1_SHIFT;

    if (#EASTERTIMEPENALTY == 0)
        goto L_WarmUp;
    // prevent clicking multiple times:
    if (gettimetick(2) < #EASTERTIMEPENALTY + get(.wait_time, "Easter Eggs"))
        goto L_End2;
    if (@easter_year > gettime(7) - 2000)
        goto L_End3;
    #EASTERTIMEPENALTY = gettimetick(2);

    set .found, .found + 1; // this egg has been found X times
    set @AnnualEasterTries, @AnnualEasterTries + 1; // you tried X times since login

    message strcharinfo(0), "Eggs : You found something!";
    .@size = get(.small_rewards, "Easter Eggs");
    .@random = rand(.@size+2);
    if (.@random < .@size)
        getitem get(.small_rewards$[.@random], "Easter Eggs"), rand(1, 2);
    else if (.@random == .@size)
        getexp rand(200), 0;
    else
        Zeny = Zeny + rand(50);

    if (rand(get(.chance, "Easter Eggs")))
        goto L_NoEasterEgg;


    .@random = rand(get(.medium_rewards$, "Easter Eggs"));
    getitem get(.medium_rewards$[.@random], "Easter Eggs"), 1;
    misceffect FX_GETITEM, strcharinfo(0);
    goto L_NoEasterEgg;

L_NoEasterEgg:
    .@fchance = get(.final_rew_chance, "Easter Eggs");
    if (@AnnualEasterTries > .@fchance)
        @AnnualEasterTries = .@fchance;
    .@random = rand(.@fchance - @AnnualEasterTries + 1);
    if (.@random || @easter_year > gettime(7) - 2000)
        goto L_Reward_End;

    // block for further items this year:
    @easter_year = gettime(7) - 2000 + 1;
    Annual_Quest = (Annual_Quest & ~(BYTE_1_MASK) | (@easter_year << BYTE_1_SHIFT));

    // Hand out pretty unique rewards depending on the current year:
    // We'll be handing out 2 different items each year, whereas one of them
    // will be very common (95 %) and the other rare (5 %) for the players.
    // The rare item will become the common item next year.
    .@rewardindex = gettime(7) - 2012;
    if (rand(100) < 5)
        .@rewardindex = .@rewardindex + 1;

    // now hand out the specific item:
    .@rewardindex = .@rewardindex % get(.big_rewards, "Easter Eggs");
    getitem get(.big_rewards$[.@rewardindex], "Easter Eggs"), 1;
    misceffect FX_GETITEM, strcharinfo(0);
    message strcharinfo(0), "Eggs : This is really special. You won't find anything like this again.";
    goto L_Reward_End;

L_Reward_End:
    if (.found >= get(.mapcount, "Easter Eggs"))
        goto L_Destroy;
    end;

L_Destroy:
    set(getvariableofnpc(.eggs, "Easter Eggs"), get(.eggs, "Easter Eggs") - 1); // tell the puppeteer we lost an egg
    destroy;

L_EndTooYoung:
    message strcharinfo(0), "Eggs : The nest is empty.";
    end;

L_WarmUp:
    #EASTERTIMEPENALTY = gettimetick(2);
    getitem "MoubooFigurine", 1;
    misceffect FX_GETITEM, strcharinfo(0);
    message strcharinfo(0), "Eggs : Hmmm eggs! Maybe you can find something nice there!";
    end;

L_End3:
    message strcharinfo(0), "Eggs : Don't be greedy! You already found something nice.";
    end;

L_End2:
    message strcharinfo(0), "Eggs : Don't be greedy! You just found something a moment ago.";
    #EASTERTIMEPENALTY = #EASTERTIMEPENALTY + 5;
    if (#EASTERTIMEPENALTY > gettimetick(2))
        #EASTERTIMEPENALTY = gettimetick(2);
    end;

OnTimer5000:
    if (get(.disabled, "Easter Eggs") || $@isEaster < 1)
        goto L_Destroy;
    initnpctimer;
    end;



OnSpawn:
    .@e = rand(2,.loc[1]);
    .@x = .loc[.@e];
    .@y = .loc[(.@e-1)+.loc[1]];
    set .eID, .eID + 1; // give the egg an id
    .@name$ = "#--Ee"+chr(3)+.eID;
    if (.eID == 2147483647)
        set .eID, 0; // start over if id = 0x7FFFFFFF
    if (puppet(strnpcinfo(3), .@x, .@y, .@name$, 375) < 1) goto L_RetrySpawn; // spawn the egg
    initnpctimer .@name$; // init puppeteer check timer
    end;

L_RetrySpawn:
    addnpctimer 0, strnpcinfo(0) + "::OnSpawn"; // schedule a spawn
    end;

S_Spawn:
    if (.eggs >= .max_eggs)
        goto S_Return;
    .eggs = .eggs + 1;
    addnpctimer 125 + rand(250), strnpcinfo(0) + "::OnSpawn"; // schedule a spawn
    if (.eggs < .min_eggs)
        goto S_Spawn;
    return;

S_Return:
    return;

OnHeartbeat:
    if (.max_eggs < 1 || .disabled || $@isEaster < 1) end;
    .mapcount = 1 + getmapusers(strnpcinfo(3)) / 3;
    callsub S_Spawn;
    addnpctimer 1000, strnpcinfo(0) + "::OnHeartbeat"; // heartbeat
    end;

OnCheckEaster:
    if ((gettime(6) == 3 && gettime(5) >= 22) || (gettime(6) == 4 && gettime(5) <= 25))
        $@isEaster = 1;
    else
        $@isEaster = 0;
    if ($@isEaster && .eggs < 1)
        donpcevent "Easter Eggs::OnStart";
    end;

OnStart:
    if (.disabled || $@isEaster < 1) end;
    set .min_eggs, 1; // min number of eggs
    set .max_eggs, 3; // max number of eggs
    set .eggs, 0; // virtual amount of eggs
    set .eID, 0; // last egg id
    .wait_time = 15;
    .final_rew_chance = 70;
    .chance = 750;
    setarray .loc[0], 0, 1,1, // first row: x, second row: y
        41, 45, 50, 57, 60, 64, 67, 65, 59, 72, 70, 82, 81, 93, 97, 101, 88, 108, 115, 122, 122, 129, 129, 130, 135, 123, 132, 132, 127, 124, 121, 107, 100, 101, 109, 104, 88, 84, 92, 59, 71, 65, 53, 55, 74, 59, 53, 46, 44, 44, 38, 43, 40, 43, 37,
        87, 89, 88, 93, 98, 90, 96, 82, 81, 82, 96, 98, 92, 89, 89,  81, 82,  94,  96,  96,  90,  86,  72,  65,  60,  46,  25,  21,  20,  22,  20,  34,  24,  41,  43,  42, 48, 28, 27, 17, 23, 29, 25, 20, 39, 41, 34, 36, 18, 25, 31, 39, 64, 69, 73;
    set .loc[0], (getarraysize(.loc) - 1); // loc 0 and 1 are special (stores array size, and half index)
    .loc[1] = ((.loc[0]+1)/2);
    setarray .small_rewards$[0], 0, "AppleCake", "CactusDrink", "CactusPotion", "Cake", "Candy", "CherryCake", "ChocolateBar", "ChocolateCake", "GreenApple", "Orange", "OrangeCake", "OrangeCupcake", "RedApple", "WhiteCake";
    .small_rewards = getarraysize(.small_rewards$);
    setarray .medium_rewards$[0], 0, "RedEasterEgg", "GreenEasterEgg",  "BlueEasterEgg", "YellowEasterEgg",  "PinkEasterEgg", "TealEasterEgg";
    setarray .big_rewards$[0], 0, "RedEggshellHat", "BlueEggshellHat", "YellowEggshellHat", "GreenEggshellHat", "OrangeEggshellHat", "DarkEggshellHat";
    .big_rewards = getarraysize(.big_rewards$);
    donpcevent strnpcinfo(0) + "::OnHeartbeat"; // first heartbeat
    end;
}

function	script	Easter Debug	{
    goto L_Menu;

L_Menu:
    clear;
    mes "Please choose an option.";
    if (get(.disabled, "Easter Eggs"))
        menu
            "Do Nothing.", L_Return,
            "Enable eggs.", L_Enable;
    menu
        "Do Nothing.", L_Return,
        "Disable eggs.", L_Disable;

L_Enable:
    set(getvariableofnpc(.disabled, "Easter Eggs"), 0);
    clear;
    mes "Easter Eggs enabled.";
    next;
    goto L_Menu;

L_Disable:
    set(getvariableofnpc(.disabled, "Easter Eggs"), 1);
    // TODO: Destroy puppets/timers/etc
    clear;
    mes "Easter Eggs disabled.";
    next;
    goto L_Menu;

L_Return:
    return;
}