summaryrefslogtreecommitdiff
path: root/world/map/npc/annuals/xmas/core.txt
blob: 4e628bb49cbaf1e2cd3d4e991ef1e9702d02220b (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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// This file is part of Christmas Event
// author: Jenalya, Chayenne, cinderweb, wushin
// please see #XmasConfig

function|script|XmasNaughty
{
    set @xmas_karma, ((XMASTIME & NIBBLE_1_MASK) >> NIBBLE_1_SHIFT);
    if((@xmas_karma - @karma_bonus) >= 0)
        goto L_SetNaughty;
    goto L_ResetNaughty;

L_SetNaughty:
    set @xmas_karma, (@xmas_karma - @karma_bonus);
    goto L_Return;

L_ResetNaughty:
    set @xmas_karma, 0;
    goto L_Return;

L_Return:
    set XMASTIME, (XMASTIME & ~(NIBBLE_1_MASK) | (@xmas_karma << NIBBLE_1_SHIFT));
    set @karma_bonus, 0;
    return;
}

function|script|XmasNice
{
    set @xmas_karma, ((XMASTIME & NIBBLE_1_MASK) >> NIBBLE_1_SHIFT);
    if((@xmas_karma + @karma_bonus) < 16)
        goto L_SetNice;
    goto L_ResetNice;

L_SetNice:
    set @xmas_karma, (@karma_bonus + @xmas_karma);
    goto L_Return;

L_ResetNice:
    set @xmas_karma, 15;
    goto L_Return;

L_Return:
    set XMASTIME, (XMASTIME & ~(NIBBLE_1_MASK) | (@xmas_karma << NIBBLE_1_SHIFT));
    set @karma_bonus, 0;
    return;
}

// Called for a basic reward for quests state completion
function|script|XmasXpReward
{
    if (BaseLevel >= 10)
        goto L_HigherLevel;
    goto L_LowLevel;

L_HigherLevel:
    getexp ((BaseLevel / 10) * ($@xmas_base_bonus_xp * BaseLevel)), 0;
    goto L_Return;

L_LowLevel:
    getexp ($@xmas_base_bonus_xp * BaseLevel), 0;
    goto L_Return;

L_Return:
    return;
}

function|script|XmasSetState
{
    set XMASTIME, (XMASTIME & ~(NIBBLE_0_MASK) | (@xmas_state << NIBBLE_0_SHIFT));
    return;
}

function|script|XmasSetSide
{
    set XMASTIME, XMASTIME | $@xmas_side_bit;
    return;
}

function|script|XmasSetRoute
{
    set XMASTIME, XMASTIME | $@xmas_route_bit;
    return;
}

function|script|XmasThrowOut
{
    set XMASTIME, XMASTIME | $@xmas_thrown_out_bit;
    return;
}

function|script|XmasSetBossStart
{
    set XMASTIME, XMASTIME | $@xmas_boss_start_bit;
    return;
}

function|script|XmasSetBossHero
{
    set XMASTIME, XMASTIME | $@xmas_boss_hero_bit;
    return;
}

// Tallys the players quest
function|script|XmasSetReward
{
    set @xmas_endgame, 0;
    set @xmas_reward_side, 0;
    set @xmas_reward_tally, 0;
    if(@xmas_side)
        goto L_SetSide;
    goto L_NotSetSide;

L_SetSide:
    set @xmas_reward_side, 1;
    set @xmas_reward_tally, (@xmas_reward_tally + ($@xmas_reward_max_karma - @xmas_karma));
    goto L_SetRewardBonus;

L_NotSetSide:
    set @xmas_reward_tally, (@xmas_reward_tally + @xmas_karma);
    goto L_SetRewardBonus;

L_SetRewardBonus:
    if(@xmas_boss_hero)
        set @xmas_reward_tally, (@xmas_reward_tally + $@xmas_reward_hero_boss);
    if(@xmas_all_helpers)
        set @xmas_reward_tally, (@xmas_reward_tally + $@xmas_reward_all_helpers);
    if(@xmas_all_lists)
        set @xmas_reward_tally, (@xmas_reward_tally + $@xmas_reward_all_lists);
    //formula should:
    if (@xmas_reward_tally > 5)
        set @xmas_reward_lower_bound, 2 * @xmas_reward_tally - rand(5);
    if (@xmas_reward_tally <= 5)
        set @xmas_reward_lower_bound, @xmas_reward_tally;
    set @xmas_reward_upper_bound, @xmas_reward_lower_bound + ((Luk) / 5);
    set @xmas_reward, (rand(@xmas_reward_lower_bound, @xmas_reward_upper_bound));
    set @xmas_reward_lower_bound, 0;
    set @xmas_reward_upper_bound, 0;
    return;
}

// Main quest completion reward
function|script|XmasMainXpBpReward
{
    callfunc "XmasSetReward";

    if(BaseLevel >= 135)
        goto L_EndGameReward;
    goto L_LevelingReward;

L_EndGameReward:
    set @xmas_bp_reward, 100 + rand(@xmas_reward, 2 * @xmas_reward);
    set BOSS_POINTS, BOSS_POINTS + @xmas_bp_reward;
    message strcharinfo(0), "You gain " + @xmas_bp_reward + " Bosspoints, giving you a total of " + BOSS_POINTS + ".";
    set @xmas_bp_reward, 0;
    return;

L_LevelingReward:
    if(@xmas_reward >= $@xmas_reward_tally_rare)
        goto L_XmasLevel;
    goto L_XmasExp;

L_XmasLevel:
    set BaseLevel, BaseLevel + 1;
    return;

L_XmasExp:
    getexp ((@xmas_reward * BaseLevel * (BaseLevel + 10)) / 10), 0;
    return;
}

// Final Item reward
function|script|XmasMainItemReward
{
    callfunc "XmasSetReward";

    if (($@xmas_time == $@xmas_reward_time) && ((@xmas_reward_start_state) || (@xmas_reward1_done_state)))
        goto L_FinalGift;
    if (($@xmas_time == $@xmas_reward_time) && ((@xmas_reward_done_state) || (@xmas_reward2_done_state)))
        goto L_GotGift;
    if ($@xmas_time == $@xmas_reward_time)
        goto L_NoGift;
    goto L_Return;

L_GotGift:
    mes "Hey, this is not for you!";
    goto L_Return;

L_NoGift:
    mes "Oh someone got a present. Maybe you can get one too if help the right person?";
    goto L_Return;

L_FinalGift:
    mes "[To: " + strcharinfo(0) + "]";
    mes "[From: " + $@xmas_present_from$[@xmas_reward_side] + "]";
    mes "O look, a present from " + $@xmas_present_from$[@xmas_reward_side];
    next;
    getinventorylist;
    if (@inventorylist_count > 97)
        goto L_FullInv;
    set @xmas_reward, (@xmas_reward + ((BaseLevel + 10)/10));
    if (debug > 0)
        message strcharinfo(0), "Reward variable: " + @xmas_reward;
    set @xmas_uncommon_slot1, rand(getarraysize($@xmas_uncommon_reward$));
    set @xmas_uncommon_slot2, rand(getarraysize($@xmas_uncommon_reward$));
    if(@xmas_reward >= $@xmas_reward_tally_rare)
        set @xmas_reward_item$, $@xmas_rare_reward$[@xmas_reward_side];
    if(@xmas_reward >= $@xmas_reward_tally_common)
        set @xmas_reward_item1$, $@xmas_uncommon_reward$[@xmas_uncommon_slot1];
    set @xmas_reward_item2$, $@xmas_uncommon_reward$[@xmas_uncommon_slot2];
    if(checkweight("Iten", 1) == 0)
        goto L_FullInv;
    if(@xmas_reward >= $@xmas_reward_tally_rare)
        getitem @xmas_reward_item$, 1;
    if(@xmas_reward >= $@xmas_reward_tally_common)
        getitem @xmas_reward_item1$, 1;
    getitem @xmas_reward_item2$, 1;
    set @xmas_uncommon_slot1, 0;
    set @xmas_uncommon_slot2, 0;
    set @xmas_reward_item$, "";
    set @xmas_reward_item1$, "";
    set @xmas_reward_item2$, "";
    if (@xmas_reward_start_state)
        set @xmas_state, $@xmas_reward2_done;
    if (@xmas_reward1_done_state)
        set @xmas_state, $@xmas_reward_done;
    callfunc "XmasSetState";
    goto L_Return;

L_FullInv:
    mes "\"You have no place to put the present.\"";
    goto L_Return;

L_Return:
    return;
}

// Checks for an expired event key
// Each new annual event needs a new key
// or it will allow completion from last year
function|script|XmasCheckOld
{
    if(XMASYEAR == $XMAS_TIME_KEY[5])
        goto L_Return;
    goto L_OldMatch;

L_OldMatch:
    set XMASTIME, 0;
    set XMASYEAR, $XMAS_TIME_KEY[5];
    goto L_Return;

L_Return:
    return;
}