Added constants for Castle Data manipulation (#3531)

* Fixes #3530.
* Added constants for script commands getcastledata and setcastledata.
* Adjusted the guardian constants to adjust based on MAX_GUARDIANS define value.
* Updated scripts to reflect changes.
Thanks to @keitenai, @Atemo, and @Lemongrass3110!
This commit is contained in:
Aleos
2018-11-08 16:27:03 -05:00
committed by GitHub
parent 75d24ad1ad
commit 7045d585e4
13 changed files with 263 additions and 226 deletions

View File

@@ -63,7 +63,7 @@
// War of Emperium has started.
OnAgitStart:
if (strnpcinfo(0) == "Gld_Agit_Manager") end;
MapRespawnGuildID strnpcinfo(2),GetCastleData(strnpcinfo(2),1),6;
MapRespawnGuildID strnpcinfo(2),GetCastleData(strnpcinfo(2),CD_GUILD_ID),6;
GvgOn strnpcinfo(2);
// Spawn (fall through), or respawn the Emperium once it has been broken.
@@ -109,16 +109,16 @@ OnAgitBreak:
end;
}
// Adjust Economy Invest Level for Castle
set .@Economy,GetCastleData(strnpcinfo(2),2) - 5;
set .@Economy,GetCastleData(strnpcinfo(2),CD_CURRENT_ECONOMY) - 5;
if (.@Economy < 0) set .@Economy, 0;
SetCastleData strnpcinfo(2), 2, .@Economy;
SetCastleData strnpcinfo(2), CD_CURRENT_ECONOMY, .@Economy;
// Adjust Defense Invest Level for Castle
set .@Defence,GetCastleData(strnpcinfo(2),3) - 5;
set .@Defence,GetCastleData(strnpcinfo(2),CD_CURRENT_DEFENSE) - 5;
if (.@Defence < 0) set .@Defence, 0;
SetCastleData strnpcinfo(2), 3, .@Defence;
SetCastleData strnpcinfo(2), CD_CURRENT_DEFENSE, .@Defence;
// Set new Castle Occupant
SetCastleData strnpcinfo(2),1, .@GID;
SetCastleData strnpcinfo(2),CD_GUILD_ID, .@GID;
// Announce that the Emperium is destroyed, and respawn all but new castle-occupants.
mapannounce strnpcinfo(2),"The emperium has been destroyed.",bc_map|bc_woe,"0x00CCFF",FW_NORMAL,12;
@@ -127,12 +127,12 @@ OnAgitBreak:
// Refresh castle data, disable Kafra and reset Invest information.
donpcevent strnpcinfo(0)+"::OnRecvCastle";
disablenpc "Kafra Staff#"+strnpcinfo(2);
for( set .@i, 4; .@i <= 9; set .@i, .@i+1 ) {
for( set .@i, CD_INVESTED_ECONOMY; .@i <= CD_ENABLED_KAFRA; set .@i, .@i+1 ) {
SetCastleData strnpcinfo(2), .@i, 0;
}
// Erase Guardian Database information if the new owners do not have Guardian Research.
if( getgdskilllv(.@GID,10002) == 0 ) {
for( set .@i, 10; .@i <= 17; set .@i, .@i+1 ) {
for( set .@i, CD_ENABLED_GUARDIAN00; .@i < CD_MAX; set .@i, .@i+1 ) {
SetCastleData strnpcinfo(2), .@i, 0;
}
}
@@ -149,7 +149,7 @@ OnAgitEnd:
if (strnpcinfo(0) == "Gld_Agit_Manager") end;
GvgOff strnpcinfo(2);
// If the castle has no owner at the end of WoE, do not kill Emperium.
if (GetCastleData(strnpcinfo(2),1)) {
if (GetCastleData(strnpcinfo(2),CD_GUILD_ID)) {
KillMonster strnpcinfo(2),"Agit#"+strnpcinfo(2)+"::OnAgitBreak";
}
end;
@@ -160,7 +160,7 @@ OnGuildBreak:
// Kill guardians, disable the Kafra, and set owner to 0.
killmonster strnpcinfo(2),"Guardian#"+strnpcinfo(2)+"::OnGuardianDied";
disablenpc "Kafra Staff#"+strnpcinfo(2);
SetCastleData strnpcinfo(2),1,0;
SetCastleData strnpcinfo(2),CD_GUILD_ID,0;
// Wait before refreshing guild information.
sleep 7000;
Announce "Guild Base [" + GetCastleName(strnpcinfo(2)) + "] has been abandoned.",0;
@@ -171,7 +171,7 @@ OnAgitInit:
OnRecvCastle:
if (strnpcinfo(0) == "Gld_Agit_Manager") end;
// Spawn Monsters if the castle is empty.
set .@GID, GetCastleData(strnpcinfo(2),1);
set .@GID, GetCastleData(strnpcinfo(2),CD_GUILD_ID);
if (.@GID == 0) {
killmonsterall strnpcinfo(2);
if (compare(strnpcinfo(2),"aldeg")) {
@@ -309,7 +309,7 @@ OnRecvCastle:
// And load purchased Guardian in castles.
donpcevent "Guardian#"+strnpcinfo(2)+"::OnSpawnGuardians";
// And display Kafra if purchased.
if (GetCastleData(strnpcinfo(2),9) < 1) disablenpc "Kafra Staff#"+strnpcinfo(2);
if (GetCastleData(strnpcinfo(2),CD_ENABLED_KAFRA) < 1) disablenpc "Kafra Staff#"+strnpcinfo(2);
}
end;
}
@@ -318,7 +318,7 @@ OnRecvCastle:
//============================================================
- script Kafra Staff#woe::guildkafra -1,{
set .@GID,GetCastleData(strnpcinfo(2),1);
set .@GID,GetCastleData(strnpcinfo(2),CD_GUILD_ID);
if (compare(strnpcinfo(2),"aldeg")) {
setarray .@destination$[0],"Al De Baran","aldebaran";
@@ -467,7 +467,7 @@ OnRecvCastle:
//============================================================
- script Castle Manager#cm::cm -1,{
set .@GID,GetCastleData(strnpcinfo(2),1);
set .@GID,GetCastleData(strnpcinfo(2),CD_GUILD_ID);
// .@guardiantype = Defines the types of guardians per castle basis.
// 1 - Soldier Guardian, 2 - Archer Guardian, 3 - Knight Guardian
@@ -624,19 +624,19 @@ OnRecvCastle:
mes "["+strnpcinfo(1)+"]";
mes "I will report the Castle briefing, Master.";
mes " ";
mes "^0000ffNow, the commercial growth level is "+GetCastleData(strnpcinfo(2),2)+".";
if (GetCastleData(strnpcinfo(2),4)) {
mes " You invested "+GetCastleData(strnpcinfo(2),4)+" times in past 1 day.";
mes "^0000ffNow, the commercial growth level is "+GetCastleData(strnpcinfo(2),CD_CURRENT_ECONOMY)+".";
if (GetCastleData(strnpcinfo(2),CD_INVESTED_ECONOMY)) {
mes " You invested "+GetCastleData(strnpcinfo(2),CD_INVESTED_ECONOMY)+" times in past 1 day.";
}
mes " Now, the Castle Defense level is "+GetCastleData(strnpcinfo(2),3)+".^000000";
if (GetCastleData(strnpcinfo(2),5)) {
mes " ^0000ff- You invested "+GetCastleData(strnpcinfo(2),5)+" times in past 1 day.^000000";
mes " Now, the Castle Defense level is "+GetCastleData(strnpcinfo(2),CD_CURRENT_DEFENSE)+".^000000";
if (GetCastleData(strnpcinfo(2),CD_INVESTED_DEFENSE)) {
mes " ^0000ff- You invested "+GetCastleData(strnpcinfo(2),CD_INVESTED_DEFENSE)+" times in past 1 day.^000000";
}
mes " ";
mes "That's all I have to report, Master.";
close;
case 2:
set .@Economy,GetCastleData(strnpcinfo(2),2);
set .@Economy,GetCastleData(strnpcinfo(2),CD_CURRENT_ECONOMY);
if (.@Economy < 6) { set .@eco_invest,5000; }
else if ((.@Economy >= 6) && (.@Economy <= 10)) { set .@eco_invest,10000; }
else if ((.@Economy >= 11) && (.@Economy <= 15)) { set .@eco_invest,20000; }
@@ -658,7 +658,7 @@ OnRecvCastle:
else if ((.@Economy >= 91) && (.@Economy <= 95)) { set .@eco_invest,860000; }
else if ((.@Economy >= 96) && (.@Economy <= 100)) { set .@eco_invest,955000; }
//Quadruple the cost of investing if you've already invested once.
if (GetCastleData(strnpcinfo(2),4)) {
if (GetCastleData(strnpcinfo(2),CD_INVESTED_ECONOMY)) {
set .@eco_invest,.@eco_invest*4;
}
mes "["+strnpcinfo(1)+"]";
@@ -670,12 +670,12 @@ OnRecvCastle:
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";
close;
}
if (GetCastleData(strnpcinfo(2),4) >= 2) {
if (GetCastleData(strnpcinfo(2),CD_INVESTED_ECONOMY) >= 2) {
mes " ";
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.";
close;
}
if (GetCastleData(strnpcinfo(2),4) == 0) {
if (GetCastleData(strnpcinfo(2),CD_INVESTED_ECONOMY) == 0) {
mes " ";
mes "The current investment amount required is ^ff0000"+.@eco_invest+"^000000 zeny. Will you invest?";
}
@@ -692,7 +692,7 @@ OnRecvCastle:
close;
}
set Zeny, Zeny - .@eco_invest;
SetCastleData strnpcinfo(2),4,GetCastleData(strnpcinfo(2),4)+1;
SetCastleData strnpcinfo(2),CD_INVESTED_ECONOMY,GetCastleData(strnpcinfo(2),CD_INVESTED_ECONOMY)+1;
mes "[ "+strnpcinfo(1)+"]";
mes "We finished the investment safely. I expect that our growth level will be increased by tomorrow.";
close;
@@ -702,7 +702,7 @@ OnRecvCastle:
close;
}
case 3:
set .@Defence,GetCastleData(strnpcinfo(2),3);
set .@Defence,GetCastleData(strnpcinfo(2),CD_CURRENT_DEFENSE);
if (.@Defence < 6) { set .@def_invest,10000; }
else if ((.@Defence >= 6) && (.@Defence <= 10)) { set .@def_invest,20000; }
else if ((.@Defence >= 11) && (.@Defence <= 15)) { set .@def_invest,40000; }
@@ -724,7 +724,7 @@ OnRecvCastle:
else if ((.@Defence >= 91) && (.@Defence <= 95)) { set .@def_invest,1720000; }
else if ((.@Defence >= 96) && (.@Defence <= 100)) { set .@def_invest,1910000; }
//Quadruple the cost of investing if you've already invested once.
if (GetCastleData(strnpcinfo(2),5)) {
if (GetCastleData(strnpcinfo(2),CD_INVESTED_DEFENSE)) {
set .@def_invest,.@def_invest*4;
}
mes "["+strnpcinfo(1)+"]";
@@ -736,12 +736,12 @@ OnRecvCastle:
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";
close;
}
if (GetCastleData(strnpcinfo(2),5) >= 2) {
if (GetCastleData(strnpcinfo(2),CD_INVESTED_DEFENSE) >= 2) {
mes " ";
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.";
close;
}
if (GetCastleData(strnpcinfo(2),5) == 0) {
if (GetCastleData(strnpcinfo(2),CD_INVESTED_DEFENSE) == 0) {
mes " ";
mes "The current investment amount required is ^ff0000"+.@def_invest+"^000000 zeny. Will you invest?";
}
@@ -758,7 +758,7 @@ OnRecvCastle:
close;
}
set Zeny, Zeny - .@def_invest;
SetCastleData strnpcinfo(2),5,GetCastleData(strnpcinfo(2),5)+1;
SetCastleData strnpcinfo(2),CD_INVESTED_DEFENSE,GetCastleData(strnpcinfo(2),CD_INVESTED_DEFENSE)+1;
mes "[ "+strnpcinfo(1)+"]";
mes "We finished the investment safely. I expect that our Castle Defense level will be increased by tomorrow.";
close;
@@ -821,7 +821,7 @@ OnRecvCastle:
close;
}
case 5:
if (GetCastleData(strnpcinfo(2),9) == 1) {
if (GetCastleData(strnpcinfo(2),CD_ENABLED_KAFRA) == 1) {
mes "["+strnpcinfo(1)+"]";
mes "We are currently hiring a Kafra Employee... Do you want to fire the Kafra Employee?";
next;
@@ -850,7 +850,7 @@ OnRecvCastle:
close;
}
disablenpc "Kafra Staff#"+strnpcinfo(2);
SetCastleData strnpcinfo(2),9,0;
SetCastleData strnpcinfo(2),CD_ENABLED_KAFRA,0;
mes "["+strnpcinfo(1)+"]";
mes "....";
mes "I have discharged the Kafra Employee... But... are you unsatisfied with something?";
@@ -874,7 +874,7 @@ OnRecvCastle:
}
set Zeny, Zeny - 10000;
enablenpc "Kafra Staff#"+strnpcinfo(2);
SetCastleData strnpcinfo(2),9,1;
SetCastleData strnpcinfo(2),CD_ENABLED_KAFRA,1;
mes "["+strnpcinfo(1)+"]";
mes "We obtained a contract with the kafra Main Office, and hired a Kafra Employee.";
next;
@@ -919,7 +919,7 @@ OnRecvCastle:
//============================================================
- script Lever#gd::gdlever -1,{
set .@GID,GetCastleData(strnpcinfo(2),1);
set .@GID,GetCastleData(strnpcinfo(2),CD_GUILD_ID);
if (.@GID == 0) {
mes "[Ringing Voice]";
@@ -1133,13 +1133,13 @@ OnClock0001:
// Do nothing if this script is the template.
if (strnpcinfo(1) == "Gld_Trea_Spawn") end;
set .@GID, GetCastleData(strnpcinfo(2),1);
set .@GID, GetCastleData(strnpcinfo(2),CD_GUILD_ID);
// If there is no owner, do nothing.
if (!.@GID) end;
// Is there Economy in this castle?
set .@Treasure,GetCastleData(strnpcinfo(2),2)/5+4;
set .@Treasure,GetCastleData(strnpcinfo(2),CD_CURRENT_ECONOMY)/5+4;
// Set information
if (strnpcinfo(2) == "aldeg_cas01") {
@@ -1249,19 +1249,19 @@ OnClock0001:
// Apply investment to Eco. and Def. Only happens if there were investments made.
// Permanent Development can only happen once per day.
if (GetCastleData(strnpcinfo(2),4)) {
set .@Economy,GetCastleData(strnpcinfo(2),2);
SetCastleData strnpcinfo(2),2,.@Economy + GetCastleData(strnpcinfo(2),4) + (rand(2) && getgdskilllv(.@GID,10014));
if (GetCastleData(strnpcinfo(2),2) > 100) SetCastleData strnpcinfo(2),2,100;
if (GetCastleData(strnpcinfo(2),CD_INVESTED_ECONOMY)) {
set .@Economy,GetCastleData(strnpcinfo(2),CD_INVESTED_ECONOMY);
SetCastleData strnpcinfo(2),CD_INVESTED_ECONOMY,.@Economy + GetCastleData(strnpcinfo(2),CD_INVESTED_ECONOMY) + (rand(2) && getgdskilllv(.@GID,10014));
if (GetCastleData(strnpcinfo(2),CD_CURRENT_ECONOMY) > 100) SetCastleData strnpcinfo(2),CD_CURRENT_ECONOMY,100;
}
if (GetCastleData(strnpcinfo(2),5)) {
set .@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;
if (GetCastleData(strnpcinfo(2),CD_INVESTED_DEFENSE)) {
set .@Defence,GetCastleData(strnpcinfo(2),CD_CURRENT_DEFENSE);
SetCastleData strnpcinfo(2),CD_CURRENT_DEFENSE,.@Defence + GetCastleData(strnpcinfo(2),CD_INVESTED_DEFENSE);
if (GetCastleData(strnpcinfo(2),CD_CURRENT_DEFENSE) > 100) SetCastleData strnpcinfo(2),CD_CURRENT_DEFENSE,100;
}
// Reset daily investment limits.
setcastledata strnpcinfo(2),4,0;
setcastledata strnpcinfo(2),5,0;
setcastledata strnpcinfo(2),CD_INVESTED_ECONOMY,0;
setcastledata strnpcinfo(2),CD_INVESTED_DEFENSE,0;
// Spawn boxes in proper order.
for (set .@i,0; .@i < .@Treasure ; set .@i,.@i+1) {