OSDN Git Service

First version
[st-ro/stro.git] / npc / guild / agit_main.txt
1 //===== rAthena Script =======================================
2 //= War of Emperium Guild Template File
3 //===== By: ==================================================
4 //= L0ne_W0lf
5 //===== Current Version: =====================================
6 //= 2.0
7 //===== Compatible With: =====================================
8 //= rAthena Project
9 //===== Description: =========================================
10 //= [Official Conversion]
11 //= ----------------------------------------------------------
12 //= - THIS FILE IS REQUIRED FOR GUILD CASTLES TO FUNCTION.
13 //= ----------------------------------------------------------
14 //= - Enables AGIT Manager inside Guild Strongholds.
15 //=   Visible Name required: Agit
16 //=   Manages the various functions used in and out of WoE.
17 //=
18 //= - Enables Stewards inside Guild Strongholds which let's
19 //=   the guild master invest in Defense and Economy, and
20 //=   to summon guardians, a Kafra, and enter master's room.
21 //=
22 //= - Guardian Spawning Template
23 //=   Visible Name required: Guardian
24 //=   Spawn guardians when guild castle data is recieved.
25 //=
26 //= - Enables Kafra Services inside Guild Strongholds.
27 //=   Visible Name required: Kafra Employee
28 //=   Storage, Guild Storage, Teleport Service, Cart rental.
29 //=
30 //= - Treasure Chest spawning.
31 //=   Chests will NOT be saved anymore in the event of crashes.
32 //=   Treasures will NOT spawn on a location that already has
33 //=   treasure chest spawned.
34 //===== Additional Comments: =================================
35 //= 1.0 First Version. No longer uses functions. [L0ne_W0lf]
36 //= 1.1 Daily investement will now be reset. [L0ne_W0lf]
37 //=     Template will no longer try to spawn chests.
38 //= 1.2 Fixed Eco Invest option charging twice. [L0ne_W0lf]
39 //= 1.3 Fixed a loading flag emblem for Payon 1. [L0ne_W0lf]
40 //=     Fixed two typos regarding Guild Steward name.
41 //= 1.4 Fixed a typo in defense investment. [L0ne_W0lf]
42 //= 1.5 Fixed spawn point of the emperium in Payon 1. [L0ne_W0lf]
43 //=     Double-investing doubles the price now.
44 //= 1.6 Corrected Zeny check when summoning guardians. [L0ne_W0lf]
45 //=     Corrected cost for investing, thanks to Ai4rei.
46 //=     Second invest is now quadruple the value of the first
47 //=     Investing now happens at the turn of the day.
48 //= 1.6a Corrected conditions in the new investing blocks. [L0ne_W0lf]
49 //= 1.6b Moved where investments are added to eco/def. [L0ne_W0lf]
50 //= 1.7 Updated Agitbreak announcements, added bc_woe [L0ne_W0lf]
51 //=     and added extended anouncement format for mapannounce.
52 //= 1.8 Fixed a possible exploit in guild castle investment. [Brian]
53 //= 1.9 Partially rewrote Script. [Masao]
54 //= 1.9a Fixed incorrect setcastledata parameter. [Euphy]
55 //= 2.0 Fixed an issue where Castle Manager couldn't be fired. [Joseph]
56 //============================================================
57
58 // WoE : Main Functions
59 //============================================================
60 -       script  Gld_Agit_Manager::Gld_Agit_Manager      -1,{
61         end;
62
63 // War of Emperium has started.
64 OnAgitStart:
65         if (strnpcinfo(0) == "Gld_Agit_Manager") end;
66         MapRespawnGuildID strnpcinfo(2),GetCastleData(strnpcinfo(2),1),6;
67         GvgOn strnpcinfo(2);
68
69 // Spawn (fall through), or respawn the Emperium once it has been broken.
70 OnStartArena:
71         // OnAgitStart will fall through and spawn the Emperium.
72         if (strnpcinfo(2) == "aldeg_cas01") { setarray .@emproom[0],216,23; }
73         else if (strnpcinfo(2) == "aldeg_cas02") { setarray .@emproom[0],213,23; }
74         else if (strnpcinfo(2) == "aldeg_cas03") { setarray .@emproom[0],205,31; }
75         else if (strnpcinfo(2) == "aldeg_cas04") { setarray .@emproom[0],36,217; }
76         else if (strnpcinfo(2) == "aldeg_cas05") { setarray .@emproom[0],27,101; }
77         else if (strnpcinfo(2) == "gefg_cas01") { setarray .@emproom[0],197,181; }
78         else if (strnpcinfo(2) == "gefg_cas02") { setarray .@emproom[0],176,178; }
79         else if (strnpcinfo(2) == "gefg_cas03") { setarray .@emproom[0],244,166; }
80         else if (strnpcinfo(2) == "gefg_cas04") { setarray .@emproom[0],174,177; }
81         else if (strnpcinfo(2) == "gefg_cas05") { setarray .@emproom[0],194,184; }
82         else if (strnpcinfo(2) == "payg_cas01") { setarray .@emproom[0],139,139; }
83         else if (strnpcinfo(2) == "payg_cas02") { setarray .@emproom[0],38,25; }
84         else if (strnpcinfo(2) == "payg_cas03") { setarray .@emproom[0],269,265; }
85         else if (strnpcinfo(2) == "payg_cas04") { setarray .@emproom[0],270,28; }
86         else if (strnpcinfo(2) == "payg_cas05") { setarray .@emproom[0],30,30; }
87         else if (strnpcinfo(2) == "prtg_cas01") { setarray .@emproom[0],197,197; }
88         else if (strnpcinfo(2) == "prtg_cas02") { setarray .@emproom[0],157,174; }
89         else if (strnpcinfo(2) == "prtg_cas03") { setarray .@emproom[0],16,220; }
90         else if (strnpcinfo(2) == "prtg_cas04") { setarray .@emproom[0],291,14; }
91         else if (strnpcinfo(2) == "prtg_cas05") { setarray .@emproom[0],266,266; }
92         // Add custom Guild Castles here.
93         else {
94                 end;
95         }
96         if (!mobcount(strnpcinfo(2),"Agit#"+strnpcinfo(2)+"::OnAgitBreak")) {
97                 monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Emperium",1288,1,"Agit#"+strnpcinfo(2)+"::OnAgitBreak";
98         }
99         end;
100
101 // The Emperium has been broken.
102 OnAgitBreak:
103         set .@GID,getcharid(2);
104         // Show and log error if an unguilded player breaks the Emperium. (Should NEVER happen)
105         if (.@GID <= 0) {
106                 set .@notice$,"Character "+strcharinfo(0)+" ("+getcharid(0)+") broke the Emperium in Castle: "+strnpcinfo(2)+" while guildless. No data will be saved and Emperium respawned.";
107                 logmes .@notice$; debugmes .@notice$;
108                 donpcevent "Agit#"+strnpcinfo(2)+"::OnStartArena";
109                 end;
110         }
111         // Adjust Economy Invest Level for Castle
112         set .@Economy,GetCastleData(strnpcinfo(2),2) - 5;
113         if (.@Economy < 0) set .@Economy, 0;
114         SetCastleData strnpcinfo(2), 2, .@Economy;
115         // Adjust Defense Invest Level for Castle
116         set .@Defence,GetCastleData(strnpcinfo(2),3) - 5;
117         if (.@Defence < 0) set .@Defence, 0;
118         SetCastleData strnpcinfo(2), 3, .@Defence;
119
120         // Set new Castle Occupant
121         SetCastleData strnpcinfo(2),1, .@GID;
122
123         // Announce that the Emperium is destroyed, and respawn all but new castle-occupants.
124         mapannounce strnpcinfo(2),"The emperium has been destroyed.",bc_map|bc_woe,"0x00CCFF",FW_NORMAL,12;
125         MapRespawnGuildID strnpcinfo(2),.@GID,6;
126
127         // Refresh castle data, disable Kafra and reset Invest information.
128         donpcevent strnpcinfo(0)+"::OnRecvCastle";
129         disablenpc "Kafra Staff#"+strnpcinfo(2);
130         for( set .@i, 4; .@i <= 9; set .@i, .@i+1 ) {
131                 SetCastleData strnpcinfo(2), .@i, 0;
132         }
133         // Erase Guardian Database information if the new owners do not have Guardian Research.
134         if( getgdskilllv(.@GID,10002) == 0 ) {
135                 for( set .@i, 10; .@i <= 17; set .@i, .@i+1 ) {
136                         SetCastleData strnpcinfo(2), .@i, 0;
137                 }
138         }
139         // Respawn the Emperium, and display new owners.
140         sleep 500; // Slow down script execution slightly.
141         if( agitcheck() )
142                 donpcevent "Agit#"+strnpcinfo(2)+"::OnStartArena";
143         sleep 7000;
144         announce "The [" + getcastlename(strnpcinfo(2)) + "] castle has been conquered by the [" + getguildName(.@GID) + "] guild.",bc_all|bc_woe;
145         end;
146
147 // War of Emperium has ended.
148 OnAgitEnd:
149         if (strnpcinfo(0) == "Gld_Agit_Manager") end;
150         GvgOff strnpcinfo(2);
151         // If the castle has no owner at the end of WoE, do not kill Emperium.
152         if (GetCastleData(strnpcinfo(2),1)) {
153                 KillMonster strnpcinfo(2),"Agit#"+strnpcinfo(2)+"::OnAgitBreak";
154         }
155         end;
156
157 // Occupying Guild has been disbanded.
158 OnGuildBreak:
159         if (strnpcinfo(0) == "Gld_Agit_Manager") end;
160         // Kill guardians, disable the Kafra, and set owner to 0.
161         killmonster strnpcinfo(2),"Guardian#"+strnpcinfo(2)+"::OnGuardianDied";
162         disablenpc "Kafra Staff#"+strnpcinfo(2);
163         SetCastleData strnpcinfo(2),1,0;
164         // Wait before refreshing guild information.
165         sleep 7000;
166         Announce "Guild Base [" + GetCastleName(strnpcinfo(2)) + "] has been abandoned.",0;
167         donpcevent strnpcinfo(0)+"::OnRecvCastle";
168         end;
169
170 OnAgitInit:
171 OnRecvCastle:
172         if (strnpcinfo(0) == "Gld_Agit_Manager") end;
173         // Spawn Monsters if the castle is empty.
174         set .@GID, GetCastleData(strnpcinfo(2),1);
175         if (.@GID == 0) {
176                 killmonsterall strnpcinfo(2);
177                 if (compare(strnpcinfo(2),"aldeg")) {
178                         // Normal Spawns
179                         monster strnpcinfo(2),0,0,"Evil Druid",1117,10;
180                         monster strnpcinfo(2),0,0,"Khalitzburg",1132,4;
181                         monster strnpcinfo(2),0,0,"Abysmal Knight",1219,2;
182                         monster strnpcinfo(2),0,0,"Executioner",1205,1;
183                         monster strnpcinfo(2),0,0,"Penomena",1216,10;
184                         monster strnpcinfo(2),0,0,"Alarm",1193,18;
185                         monster strnpcinfo(2),0,0,"Clock",1269,9;
186                         monster strnpcinfo(2),0,0,"Raydric Archer",1276,7;
187                         monster strnpcinfo(2),0,0,"Wanderer",1208,3;
188                         monster strnpcinfo(2),0,0,"Alice",1275,1;
189                         monster strnpcinfo(2),0,0,"Bloody Knight",1268,1;
190                         monster strnpcinfo(2),0,0,"Dark Lord",1272,1;
191                         // Set Emperium room spawn coordinates and spawn monsters.
192                         if (strnpcinfo(2) == "aldeg_cas01") { setarray .@emproom[0],216,23; }
193                         else if (strnpcinfo(2) == "aldeg_cas02") { setarray .@emproom[0],213,23; }
194                         else if (strnpcinfo(2) == "aldeg_cas03") { setarray .@emproom[0],205,31; }
195                         else if (strnpcinfo(2) == "aldeg_cas04") { setarray .@emproom[0],36,217; }
196                         else if (strnpcinfo(2) == "aldeg_cas05") { setarray .@emproom[0],27,101; }
197                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Dark Lord",1272,1;
198                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Tower Keeper",1270,4;
199                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Bloody Knight",1268,1;
200                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Abysmal Knight",1219,1;
201                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Raydric Archer",1276,5;
202                 }
203                 else if (compare(strnpcinfo(2),"gefg")) {
204                         // Normal Spawns
205                         monster strnpcinfo(2),0,0,"Evil Druid",1117,10;
206                         monster strnpcinfo(2),0,0,"Wind Ghost",1263,11;
207                         monster strnpcinfo(2),0,0,"Bathory",1102,10;
208                         monster strnpcinfo(2),0,0,"Jakk",1130,10;
209                         monster strnpcinfo(2),0,0,"Marduk",1140,20;
210                         monster strnpcinfo(2),0,0,"Raydric",1163,9;
211                         monster strnpcinfo(2),0,0,"Alice",1275,1;
212                         monster strnpcinfo(2),0,0,"Abysmal Knight",1219,1;
213                         monster strnpcinfo(2),0,0,"Moonlight Flower",1150,1;
214                         monster strnpcinfo(2),0,0,"Phreeoni",1159,1;
215                         // Set Emperium room spawn coordinates and spawn monsters.
216                         if (strnpcinfo(2) == "gefg_cas01") { setarray .@emproom[0],197,181; }
217                         else if (strnpcinfo(2) == "gefg_cas02") { setarray .@emproom[0],176,178; }
218                         else if (strnpcinfo(2) == "gefg_cas03") { setarray .@emproom[0],244,166; }
219                         else if (strnpcinfo(2) == "gefg_cas04") { setarray .@emproom[0],174,177; }
220                         else if (strnpcinfo(2) == "gefg_cas05") { setarray .@emproom[0],194,184; }
221                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Mysteltainn",1203,1;
222                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Orc Hero",1087,1;
223                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"High Orc",1213,10;
224                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Orc Archer",1189,10;
225                 }
226                 else if (compare(strnpcinfo(2),"payg")) {
227                         // Normal Spawns
228                         monster strnpcinfo(2),0,0,"Greatest General",1277,9;
229                         monster strnpcinfo(2),0,0,"Wanderer",1208,10;
230                         monster strnpcinfo(2),0,0,"Mutant Dragonoid",1262,5;
231                         monster strnpcinfo(2),0,0,"Bathory",1102,5;
232                         monster strnpcinfo(2),0,0,"Moonlight Flower",1150,1;
233                         monster strnpcinfo(2),0,0,"Eddga",1115,1;
234                         monster strnpcinfo(2),0,0,"Horong",1129,11;
235                         monster strnpcinfo(2),0,0,"Raydric Archer",1276,5;
236                         monster strnpcinfo(2),0,0,"Kobold Archer",1282,4;
237                         monster strnpcinfo(2),0,0,"Gargoyle",1253,5;
238                         // Set Emperium room spawn coordinates and spawn monsters.
239                         if (strnpcinfo(2) == "payg_cas01") { setarray .@emproom[0],139,139; }
240                         else if (strnpcinfo(2) == "payg_cas02") { setarray .@emproom[0],38,25; }
241                         else if (strnpcinfo(2) == "payg_cas03") { setarray .@emproom[0],269,265; }
242                         else if (strnpcinfo(2) == "payg_cas04") { setarray .@emproom[0],270,28; }
243                         else if (strnpcinfo(2) == "payg_cas05") { setarray .@emproom[0],30,30; }
244                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Moonlight Flower",1150,1;
245                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Eddga",1115,1;
246                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Wanderer",1208,6;
247                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Raydric Archer",1276,5;
248                 }
249                 else if (compare(strnpcinfo(2),"prtg")) {
250                         // Normal Spawns
251                         monster strnpcinfo(2),0,0,"Raydric",1163,1;
252                         monster strnpcinfo(2),0,0,"Khalitzburg",1132,10;
253                         monster strnpcinfo(2),0,0,"Abysmal Knight",1219,5;
254                         monster strnpcinfo(2),0,0,"Bloody Knight",1268,5;
255                         monster strnpcinfo(2),0,0,"Stormy Knight",1251,1;
256                         monster strnpcinfo(2),0,0,"Hatii",1252,1;
257                         monster strnpcinfo(2),0,0,"Raydric Archer",1276,5;
258                         monster strnpcinfo(2),0,0,"Gryphon",1259,2;
259                         monster strnpcinfo(2),0,0,"Chimera",1283,3;
260                         monster strnpcinfo(2),0,0,"Alice",1275,1;
261                         monster strnpcinfo(2),0,0,"Zealotus",1200,1;
262                         // Set Emperium room spawn coordinates and spawn monsters.
263                         if (strnpcinfo(2) == "prtg_cas01") { setarray .@emproom[0],197,197; }
264                         else if (strnpcinfo(2) == "prtg_cas02") { setarray .@emproom[0],157,174; }
265                         else if (strnpcinfo(2) == "prtg_cas03") { setarray .@emproom[0],16,220; }
266                         else if (strnpcinfo(2) == "prtg_cas04") { setarray .@emproom[0],291,14; }
267                         else if (strnpcinfo(2) == "prtg_cas05") { setarray .@emproom[0],266,266; }
268                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Guardian Knight",1268,1;
269                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Guardian Master",1251,1;
270                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Hatii",1252,1;
271                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Guardian Knight",1219,1;
272                         monster strnpcinfo(2),.@emproom[0],.@emproom[1],"Raydric Archer",1276,5;
273                 }
274                 // Add custom Guild Castles here.
275                 else {
276                         end;
277                 }
278                 donpcevent "Agit#"+strnpcinfo(2)+"::OnStartArena";
279                 // Disable Kafra Staff...
280                 disablenpc "Kafra Staff#"+strnpcinfo(2);
281                 end;
282         }
283         else {
284                 // Otherwise place the guild emblem on flags.
285                 if (strnpcinfo(2) == "aldeg_cas01") { donpcevent "::OnRecvCastleA01"; }
286                 else if (strnpcinfo(2) == "aldeg_cas02") { donpcevent "::OnRecvCastleA02"; }
287                 else if (strnpcinfo(2) == "aldeg_cas03") { donpcevent "::OnRecvCastleA03"; }
288                 else if (strnpcinfo(2) == "aldeg_cas04") { donpcevent "::OnRecvCastleA04"; }
289                 else if (strnpcinfo(2) == "aldeg_cas05") { donpcevent "::OnRecvCastleA05"; }
290                 else if (strnpcinfo(2) == "gefg_cas01") { donpcevent "::OnRecvCastleG01"; }
291                 else if (strnpcinfo(2) == "gefg_cas02") { donpcevent "::OnRecvCastleG02"; }
292                 else if (strnpcinfo(2) == "gefg_cas03") { donpcevent "::OnRecvCastleG03"; }
293                 else if (strnpcinfo(2) == "gefg_cas04") { donpcevent "::OnRecvCastleG04"; }
294                 else if (strnpcinfo(2) == "gefg_cas05") { donpcevent "::OnRecvCastleG05"; }
295                 else if (strnpcinfo(2) == "payg_cas01") { donpcevent "::OnRecvCastlePy01"; }
296                 else if (strnpcinfo(2) == "payg_cas02") { donpcevent "::OnRecvCastlePy02"; }
297                 else if (strnpcinfo(2) == "payg_cas03") { donpcevent "::OnRecvCastlePy03"; }
298                 else if (strnpcinfo(2) == "payg_cas04") { donpcevent "::OnRecvCastlePy04"; }
299                 else if (strnpcinfo(2) == "payg_cas05") { donpcevent "::OnRecvCastlePy05"; }
300                 else if (strnpcinfo(2) == "prtg_cas01") { donpcevent "::OnRecvCastlePt01"; }
301                 else if (strnpcinfo(2) == "prtg_cas02") { donpcevent "::OnRecvCastlePt02"; }
302                 else if (strnpcinfo(2) == "prtg_cas03") { donpcevent "::OnRecvCastlePt03"; }
303                 else if (strnpcinfo(2) == "prtg_cas04") { donpcevent "::OnRecvCastlePt04"; }
304                 else if (strnpcinfo(2) == "prtg_cas05") { donpcevent "::OnRecvCastlePt05"; }
305                 // Add custom Guild Castles here.
306                 else {
307                         end;
308                 }
309                 // And load purchased Guardian in castles.
310                 donpcevent "Guardian#"+strnpcinfo(2)+"::OnSpawnGuardians";
311                 // And display Kafra if purchased.
312                 if (GetCastleData(strnpcinfo(2),9) < 1) disablenpc "Kafra Staff#"+strnpcinfo(2);
313         }
314         end;
315 }
316
317 // WoE : Guild Kafras
318 //============================================================
319 -       script  Kafra Staff#woe::guildkafra     -1,{
320
321         set .@GID,GetCastleData(strnpcinfo(2),1);
322
323         if (compare(strnpcinfo(2),"aldeg")) {
324                 setarray .@destination$[0],"Al De Baran","aldebaran";
325                 setarray .@coordinates[0],132,103;
326         }
327         else if (compare(strnpcinfo(2),"gefg")) {
328                 setarray .@destination$[0],"Geffen","geffen";
329                 setarray .@coordinates[0],120,39;
330         }
331         else if (compare(strnpcinfo(2),"payg")) {
332                 setarray .@destination$[0],"Payon","payon";
333                 setarray .@coordinates[0],70,100;
334         }
335         else if (compare(strnpcinfo(2),"prtg")) {
336                 setarray .@destination$[0],"Prontera","prontera";
337                 setarray .@coordinates[0],278,211;
338         }
339         // Add custom Guild Castles here.
340         else {
341                 end;
342         }
343
344         cutin "kafra_01",2;
345         if (getcharid(2) == .@GID) {
346                 mes "[Kafra Employee]";
347                 mes "Welcome. ^ff0000" + GetGuildName(.@GID) + "^000000 Member.";
348                 mes "The Kafra Corporation will stay with you wherever you go.";
349                 next;
350                 switch (select("Use Storage:Use Teleport Service:Rent a Pushcart:Cancel")) {
351                 case 1:
352                         if(!callfunc("F_CanOpenStorage")){
353                                 mes "[Kafra Employee]";
354                                 mes "I'm sorry, but you";
355                                 mes "need the Novice's";
356                                 mes "Basic Skill Level 6 to";
357                                 mes "use the Storage Service.";
358                                 close2;
359                                 cutin "",255;
360                                 end;
361                         }
362                         mes "[Kafra Employee]";
363                         mes "Here, let me open";
364                         mes "your Storage for you.";
365                         mes "Thank you for using";
366                         mes "the Kafra Service.";
367                         close2;
368                         cutin "",255;
369                         openstorage;
370                         end;
371                 case 2:
372                         mes "[Kafra Employee]";
373                         mes "Please choose";
374                         mes "your destination.";
375                         next;
376                         switch (select(.@destination$+" -> 200z:Cancel")) {
377                         case 1:
378                                 if (Zeny < 200) {
379                                         mes "[Kafra Employee]";
380                                         mes "I'm sorry, but you don't have";
381                                         mes "enough zeny for the Teleport";
382                                         mes "Service. The fee to teleport";
383                                         mes "to "+.@destination$+" is 200 zeny.";
384                                         close2;
385                                         cutin "",255;
386                                         end;
387                                 }
388                                 set Zeny, Zeny - 200;
389                                 set RESRVPTS,RESRVPTS+20;
390                                 close2;
391                                 warp .@destination$[1],.@coordinates[0],.@coordinates[1];
392                                 end;
393                         case 2:
394                                 close2;
395                                 cutin "",255;
396                                 end;
397                         }
398                 case 3:
399                         if (BaseClass != Job_Merchant) {
400                                 mes "[Kafra Employee]";
401                                 mes "I'm sorry, but the";
402                                 mes "Pushcart rental service";
403                                 mes "is only available to Merchants,";
404                                 mes "Blacksmiths, Master Smiths,";
405                                 mes "Alchemists, Biochemists,";
406                                 mes "Mechanics and Geneticists.";
407                                 close2;
408                                 cutin "",255;
409                                 end;
410                         }
411                         if (checkcart()) {
412                                 mes "[Kafra Employee]";
413                                 mes "You already have";
414                                 mes "a Pushcart equipped.";
415                                 mes "Unfortunately, we can't";
416                                 mes "rent more than one to";
417                                 mes "each customer at a time.";
418                                 close2;
419                                 cutin "",255;
420                                 end;
421                         }
422                         mes "[Kafra Employee]";
423                         mes "The Pushcart rental";
424                         mes "fee is 800 zeny. Would";
425                         mes "you like to rent a Pushcart?";
426                         next;
427                         switch (select("Rent a Pushcart.:Cancel")) {
428                         case 1:
429                                 if (Zeny < 800) {
430                                         mes "[Kafra Employee]";
431                                         mes "I'm sorry, but you";
432                                         mes "don't have enough";
433                                         mes "zeny to pay the Pushcart";
434                                         mes "rental fee of 800 zeny.";
435                                         close2;
436                                         cutin "",255;
437                                         end;
438                                 }
439                                 set RESRVPTS,RESRVPTS+80;
440                                 set Zeny, Zeny - 800;
441                                 setcart;
442                                 close2;
443                                 cutin "",255;
444                                 end;
445                         case 2:
446                                 close2;
447                                 cutin "",255;
448                                 end;
449                         }
450                 case 4:
451                         mes "[Kafra Employee]";
452                         mes "We, here at Kafra Corporation,";
453                         mes "are always endeavoring to provide you with the best services. We hope that we meet your adventuring needs and standards of excellence.";
454                         close2;
455                         cutin "",255;
456                         end;
457                 }
458         }
459         mes "[Kafra Employee]";
460         mes "I am instructed to only offer my services to the ^ff0000"+GetGuildName(.@GID)+"^000000 Guild. Please try another Kafra Employee around here. Sorry for the inconvenience.";
461         close2;
462         cutin "",255;
463         end;
464 }
465
466 // WoE : Castle Managers
467 //============================================================
468 -       script  Castle Manager#cm::cm   -1,{
469
470         set .@GID,GetCastleData(strnpcinfo(2),1);
471
472         // .@guardiantype = Defines the types of guardians per castle basis.
473         // 1 - Soldier Guardian, 2 - Archer Guardian, 3 - Knight Guardian
474         // .@guardianposx = Define the x spawn point for each uardian.
475         // [0] = 1st guardian's x spawn point.
476         // .@guardianposy = Define the y spawn point for each guardian.
477         // [0] = 1st guardian's y spawn point.
478         // .@masterroom = Defines the coordinates of the Treasure Room.
479         if (strnpcinfo(2) == "aldeg_cas01") { 
480                 setarray .@guardiantype[0],1,2,2,2,2,3,3,3;
481                 setarray .@guardianposx[0],17,39,38,45,21,218,213,73;
482                 setarray .@guardianposy[0],218,208,196,228,194,24,24,70;
483                 setarray .@masterroom[0],113,223;
484         }
485         else if (strnpcinfo(2) == "aldeg_cas02") {
486                 setarray .@guardiantype[0],3,3,3,1,1,2,2,2;
487                 setarray .@guardianposx[0],27,88,117,60,51,21,36,210;
488                 setarray .@guardianposy[0],184,43,46,202,183,177,183,7;
489                 setarray .@masterroom[0],134,225;
490         }
491         else if (strnpcinfo(2) == "aldeg_cas03") {
492                 setarray .@guardiantype[0],3,3,1,1,1,2,2,2;
493                 setarray .@guardianposx[0],90,116,86,116,64,212,195,110;
494                 setarray .@guardianposy[0],112,112,120,76,103,160,151,217;
495                 setarray .@masterroom[0],229,267;
496         }
497         else if (strnpcinfo(2) == "aldeg_cas04") {
498                 setarray .@guardiantype[0],2,2,2,1,1,1,3,3;
499                 setarray .@guardianposx[0],187,192,148,145,169,198,48,55;
500                 setarray .@guardianposy[0],100,42,88,209,53,77,72,88;
501                 setarray .@masterroom[0],83,17;
502         }
503         else if (strnpcinfo(2) == "aldeg_cas05") {
504                 setarray .@guardiantype[0],2,2,1,1,3,3,3,3;
505                 setarray .@guardianposx[0],51,188,157,157,27,145,156,41;
506                 setarray .@guardianposy[0],202,79,192,74,221,78,73,112;
507                 setarray .@masterroom[0],64,8;
508         }
509         // Geffen (Britoniah) Castles
510         else if (strnpcinfo(2) == "gefg_cas01") {
511                 setarray .@guardiantype[0],1,1,1,2,2,3,3,3;
512                 setarray .@guardianposx[0],67,184,62,36,50,50,189,200;
513                 setarray .@guardianposy[0],179,20,41,186,186,67,41,167;
514                 setarray .@masterroom[0],152,117;
515         }
516         else if (strnpcinfo(2) == "gefg_cas02") {
517                 setarray .@guardiantype[0],1,1,1,2,2,3,3,3;
518                 setarray .@guardianposx[0],64,56,166,35,20,19,166,159;
519                 setarray .@guardianposy[0],168,41,25,148,150,41,42,188;
520                 setarray .@masterroom[0],145,115;
521         }
522         else if (strnpcinfo(2) == "gefg_cas03") {
523                 setarray .@guardiantype[0],2,2,1,1,1,3,3,3;
524                 setarray .@guardianposx[0],48,113,48,157,243,157,234,238;
525                 setarray .@guardianposy[0],176,214,207,62,41,45,25,160;
526                 setarray .@masterroom[0],275,289;
527         }
528         else if (strnpcinfo(2) == "gefg_cas04") {
529                 setarray .@guardiantype[0],2,2,1,1,1,3,3,3;
530                 setarray .@guardianposx[0],53,31,49,29,147,57,160,148;
531                 setarray .@guardianposy[0],191,178,220,46,65,46,50,189;
532                 setarray .@masterroom[0],116,123;
533         }
534         else if (strnpcinfo(2) == "gefg_cas05") {
535                 setarray .@guardiantype[0],2,2,1,1,1,3,3,3;
536                 setarray .@guardianposx[0],45,71,72,66,177,66,177,193;
537                 setarray .@guardianposy[0],149,163,142,47,50,17,35,166;
538                 setarray .@masterroom[0],149,106;
539         }
540         // Payon (Baulder) Castles
541         else if (strnpcinfo(2) == "payg_cas01") {
542                 setarray .@guardiantype[0],2,2,2,2,2,2,2,3;
543                 setarray .@guardianposx[0],229,225,222,99,65,36,51,138;
544                 setarray .@guardianposy[0],92,80,111,45,31,127,144,133;
545                 setarray .@masterroom[0],295,8;
546         }
547         else if (strnpcinfo(2) == "payg_cas02") {
548                 setarray .@guardiantype[0],2,2,2,2,2,2,2,3;
549                 setarray .@guardianposx[0],237,228,210,57,42,287,264,27;
550                 setarray .@guardianposy[0],54,72,41,241,241,257,272,20;
551                 setarray .@masterroom[0],141,149;
552         }
553         else if (strnpcinfo(2) == "payg_cas03") {
554                 setarray .@guardiantype[0],2,2,2,2,2,2,2,3;
555                 setarray .@guardianposx[0],245,269,36,41,39,19,37,268;
556                 setarray .@guardianposy[0],37,51,39,39,65,276,277,244;
557                 setarray .@masterroom[0],163,167;
558         }
559         else if (strnpcinfo(2) == "payg_cas04") {
560                 setarray .@guardiantype[0],2,2,2,2,2,2,2,3;
561                 setarray .@guardianposx[0],251,232,231,32,32,35,36,270;
562                 setarray .@guardianposy[0],212,212,175,287,232,45,17,41;
563                 setarray .@masterroom[0],151,47;
564         }
565         else if (strnpcinfo(2) == "payg_cas05") {
566                 setarray .@guardiantype[0],2,2,2,2,2,2,2,3;
567                 setarray .@guardianposx[0],19,33,266,266,263,263,250,36;
568                 setarray .@guardianposy[0],279,260,234,279,37,21,22,36;
569                 setarray .@masterroom[0],153,137;
570         }
571         // Prontera (Valkyrie Realms) Castles
572         else if (strnpcinfo(2) == "prtg_cas01") {
573                 setarray .@guardiantype[0],1,1,1,2,2,3,3,3;
574                 setarray .@guardianposx[0],182,182,153,59,50,184,196,107;
575                 setarray .@guardianposy[0],62,116,86,28,36,183,189,179;
576                 setarray .@masterroom[0],15,209;
577         }
578         else if (strnpcinfo(2) == "prtg_cas02") {
579                 setarray .@guardiantype[0],3,3,3,1,1,2,2,2;
580                 setarray .@guardianposx[0],161,153,178,71,49,64,7,75;
581                 setarray .@guardianposy[0],161,161,44,75,28,186,196,175;
582                 setarray .@masterroom[0],207,229;
583         }
584         else if (strnpcinfo(2) == "prtg_cas03") {
585                 setarray .@guardiantype[0],3,3,3,1,1,2,2,2;
586                 setarray .@guardianposx[0],191,137,45,50,41,191,179,191;
587                 setarray .@guardianposy[0],190,190,99,87,87,42,43,72;
588                 setarray .@masterroom[0],190,130;
589         }
590         else if (strnpcinfo(2) == "prtg_cas04") {
591                 setarray .@guardiantype[0],3,3,3,1,1,1,2,2;
592                 setarray .@guardianposx[0],276,274,246,38,29,33,78,36;
593                 setarray .@guardianposy[0],14,35,246,240,240,258,48,61;
594                 setarray .@masterroom[0],275,160;
595         }
596         else if (strnpcinfo(2) == "prtg_cas05") {
597                 setarray .@guardiantype[0],3,3,3,1,1,1,2,2;
598                 setarray .@guardianposx[0],266,287,245,236,251,278,32,44;
599                 setarray .@guardianposy[0],262,280,250,63,63,253,253,248;
600                 setarray .@masterroom[0],281,176;
601         }
602         // Add custom Guild Castles here.
603         else {
604                 end;
605         }
606
607         if (.@GID == 0) {
608                 mes "["+strnpcinfo(1)+"]";
609                 mes "I have been waiting for a master to fulfill my destiny.";
610                 mes "Brave soul... fate will guide you towards your future...";
611                 close;
612         }
613         if (GetGuildMaster(.@GID) != strcharinfo(0)) {
614                 mes "["+strnpcinfo(1)+"]";
615                 mes "No matter how much you pester me, I'll still follow my master ^ff0000"+GetGuildMaster(.@GID)+"^000000. Where are the Guardians?! Send these ruffians away right now!";
616                 close;
617         }
618         mes "["+strnpcinfo(1)+"]";
619         mes "Welcome. My honorable master, ^ff0000"+strcharinfo(0)+"^000000...";
620         mes "Your humble servent, "+strnpcinfo(1)+", is here to serve you.";
621         next;
622         switch (select("Castle briefing:Invest in commercial growth:Invest in Castle Defenses:Summon Guardian:Hire / Fire a Kafra Employee:Go into Master's room")) {
623         case 1:
624                 mes "["+strnpcinfo(1)+"]";
625                 mes "I will report the Castle briefing, Master.";
626                 mes " ";
627                 mes "^0000ffNow, the commercial growth level is "+GetCastleData(strnpcinfo(2),2)+".";
628                 if (GetCastleData(strnpcinfo(2),4)) {
629                         mes " You invested "+GetCastleData(strnpcinfo(2),4)+" times in past 1 day.";
630                 }
631                 mes " Now, the Castle Defense level is "+GetCastleData(strnpcinfo(2),3)+".^000000";
632                 if (GetCastleData(strnpcinfo(2),5)) {
633                         mes " ^0000ff- You invested "+GetCastleData(strnpcinfo(2),5)+" times in past 1 day.^000000";
634                 }
635                 mes " ";
636                 mes "That's all I have to report, Master.";
637                 close;
638         case 2:
639                 set .@Economy,GetCastleData(strnpcinfo(2),2);
640                 if (.@Economy < 6) { set .@eco_invest,5000; }
641                 else if ((.@Economy >= 6) && (.@Economy <= 10)) { set .@eco_invest,10000; }
642                 else if ((.@Economy >= 11) && (.@Economy <= 15)) { set .@eco_invest,20000; }
643                 else if ((.@Economy >= 16) && (.@Economy <= 20)) { set .@eco_invest,35000; }
644                 else if ((.@Economy >= 21) && (.@Economy <= 25)) { set .@eco_invest,55000; }
645                 else if ((.@Economy >= 26) && (.@Economy <= 30)) { set .@eco_invest,80000; }
646                 else if ((.@Economy >= 31) && (.@Economy <= 35)) { set .@eco_invest,110000; }
647                 else if ((.@Economy >= 36) && (.@Economy <= 40)) { set .@eco_invest,145000; }
648                 else if ((.@Economy >= 41) && (.@Economy <= 45)) { set .@eco_invest,185000; }
649                 else if ((.@Economy >= 46) && (.@Economy <= 50)) { set .@eco_invest,230000; }
650                 else if ((.@Economy >= 51) && (.@Economy <= 55)) { set .@eco_invest,280000; }
651                 else if ((.@Economy >= 56) && (.@Economy <= 60)) { set .@eco_invest,335000; }
652                 else if ((.@Economy >= 61) && (.@Economy <= 65)) { set .@eco_invest,395000; }
653                 else if ((.@Economy >= 66) && (.@Economy <= 70)) { set .@eco_invest,460000; }
654                 else if ((.@Economy >= 71) && (.@Economy <= 75)) { set .@eco_invest,530000; }
655                 else if ((.@Economy >= 76) && (.@Economy <= 80)) { set .@eco_invest,605000; }
656                 else if ((.@Economy >= 81) && (.@Economy <= 85)) { set .@eco_invest,685000; }
657                 else if ((.@Economy >= 86) && (.@Economy <= 90)) { set .@eco_invest,770000; }
658                 else if ((.@Economy >= 91) && (.@Economy <= 95)) { set .@eco_invest,860000; }
659                 else if ((.@Economy >= 96) && (.@Economy <= 100)) { set .@eco_invest,955000; }
660                 //Quadruple the cost of investing if you've already invested once.
661                 if (GetCastleData(strnpcinfo(2),4)) {
662                         set .@eco_invest,.@eco_invest*4;
663                 }
664                 mes "["+strnpcinfo(1)+"]";
665                 mes "If you invest in commercial growth, the quantity of goods made by the guild will increase. Therfore, if you consider our future, investments will be a necessity.";
666                 mes " ";
667                 mes "Initially, you are able to invest just once but if you pay more money, you will be able to invest twice.";
668                 if (.@Economy >= 100) {
669                         mes " ";
670                         mes "^ff0000The commercial growth level of our Castle is at it's highest, 100%. No more investments are needed. Just as I have expected from a great economist like you, Master.^000000";
671                         close;
672                 }
673                 if (GetCastleData(strnpcinfo(2),4) >= 2) {
674                         mes " ";
675                         mes "^ff0000You have already invested twice today. You cannot invest any more.^000000 I expect riches of the guild to grow at a high rate.";
676                         close;
677                 }
678                 if (GetCastleData(strnpcinfo(2),4) == 0) {
679                         mes " ";
680                         mes "The current investment amount required is ^ff0000"+.@eco_invest+"^000000 zeny. Will you invest?";
681                 }
682                 else {
683                         mes " ";
684                         mes "You've invested once today... if you wish to invest once more, ^ff0000"+.@eco_invest+"^000000 more zeny will be needed.";
685                 }
686                 next;
687                 switch (select("Invest in commercial growth:Cancel")) {
688                 case 1:
689                         if (Zeny < .@eco_invest) {
690                                 mes "["+strnpcinfo(1)+"]";
691                                 mes "I'm sorry but there is not enough zeny to invest. You will have to try again when you have the funds, Master.";
692                                 close;
693                         }
694                         set Zeny, Zeny - .@eco_invest;
695                         SetCastleData strnpcinfo(2),4,GetCastleData(strnpcinfo(2),4)+1;
696                         mes "[ "+strnpcinfo(1)+"]";
697                         mes "We finished the investment safely. I expect that our growth level will be increased by tomorrow.";
698                         close;
699                 case 2:
700                         mes "["+strnpcinfo(1)+"]";
701                         mes "I'll do as you bid, my master... There is no hurry. We will do our best.";
702                         close;
703                 }
704         case 3:
705                 set .@Defence,GetCastleData(strnpcinfo(2),3);
706                 if (.@Defence < 6) { set .@def_invest,10000; }
707                 else if ((.@Defence >= 6) && (.@Defence <= 10)) { set .@def_invest,20000; }
708                 else if ((.@Defence >= 11) && (.@Defence <= 15)) { set .@def_invest,40000; }
709                 else if ((.@Defence >= 16) && (.@Defence <= 20)) { set .@def_invest,70000; }
710                 else if ((.@Defence >= 21) && (.@Defence <= 25)) { set .@def_invest,110000; }
711                 else if ((.@Defence >= 26) && (.@Defence <= 30)) { set .@def_invest,160000; }
712                 else if ((.@Defence >= 31) && (.@Defence <= 35)) { set .@def_invest,220000; }
713                 else if ((.@Defence >= 36) && (.@Defence <= 40)) { set .@def_invest,290000; }
714                 else if ((.@Defence >= 41) && (.@Defence <= 45)) { set .@def_invest,370000; }
715                 else if ((.@Defence >= 46) && (.@Defence <= 50)) { set .@def_invest,460000; }
716                 else if ((.@Defence >= 51) && (.@Defence <= 55)) { set .@def_invest,560000; }
717                 else if ((.@Defence >= 56) && (.@Defence <= 60)) { set .@def_invest,670000; }
718                 else if ((.@Defence >= 61) && (.@Defence <= 65)) { set .@def_invest,790000; }
719                 else if ((.@Defence >= 66) && (.@Defence <= 70)) { set .@def_invest,920000; }
720                 else if ((.@Defence >= 71) && (.@Defence <= 75)) { set .@def_invest,1060000; }
721                 else if ((.@Defence >= 76) && (.@Defence <= 80)) { set .@def_invest,1210000; }
722                 else if ((.@Defence >= 81) && (.@Defence <= 85)) { set .@def_invest,1370000; }
723                 else if ((.@Defence >= 86) && (.@Defence <= 90)) { set .@def_invest,1540000; }
724                 else if ((.@Defence >= 91) && (.@Defence <= 95)) { set .@def_invest,1720000; }
725                 else if ((.@Defence >= 96) && (.@Defence <= 100)) { set .@def_invest,1910000; }
726                 //Quadruple the cost of investing if you've already invested once.
727                 if (GetCastleData(strnpcinfo(2),5)) {
728                         set .@def_invest,.@def_invest*4;
729                 }
730                 mes "["+strnpcinfo(1)+"]";
731                 mes "If you raise Castle Defenses, the durability of Guardians and the Emperium will increase. Therefore, if you consider our coming battles, some investment in this area will be required.";
732                 mes " ";
733                 mes "Originally you can invest just once but if you pay more money, you can invest twice.";
734                 if (.@Defence >= 100) {
735                         mes " ";
736                         mes "^ff0000But the Castle Defense level of our Castle is at it's highest, 100%. No more investments are needed. Just as I have expected from a great strategist like you, Master.^000000";
737                         close;
738                 }
739                 if (GetCastleData(strnpcinfo(2),5) >= 2) {
740                         mes " ";
741                         mes "^ff0000You have already invested twice today. You cannot invest any more.^000000 I expect the Defenses of the guild to grow at a high rate.";
742                         close;
743                 }
744                 if (GetCastleData(strnpcinfo(2),5) == 0) {
745                         mes " ";
746                         mes "The current investment amount required is ^ff0000"+.@def_invest+"^000000 zeny. Will you invest?";
747                 }
748                 else {
749                         mes " ";
750                         mes "You've invested once today... if you wish to invest once more, ^ff0000"+.@def_invest+"^000000 more zeny will be needed.";
751                 }
752                 next;
753                 switch (select("Invest in Castle Defenses.:Cancel")) {
754                 case 1:
755                         if (Zeny < .@def_invest) {
756                                 mes "["+strnpcinfo(1)+"]";
757                                 mes "I'm sorry but there is not enough zeny to invest. You will have to try again when you have the funds, Master.";
758                                 close;
759                         }
760                         set Zeny, Zeny - .@def_invest;
761                         SetCastleData strnpcinfo(2),5,GetCastleData(strnpcinfo(2),5)+1;
762                         mes "[ "+strnpcinfo(1)+"]";
763                         mes "We finished the investment safely. I expect that our Castle Defense level will be increased by tomorrow.";
764                         close;
765                 case 2:
766                         mes "["+strnpcinfo(1)+"]";
767                         mes "I'll do as you bid, my master... There is no hurry. We will do our best.";
768                         close;
769                 }
770         case 4:
771                 mes "["+strnpcinfo(1)+"]";
772                 mes "Will you summon a Guardian? It'll be a protector to defend us loyally.";
773                 mes "Please select a guardian to defend us.";
774                 next;
775                 for( set .@i, 0; .@i <= 7 ; set .@i, .@i+1 ) {
776                         if (.@guardiantype[.@i] == 1) { set .@type$,"Guardian Soldier"; }
777                         else if (.@guardiantype[.@i] == 2) { set .@type$,"Guardian Archer"; }
778                         else { set .@type$,"Guardian Knight"; }
779                         if (guardianinfo(strnpcinfo(2),.@i,0)) {
780                                 setarray .@gname$[.@i], .@type$ + " - Implemented (" + guardianinfo(strnpcinfo(2),.@i,2) + "/" + guardianinfo(strnpcinfo(2),.@i,1) + ")";
781                         }
782                         else {
783                                 setarray .@gname$[.@i], .@type$ + " - Not Implemented";
784                         }
785                 }
786                 set .@menu$,.@gname$[0]+":"+.@gname$[1]+":"+.@gname$[2]+":"+.@gname$[3]+":"+.@gname$[4]+":"+.@gname$[5]+":"+.@gname$[6]+":"+.@gname$[7];
787                 set .@GDnum,select(.@menu$)+9;
788                 mes "["+strnpcinfo(1)+"]";
789                 mes "Will you summon the chosen guardian? 10,000 zeny are required to summon a Guardian.";
790                 next;
791                 switch (select("Summon:Cancel")) {
792                 case 1:
793                         if (getgdskilllv(.@GID,10002) == 0) {
794                                 mes "["+strnpcinfo(1)+"]";
795                                 mes "Master, we have not the resources to Summon the Guardian. If you want to accumulate them, you have to learn the Guild skill. We failed to summon the Guardian.";
796                                 close;
797                         }
798                         if (GetCastleData(strnpcinfo(2),.@GDnum) == 1) {
799                                 mes "["+strnpcinfo(1)+"]";
800                                 mes "Master, you already have summoned that Guardian. We cannot summon another.";
801                                 close;
802                         }
803                         if (Zeny < 10000) {
804                                 mes "["+strnpcinfo(1)+"]";
805                                 mes "Well... I'm sorry but we don't have funds to summon the Guardian. We failed to summon the Guardian.";
806                                 close;
807                         }
808                         set Zeny, Zeny - 10000;
809                         SetCastleData strnpcinfo(2),.@GDnum,1; // mark as 'installed'
810                         set .@UseGID,.@GDnum - 10;
811                         if (.@guardiantype[.@UseGID] == 1) { set .@type,1287; }
812                         else if (.@guardiantype[.@UseGID] == 2) { set .@type,1285; }
813                         else { set .@type,1286; }
814                         guardian strnpcinfo(2),.@guardianposx[.@UseGID],.@guardianposy[.@UseGID],strmobinfo(2,.@type),.@type,"Guardian#"+strnpcinfo(2)+"::OnGuardianDied",.@UseGID;
815                         mes "["+strnpcinfo(1)+"]";
816                         mes "We completed the summoning of the Guardian. Our defenses are now increased with it in place.";
817                         close;
818                 case 2:
819                         mes "["+strnpcinfo(1)+"]";
820                         mes "I did as you ordered. But please remember if you the have money to spare, it'll be better to set it up.";
821                         close;
822                 }
823         case 5:
824                 if (GetCastleData(strnpcinfo(2),9) == 1) {
825                         mes "["+strnpcinfo(1)+"]";
826                         mes "We are currently hiring a Kafra Employee... Do you want to fire the Kafra Employee?";
827                         next;
828                         switch (select("Fire:Cancel")) {
829                         case 1:
830                                 cutin "kafra_01",2;
831                                 mes "[ Hired Kafra Employee ]";
832                                 mes "I worked so hard... How can you do that, Master?... Please... Please reconsider... Check it again, Master... Please...";
833                                 next;
834                                 switch (select("Fire:Cancel")) {
835                                 case 1:
836                                         mes "[ Hired Kafra Employee ]";
837                                         mes "Oh, my goodness! This is nonsense!";
838                                         next;
839                                         cutin "",255;
840                                         break;
841                                 case 2:
842                                         mes "[ Hired Kafra Employee ]";
843                                         mes "I'll work hard for you... Thank you!";
844                                         close;
845                                 }
846                                 break;
847                         case 2:
848                                 mes "["+strnpcinfo(1)+"]";
849                                 mes "She worked hard in my opinion. It was a good decision to keep her.";
850                                 close;
851                         }
852                         disablenpc "Kafra Staff#"+strnpcinfo(2);
853                         SetCastleData strnpcinfo(2),9,0;
854                         mes "["+strnpcinfo(1)+"]";
855                         mes "....";
856                         mes "I have discharged the Kafra Employee... But... are you unsatisfied with something?";
857                         close;
858                 }
859                 mes "["+strnpcinfo(1)+"]";
860                 mes "Will you contact the kafra Main Office and Hire a Employee for our Castle?";
861                 mes "^ff0000 10,000 zeny is required for their services. ";
862                 next;
863                 switch (select("Hire.:Cancel")) {
864                 case 1:
865                         if (getgdskilllv(.@GID,10001) == 0) {
866                                 mes "["+strnpcinfo(1)+"]";
867                                 mes "Master, we can't hire a Kafra Employee because we don't have a contract with the Kafra Main Office. If you want to obtain a contract with the Kafra Main Office, you will need to learn the Guild skill first.";
868                                 close;
869                         }
870                         if (Zeny < 10000) {
871                                 mes "["+strnpcinfo(1)+"]";
872                                 mes "Well... I'm sorry but we don't have enough funds to hire a Kafra Employee.";
873                                 close;
874                         }
875                         set Zeny, Zeny - 10000;
876                         enablenpc "Kafra Staff#"+strnpcinfo(2);
877                         SetCastleData strnpcinfo(2),9,1;
878                         mes "["+strnpcinfo(1)+"]";
879                         mes "We obtained a contract with the kafra Main Office, and hired a Kafra Employee.";
880                         next;
881                         cutin "kafra_01",2;
882                         mes "[ Hired Kafra Employee ]";
883                         mes "How do you do? I was dispatched from the Main Office.";
884                         mes "I'll do my best to not tarnish the reputation of the Guild.";
885                         next;
886                         cutin "",255;
887                         mes "["+strnpcinfo(1)+"]";
888                         mes "The Contract terms of the hired Kafra Employee are for 1 month and after this term, you will need to to pay an additional fee.";
889                         mes "It will be useful for our members.";
890                         close;
891                 case 2:
892                         mes "["+strnpcinfo(1)+"]";
893                         mes "I did as you ordered, but some of our members will be unhappy. It will be better to hire a Kafra Employee quickly.";
894                         close;
895                 }
896         case 6:
897                 mes "["+strnpcinfo(1)+"]";
898                 mes "Do you want to visit the room where our valuables are stored?";
899                 mes "That room is restricted to you... you are the only one with access to it.";
900                 next;
901                 switch (select("Go into Master's room.:Cancel")) {
902                 case 1:
903                         mes "["+strnpcinfo(1)+"]";
904                         mes "I'll show you the secret path. Follow me...please.";
905                         mes "When you want to return here, please press the secret switch.";
906                         close2;
907                         warp strnpcinfo(2),.@masterroom[0],.@masterroom[1];
908                         end;
909                 case 2:
910                         mes "["+strnpcinfo(1)+"]";
911                         mes "Goods are produced once a day... if you don't remove them in time, they will not be produced anymore.";
912                         mes "Therefore, it will be better if you check up on them from time to time.";
913                         close;
914                 }
915         }
916 }
917
918 // WoE : Guild Dungeon Entrances
919 //============================================================
920 -       script  Lever#gd::gdlever       -1,{
921
922         set .@GID,GetCastleData(strnpcinfo(2),1);
923
924         if (.@GID == 0) {
925                 mes "[Ringing Voice]";
926                 mes "'Those who overcome an ordeal shows a great deal of bravery... and will find their way to another ordeal.'";
927                 close;
928         }
929
930         if (compare(strnpcinfo(2),"aldeg")) {
931                 set .@destination$,"gld_dun02";
932                 if (compare(strnpcinfo(2),"cas01")) setarray .@coordinates[0],32,122;
933                 else if (compare(strnpcinfo(2),"cas02")) setarray .@coordinates[0],79,30;
934                 else if (compare(strnpcinfo(2),"cas03")) setarray .@coordinates[0],165,38;
935                 else if (compare(strnpcinfo(2),"cas04")) setarray .@coordinates[0],160,148;
936                 else if (compare(strnpcinfo(2),"cas05")) setarray .@coordinates[0],103,169;
937         }
938         else if (compare(strnpcinfo(2),"gefg")) {
939                 set .@destination$,"gld_dun04";
940                 if (compare(strnpcinfo(2),"cas01")) setarray .@coordinates[0],39,258;
941                 else if (compare(strnpcinfo(2),"cas02")) setarray .@coordinates[0],125,270;
942                 else if (compare(strnpcinfo(2),"cas03")) setarray .@coordinates[0],268,251;
943                 else if (compare(strnpcinfo(2),"cas04")) setarray .@coordinates[0],268,108;
944                 else if (compare(strnpcinfo(2),"cas05")) setarray .@coordinates[0],230,35;
945         }
946         else if (compare(strnpcinfo(2),"payg")) {
947                 set .@destination$,"gld_dun01";
948                 if (compare(strnpcinfo(2),"cas01")) setarray .@coordinates[0],186,165;
949                 else if (compare(strnpcinfo(2),"cas02")) setarray .@coordinates[0],54,165;
950                 else if (compare(strnpcinfo(2),"cas03")) setarray .@coordinates[0],54,39;
951                 else if (compare(strnpcinfo(2),"cas04")) setarray .@coordinates[0],186,39;
952                 else if (compare(strnpcinfo(2),"cas05")) setarray .@coordinates[0],223,202;
953         }
954         else if (compare(strnpcinfo(2),"prtg")) {
955                 set .@destination$,"gld_dun03";
956                 if (compare(strnpcinfo(2),"cas01")) setarray .@coordinates[0],28,251;
957                 else if (compare(strnpcinfo(2),"cas02")) setarray .@coordinates[0],164,268;
958                 else if (compare(strnpcinfo(2),"cas03")) setarray .@coordinates[0],164,179;
959                 else if (compare(strnpcinfo(2),"cas04")) setarray .@coordinates[0],268,203;
960                 else if (compare(strnpcinfo(2),"cas05")) setarray .@coordinates[0],199,28;
961         }
962         // Add custom Guild Castles here.
963         else {
964                 end;
965         }
966
967         mes "[Ringing Voice]";
968         mes "'Only the truly brave can take the test.'";
969         next;
970         mes " ";
971         mes "There's a small lever. Will you pull it?";
972         next;
973         if(select("Pull.:Don't pull.") == 1) {
974                 if (getcharid(2) == .@GID) {
975                         close2;
976                         warp .@destination$,.@coordinates[0],.@coordinates[1];
977                         end;
978                 }
979                 mes " ";
980                 mes "Nothing happened.";
981                 close;
982         }
983         close;
984 }
985
986 // Guardian Spawner Template
987 //============================================================
988 -       script  Gld_Guard_Template::Gld_Guard_Template  -1,{
989 // Spawn Guardians in castles
990 // When adding new castles, ensure that the coordinates coincide
991 // with the coordinates defined in the Guild Steward template.
992 OnSpawnGuardians:
993         // Define the types of guardians on a per castle basis.
994         // 1 - Soldier Guardian; 2 - Archer Guardian; 3 - Knight Guardian
995         // Define the x spawn point for each uardian.
996         // [0] = 1st guardian's x spawn point.
997         // Define the y spawn point for each uardian.
998         // [0] = 1st guardian's y spawn point.
999         // Aldebaran (Luina) Castles
1000         if (strnpcinfo(2) == "aldeg_cas01") { 
1001                 setarray .@guardiantype[0],1,2,2,2,2,3,3,3;
1002                 setarray .@guardianposx[0],17,39,38,45,21,218,213,73;
1003                 setarray .@guardianposy[0],218,208,196,228,194,24,24,70;
1004         }
1005         else if (strnpcinfo(2) == "aldeg_cas02") {
1006                 setarray .@guardiantype[0],3,3,3,1,1,2,2,2;
1007                 setarray .@guardianposx[0],27,88,117,60,51,21,36,210;
1008                 setarray .@guardianposy[0],184,43,46,202,183,177,183,7;
1009         }
1010         else if (strnpcinfo(2) == "aldeg_cas03") {
1011                 setarray .@guardiantype[0],3,3,1,1,1,2,2,2;
1012                 setarray .@guardianposx[0],90,116,86,116,64,212,195,110;
1013                 setarray .@guardianposy[0],112,112,120,76,103,160,151,217;
1014         }
1015         else if (strnpcinfo(2) == "aldeg_cas04") {
1016                 setarray .@guardiantype[0],2,2,2,1,1,1,3,3;
1017                 setarray .@guardianposx[0],187,192,148,145,169,198,48,55;
1018                 setarray .@guardianposy[0],100,42,88,209,53,77,72,88;
1019         }
1020         else if (strnpcinfo(2) == "aldeg_cas05") {
1021                 setarray .@guardiantype[0],2,2,1,1,3,3,3,3;
1022                 setarray .@guardianposx[0],51,188,157,157,27,145,156,41;
1023                 setarray .@guardianposy[0],202,79,192,74,221,78,73,112;
1024         }
1025         // Geffen (Britoniah) Castles
1026         else if (strnpcinfo(2) == "gefg_cas01") {
1027                 setarray .@guardiantype[0],1,1,1,2,2,3,3,3;
1028                 setarray .@guardianposx[0],67,184,62,36,50,50,189,200;
1029                 setarray .@guardianposy[0],179,20,41,186,186,67,41,167;
1030         }
1031         else if (strnpcinfo(2) == "gefg_cas02") {
1032                 setarray .@guardiantype[0],1,1,1,2,2,3,3,3;
1033                 setarray .@guardianposx[0],64,56,166,35,20,19,166,159;
1034                 setarray .@guardianposy[0],168,41,25,148,150,41,42,188;
1035         }
1036         else if (strnpcinfo(2) == "gefg_cas03") {
1037                 setarray .@guardiantype[0],2,2,1,1,1,3,3,3;
1038                 setarray .@guardianposx[0],48,113,48,157,243,157,234,238;
1039                 setarray .@guardianposy[0],176,214,207,62,41,45,25,160;
1040         }
1041         else if (strnpcinfo(2) == "gefg_cas04") {
1042                 setarray .@guardiantype[0],2,2,1,1,1,3,3,3;
1043                 setarray .@guardianposx[0],53,31,49,29,147,57,160,148;
1044                 setarray .@guardianposy[0],191,178,220,46,65,46,50,189;
1045         }
1046         else if (strnpcinfo(2) == "gefg_cas05") {
1047                 setarray .@guardiantype[0],2,2,1,1,1,3,3,3;
1048                 setarray .@guardianposx[0],45,71,72,66,177,66,177,193;
1049                 setarray .@guardianposy[0],149,163,142,47,50,17,35,166;
1050         }
1051         // Payon (Baulder) Castles
1052         else if (strnpcinfo(2) == "payg_cas01") {
1053                 setarray .@guardiantype[0],2,2,2,2,2,2,2,3;
1054                 setarray .@guardianposx[0],229,225,222,99,65,36,51,138;
1055                 setarray .@guardianposy[0],92,80,111,45,31,127,144,133;
1056         }
1057         else if (strnpcinfo(2) == "payg_cas02") {
1058                 setarray .@guardiantype[0],2,2,2,2,2,2,2,3;
1059                 setarray .@guardianposx[0],237,228,210,57,42,287,264,27;
1060                 setarray .@guardianposy[0],54,72,41,241,241,257,272,20;
1061         }
1062         else if (strnpcinfo(2) == "payg_cas03") {
1063                 setarray .@guardiantype[0],2,2,2,2,2,2,2,3;
1064                 setarray .@guardianposx[0],245,269,36,41,39,19,37,268;
1065                 setarray .@guardianposy[0],37,51,39,39,65,276,277,244;
1066         }
1067         else if (strnpcinfo(2) == "payg_cas04") {
1068                 setarray .@guardiantype[0],2,2,2,2,2,2,2,3;
1069                 setarray .@guardianposx[0],251,232,231,32,32,35,36,270;
1070                 setarray .@guardianposy[0],212,212,175,287,232,45,17,41;
1071         }
1072         else if (strnpcinfo(2) == "payg_cas05") {
1073                 setarray .@guardiantype[0],2,2,2,2,2,2,2,3;
1074                 setarray .@guardianposx[0],19,33,266,266,263,263,250,36;
1075                 setarray .@guardianposy[0],279,260,234,279,37,21,22,36;
1076         }
1077         // Prontera (Valkyrie Realms) Castles
1078         else if (strnpcinfo(2) == "prtg_cas01") {
1079                 setarray .@guardiantype[0],1,1,1,2,2,3,3,3;
1080                 setarray .@guardianposx[0],182,182,153,59,50,184,196,107;
1081                 setarray .@guardianposy[0],62,116,86,28,36,183,189,179;
1082         }
1083         else if (strnpcinfo(2) == "prtg_cas02") {
1084                 setarray .@guardiantype[0],3,3,3,1,1,2,2,2;
1085                 setarray .@guardianposx[0],161,153,178,71,49,64,7,75;
1086                 setarray .@guardianposy[0],161,161,44,75,28,186,196,175;
1087         }
1088         else if (strnpcinfo(2) == "prtg_cas03") {
1089                 setarray .@guardiantype[0],3,3,3,1,1,2,2,2;
1090                 setarray .@guardianposx[0],191,137,45,50,41,191,179,191;
1091                 setarray .@guardianposy[0],190,190,99,87,87,42,43,72;
1092         }
1093         else if (strnpcinfo(2) == "prtg_cas04") {
1094                 setarray .@guardiantype[0],3,3,3,1,1,1,2,2;
1095                 setarray .@guardianposx[0],276,274,246,38,29,33,78,36;
1096                 setarray .@guardianposy[0],14,35,246,240,240,258,48,61;
1097         }
1098         else if (strnpcinfo(2) == "prtg_cas05") {
1099                 setarray .@guardiantype[0],3,3,3,1,1,1,2,2;
1100                 setarray .@guardianposx[0],266,287,245,236,251,278,32,44;
1101                 setarray .@guardianposy[0],262,280,250,63,63,253,253,248;
1102         }
1103         // Add custom Guild Castles here.
1104         else {
1105                 end;
1106         }
1107
1108         // Kill all existing guardians before spawning new ones.
1109         // This should prevent duplicating Guardians when char Server disconnects.
1110         killmonster strnpcinfo(2),strnpcinfo(0)+"::OnGuardianDied";
1111
1112         for( set .@i, 0; .@i <= 7 ; set .@i, .@i+1 ) {
1113                 set .@UseGID,.@i + 10;
1114                 if (.@guardiantype[.@i] == 1) { set .@type,1287; }
1115                 else if (.@guardiantype[.@i] == 2) { set .@type,1285; }
1116                 else { set .@type,1286; }
1117                 if (GetCastleData(strnpcinfo(2),.@UseGID)) {
1118                         guardian strnpcinfo(2),.@guardianposx[.@i],.@guardianposy[.@i],strmobinfo(2,.@type),.@type,"Guardian#"+strnpcinfo(2)+"::OnGuardianDied",.@i;
1119                 }
1120         }
1121         end;
1122
1123 OnGuardianDied:
1124         end;
1125 }
1126
1127 // Treasure Room Spawn Template
1128 //============================================================
1129 -       script  Gld_Trea_Spawn::Gld_Trea_Spawn  -1,{
1130         end;
1131
1132 OnClock0001:
1133         // Do nothing if this script is the template.
1134         if (strnpcinfo(1) == "Gld_Trea_Spawn") end;
1135         
1136         set .@GID, GetCastleData(strnpcinfo(2),1);
1137         
1138         // If there is no owner, do nothing.
1139         if (!.@GID) end;
1140
1141         // Is there Economy in this castle?
1142         set .@Treasure,GetCastleData(strnpcinfo(2),2)/5+4;
1143
1144         // Set information
1145         if (strnpcinfo(2) == "aldeg_cas01") { 
1146                 set .@treasurebox,1324;
1147                 setarray .@treasurex[0],115,122,115,122,116,117,118,119,120,121,121,121,121,121,121,120,119,118,117,116,116,116,116,116;
1148                 setarray .@treasurey[0],226,226,219,219,225,225,225,225,225,225,224,223,222,221,220,220,220,220,220,220,221,222,223,224;
1149         }
1150         else if (strnpcinfo(2) == "aldeg_cas02") { 
1151                 set .@treasurebox,1326;
1152                 setarray .@treasurex[0],134,135,135,134,132,133,134,135,136,137,137,137,137,137,137,136,135,134,133,132,132,132,132,132;
1153                 setarray .@treasurey[0],231,231,230,230,233,233,233,233,233,233,232,231,230,229,228,228,228,228,228,228,229,230,231,232;
1154         }
1155         else if (strnpcinfo(2) == "aldeg_cas03") { 
1156                 set .@treasurebox,1328;
1157                 setarray .@treasurex[0],224,225,225,224,222,223,224,225,226,227,227,227,227,227,227,226,225,224,223,222,222,222,222,222;
1158                 setarray .@treasurey[0],269,269,268,268,271,271,271,271,271,271,270,269,268,267,266,266,266,266,266,266,267,268,269,270;
1159         }
1160         else if (strnpcinfo(2) == "aldeg_cas04") { 
1161                 set .@treasurebox,1330;
1162                 setarray .@treasurex[0],84,85,85,84,82,83,84,85,86,87,87,87,87,87,87,86,85,84,83,82,82,82,82,82;
1163                 setarray .@treasurey[0],13,13,12,12,15,15,15,15,15,15,14,13,12,11,10,10,10,10,10,10,11,12,13,14;
1164         }
1165         else if (strnpcinfo(2) == "aldeg_cas05") { 
1166                 set .@treasurebox,1332;
1167                 setarray .@treasurex[0],61,62,62,61,59,60,61,62,63,64,64,64,64,64,64,63,62,61,60,59,59,59,59,59;
1168                 setarray .@treasurey[0],12,12,11,11,14,14,14,14,14,14,13,12,11,10,9,9,9,9,9,9,10,11,12,13;
1169         }
1170         else if (strnpcinfo(2) == "gefg_cas01") { 
1171                 set .@treasurebox,1334;
1172                 setarray .@treasurex[0],153,154,154,153,151,152,153,154,155,156,156,156,156,156,156,155,154,153,152,151,151,151,151,151;
1173                 setarray .@treasurey[0],113,113,112,112,115,115,115,115,115,115,114,113,112,111,110,110,110,110,110,110,111,112,113,114;
1174         }
1175         else if (strnpcinfo(2) == "gefg_cas02") { 
1176                 set .@treasurebox,1336;
1177                 setarray .@treasurex[0],139,140,140,139,137,138,139,140,141,142,142,142,142,142,142,141,140,139,138,137,137,137,137,137;
1178                 setarray .@treasurey[0],115,115,114,114,117,117,117,117,117,117,116,115,114,113,112,112,112,112,112,112,113,114,115,116;
1179         }
1180         else if (strnpcinfo(2) == "gefg_cas03") { 
1181                 set .@treasurebox,1338;
1182                 setarray .@treasurex[0],269,270,270,269,267,268,269,270,271,272,272,272,272,272,272,271,270,269,268,267,267,267,267,267;
1183                 setarray .@treasurey[0],291,291,290,290,293,293,293,293,293,293,292,291,290,289,288,288,288,288,288,288,289,290,291,292;
1184         }
1185         else if (strnpcinfo(2) == "gefg_cas04") { 
1186                 set .@treasurebox,1340;
1187                 setarray .@treasurex[0],115,116,116,115,113,114,115,116,117,118,118,118,118,118,118,117,116,115,114,113,113,113,113,113;
1188                 setarray .@treasurey[0],119,119,118,118,121,121,121,121,121,121,120,119,118,117,116,116,116,116,116,116,117,118,119,120;
1189         }
1190         else if (strnpcinfo(2) == "gefg_cas05") { 
1191                 set .@treasurebox,1342;
1192                 setarray .@treasurex[0],143,144,144,143,141,142,143,144,145,146,146,146,146,146,146,145,144,143,142,141,141,141,141,141;
1193                 setarray .@treasurey[0],110,110,109,109,112,112,112,112,112,112,111,110,109,108,107,107,107,107,107,107,108,109,110,111;
1194         }
1195         else if (strnpcinfo(2) == "payg_cas01") { 
1196                 set .@treasurebox,1344;
1197                 setarray .@treasurex[0],289,292,292,289,288,289,290,291,292,293,293,293,293,293,293,292,291,290,289,288,288,288,288,288;
1198                 setarray .@treasurey[0],10,10,7,7,11,11,11,11,11,11,10,9,8,7,6,6,6,6,6,6,7,8,9,10;
1199         }
1200         else if (strnpcinfo(2) == "payg_cas02") { 
1201                 set .@treasurebox,1346;
1202                 setarray .@treasurex[0],143,146,146,143,142,143,144,145,146,147,147,147,147,147,147,146,145,144,143,142,142,142,142,142;
1203                 setarray .@treasurey[0],146,146,143,143,147,147,147,147,147,147,146,145,144,143,142,142,142,142,142,142,143,144,145,146;
1204         }
1205         else if (strnpcinfo(2) == "payg_cas03") { 
1206                 set .@treasurebox,1348;
1207                 setarray .@treasurex[0],158,159,159,158,156,157,158,159,160,161,161,161,161,161,161,160,159,158,157,156,156,156,156,156;
1208                 setarray .@treasurey[0],169,169,168,168,171,171,171,171,171,171,170,169,168,167,166,166,166,166,166,166,167,168,169,170;
1209         }
1210         else if (strnpcinfo(2) == "payg_cas04") { 
1211                 set .@treasurebox,1350;
1212                 setarray .@treasurex[0],146,147,147,146,144,145,146,147,148,149,149,149,149,149,149,148,147,146,145,144,144,144,144,144;
1213                 setarray .@treasurey[0],48,48,47,47,50,50,50,50,50,50,49,48,47,46,45,45,45,45,45,45,46,47,48,49;
1214         }
1215         else if (strnpcinfo(2) == "payg_cas05") { 
1216                 set .@treasurebox,1352;
1217                 setarray .@treasurex[0],155,158,158,155,154,155,156,157,158,159,159,159,159,159,159,158,157,156,155,154,154,154,154,154;
1218                 setarray .@treasurey[0],134,134,131,131,135,135,135,135,135,135,134,133,132,131,130,130,130,130,130,130,131,132,133,134;
1219         }
1220         else if (strnpcinfo(2) == "prtg_cas01") { 
1221                 set .@treasurebox,1354;
1222                 setarray .@treasurex[0],10,11,11,10,8,9,10,11,12,13,13,13,13,13,13,12,11,10,9,8,8,8,8,8;
1223                 setarray .@treasurey[0],209,209,208,208,211,211,211,211,211,211,210,209,208,207,206,206,206,206,206,206,207,208,209,210;
1224         }
1225         else if (strnpcinfo(2) == "prtg_cas02") { 
1226                 set .@treasurebox,1356;
1227                 setarray .@treasurex[0],201,202,202,201,199,200,201,202,203,204,204,204,204,204,204,203,202,201,200,199,199,199,199,199;
1228                 setarray .@treasurey[0],228,228,227,227,230,230,230,230,230,230,229,228,227,226,225,225,225,225,225,225,226,227,228,229;
1229         }
1230         else if (strnpcinfo(2) == "prtg_cas03") { 
1231                 set .@treasurebox,1358;
1232                 setarray .@treasurex[0],187,188,188,187,185,186,187,188,189,190,190,190,190,190,190,189,188,187,186,185,185,185,185,185;
1233                 setarray .@treasurey[0],132,132,131,131,134,134,134,134,134,134,133,132,131,130,129,129,129,129,129,129,130,131,132,133;
1234         }
1235         else if (strnpcinfo(2) == "prtg_cas04") { 
1236                 set .@treasurebox,1360;
1237                 setarray .@treasurex[0],269,270,270,269,267,268,269,270,271,272,272,272,272,272,272,271,270,269,268,267,267,267,267,267;
1238                 setarray .@treasurey[0],162,162,161,161,164,164,164,164,164,164,163,162,161,160,159,159,159,159,159,159,160,161,162,163;
1239         }
1240         else if (strnpcinfo(2) == "prtg_cas05") { 
1241                 set .@treasurebox,1362;
1242                 setarray .@treasurex[0],275,276,276,275,273,274,275,276,277,278,278,278,278,278,278,277,276,275,274,273,273,273,273,273;
1243                 setarray .@treasurey[0],178,178,177,177,180,180,180,180,180,180,179,178,177,176,175,175,175,175,175,175,176,177,178,179;
1244         }
1245         // Add custom Guild Castles here.
1246         else {
1247                 end;
1248         }
1249
1250         // Apply investment to Eco. and Def. Only happens if there were investments made.
1251         // Permanent Development can only happen once per day.
1252         if (GetCastleData(strnpcinfo(2),4)) {
1253                 set .@Economy,GetCastleData(strnpcinfo(2),2);
1254                 SetCastleData strnpcinfo(2),2,.@Economy + GetCastleData(strnpcinfo(2),4) + (rand(2) && getgdskilllv(.@GID,10014));
1255                 if (GetCastleData(strnpcinfo(2),2) > 100) SetCastleData strnpcinfo(2),2,100;
1256         }
1257         if (GetCastleData(strnpcinfo(2),5)) {
1258                 set .@Defence,GetCastleData(strnpcinfo(2),3);
1259                 SetCastleData strnpcinfo(2),3,.@Defence + GetCastleData(strnpcinfo(2),5);
1260                 if (GetCastleData(strnpcinfo(2),3) > 100) SetCastleData strnpcinfo(2),3,100;
1261         }
1262         // Reset daily investment limits.
1263         setcastledata strnpcinfo(2),4,0;
1264         setcastledata strnpcinfo(2),5,0;
1265
1266         // Spawn boxes in proper order.
1267         for (set .@i,0; .@i < .@Treasure ; set .@i,.@i+1) {
1268                 // set treasure box ID
1269                 set .@boxid, .@treasurebox + (.@i+2) % 2;
1270                 set .@box,1 << .@i;
1271                 // Spawn or do not spawn chests if one already exists.
1272                 if ((getd("$@"+strnpcinfo(2)+"_treasure") & .@box) == 0) {
1273                         monster strnpcinfo(2),.@treasurex[.@i],.@treasurey[.@i],"Treasure Chest",.@boxid,1,"Treasure#"+strnpcinfo(2)+"::OnTreasureDied"+.@i;
1274                         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") | .@box;
1275                 }
1276         }
1277         end;
1278
1279 // Individual "You killed a chest" events to ensure proper spawning at the change of day.
1280 OnTreasureDied0:
1281         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~1;
1282         end;
1283 OnTreasureDied1:
1284         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~2;
1285         end;
1286 OnTreasureDied2:
1287         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~4;
1288         end;
1289 OnTreasureDied3:
1290         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~8;
1291         end;
1292 OnTreasureDied4:
1293         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~16;
1294         end;
1295 OnTreasureDied5:
1296         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~32;
1297         end;
1298 OnTreasureDied6:
1299         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~64;
1300         end;
1301 OnTreasureDied7:
1302         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~128;
1303         end;
1304 OnTreasureDied8:
1305         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~256;
1306         end;
1307 OnTreasureDied9:
1308         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~512;
1309         end;
1310 OnTreasureDied10:
1311         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~1024;
1312         end;
1313 OnTreasureDied11:
1314         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~2048;
1315         end;
1316 OnTreasureDied12:
1317         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~4096;
1318         end;
1319 OnTreasureDied13:
1320         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~8192;
1321         end;
1322 OnTreasureDied14:
1323         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~16384;
1324         end;
1325 OnTreasureDied15:
1326         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~32768;
1327         end;
1328 OnTreasureDied16:
1329         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~65536;
1330         end;
1331 OnTreasureDied17:
1332         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~131072;
1333         end;
1334 OnTreasureDied18:
1335         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~262144;
1336         end;
1337 OnTreasureDied19:
1338         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~524288;
1339         end;
1340 OnTreasureDied20:
1341         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~1048576;
1342         end;
1343 OnTreasureDied21:
1344         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~2097152;
1345         end;
1346 OnTreasureDied22:
1347         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~4194304;
1348         end;
1349 OnTreasureDied23:
1350         setd "$@"+strnpcinfo(2)+"_treasure",getd("$@"+strnpcinfo(2)+"_treasure") & ~8388608;
1351         end;
1352 }