summaryrefslogtreecommitdiff
path: root/npc/052-2/storage.txt
blob: b56314e2de6ddf7fb5a50180e0690dadbe4c23e5 (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
052-2,33,79,0	script	#TriggerItemsInvoker	NPC32767,1,0,{
    @step = 6;
    if ($@illia_progress < @step) goto L_ShouldNotBeHere;
    if (strcharinfo(0) != $@iLLIA_HERO$) end;
    if ($@illia_level_6_progress == 0) goto L_StartItemInvoker;
    end;

L_ShouldNotBeHere:
    die();
    end;

L_StartItemInvoker:
    $@illia_level_6_progress = 1;
    donpcevent "#ItemsInvoker::OnCommandStart";
    end;

}

052-2,1,1,0	script	#ItemsInvoker	NPC32767,{
end;

OnInit:
    setarray $@illia_storage_items, 541, 567, 568, 562;
    setarray $@illia_storage_special_items, 687, 827, 1229;
    // Map coords:* x1,y1, x2,y2, ...
    setarray $@illia_storage_item_points, 30,77, 32,85, 37,81, 40,83, 44,86, 40,74, 44,75, 44,72, 31,71, 32,74;
    end;

OnCommandStart:
    $@illia_storage_max_items = 20;
    $@illia_storage_deviation = (8 + ($Illia_Luvia_Harvest*70)/100)*3;
    initnpctimer;
    areatimer 0, "052-2", 29, 70, 45, 88, 10, "#ItemsInvoker::OnStart";
    end;

OnStart:
    message strcharinfo(0), "You feel a strange atmosphere in this room... You sense a strong magic rising from the depth!";
    end;

OnTimer1000:
    if ($@illia_storage_max_items == 0)
        goto L_CheckMobs;
    $@item_invoke_index = rand(getarraysize($@illia_storage_item_points)/2);
    $@item_invoke_x = $@illia_storage_item_points[$@item_invoke_index*2];
    $@item_invoke_y = $@illia_storage_item_points[($@item_invoke_index*2)+1];
    npcwarp $@item_invoke_x, $@item_invoke_y, "#ItemsInvoker";
    // This is a fix to force the official mana client to display a npc after a warp.
    // Note: the manaplus client do not need this.
    disablenpc "#ItemsInvoker";
    end;

OnTimer1500:
    // See the note above.
    enablenpc "#ItemsInvoker";
    areatimer 0, "052-2", 29, 70, 45, 88, 10, "#ItemsInvoker::OnItem";
    misceffect FX_GROUND_SPAWN;
    end;

OnTimer3750:
    setnpctimer 0;
    $@item_invoke_x = 0;
    $@item_invoke_y = 0;
    $@item_invoke_index = 0;
    end;

OnItem:
    if (strcharinfo(0) == $@iLLIA_HERO$)
        goto L_ItemSpawn;
    end;

L_ItemSpawn:
    // This section will decide what to spawn: special monster, monster, item, special item
    // Calculation uses a decreasing variable which introduces a deviation.
    // Its initial value is based on $@illia_Luvia_Harvest
    //  * first decide (50% / 50%) if the deviation will be positive or negative
    //  * Apply the deviation to a random number between 0, 100. (note the final value can be < 0 or > 100)
    // The purpose is that, when the initial deviation is high, there are high chances to get either
    // a special monster, or a special item.
    @m = rand(100);
    if (@m < 50)
        @r = rand(100) - $@illia_storage_deviation;
    if (@m >= 50)
        @r = rand(100) + $@illia_storage_deviation;
    // Reduce the deviation
    $@illia_storage_deviation = $@illia_storage_deviation*83/100;
    if (@r < 5)
        goto L_MakeSpecialMonster;
    if (@r < 50)
        goto L_MakeMonster;
    if (@r > 98)
        goto L_MakeSpecialItem;
    // Normal item
    makeitem $@illia_storage_items[rand(getarraysize($@illia_storage_items))], rand(2, 8), "052-2", $@item_invoke_x, $@item_invoke_y;
    $@illia_storage_max_items = $@illia_storage_max_items - 1;
    @r = 0;
    end;

L_MakeSpecialMonster:
    monster "052-2", $@item_invoke_x, $@item_invoke_y, "", 1103, 1, "#ItemsInvoker::OnDeath";
    areatimer 0, "052-2", 29, 70, 45, 88, 10, "#ItemsInvoker::OnWtf";
    $@illia_storage_max_items = $@illia_storage_max_items - 1;
    end;

L_MakeMonster:
    monster "052-2", $@item_invoke_x, $@item_invoke_y, "", 1101, rand(1, 3), "#ItemsInvoker::OnDeath";
    $@illia_storage_max_items = $@illia_storage_max_items - 1;
    @r = 0;
    end;

L_MakeSpecialItem:
    makeitem $@illia_storage_special_items[rand(getarraysize($@illia_storage_special_items))], rand(2, 4), "052-2", $@item_invoke_x, $@item_invoke_y;
    areatimer 0, "052-2", 29, 70, 45, 88, 10, "#ItemsInvoker::OnWow";
    $@illia_storage_max_items = $@illia_storage_max_items - 1;
    @r = 0;
    end;

L_CheckMobs:
    if ($@illia_progress != 6)
        goto L_Clear;
    if (mobcount("052-2", "#ItemsInvoker::OnDeath") <= 0)
        goto L_Stop;
    setnpctimer 0;
    end;

L_Clear:
    stopnpctimer;
    setnpctimer 0;
    $@illia_storage_deviation = 0;
    $@illia_storage_max_items = 0;
    killmonster "052-2", "#ItemsInvoker::OnDeath";
    end;

L_Stop:
    stopnpctimer;
    setnpctimer 0;
    npcwarp 1, 1, "#ItemsInvoker";
    $@illia_storage_deviation = 0;
    $@illia_storage_max_items = 0;
    $@illia_level_6_progress = 2;
    $@illia_progress = 7;
    callfunc "UpdateIlliaProgress";
    $@illia_max_time = $@illia_max_time + 900;
    areatimer 0, "052-2", 29, 70, 45, 88, 10, "#ItemsInvoker::OnStop";
    end;

OnDeath:
    end;

OnStop:
    message strcharinfo(0), "The magic seems to quickly dissipate.";
    end;

OnWtf:
    message strcharinfo(0), "Look out!";
    end;

OnWow:
    message strcharinfo(0), "Wow, see what appeared!";
    end;

}

052-2,45,78,0	script	#ToPartyRoom	NPC32767,1,1,{
    @step = 6;
    if ($@illia_progress < @step) goto L_ShouldNotBeHere;
    if ($@illia_level_6_progress == 2) goto L_Warp;
    message strcharinfo(0), "The strong magic inside this room prevents you from going further.";
    end;

L_Warp:
    warp "052-2", 83, 58;
    end;

L_ShouldNotBeHere:
    die();
    end;

}