- 0
	
		 Sign in to follow this  
	
	
	
		
		
			Followers
			0
		
	
Treasure chest randomization for SE castles
				
				
					Asked by 
Anisotropic Defixation
				
				
				
			
- 
Recently Browsing 0 membersNo registered users viewing this page. 
 

While this was very simple for FE script, I'm scratching my head with this.
What I want is to basically make it always spawn the default chest (1324) plus a random one from the array, still based on investment.
Here's the default portion of the script (agit_main_se):
OnClock0001: // Spawn Treasure Chests based on castle economy. if (strnpcinfo(2) == "template") end; if (!getcastledata(strnpcinfo(2),1)) end; killmonster strnpcinfo(2),strnpcinfo(0)+"::OnTreasureDied"; if (getcastledata(strnpcinfo(2),4)) { .@Economy = getcastledata(strnpcinfo(2),2); setcastledata strnpcinfo(2),2,.@Economy+getcastledata(strnpcinfo(2),4)+(rand(2) && getgdskilllv(getcastledata(strnpcinfo(2),1),10014)); if (getcastledata(strnpcinfo(2),2) > 100) setcastledata strnpcinfo(2),2,100; setcastledata strnpcinfo(2),4,0; } if (getcastledata(strnpcinfo(2),5)) { .@defence = getcastledata(strnpcinfo(2),3); setcastledata strnpcinfo(2),3,.@defence+getcastledata(strnpcinfo(2),5); if (getcastledata(strnpcinfo(2),3) > 100) setcastledata strnpcinfo(2),3,100; setcastledata strnpcinfo(2),5,0; } .@Treasure = getcastledata(strnpcinfo(2),2)/5+4; if (!.@Treasure) end; freeloop(1); if (compare(strnpcinfo(2),"arug")) { if (strnpcinfo(2) == "arug_cas01") { .@treasurebox = 1943; setarray .@treasurex[0],251,252,253,254,255,256,257,258,251,252,253,254,255,256,257,258,251,252,253,254,255,256,257,258; setarray .@treasurey[0],369,369,369,369,368,368,368,368,367,367,367,367,366,366,366,366,365,365,365,365,364,364,364,364; } else if (strnpcinfo(2) == "arug_cas02") { .@treasurebox = 1944; setarray .@treasurex[0],382,383,384,385,386,387,384,385,386,387,388,389,382,383,384,385,386,387,384,385,386,387,388,389; setarray .@treasurey[0],231,231,231,231,231,231,230,230,230,230,230,230,225,225,225,225,225,225,224,224,224,224,224,224; } else { // Castles 3,4,5 are identical, except 4's treasure. .@treasurebox = (strnpcinfo(2) == "arug_cas04")?1946:1945; setarray .@treasurex[0],291,292,293,294,295,296,293,294,295,296,297,298,291,292,293,294,295,296,293,294,295,296,297,298; setarray .@treasurey[0],276,276,276,276,276,276,274,274,274,274,274,274,272,272,272,272,272,272,269,269,269,269,269,269; } } else { if (strnpcinfo(2) == "schg_cas02") { .@treasurebox = 1939; setarray .@treasurex[0],249,250,251,252,253,246,247,248,249,250,250,251,252,253,246,247,248,249,250,249,250,251,252,253; setarray .@treasurey[0],378,378,378,378,378,376,376,376,376,376,374,374,374,374,372,372,372,372,372,370,370,370,370,370; } else if (strnpcinfo(2) == "schg_cas03") { .@treasurebox = 1940; setarray .@treasurex[0],189,190,191,192,193,194,189,190,191,192,193,194,189,190,191,192,193,194,189,190,191,192,193,194; setarray .@treasurey[0], 21, 21, 21, 21, 21, 21, 19, 19, 19, 19, 19, 19, 17, 17, 17, 17, 17, 17, 15, 15, 15, 15, 15, 15; } else { // Castles 1,4,5 are identical, except treasures. if (strnpcinfo(2) == "schg_cas01") .@treasurebox = 1938; else if (strnpcinfo(2) == "schg_cas04") .@treasurebox = 1941; else .@treasurebox = 1942; setarray .@treasurex[0],388,388,388,387,386,385,384,384,384,384,384,384,385,386,387,388,389,390,390,390,389,388,387,386; setarray .@treasurey[0],388,389,390,390,390,390,389,388,387,386,385,384,384,384,384,384,384,384,385,386,386,386,386,386; } } for(.@i = 0; .@i<4; ++.@i) monster strnpcinfo(2),.@treasurex[.@i],.@treasurey[.@i],"Treasure Chest",(.@i%2)?.@treasurebox:1324,1,strnpcinfo(0)+"::OnTreasureDied"; for(.@i = 4; .@i<24; ++.@i) { if (.@Treasure < .@i+1) break; monster strnpcinfo(2),.@treasurex[.@i],.@treasurey[.@i],"Treasure Chest",(.@i%2)?.@treasurebox:1324,1,strnpcinfo(0)+"::OnTreasureDied"; } freeloop(0); end;OnTreasureDied: end;}Here's mine (differences are bold):
OnClock0001:
// Spawn Treasure Chests based on castle economy.
if (strnpcinfo(2) == "template") end;
if (!getcastledata(strnpcinfo(2),1)) end;
killmonster strnpcinfo(2),strnpcinfo(0)+"::OnTreasureDied";
if (getcastledata(strnpcinfo(2),4)) {
.@Economy = getcastledata(strnpcinfo(2),2);
setcastledata strnpcinfo(2),2,.@Economy+getcastledata(strnpcinfo(2),4)+(rand(2) && getgdskilllv(getcastledata(strnpcinfo(2),1),10014));
if (getcastledata(strnpcinfo(2),2) > 100) setcastledata strnpcinfo(2),2,100;
setcastledata strnpcinfo(2),4,0;
}
if (getcastledata(strnpcinfo(2),5)) {
.@defence = getcastledata(strnpcinfo(2),3);
setcastledata strnpcinfo(2),3,.@defence+getcastledata(strnpcinfo(2),5);
if (getcastledata(strnpcinfo(2),3) > 100) setcastledata strnpcinfo(2),3,100;
setcastledata strnpcinfo(2),5,0;
}
.@Treasure = getcastledata(strnpcinfo(2),2)/5+4;
if (!.@Treasure) end;
freeloop(1);
if (compare(strnpcinfo(2),"arug")) {
if (strnpcinfo(2) == "arug_cas01") {
setarray .@rand[0],1938,1939,1940;
set .@treasurebox,.@rand[getarraysize(.@rand)];
setarray .@treasurex[0],251,252,253,254,255,256,257,258,251,252,253,254,255,256,257,258,251,252,253,254,255,256,257,258;
setarray .@treasurey[0],369,369,369,369,368,368,368,368,367,367,367,367,366,366,366,366,365,365,365,365,364,364,364,364;
}
else if (strnpcinfo(2) == "arug_cas02") {
setarray .@rand[0],1938,1939,1940;
set .@treasurebox,.@rand[getarraysize(.@rand)];
setarray .@treasurex[0],382,383,384,385,386,387,384,385,386,387,388,389,382,383,384,385,386,387,384,385,386,387,388,389;
setarray .@treasurey[0],231,231,231,231,231,231,230,230,230,230,230,230,225,225,225,225,225,225,224,224,224,224,224,224;
}
else {
setarray .@rand[0],1938,1939,1940;
set .@treasurebox,.@rand[getarraysize(.@rand)];
setarray .@treasurex[0],291,292,293,294,295,296,293,294,295,296,297,298,291,292,293,294,295,296,293,294,295,296,297,298;
setarray .@treasurey[0],276,276,276,276,276,276,274,274,274,274,274,274,272,272,272,272,272,272,269,269,269,269,269,269;
}
}
else {
if (strnpcinfo(2) == "schg_cas02") {
setarray .@rand[0],1938,1939,1940;
set .@treasurebox,.@rand[getarraysize(.@rand)];
setarray .@treasurex[0],249,250,251,252,253,246,247,248,249,250,250,251,252,253,246,247,248,249,250,249,250,251,252,253;
setarray .@treasurey[0],378,378,378,378,378,376,376,376,376,376,374,374,374,374,372,372,372,372,372,370,370,370,370,370;
}
else if (strnpcinfo(2) == "schg_cas03") {
setarray .@rand[0],1938,1939,1940;
set .@treasurebox,.@rand[getarraysize(.@rand)];
setarray .@treasurex[0],189,190,191,192,193,194,189,190,191,192,193,194,189,190,191,192,193,194,189,190,191,192,193,194;
setarray .@treasurey[0], 21, 21, 21, 21, 21, 21, 19, 19, 19, 19, 19, 19, 17, 17, 17, 17, 17, 17, 15, 15, 15, 15, 15, 15;
}
else {
setarray .@rand[0],1938,1939,1940;
set .@treasurebox,.@rand[getarraysize(.@rand)];
setarray .@treasurex[0],388,388,388,387,386,385,384,384,384,384,384,384,385,386,387,388,389,390,390,390,389,388,387,386;
setarray .@treasurey[0],388,389,390,390,390,390,389,388,387,386,385,384,384,384,384,384,384,384,385,386,386,386,386,386;
}
}
for(.@i = 0; .@i<4; ++.@i) {
monster strnpcinfo(2),.@treasurex[.@i],.@treasurey[.@i],"Treasure Chest",(.@i%2)?.@treasurebox:1324,1,strnpcinfo(0)+"::OnTreasureDied";
monster strnpcinfo(2),.@treasurex[.@i],.@treasurey[.@i],"Treasure Chest",.@treasurebox,1,strnpcinfo(0)+"::OnTreasureDied";
}
for(.@i = 4; .@i<24; ++.@i) {
if (.@Treasure < .@i+1) break;
monster strnpcinfo(2),.@treasurex[.@i],.@treasurey[.@i],"Treasure Chest",(.@i%2)?.@treasurebox:1324,1,strnpcinfo(0)+"::OnTreasureDied";
monster strnpcinfo(2),.@treasurex[.@i],.@treasurey[.@i],"Treasure Chest",.@treasurebox,1,strnpcinfo(0)+"::OnTreasureDied";
}
freeloop(0);
end;
OnTreasureDied:
end;
}
All this does is only spawn the default chest (1324) and nothing else, stuff from the array isn't pulled in.
Any help is appreciated!
Edited by Anisotropic DefixationShare this post
Link to post
Share on other sites