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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
// Annual easter event.
// Annual_Quest byte 1 is used, see Oscar.txt for further information.
// Author: PjotrOrial
// read up on http://en.wikipedia.org/wiki/Computus
// Easter cannot be before march 22 or after april 25, so activate
// the event in these days.
function|script|AnnualEasterEvent
{
if ((gettimetick(2)-TUT_var < 5*7*86400) || (BaseLevel < 40)) //player must be created at least 5 weeks ago
goto L_EndTooYoung;
if (@eastertimepenalty == 0)
goto L_WarmUp;
// prevent clicking multiple times:
if (gettimetick(2) < @eastertimepenalty + $@EASTER_FOUND_WAIT_TIME)
goto L_End2;
set @eastertimepenalty, gettimetick(2);
// global counter to determine reshuffle times of the eggs.
set $@peopleFoundEggs[@EasterEggID], $@peopleFoundEggs[@EasterEggID]+1;
set @AnnualEasterTries, @AnnualEasterTries + 1;
// give a small reward:
message strcharinfo(0), "You found something!";
set @tmp, getarraysize($@SmallAnnualEasterItems$);
set @random, rand(@tmp + 2);
if (@random < @tmp) getitem $@SmallAnnualEasterItems$[@random], rand(1, 2);
if (@random == @tmp) getexp rand(200), 0;
if (@random == @tmp + 1) set Zeny, Zeny + rand(50);
misceffect FX_GETITEM, strcharinfo(0);
// give out a better reward occasionally:
// standard case is branch taken, so only if rand yields 0, medium rewarding.
if (rand($@EASTER_EGG_INV_CHANCE))
goto L_NoEasterEgg;
set @random, rand(getarraysize($@MediumAnnualEasterRewards$));
getitem $@MediumAnnualEasterRewards$[@random], 1;
misceffect FX_GETITEM, strcharinfo(0);
goto L_NoEasterEgg;
L_NoEasterEgg:
// If you're lucky you get a bigger unique reward per year:
// so only pass on a small chance iff you don't have the item yet.
// Usually the journey ends here because @random != 0 -> end
callsub S_Read_Annual_Quest;
if (@AnnualEasterTries > $@EASTER_FINAL_REW_INV_CHANCE)
set @AnnualEasterTries, $@EASTER_FINAL_REW_INV_CHANCE;
set @random, rand($@EASTER_FINAL_REW_INV_CHANCE - @AnnualEasterTries + 1);
if (@random || @easter_year > gettime(7) - 2000)
goto L_End1;
// block for further items this year:
set @easter_year, gettime(7) - 2000 + 1;
callsub S_Update_Annual_Quest;
// 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.
set @rewardindex, gettime(7) - 2012;
if (rand(100) < 5)
set @rewardindex, @rewardindex + 1;
// now hand out the specific item:
set @rewardindex, @rewardindex % getarraysize($@FinalAnnualEasterReward$);
getitem $@FinalAnnualEasterReward$[@rewardindex], 1;
misceffect FX_GETITEM, strcharinfo(0);
message strcharinfo(0), "This is really special. You won't find anything like this again.";
goto L_End1;
S_Read_Annual_Quest:
set @easter_year, (Annual_Quest & BYTE_1_MASK) >> BYTE_1_SHIFT;
return;
S_Update_Annual_Quest:
set Annual_Quest, (Annual_Quest & ~(BYTE_1_MASK) | (@easter_year << BYTE_1_SHIFT));
return;
L_EndTooYoung:
message strcharinfo(0), "The nest is empty.";
goto L_End1;
L_WarmUp:
set @eastertimepenalty, gettimetick(2);
getitem "GreenApple", 1;
misceffect FX_GETITEM, strcharinfo(0);
message strcharinfo(0), "Hmmm eggs! Maybe you can find something nice there!";
goto L_End1;
L_End2:
message strcharinfo(0), "Don't be greedy! You just found something a moment ago.";
set @eastertimepenalty, @eastertimepenalty + 5;
if (@eastertimepenalty > gettimetick(2))
set @eastertimepenalty, gettimetick(2);
goto L_End1;
L_End1:
set @rewardindex, 0;
set @easter_year, 0;
set @random, 0;
set @tmp, 0;
set @EasterEggID, 0;
return;
}
008-1,65,40,0|script|#TestEgg0|375
{
set @EasterEggID, 0;
callfunc("AnnualEasterEvent");
end;
}
008-1,65,40,0|script|#TestEgg1|375
{
set @EasterEggID, 1;
callfunc("AnnualEasterEvent");
end;
}
008-1,65,40,0|script|#TestEgg2|375
{
set @EasterEggID, 2;
callfunc("AnnualEasterEvent");
end;
}
008-1,59,38,0|script|#AnnualEaster|32767
{
end;
OnInit:
set $@EASTER_FOUND_WAIT_TIME, 15;
set $@EASTER_FINAL_REW_INV_CHANCE, 70;
set $@EASTER_EGG_INV_CHANCE, 750;
setarray $@easteregg_posx, 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;
setarray $@easteregg_posy, 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;
if (getarraysize($@easteregg_posy) != getarraysize($@easteregg_posx))
goto L_FAULTY_SETUP;
setarray $@SmallAnnualEasterItems$, "AppleCake", "CactusDrink", "CactusPotion", "Cake", "Candy", "CherryCake", "ChocolateBar", "ChocolateCake", "GreenApple", "Orange", "OrangeCake", "OrangeCupcake", "RedApple", "WhiteCake";
setarray $@MediumAnnualEasterRewards$, "RedEasterEgg", "GreenEasterEgg", "BlueEasterEgg", "YellowEasterEgg", "PinkEasterEgg", "TealEasterEgg";
// DO NOT CHANGE SIZE AFTER EASTER 2013!
setarray $@FinalAnnualEasterReward$, "RedEggshellHat", "BlueEggshellHat", "YellowEggshellHat", "GreenEggshellHat", "OrangeEggshellHat", "DarkEggshellHat";
callsub S_disableEggs;
if (debug >= 2) end;
initnpctimer;
end;
L_FAULTY_SETUP:
mapexit;
OnTimer1000:
setnpctimer 0;
// an egg can be 'found' multiple times, make this number of possible findings
// depend on the number of players currently on the map.
set $@AEASTER_mapcount, 1 + getmapusers("008-1") / 3;
set $@isEaster, 0;
if ((gettime(6) == 3 && gettime(5) >= 22) || (gettime(6) == 4 && gettime(5) <= 25))
set $@isEaster, 1;
if (!$@wasEaster && $@isEaster)
goto L_do_update_enable;
if ($@wasEaster && !$@isEaster)
goto L_do_update_disable;
goto L_done_update;
L_do_update_enable:
callsub S_enableEggs;
goto L_done_update;
L_do_update_disable:
callsub S_disableEggs;
goto L_done_update;
L_done_update:
set $@wasEaster, $@isEaster;
if (!$@isEaster)
goto L_End;
set $@EggID, 0;
callsub S_relocateEasterEgg;
set $@EggID, 1;
callsub S_relocateEasterEgg;
set $@EggID, 2;
callsub S_relocateEasterEgg;
// intentional fallthrough to L_End
goto L_End;
L_End:
set $@AEASTER_mapcount, 0;
set $@EggID, 0;
set $@isEaster, 0;
end;
S_enableEggs:
enablenpc "#TestEgg0";
enablenpc "#TestEgg1";
enablenpc "#TestEgg2";
return;
S_disableEggs:
disablenpc "#TestEgg0";
disablenpc "#TestEgg1";
disablenpc "#TestEgg2";
return;
S_relocateEasterEgg:
if ($@peopleFoundEggs[$@EggID] < $@AEASTER_mapcount)
goto S_Return;
set $@peopleFoundEggs[$@EggID], 0;
set $@eastereggPos, rand(getarraysize($@easteregg_posx));
npcwarp $@easteregg_posx[$@eastereggPos], $@easteregg_posy[$@eastereggPos], "#TestEgg" + $@EggID;
goto S_Return;
S_Return:
return;
}
|