//===== eAthena Script =======================================
//= War of Emperium - prtg_cas02 Treasure Room Script
//===== By: ==================================================
//= holyAngelX (1.0)
//===== Current Version: =====================================
//= 1.1
//===== Compatible With: =====================================
//= eAthena 0.1+; RO Episode 4+
//===== Description: =========================================
//= Treasure Room Script in prtg_cas02
//===== Additional Comments: =================================
//= 1.1 by Akaru and ho|yAnge|X
//============================================================

//================================================
// Exit Treasure Room Switch
//================================================
prtg_cas02.gat,207,228,0	script	Switch	111,{
	mes " ";
	mes "There is little switch over here";
	mes "Would you like to pull the switch down?";
	next;
	menu "Yes",L1,"No",L2;
	
L1:
	warp "prtg_cas02.gat",94,62;
	
L2:
	close;
}

//================================================
// Treasure Spawning Script
//================================================
prtg_cas02.gat,202,228,0	script	Treasure_D02	-1,{
OnClock1200:
	SetCastleData "prtg_cas02.gat",4,0;
	SetCastleData "prtg_cas02.gat",5,0;
	KillMonster "prtg_cas02.gat","Treasure_D02::TreasureDied";
	set $Economy16,GetCastleData("prtg_cas02.gat",2);
	if ($Economy16 > 100) break;
	if (GetCastleData("prtg_cas02.gat",1) == 0) break;
	set $boxnum16,GetCastleData("prtg_cas02.gat",2)/5+4;
	goto TreasureCheck;

TreasureCheck:
	if ($boxnum16 <= 0) break;
	set $boxid16,rand(4);
	goto TreasureSpawn;

TreasureSpawn:
	if ($boxid16 > 2) goto TreasureSpawn2;
	areamonster "prtg_cas02.gat",198,224,207,233,"Treasure Chest",1356,1,"Treasure_D02::TreasureDied";
	set $boxnum16,$boxnum16-1;
	if ($boxnum16 <= 0) break;
	goto TreasureCheck;

TreasureSpawn2:
	areamonster "prtg_cas02.gat",198,224,207,233,"Treasure Chest",1357,1,"Treasure_D02::TreasureDied";
	set $boxnum16,$boxnum16-1;
	if ($boxnum16 <= 0) break;
	goto TreasureCheck;

TreasureDied:
	MapAnnounce "prtg_cas02.gat","Treasure Chest Broken Open",17;
	break;	
}
