OSDN Git Service

First version
[st-ro/stro.git] / npc / re / guild3 / agit_main_te.txt
1 //===== rAthena Script =======================================
2 //= War of Emperium TE - Template File
3 //===== Description: =========================================
4 //= [Official Conversion]
5 //= Like agit_main, this file is required
6 //= for TE castles to function.
7 //= - Enables AGIT Manager.
8 //= - Enables Stewards to invest.
9 //= - Enables Kafra Services inside Guild.
10 //= - Treasure Chest spawning.
11 //= - Flag Template.
12 //= - GM NPC.
13 //===== Changelogs: ==========================================
14 //= 1.0 First Version. [Capuche]
15 //============================================================
16
17 -       script  Manager_TE      -1,{
18 OnAgitInit3:
19         .@map$ = strnpcinfo(4);
20         if (.@map$ == "") end;
21         .@npc_name$ = strnpcinfo(0);
22         .@guild_id = getcastledata(.@map$,1);
23         if (.@guild_id == 0) {
24                 killmonster .@map$, .@npc_name$ +"::OnMyMobDead";
25                 donpcevent strnpcinfo(0)+"::OnEmpSpawn";
26                 if (compare(.@map$,"te_aldecas")) {
27                         monster .@map$,0,0,"Evil Druid",1117,10,.@npc_name$ +"::OnMyMobDead";
28                         monster .@map$,0,0,"Khalitzburg",1132,4,.@npc_name$ +"::OnMyMobDead";
29                         monster .@map$,0,0,"Abysmal Knight",1219,2,.@npc_name$ +"::OnMyMobDead";
30                         monster .@map$,0,0,"Executioner",1205,1,.@npc_name$ +"::OnMyMobDead";
31                         monster .@map$,0,0,"Penomena",1216,10,.@npc_name$ +"::OnMyMobDead";
32                         monster .@map$,0,0,"Alarm",1193,18,.@npc_name$ +"::OnMyMobDead";
33                         monster .@map$,0,0,"Clock",1269,9,.@npc_name$ +"::OnMyMobDead";
34                         monster .@map$,0,0,"Raydric Archer",1276,7,.@npc_name$ +"::OnMyMobDead";
35                         monster .@map$,0,0,"Wanderer",1208,3,.@npc_name$ +"::OnMyMobDead";
36                         monster .@map$,0,0,"Alice",1275,1,.@npc_name$ +"::OnMyMobDead";
37                         monster .@map$,0,0,"Bloody Knight",1268,1,.@npc_name$ +"::OnMyMobDead";
38                         monster .@map$,0,0,"Dark Lord",1272,1,.@npc_name$ +"::OnMyMobDead";
39                         if (.@map$ == "te_aldecas1") { setarray .@emproom[0],216,23; }
40                         else if (.@map$ == "te_aldecas2") { setarray .@emproom[0],213,23; }
41                         else if (.@map$ == "te_aldecas3") { setarray .@emproom[0],205,31; }
42                         else if (.@map$ == "te_aldecas4") { setarray .@emproom[0],36,217; }
43                         else if (.@map$ == "te_aldecas5") { setarray .@emproom[0],27,101; }
44                         monster .@map$,.@emproom[0],.@emproom[1],"Dark Lord",1272,1,.@npc_name$ +"::OnMyMobDead";
45                         monster .@map$,.@emproom[0],.@emproom[1],"Tower Keeper",1270,4,.@npc_name$ +"::OnMyMobDead";
46                         monster .@map$,.@emproom[0],.@emproom[1],"Bloody Knight",1268,1,.@npc_name$ +"::OnMyMobDead";
47                         monster .@map$,.@emproom[0],.@emproom[1],"Abysmal Knight",1219,1,.@npc_name$ +"::OnMyMobDead";
48                         monster .@map$,.@emproom[0],.@emproom[1],"Raydric Archer",1276,5,.@npc_name$ +"::OnMyMobDead";
49                 }
50                 else if (compare(.@map$,"te_prtcas")) {
51                         monster .@map$,0,0,"Raydric",1163,10,.@npc_name$ +"::OnMyMobDead";
52                         monster .@map$,0,0,"Khalitzburg",1132,10,.@npc_name$ +"::OnMyMobDead";
53                         monster .@map$,0,0,"Abysmal Knight",1219,5,.@npc_name$ +"::OnMyMobDead";
54                         monster .@map$,0,0,"Bloody Knight",1268,5,.@npc_name$ +"::OnMyMobDead";
55                         monster .@map$,0,0,"Stormy Knight",1251,1,.@npc_name$ +"::OnMyMobDead";
56                         monster .@map$,0,0,"Hatii",1252,1,.@npc_name$ +"::OnMyMobDead";
57                         monster .@map$,0,0,"Raydric Archer",1276,5,.@npc_name$ +"::OnMyMobDead";
58                         monster .@map$,0,0,"Gryphon",1259,2,.@npc_name$ +"::OnMyMobDead";
59                         monster .@map$,0,0,"Chimera",1283,2,.@npc_name$ +"::OnMyMobDead";
60                         monster .@map$,0,0,"Alice",1275,1,.@npc_name$ +"::OnMyMobDead";
61                         monster .@map$,0,0,"Zealotus",1200,1,.@npc_name$ +"::OnMyMobDead";
62                         if (.@map$ == "te_prtcas01") { setarray .@emproom[0],197,197; }
63                         else if (.@map$ == "te_prtcas02") { setarray .@emproom[0],157,174; }
64                         else if (.@map$ == "te_prtcas03") { setarray .@emproom[0],16,220; }
65                         else if (.@map$ == "te_prtcas04") { setarray .@emproom[0],291,14; }
66                         else if (.@map$ == "te_prtcas05") { setarray .@emproom[0],266,266; }
67                         monster .@map$,.@emproom[0],.@emproom[1],"Guardian Knight of Emperium",1268,1,.@npc_name$ +"::OnMyMobDead";
68                         monster .@map$,.@emproom[0],.@emproom[1],"Chief Guardian Knight of Emperium",1251,1,.@npc_name$ +"::OnMyMobDead";
69                         monster .@map$,.@emproom[0],.@emproom[1],"Hatii",1252,1,.@npc_name$ +"::OnMyMobDead";
70                         monster .@map$,.@emproom[0],.@emproom[1],"Guardian Knight of Emperium",1219,2,.@npc_name$ +"::OnMyMobDead";
71                         monster .@map$,.@emproom[0],.@emproom[1],"Raydric Archer",1276,5,.@npc_name$ +"::OnMyMobDead";
72                 }
73                 disablenpc "Kafra Employee#"+ replacestr(.@map$, "cas", "");
74         }
75         else {
76                 requestguildinfo .@guild_id;
77                 donpcevent "::OnFlagTE" + strnpcinfo(2);// Guild emblem on flags.
78                 if (getcastledata(.@map$,9)  == 0)
79                         disablenpc "Kafra Employee#"+ replacestr(.@map$, "cas", "");
80
81                 // Load purchased Guardian in castles.
82                 if (.@map$ == "te_aldecas1") donpcevent "Clode::OnSpawnGuardians";
83                 else if (.@map$ == "te_aldecas2") donpcevent "Lares::OnSpawnGuardians";
84                 else if (.@map$ == "te_aldecas3") donpcevent "Valerian::OnSpawnGuardians";
85                 else if (.@map$ == "te_aldecas4") donpcevent "Alpores::OnSpawnGuardians";
86                 else if (.@map$ == "te_aldecas5") donpcevent "Anpere::OnSpawnGuardians";
87                 else if (.@map$ == "te_prtcas01") donpcevent "Kurbe::OnSpawnGuardians";
88                 else if (.@map$ == "te_prtcas02") donpcevent "Kamiyu::OnSpawnGuardians";
89                 else if (.@map$ == "te_prtcas03") donpcevent "Eduare::OnSpawnGuardians";
90                 else if (.@map$ == "te_prtcas04") donpcevent "Casate::OnSpawnGuardians";
91                 else if (.@map$ == "te_prtcas05") donpcevent "Pisaro::OnSpawnGuardians";
92         }
93         end;
94
95 OnEmpSpawn:
96         .@map$ = strnpcinfo(4);
97         if (!mobcount( .@map$, strnpcinfo(0) +"::OnAgitBreak" )) {
98                 if (.@map$ == "te_aldecas1") { setarray .@emproom[0],216,23; }
99                 else if (.@map$ == "te_aldecas2") { setarray .@emproom[0],213,23; }
100                 else if (.@map$ == "te_aldecas3") { setarray .@emproom[0],205,31; }
101                 else if (.@map$ == "te_aldecas4") { setarray .@emproom[0],36,217; }
102                 else if (.@map$ == "te_aldecas5") { setarray .@emproom[0],27,101; }
103                 else if (.@map$ == "te_prtcas01") { setarray .@emproom[0],197,197; }
104                 else if (.@map$ == "te_prtcas02") { setarray .@emproom[0],157,174; }
105                 else if (.@map$ == "te_prtcas03") { setarray .@emproom[0],16,220; }
106                 else if (.@map$ == "te_prtcas04") { setarray .@emproom[0],291,14; }
107                 else if (.@map$ == "te_prtcas05") { setarray .@emproom[0],266,266; }
108                 monster .@map$,.@emproom[0],.@emproom[1],"Emperium",1288,1, strnpcinfo(0) +"::OnAgitBreak";
109         }
110         end;
111
112 OnAgitStart3:
113         .@map$ = strnpcinfo(4);
114         if (.@map$ == "") end;
115         if (agitcheck3()) {
116                 maprespawnguildid .@map$, getcastledata(.@map$,1),2;// warp all non-guild members
117                 gvgon3 .@map$;
118                 donpcevent strnpcinfo(0)+"::OnEmpSpawn";
119                 callsub S_Message,"OnCommandOn";
120         }
121         end;
122
123 OnAgitEnd3:
124         .@map$ = strnpcinfo(4);
125         if (.@map$ == "") end;
126         gvgoff3 .@map$;
127         if (getcastledata(.@map$,1))
128                 killmonster .@map$, strnpcinfo(0) +"::OnAgitBreak";
129         callsub S_Message,"OnReset";
130         end;
131
132 OnAgitBreak:
133         .@guild_id = getcharid(2);
134         .@map$ = strnpcinfo(4);
135
136         .@economy = getcastledata(.@map$,2) - 5;// Adjust economy Invest Level for Castle
137         if (.@economy < 1)
138                 setcastledata .@map$, 2,1;
139         else
140                 setcastledata .@map$, 2,.@economy;
141         .@defense = getcastledata(.@map$,3) - 5;// Adjust Defense Invest Level for Castle
142         if (.@defense < 1)
143                 setcastledata .@map$, 3,1;
144         else
145                 setcastledata .@map$, 3,.@defense;
146         setcastledata .@map$,1,.@guild_id;
147
148         // Reset Invest information and refresh castle data
149         for ( .@i = 4; .@i <= 9; .@i++ )
150                 setcastledata .@map$,.@i,0;
151         donpcevent strnpcinfo(0) +"::OnAgitInit3";// spawn guardians / monsters
152
153         // Erase Guardian Database information if the new owners do not have Guardian Research.
154         if (getgdskilllv(.@guild_id,10002) == 0) {
155                 for ( .@i = 10; .@i <= 17; .@i++ )
156                         setcastledata .@map$,.@i,0;
157         }
158
159         mapannounce .@map$,"Emperium has been destroyed.",bc_map,"0x00FF00",FW_BOLD,20,0,40;
160         maprespawnguildid .@map$,.@guild_id,2;// Respawn all but new castle-occupants, don't remove monsters.
161
162         sleep 500;
163         if (agitcheck3())
164                 donpcevent strnpcinfo(0) +"::OnEmpSpawn";
165         sleep 7000;
166         announce "The [" + getcastlename(.@map$) + "] castle has been conquered by the [" + getguildName(.@guild_id) + "] guild.",bc_all|bc_woe;
167         end;
168
169 OnGuildBreak:
170         .@map$ = strnpcinfo(4);
171         if (.@map$ == "") end;
172         .@tmp$ = replacestr(.@map$, "cas", "");
173         killmonster .@map$, "Kafra Employee#"+ .@tmp$ +"::OnGuardianDied";
174         disablenpc "Kafra Employee#"+ .@tmp$;
175         setcastledata .@map$,1,0;
176         sleep 7000;
177         announce "Guild Base [" + getcastlename(.@map$) + "] has been abandoned.",bc_all;
178         donpcevent strnpcinfo(0) +"::OnAgitInit3";
179         end;
180
181 S_Message:
182         .@map$ = strnpcinfo(4);
183         .@guild_id = getcastledata(.@map$,1);
184         
185         if (.@guild_id)
186                 announce "The [" + getcastlename(.@map$) + "] castle is occupied by the [" + getguildname(.@guild_id) + "] guild.",bc_all,"0xFF0000",FW_NORMAL,10;
187         else
188                 announce "The [" + getcastlename(.@map$) + "] castle is currently unoccupied.", bc_all,"0xFF0000",FW_NORMAL,10;
189         if (compare( .@map$,"te_alde" ))
190                 .@string$ = "alde0"+ charat( .@map$,getstrlen(.@map$)-1 );
191         else
192                 .@string$ = "prt0"+ charat( .@map$,getstrlen(.@map$)-1 );
193         donpcevent "#popswitch_"+ .@string$ +"::"+ getarg(0);// monsters for mission TE
194
195         if (.@map$ == "te_aldecas1") {
196                 donpcevent "Blacksmith Cano#tegod01::OnInit";// god item TE
197                 $2012_tegod_kafra = 0;
198                 $@2012_tegirls_alde01 = 0;
199         }
200         else if (.@map$ == "te_prtcas01") {
201         $2012_tegod_gloria = 0;
202         $@2012_tegirls_prt01 = 0;
203         donpcevent "Blacksmith Kai#tegod01::OnInit";
204         }
205         return;
206
207 OnMyMobDead:
208         end;
209 }
210
211 // Guild Kafras
212 //============================================================
213 -       script  Kafra_Staff_TE  -1,{
214         .@guild_id = getcastledata( strnpcinfo(4),1 );
215         .@guildname$ = getguildname(.@guild_id);
216
217         cutin "kafra_01",2;
218         mes "[Kafra Employee]";
219         if (.@guild_id == getcharid(2)) {
220                 mes "Welcome. ^ff0000" + .@guildname$ + "^000000 Member.";
221                 mes "The Kafra Corporation will stay with you wherever you go.";
222                 next;
223                 switch( select( "Use Storage", "Use Teleport Service", "Rent a Pushcart", "Cancel" ) ) {
224                 case 1:
225                         if (getskilllv("NV_BASIC") > 5) {
226                                 mes "[Kafra Employee]";
227                                 mes "Here, let me open";
228                                 mes "your Storage for you.";
229                                 mes "Thank you for using";
230                                 mes "the Kafra Service.";
231                                 close2;
232                                 openstorage;
233                         } else {
234                                 mes "[Kafra Employee]";
235                                 mes "I'm sorry, but you";
236                                 mes "need the Novice's";
237                                 mes "Basic Skill Level 6 to";
238                                 mes "use the Storage Service.";
239                                 close2;
240                         }
241                         break;
242                 case 2:
243                         if (compare( strnpcinfo(4),"alde" ) == 1)
244                                 callsub( S_Warp, "Aldebaran", "aldebaran",132,103 );
245                         else
246                                 callsub( S_Warp, "Prontera", "prontera",278,211 );
247                 case 3:
248                         mes "[Kafra Employee]";
249                         if (BaseClass != Job_Merchant) {
250                                 mes "I'm sorry, but the";
251                                 mes "Pushcart rental service";
252                                 mes "is only available to Merchants,";
253                                 mes "Blacksmiths and Alchemists.";
254                                 close2;
255                         }
256                         else if (checkcart()) {
257                                 mes "You already have";
258                                 mes "a Pushcart equipped.";
259                                 mes "Unfortunately, we can't";
260                                 mes "rent more than one to";
261                                 mes "each customer at a time.";
262                                 close2;
263                         }
264                         else {
265                                 mes "The Pushcart rental";
266                                 mes "fee is 800 zeny. Would";
267                                 mes "you like to rent a Pushcart?";
268                                 next;
269                                 if (select( "Rent a Pushcart","Cancel" ) == 1) {
270                                         if (Zeny < 800) {
271                                                 mes "[Kafra Employee]";
272                                                 mes "I'm sorry, but you";
273                                                 mes "don't have enough";
274                                                 mes "zeny to pay the Pushcart";
275                                                 mes "rental fee of 800 zeny.";
276                                                 close2;
277                                         }
278                                         else {
279                                                 RESRVPTS = RESRVPTS + 80;
280                                                 Zeny = Zeny - 800;
281                                                 setcart();
282                                         }
283                                 }
284                         }
285                         break;
286                 case 4:
287                         mes "[Kafra Employee]";
288                         mes "We, here at Kafra Corporation,";
289                         mes "are always endeavoring to provide you with the best services. We hope that we meet your adventuring needs and standards of excellence.";
290                         close2;
291                         break;
292                 }
293         }
294         else {
295                 mes "I am instructed to only offer my services to the ^ff0000"+ .@guildname$ +"^000000 Guild. Please try another Kafra Employee around here. Sorry for the inconvenience.";
296                 close2;
297         }
298         cutin "",255;
299         end;
300
301 S_Warp:
302         mes "[Kafra Employee]";
303         mes "Please choose";
304         mes "your destination.";
305         next;
306         switch( select( getarg(0) + " -> 200 z", "Cancel it" ) ) {
307         case 1:
308                 if (Zeny < 200) {
309                         mes "[Kafra Employee]";
310                         mes "I'm sorry, but you don't have";
311                         mes "enough zeny for the Teleport";
312                         mes "Service. The fee to teleport";
313                         mes "to "+getarg(0)+" is 200 zeny.";
314                         close2;
315                         cutin "",255;
316                         end;
317                 }
318                 Zeny = Zeny - 200;
319                 RESRVPTS = RESRVPTS + 20;
320                 warp getarg(1), getarg(2),getarg(3);
321                 end;
322         case 2:
323                 cutin "",255;
324                 end;
325         }
326
327 OnGuardianDied:
328         end;
329 }
330
331 // Castle Managers (Invest)
332 //============================================================
333 -       script  invest_TE       -1,{
334 function GuardianData;
335
336         .@map$ = strnpcinfo(4);
337         .@npc_name$ = "[ Butler "+ strnpcinfo(1) +"]";
338         .@guild_id = getcastledata(.@map$,1);
339         .@guildmaster$ = getguildmaster(.@guild_id);
340
341         mes .@npc_name$;
342         if (.@guild_id == 0) {
343                 mes "I have been waiting for a master to fulfill my destiny.";
344                 mes "Brave soul... fate will guide you towards your future...";
345                 close;
346         }
347         if (strcharinfo(0) != .@guildmaster$) {
348                 mes "No matter how much you pester me, I'll still follow my master ^ff0000"+.@guildmaster$+"^000000. Where are the Guardians?! Send these ruffians away right now!";
349                 close;
350         }
351         mes "Welcome. My honorable master, ^ff0000"+strcharinfo(0)+"^000000...";
352         mes "Your humble servent, "+strnpcinfo(1)+", is here to serve you.";
353         next;
354         switch( select( "Castle briefing", "Invest in commercial growth", "Invest in Castle Defenses", "Summon Guardian", "Hire / Fire a Kafra Employee", "Go into Master's room" ) ) {
355         case 1:
356                 .@economy_today = getcastledata(.@map$,4);
357                 .@defense_today = getcastledata(.@map$,5);
358                 mes .@npc_name$;
359                 mes "I will report the Castle briefing, Master.";
360                 mes " ";
361                 mes "^0000ffNow, the commercial growth level is "+GetCastleData(.@map$,2)+".";
362                 if (.@economy_today > 0)
363                         mes " You invested "+.@economy_today+" times in past 1 day.";
364                 mes " Now, the Castle Defense level is "+GetCastleData(.@map$,3)+".^000000";
365                 if (.@defense_today > 0)
366                         mes " ^0000ff- You invested "+.@defense_today+" times in past 1 day.^000000";
367                 mes " ";
368                 mes "That's all I have to report, Master.";
369                 close;
370
371         case 2:
372                 .@economy = getcastledata(.@map$,2);
373                 setarray .@eco_invest[0], 5,5000, 10,10000, 15,20000, 20,35000, 25,55000, 30,80000, 35,110000, 40,145000, 45,185000, 50,230000,
374                         55,280000, 60,335000, 65,395000, 70,460000, 75,530000, 80,605000, 85,685000, 90,770000, 95,860000, 100,955000;
375                 for ( .@i = 0; .@i < getarraysize(.@eco_invest); .@i += 2 )
376                         if (.@economy <= .@eco_invest[.@i]) break;
377                 callsub( S_Invest, 4, .@eco_invest[.@i+1], getcastledata(.@map$,4), "commercial growth", "quantity of goods made by the guild will increase", "future", "economist", "riches" );
378
379         case 3:
380                 .@defense = getcastledata(.@map$,3);
381                 setarray .@def_invest[0], 5,10000, 10,20000, 15,40000, 20,70000, 25,110000, 30,160000, 35,220000, 40,290000, 45,370000, 50,460000,
382                         55,560000, 60,670000, 65,790000, 70,920000, 75,1060000, 80,1210000, 85,1370000, 90,1540000, 95,1720000, 100,1910000;
383                 for ( .@i = 0; .@i < getarraysize(.@def_invest); .@i += 2 )
384                         if (.@defense <= .@def_invest[.@i]) break;
385                 callsub( S_Invest, 5, .@def_invest[.@i+1], getcastledata(.@map$,5), "Castle Defenses", "durability of Guardians and the Emperium will increase", "coming battles", "strategist", "Defenses" );
386
387         case 4:
388                 mes .@npc_name$;
389                 mes "Will you summon a Guardian? It'll be a protector to defend us loyally.";
390                 mes "Please select a guardian to defend us.";
391                 next;
392                 GuardianData( .@mob_id, .@x, .@y, .@name$ );
393                 for ( .@i = 0; .@i < MAX_GUARDIANS ; .@i++ ) {
394                         if (guardianinfo(.@map$,.@i,0))
395                                 .@menu$ = .@menu$ + getmonsterinfo(.@mob_id[.@i],MOB_NAME) + " - Implemented (" + guardianinfo(.@map$,.@i,2) + "/" + guardianinfo(.@map$,.@i,1) + "):";// hp/hpmax
396                         else
397                                 .@menu$ = .@menu$ + getmonsterinfo(.@mob_id[.@i],MOB_NAME) + " - Not Implemented:";
398                 }
399                 .@s = select(.@menu$) -1;
400                 mes .@npc_name$;
401                 mes "Will you summon the chosen guardian? 10,000 zeny are required to summon a Guardian.";
402                 next;
403                 if (select( "Summon","Cancel" ) == 2) {
404                         mes .@npc_name$;
405                         mes "I did as you ordered. But please remember if you the have money to spare, it'll be better to set it up.";
406                         close;
407                 }
408                 mes .@npc_name$;
409                 if (getgdskilllv(.@guild_id,10002) == 0) {
410                         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.";
411                 }
412                 else if (getcastledata( .@map$,(.@s+10) ) == 1)
413                         mes "Master, you already have summoned that Guardian. We cannot summon another.";
414                 else if (Zeny <  10000)
415                         mes "Well... I'm sorry but we don't have funds to summon the Guardian. We failed to summon the Guardian.";
416                 else {
417                         Zeny = Zeny - 10000;
418                         setcastledata .@map$,(.@s+10),1;
419                         guardian .@map$, .@x[.@s], .@y[.@s], .@name$[.@s], .@mob_id[.@s], "Kafra Employee#"+ replacestr(.@map$, "cas", "") +"::OnGuardianDied", .@s;
420                         mes "We completed the summoning of the Guardian. Our defenses are now increased with it in place.";
421                 }
422                 close;
423
424         case 5:
425                 mes .@npc_name$;
426                 if (getcastledata(.@map$,9) == 1) {
427                         mes "We are currently hiring a Kafra Employee... Do you want to fire the Kafra Employee?";
428                         next;
429                         if (select( "Fire","Cancel" ) == 2) {
430                                 mes .@npc_name$;
431                                 mes "She worked hard in my opinion. It was a good decision to keep her.";
432                                 close;
433                         }
434                         cutin "kafra_01",2;
435                         mes "[ Hired Kafra Employee ]";
436                         mes "I worked so hard... How can you do that, Master?... Please... Please reconsider... Check it again, Master... Please...";
437                         next;
438                         if (select( "Fire","Cancel" ) == 2) {
439                                 mes "[ Hired Kafra Employee ]";
440                                 mes "I'll work hard for you... Thank you!";
441                                 close;
442                         }
443                         mes "[ Hired Kafra Employee ]";
444                         mes "Oh, my goodness! This is nonsense!";
445                         next;
446                         cutin "",255;
447                         disablenpc "Kafra Employee#" + replacestr(.@map$, "cas", "");
448                         setcastledata .@map$,9,0;
449                         mes .@npc_name$;
450                         mes "....";
451                         mes "I have discharged the Kafra Employee... But... are you unsatisfied with something?";
452                         close;
453                 }
454                 mes "Will you contact the kafra Main Office and Hire a Employee for our Castle?";
455                 mes "^ff0000 10,000 zeny is required for their services. ";
456                 next;
457                 if (select( "Hire.","Cancel" ) == 2) {
458                         mes .@npc_name$;
459                         mes "I did as you ordered, but some of our members will be unhappy. It will be better to hire a Kafra Employee quickly.";
460                         close;
461                 }
462                 mes .@npc_name$;
463                 if (getgdskilllv(.@guild_id,10001) == 0) {
464                         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.";
465                         close;
466                 }
467                 if (Zeny <  10000) {
468                         mes "Well... I'm sorry but we don't have enough funds to hire a Kafra Employee.";
469                         close;
470                 }
471                 Zeny = Zeny - 10000;
472                 enablenpc "Kafra Employee#" + replacestr(.@map$, "cas", "");
473                 setcastledata .@map$,9,1;
474
475                 mes "We obtained a contract with the kafra Main Office, and hired a Kafra Employee.";
476                 next;
477                 cutin "kafra_01",2;
478                 mes "[ Hired Kafra Employee ]";
479                 mes "How do you do? I was dispatched from the Main Office.";
480                 mes "I'll do my best to not tarnish the reputation of the Guild.";
481                 next;
482                 cutin "",255;
483                 mes .@npc_name$;
484                 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.";
485                 mes "It will be useful for our members.";
486                 close;
487
488         case 6:
489                 mes .@npc_name$;
490                 mes "Do you want to visit the room where our valuables are stored?";
491                 mes "That room is restricted to you... you are the only one with access to it.";
492                 next;
493                 mes .@npc_name$;
494                 mes "If you don't open the treasure box within time limits, there is a possibility of losing it when unexpected situation occurs.";
495                 mes "Please make sure to remember that always, Master.";
496                 mes "So, for our guild's improvement, you must find time to collect it.";
497                 next;
498                 switch( select( "Go into Master's room.","Cancel" ) ) {
499                 case 1:
500                         mes .@npc_name$;
501                         mes "I'll show you the secret path. Follow me...please.";
502                         mes "When you want to return here, please press the secret switch.";
503                         close2;
504                         if (.@map$ == "te_aldecas1") warp "te_aldecas1",113,223;
505                         else if (.@map$ == "te_aldecas2") warp "te_aldecas2",134,225;
506                         else if (.@map$ == "te_aldecas3") warp "te_aldecas3",229,267;
507                         else if (.@map$ == "te_aldecas4") warp "te_aldecas4",83,17;
508                         else if (.@map$ == "te_aldecas5") warp "te_aldecas5",64,8;
509                         else if (.@map$ == "te_prtcas01") warp "te_prtcas01",15,209;
510                         else if (.@map$ == "te_prtcas02") warp "te_prtcas02",207,229;
511                         else if (.@map$ == "te_prtcas03") warp "te_prtcas03",190,130;
512                         else if (.@map$ == "te_prtcas04") warp "te_prtcas04",275,160;
513                         else if (.@map$ == "te_prtcas05") warp "te_prtcas05",281,176;
514                         end;
515                 case 2:
516                         mes .@npc_name$;
517                         mes "Goods are produced once a day... if you don't remove them in time, they will not be produced anymore.";
518                         mes "Therefore, it will be better if you check up on them from time to time.";
519                         close;
520                 }
521         }
522
523 S_Invest:
524         .@cost_invest = getarg(1);
525         .@num_invest_today = getarg(2);
526         .@npc_name$ = "[ Butler "+ strnpcinfo(1) +"]";
527         if (.@num_invest_today)// Quadruple the cost of investing if you've already invested once.
528                 .@cost_invest = .@cost_invest * 4;
529
530         mes .@npc_name$;
531         mes "If you invest in "+ getarg(3) +", the "+ getarg(4) +". Therfore, if you consider our "+ getarg(5) +", investments will be a necessity.";
532         mes " ";
533         mes "Initially, you are able to invest just once but if you pay more money, you will be able to invest twice.";
534         mes " ";
535         if (getcastledata(strnpcinfo(4),2) >= 100) {
536                 mes "^ff0000The "+ getarg(3) +" level of our Castle is at it's highest, 100%. No more investments are needed. Just as I have expected from a great "+ getarg(6) +" like you, Master.^000000";
537                 close;
538         }
539         if (.@num_invest_today >= 2) {
540                 mes "^ff0000You have already invested twice today. You cannot invest any more.^000000 I expect the "+ getarg(7) +" of the guild to grow at a high rate.";
541                 close;
542         }
543         if (.@num_invest_today == 0)
544                 mes "The current investment amount required is ^ff0000"+.@cost_invest+"^000000 zeny. Will you invest?";
545         else
546                 mes "You've invested once today... if you wish to invest once more, ^ff0000"+.@cost_invest+"^000000 more zeny will be needed.";
547         next;
548         switch( select( "Invest in "+ getarg(3) +".","Cancel" ) ) {
549         case 1:
550                 mes .@npc_name$;
551                 if (Zeny < .@cost_invest) {
552                         mes "I'm sorry but there is not enough zeny to invest. You will have to try again when you have the funds, Master.";
553                         close;
554                 }
555                 Zeny = Zeny - .@cost_invest;
556                 setcastledata strnpcinfo(4), getarg(0), (.@num_invest_today +1);
557                 mes "We finished the investment safely. I expect that our "+ getarg(3) +" level will be increased by tomorrow.";
558                 close;
559         case 2:
560                 mes .@npc_name$;
561                 mes "I'll do as you bid, my master... There is no hurry. We will do our best.";
562                 close;
563         }
564
565 function GuardianData {
566         .@map$ = strnpcinfo(4);
567         if (.@map$ == "te_aldecas1") {
568                 setarray .@data$[0],
569                         1287, 17, 218, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
570                         1285, 39, 205, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
571                         1285, 38, 196, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
572                         1286, 21, 194, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
573                         1286, 218, 24, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
574                         1286, 213, 24, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
575                         1286, 73, 70, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
576                         1285, 45, 228, "Outer Castle Archer Guardian";// ARCHER_GUARDIAN
577         }
578         else if (.@map$ == "te_aldecas2") {
579                 setarray .@data$[0],
580                         1287, 51, 183, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
581                         1286, 27, 184, "Outer Castle Knight Guardian",// KNIGHT_GUARDIAN
582                         1286, 88, 43, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
583                         1285, 210, 7, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
584                         1287, 60, 203, "Outer Castle Soldier Guardian",// SOLDIER_GUARDIAN
585                         1285, 21, 177, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
586                         1286, 117, 46, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
587                         1285, 36, 183, "Outer Castle Archer Guardian";// ARCHER_GUARDIAN
588         }
589         else if (.@map$ == "te_aldecas3") {
590                 setarray .@data$[0],
591                         1285, 110, 217, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
592                         1286, 90, 112, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
593                         1287, 86, 120, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
594                         1285, 195, 151, "Inner Castle Archer Guardian",// ARCHER_GUARDIAN
595                         1286, 116, 112, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
596                         1287, 116, 76, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
597                         1287, 64, 103, "Outer Castle Soldier Guardian",// SOLDIER_GUARDIAN
598                         1285, 212, 160, "Inner Castle Archer Guardian";// ARCHER_GUARDIAN
599         }
600         else if (.@map$ == "te_aldecas4") {
601                 setarray .@data$[0],
602                         1285, 187, 100, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
603                         1285, 192, 42, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
604                         1286, 55, 88, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
605                         1287, 145, 209, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
606                         1287, 169, 53, "Outer Castle Soldier Guardian",// SOLDIER_GUARDIAN
607                         1287, 198, 77, "Outer Castle Soldier Guardian",// SOLDIER_GUARDIAN
608                         1285, 148, 88, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
609                         1286, 48, 72, "Inner Castle Knight Guardian";// KNIGHT_GUARDIAN
610         }
611         else if (.@map$ == "te_aldecas5") {
612                 setarray .@data$[0],
613                         1285, 51, 202, "Inner Castle Archer Guardian",// ARCHER_GUARDIAN
614                         1286, 27, 221, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
615                         1286, 145, 78, "Outer Castle Knight Guardian",// KNIGHT_GUARDIAN
616                         1287, 157, 192, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
617                         1287, 157, 74, "Outer Castle Soldier Guardian",// SOLDIER_GUARDIAN
618                         1285, 188, 79, "Inner Castle Archer Guardian",// ARCHER_GUARDIAN
619                         1286, 156, 73, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
620                         1286, 41, 112, "Inner Castle Knight Guardian";// KNIGHT_GUARDIAN
621         }
622         else if (.@map$ == "te_prtcas01") {
623                 setarray .@data$[0],
624                         1287, 182, 68, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
625                         1287, 182, 116, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
626                         1287, 153, 86, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
627                         1285, 59, 28, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
628                         1285, 50, 36, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
629                         1286, 184, 183, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
630                         1286, 196, 189, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
631                         1286, 107, 179, "Inner Castle Knight Guardian";// KNIGHT_GUARDIAN
632         }
633         else if (.@map$ == "te_prtcas02") {
634                 setarray .@data$[0],
635                         1286, 162, 161, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
636                         1286, 153, 161, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
637                         1286, 178, 44, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
638                         1287, 71, 75, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
639                         1287, 49, 28, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
640                         1285, 64, 186, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
641                         1285, 76, 196, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
642                         1285, 75, 175, "Outer Castle Archer Guardian";// ARCHER_GUARDIAN
643         }
644         else if (.@map$ == "te_prtcas03") {
645                 setarray .@data$[0],
646                         1286, 191, 190, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
647                         1286, 137, 190, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
648                         1286, 45, 99, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
649                         1287, 50, 87, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
650                         1287, 41, 87, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
651                         1285, 191, 42, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
652                         1285, 179, 43, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
653                         1285, 191, 72, "Outer Castle Archer Guardian";// ARCHER_GUARDIAN
654         }
655         else if (.@map$ == "te_prtcas04") {
656                 setarray .@data$[0],
657                         1286, 276, 14, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
658                         1286, 274, 35, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
659                         1286, 246, 246, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
660                         1287, 38, 240, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
661                         1287, 29, 240, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
662                         1287, 33, 258, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
663                         1285, 78, 48, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
664                         1285, 36, 61, "Outer Castle Archer Guardian";// ARCHER_GUARDIAN
665         }
666         else if (.@map$ == "te_prtcas05") {
667                 setarray .@data$[0],
668                         1286, 266, 262, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
669                         1286, 287, 280, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
670                         1286, 245, 250, "Inner Castle Knight Guardian",// KNIGHT_GUARDIAN
671                         1287, 236, 63, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
672                         1287, 251, 63, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
673                         1287, 278, 71, "Inner Castle Soldier Guardian",// SOLDIER_GUARDIAN
674                         1285, 32, 253, "Outer Castle Archer Guardian",// ARCHER_GUARDIAN
675                         1285, 44, 248, "Outer Castle Archer Guardian";// ARCHER_GUARDIAN
676         }
677         for ( .@i = 0; .@i < getarraysize(.@data$); .@i += 4 ) {
678                 set getelementofarray( getarg(0),.@index ), .@data$[.@i];
679                 set getelementofarray( getarg(1),.@index ), .@data$[.@i+1];
680                 set getelementofarray( getarg(2),.@index ), .@data$[.@i+2];
681                 set getelementofarray( getarg(3),.@index ), .@data$[.@i+3];
682                 .@index++;
683         }
684 }
685
686 OnSpawnGuardians:
687         GuardianData( .@mob_id, .@x, .@y, .@name$ );
688         .@map$ = strnpcinfo(4);
689         .@tmp$ = replacestr(.@map$, "cas", "");
690         killmonster .@map$, "Kafra Employee#"+ .@tmp$ +"::OnGuardianDied";
691         for ( .@i = 0; .@i < MAX_GUARDIANS; .@i++ ) {
692                 if (getcastledata( .@map$,(.@i+10) ))
693                         guardian .@map$, .@x[.@i], .@y[.@i], .@name$[.@i], .@mob_id[.@i], "Kafra Employee#"+ .@tmp$ +"::OnGuardianDied",.@i;
694         }
695 }
696
697 // Guild Dungeon Entrances
698 //============================================================
699 -       script  lever2_TE       -1,{
700         .@guild_id = getcastledata( strnpcinfo(4),1 );
701         if (.@guild_id == 0) {
702                 mes "[Ringing Voice]";
703                 mes "'Those who overcome an ordeal shows a great deal of bravery... and will find their way to another ordeal.'";
704                 close;
705         }
706         mes "[Ringing Voice]";
707         mes "'Only the truly brave can take the test.'";
708         next;
709         mes " ";
710         mes "There's a small lever. Will you pull it?";
711         next;
712         if (select( "Pull.","Don't pull." ) == 1) {
713                 if (.@guild_id == getcharid(2)) {
714                         .@npc_map$ = strnpcinfo(4);
715                         if (compare( .@npc_map$,"te_alde" )) {
716                                 .@map$ = "teg_dun02";
717                                 if (.@npc_map$ == "te_aldecas1") setarray .@coord[0],32,122;
718                                 else if (.@npc_map$ == "te_aldecas2") setarray .@coord[0],79,30;
719                                 else if (.@npc_map$ == "te_aldecas3") setarray .@coord[0],165,38;
720                                 else if (.@npc_map$ == "te_aldecas4") setarray .@coord[0],160,148;
721                                 else if (.@npc_map$ == "te_aldecas5") setarray .@coord[0],103,169;
722                         }
723                         else {
724                                 .@map$ = "teg_dun01";
725                                 if (.@npc_map$ == "te_prtcas01") setarray .@coord[0],28,251;
726                                 else if (.@npc_map$ == "te_prtcas02") setarray .@coord[0],164,268;
727                                 else if (.@npc_map$ == "te_prtcas03") setarray .@coord[0],164,179;
728                                 else if (.@npc_map$ == "te_prtcas04") setarray .@coord[0],268,203;
729                                 else if (.@npc_map$ == "te_prtcas05") setarray .@coord[0],199,28;
730                         }
731                         warp .@map$,.@coord[0],.@coord[1];
732                 }
733                 else {
734                         mes " ";
735                         mes "Nothing happened.";
736                         close;
737                 }
738         }
739         end;
740 }
741
742 // Treasure Room Exit
743 //============================================================
744 -       script  lever1_TE       -1,{
745         mes " ";
746         mes "There's a small lever. Will you pull it?";
747         next;
748         if ( select( "Pull.","Do not." ) == 1 ) {
749                 .@map$ = strnpcinfo(4);
750                 if (.@map$ == "te_aldecas1") setarray .@coord[0],218,176;
751                 else if (.@map$ == "te_aldecas2") setarray .@coord[0],51,179;
752                 else if (.@map$ == "te_aldecas3") setarray .@coord[0],110,119;
753                 else if (.@map$ == "te_aldecas4") setarray .@coord[0],67,117;
754                 else if (.@map$ == "te_aldecas5") setarray .@coord[0],51,179;
755                 else if (.@map$ == "te_prtcas01") setarray .@coord[0],112,183;
756                 else if (.@map$ == "te_prtcas02") setarray .@coord[0],94,62;
757                 else if (.@map$ == "te_prtcas03") setarray .@coord[0],51,101;
758                 else if (.@map$ == "te_prtcas04") setarray .@coord[0],259,265;
759                 else if (.@map$ == "te_prtcas05") setarray .@coord[0],36,38;
760                 warp .@map$,.@coord[0],.@coord[1];
761         }
762         end;
763 }
764
765 // Treasure Room Spawn Template
766 //============================================================
767 -       script  treasure_TE     -1,{
768 OnClock0001:// Spawn Treasure Chests based on castle economy.
769         .@map$ = strnpcinfo(4);
770         if (.@map$ == "") end;
771         .@guild_id = getcastledata(.@map$,1);
772         if (.@guild_id == 0) end;
773
774         .@economy = getcastledata(.@map$,2);
775         .@defense = getcastledata(.@map$,3);
776         .@economy_today = getcastledata(.@map$,4);
777         .@defense_today = getcastledata(.@map$,5);
778
779         killmonster .@map$, strnpcinfo(0)+"::OnTreasureDied";
780         if (.@economy_today) {
781                 .@economy = .@economy + .@economy_today + (rand(2) && getgdskilllv(.@guild_id,10014));
782                 .@economy = ( .@economy > 100 ) ? 100 : .@economy;
783                 setcastledata .@map$,2,.@economy;
784                 setcastledata .@map$,4,0;
785         }
786         if (.@defense_today) {
787                 .@defense = .@defense + .@defense_today;
788                 .@defense = ( .@defense > 100 ) ? 100 : .@defense;
789                 setcastledata .@map$,3,.@defense;
790                 setcastledata .@map$,5,0;
791         }
792
793         if (.@map$ == "te_aldecas1") {
794                 setarray .@data[0],// <mob_id>, <x>,<y>
795                         2452, 115,226,// TREASURE_BOX_TE
796                         2458, 122,226,// TREASURE_BOX_TE_6
797                         2452, 115,219,
798                         2458, 122,219,
799                         2452, 116,225,
800                         2458, 117,225,
801                         2452, 118,225,
802                         2458, 119,225,
803                         2452, 120,225,
804                         2458, 121,225,
805                         2452, 121,224,
806                         2458, 121,223,
807                         2452, 121,222,
808                         2458, 121,221,
809                         2452, 121,220,
810                         2458, 120,220,
811                         2452, 119,220,
812                         2458, 118,220,
813                         2452, 117,220,
814                         2458, 116,220,
815                         2452, 116,221,
816                         2458, 116,222,
817                         2452, 116,223,
818                         2458, 116,224;
819         }
820         else if (.@map$ == "te_aldecas2") {
821                 setarray .@data[0],
822                         2452, 134,231,// TREASURE_BOX_TE
823                         2459, 135,231,// TREASURE_BOX_TE_7
824                         2452, 135,230,
825                         2459, 134,230,
826                         2452, 132,233,
827                         2459, 133,233,
828                         2452, 134,233,
829                         2459, 135,233,
830                         2452, 136,233,
831                         2459, 137,233,
832                         2452, 137,232,
833                         2459, 137,231,
834                         2452, 137,230,
835                         2459, 137,229,
836                         2452, 137,228,
837                         2459, 136,228,
838                         2452, 135,228,
839                         2459, 134,228,
840                         2452, 133,228,
841                         2459, 132,228,
842                         2452, 132,229,
843                         2459, 132,230,
844                         2452, 132,231,
845                         2459, 132,232;
846         }
847         else if (.@map$ == "te_aldecas3") {
848                 setarray .@data[0],
849                         2452, 224,269,// TREASURE_BOX_TE
850                         2460, 225,269,// TREASURE_BOX_TE_8
851                         2452, 225,268,
852                         2460, 224,268,
853                         2452, 222,271,
854                         2460, 223,271,
855                         2452, 224,271,
856                         2460, 225,271,
857                         2452, 226,271,
858                         2460, 227,271,
859                         2452, 227,270,
860                         2460, 227,269,
861                         2452, 227,268,
862                         2460, 227,267,
863                         2452, 227,266,
864                         2460, 226,266,
865                         2452, 225,266,
866                         2460, 224,266,
867                         2452, 223,266,
868                         2460, 222,266,
869                         2452, 222,267,
870                         2460, 222,268,
871                         2452, 222,269,
872                         2460, 222,270;
873         }
874         else if (.@map$ == "te_aldecas4") {
875                 setarray .@data[0],
876                         2452, 84,13,// TREASURE_BOX_TE
877                         2461, 85,13,// TREASURE_BOX_TE_9
878                         2452, 85,12,
879                         2461, 84,12,
880                         2452, 82,15,
881                         2461, 83,15,
882                         2452, 84,15,
883                         2461, 85,15,
884                         2452, 86,15,
885                         2461, 87,15,
886                         2452, 87,14,
887                         2461, 87,13,
888                         2452, 87,12,
889                         2461, 87,11,
890                         2452, 87,10,
891                         2461, 86,10,
892                         2452, 85,10,
893                         2461, 84,10,
894                         2452, 83,10,
895                         2461, 82,10,
896                         2452, 82,11,
897                         2461, 82,12,
898                         2452, 82,13,
899                         2461, 82,14;
900         }
901         else if (.@map$ == "te_aldecas5") {
902                 setarray .@data[0],
903                         2452, 62,12,// TREASURE_BOX_TE
904                         2462, 62,11,// TREASURE_BOX_TE_10
905                         2452, 61,11,
906                         2462, 59,14,
907                         2452, 60,14,
908                         2462, 61,14,
909                         2452, 62,14,
910                         2462, 63,14,
911                         2452, 64,14,
912                         2462, 64,13,
913                         2452, 64,12,
914                         2462, 64,11,
915                         2452, 64,10,
916                         2462, 64,9,
917                         2452, 63,9,
918                         2462, 62,9,
919                         2452, 61,9,
920                         2462, 60,9,
921                         2452, 59,9,
922                         2462, 59,10,
923                         2452, 59,11,
924                         2462, 59,12,
925                         2452, 59,13;
926         }
927         else if (.@map$ == "te_prtcas01") {
928                 setarray .@data[0],
929                         2452, 8,211,// TREASURE_BOX_TE
930                         2453, 9,211,// TREASURE_BOX_TE_1
931                         2452, 10,211,
932                         2453, 11,211,
933                         2452, 12,211,
934                         2453, 13,211,
935                         2452, 13,209,
936                         2453, 12,209,
937                         2452, 11,209,
938                         2453, 10,209,
939                         2452, 9,209,
940                         2453, 8,209,
941                         2452, 8,207,
942                         2453, 9,207,
943                         2452, 10,207,
944                         2453, 11,207,
945                         2452, 12,207,
946                         2453, 13,207,
947                         2452, 13,206,
948                         2453, 12,206,
949                         2452, 11,206,
950                         2453, 10,206,
951                         2452, 9,206,
952                         2453, 8,206;
953         }
954         else if (.@map$ == "te_prtcas02") {
955                 setarray .@data[0],
956                         2452, 201,228,// TREASURE_BOX_TE
957                         2454, 202,228,// TREASURE_BOX_TE_2
958                         2452, 202,227,
959                         2454, 201,227,
960                         2452, 199,230,
961                         2454, 200,230,
962                         2452, 201,230,
963                         2454, 202,230,
964                         2452, 203,230,
965                         2454, 204,230,
966                         2452, 204,229,
967                         2454, 204,228,
968                         2452, 204,227,
969                         2454, 204,226,
970                         2452, 204,225,
971                         2454, 203,225,
972                         2452, 202,225,
973                         2454, 201,225,
974                         2452, 200,225,
975                         2454, 199,225,
976                         2452, 199,226,
977                         2454, 199,227,
978                         2452, 199,228,
979                         2454, 199,229;
980         }
981         else if (.@map$ == "te_prtcas03") {
982                 setarray .@data[0],
983                         2452, 187,132,// TREASURE_BOX_TE
984                         2455, 188,132,// TREASURE_BOX_TE_3
985                         2452, 188,131,
986                         2455, 187,131,
987                         2452, 185,134,
988                         2455, 186,134,
989                         2452, 187,134,
990                         2455, 188,134,
991                         2452, 189,134,
992                         2455, 190,134,
993                         2452, 190,133,
994                         2455, 190,132,
995                         2452, 190,131,
996                         2455, 190,130,
997                         2452, 190,129,
998                         2455, 189,129,
999                         2452, 188,129,
1000                         2455, 187,129,
1001                         2452, 186,129,
1002                         2455, 185,129,
1003                         2452, 185,130,
1004                         2455, 185,131,
1005                         2452, 185,132,
1006                         2455, 185,133;
1007         }
1008         else if (.@map$ == "te_prtcas04") {
1009                 setarray .@data[0],
1010                         2452, 269,162,// TREASURE_BOX_TE
1011                         2456, 270,162,// TREASURE_BOX_TE_4
1012                         2452, 270,161,
1013                         2456, 269,161,
1014                         2452, 267,164,
1015                         2456, 268,164,
1016                         2452, 269,164,
1017                         2456, 270,164,
1018                         2452, 271,164,
1019                         2456, 272,164,
1020                         2452, 272,163,
1021                         2456, 272,162,
1022                         2452, 272,161,
1023                         2456, 272,160,
1024                         2452, 272,159,
1025                         2456, 271,159,
1026                         2452, 270,159,
1027                         2456, 269,159,
1028                         2452, 268,159,
1029                         2456, 267,159,
1030                         2452, 267,160,
1031                         2456, 267,161,
1032                         2452, 267,162,
1033                         2456, 267,163;
1034         }
1035         else if (.@map$ == "te_prtcas05") {
1036                 setarray .@data[0],
1037                         2452, 275,178,// TREASURE_BOX_TE
1038                         2457, 276,178,// TREASURE_BOX_TE_5
1039                         2452, 276,177,
1040                         2457, 275,177,
1041                         2452, 273,180,
1042                         2457, 274,180,
1043                         2452, 275,180,
1044                         2457, 276,180,
1045                         2452, 277,180,
1046                         2457, 278,180,
1047                         2452, 278,179,
1048                         2457, 278,178,
1049                         2452, 278,177,
1050                         2457, 278,176,
1051                         2452, 278,175,
1052                         2457, 277,175,
1053                         2452, 276,175,
1054                         2457, 275,175,
1055                         2452, 274,175,
1056                         2457, 273,175,
1057                         2452, 273,176,
1058                         2457, 273,177,
1059                         2452, 273,178,
1060                         2457, 273,179;
1061         }
1062         .@treasure_num = ( 4 + ( .@economy /5 ) ) *3;// x3 <-> data[] size
1063         for ( .@i = 0; .@i < getarraysize(.@data) && .@treasure_num > .@i; .@i += 3 )// nb. [4;24] chests
1064                 monster .@map$, .@data[.@i+1], .@data[.@i+2],"Treasure Chest", .@data[.@i],1, strnpcinfo(0)+"::OnTreasureDied";
1065
1066 OnTreasureDied:
1067         end;
1068 }
1069
1070 // Flag warp Template
1071 //============================================================
1072 function        script  F_flag_woe_TE   {
1073         .@castle$ = getarg(1);
1074         .@guild_id = getcastledata( .@castle$,1 );
1075         if (.@guild_id == 0) {
1076                 mes "[ Edict of the Divine Rune-Midgarts Kingdom ]";
1077                 mes " ";
1078                 mes "1. Follow the ordinance of The Divine Rune-Midgarts Kingdom, ";
1079                 mes "We declare that";
1080                 mes "there is no formal master of this castle.";
1081                 mes " ";
1082                 mes "2. To the one who can ";
1083                 mes "overcome all trials";
1084                 mes "and destroy the Emperium,";
1085                 mes "the king will endow the one with";
1086                 mes "ownership of this castle.";
1087                 close;
1088         }
1089         if (.@guild_id == getcharid(2) && getarg(0)) {
1090                 mes "[ Echoing Voice ]";
1091                 mes "Brave ones...";
1092                 mes "Do you wish to return to your honorable place?";
1093                 next;
1094                 if (select( "Return to the guild castle.","Quit." ) == 1) {
1095                         if (jobcanentermap(.@castle$) == 0) {
1096                                 mes "Tertiary job class and users with expanded levels are not allowed to participate in Training Siege Battles.";
1097                                 close;
1098                         }
1099                         if (getcastledata( getarg(1),1 ) == getcharid(2))
1100                                 warp getarg(1),getarg(2),getarg(3);
1101                         end;
1102                 }
1103         }
1104         .@guildname$ = getguildname(.@guild_id);
1105         .@guildmaster$ = getguildmaster(.@guild_id);
1106         mes "[ Edict of the Divine Rune-Midgarts Kingdom ]";
1107         mes " ";
1108         mes "1. Follow the ordinance of The Divine Rune-Midgarts Kingdom, ";
1109         mes "we approve that this place is in";
1110         mes "the private prossession of ^ff0000"+.@guildname$+"^000000 Guild.";
1111         mes " ";
1112         mes "2. The guild Master of ^ff0000"+.@guildname$+"^000000 Guild is";
1113         mes "^ff0000"+.@guildmaster$+"^000000";
1114         mes "If there is anyone who objects to this,";
1115         mes "prove your strength and honor with a steel blade in your hand.";
1116         close;
1117 }
1118
1119 -       script  simple_info_TE  -1,{
1120         callfunc( "F_flag_woe_TE",0,strnpcinfo(4) );
1121 OnInit:
1122         if (strnpcinfo(4) != "")
1123                 flagemblem getcastledata( strnpcinfo(4),1 );
1124         end;
1125 }
1126
1127 -       script  flag_te GUILD_FLAG,{
1128         end;
1129 OnInit:
1130         if (strnpcinfo(2) != "")
1131                 flagemblem getcastledata( strnpcinfo(2),1 );
1132         end;
1133 }
1134
1135
1136 // GM NPC
1137 //============================================================
1138 prt_gld,1,4,0   script  #Enterance Button prt   CLEAR_NPC,{
1139         mes "password";
1140         next;
1141         if ( callfunc( "F_GM_NPC", 1854,0, 0,9000 ) < 1 ) {
1142                 mes "That's not right";
1143                 close;
1144         }
1145         mes "What do you want to do with the Gloria-bound warp?";
1146         next;
1147         switch( select( "Open it","Close it","Cancel","Rental item provided" ) ) {
1148         case 1:
1149                 mes "Opening the warp.";
1150                 enablenpc "to_gloria";
1151                 close;
1152         case 2:
1153                 mes "Closing the warp.";
1154                 disablenpc "to_gloria";
1155                 close;
1156         case 3:
1157                 end;
1158         case 4:
1159                 mes "You have 300 seconds.";
1160                 rentitem 13083,300;// TE_Woe_Knife
1161                 close;
1162         }
1163 }
1164
1165 alde_gld,1,4,0  script  #Enterance Button ald   CLEAR_NPC,{
1166         mes "password";
1167         next;
1168         if ( callfunc( "F_GM_NPC", 1854,0, 0,9000 ) < 1 ) {
1169                 mes "That's not right";
1170                 close;
1171         }
1172         mes "What do you want to do with the Kafragarten-bound warp?";
1173         next;
1174         switch( select( "Open it","Close it","Cancel" ) ) {
1175         case 1:
1176                 mes "Opening the warp.";
1177                 enablenpc "to_kafragarten";
1178                 close;
1179         case 2:
1180                 mes "Closing the warp.";
1181                 disablenpc "to_kafragarten";
1182                 close;
1183         case 3:
1184                 end;
1185         }
1186 }
1187
1188 // God Item Hervor & Jormungand
1189 sec_in02,20,20,0        script  Test Guide      CLEAR_NPC,{
1190         mes "Password?";
1191         next;
1192         if (callfunc( "F_GM_NPC", 18543792,0, 0,99999999 ) < 1) {
1193                 mes "Aww...";
1194                 close;
1195         }
1196         mes "We provide material items needed for testing TE.";
1197         next;
1198         switch( select( "Materials for Hervor","Materials for Jormungand" ) ) {
1199         case 1:
1200                 getitem 6595,2;// Hammer_Of_Velund
1201                 getitem 6596,1;// Anvil_Of_Velund
1202                 getitem 6594,4;// Magic_Bronze_Bullion
1203                 getitem 6597,3;// Bracelet_Of_Velund
1204                 getitem 6602,1;// Secret_Of_Rune
1205                 getitem 6605,1;// Muspellium
1206                 getitem 6604,1;// Essence_Of_Rune
1207                 getitem 2115,1;// Valkyrja's_Shield
1208                 end;
1209         case 2:
1210                 getitem 6603,4;// Skin_Of_Hraesvelg
1211                 getitem 6599,1;// Spirit_Of_Hugin
1212                 getitem 6598,1;// Rib_Of_Jormungand
1213                 getitem 6601,4;// Chisel_Of_Giant
1214                 getitem 6600,1;// Spirit_Of_Munin
1215                 getitem 6605,1;// Muspellium
1216                 getitem 6604,1;// Essence_Of_Rune
1217                 getitem 1473,1;// Wizardy_Staff
1218                 end;
1219         }
1220 }