//===== eAthena Script =======================================
//= War of Emperium Guild Manager Function
//===== By: ==================================================
//= jAthena - kalen (1.0) & eAthena Team
//===== Current Version: =====================================
//= 1.7
//===== Compatible With: =====================================
//= eAthena 0.1+; RO Episode 4+
//===== Description: =========================================
//= The Guild Manager allows the Guildmaster to invest in comerce
//= and defense, hire guardians and kafras, go to the treasure room,
//= and surrender the guild castle.
//==============================================
//= Break down of arguments used in the function:
//= arg(0): name of Castle Manager
//= arg(1): name of guild castle.
//= arg(2): x1 coordinate for warp to treasure room
//= arg(3): y1 coordinate for warp to treasure room
//= arg(4): guild script suffix for kafra, Guardian scripts etc.
//===== Additional Comments: =================================
//= 1.31: Added support for Emsolute Develop [celest]
//= 1.2: All Guild manager scripts use this function. Optimized Comerce and Defense investment. [kobra_k88]
//= 1.2a Function now returns to script that called it. Added disablenpc line to surrender castle option to remove kafra upon surrender.[kobra_k88]
//= 1.2b U can't surrender the base during WOE [Lupus]
//= 1.2c Fixed issue of guardians hp not increasing upon defense investment.[kobra_k88]
//= 1.3 Now you can't install Guardians during WOE [Lupus]
//= 1.4 Remove surrender abbility (Was 100% custom as far as I can tell) [Kayla]
//= 1.41 Fixed possible Economy investment overflow with Emsolute Develop learnt [Lupus]
//= 1.5 Official Novice Castles Menu (u can't invest / hire guardians) [Lupus]
//= 1.6 According to recent info u can re-install Guardians during WoE [Lupus]
//= 1.6a Fix for guild manager recognizing [KarLaeda]
//= 1.6b Fixed the chance for double invest, now 50% instead of 49% [Lupus]
//= 1.7 Changed hte names of the Kafra from "Service" to "Staff" [L0ne_W0lf]
//============================================================
//==============================================
function script F_GldManager {
set @GID, GetCastleData(getarg(1),1);
mes "[ "+getarg(0)+" ]";
if (@GID == 0){
mes "I am waiting for my master. Brave adventurer, follow your destiny!";
return 0;
}
if (getcharid(2) != @GID){
mes "I am here to follow ^5533FF" + getguildmaster(@GID) + "^000000's command! Hey! Your not even a part of the guild!!";
mes "Where are the guardians? Destroy these intruders!";
return 0;
}
if (strcharinfo(0) != getguildmaster(@GID)){
mes "You're not ^5533FF" + getguildmaster(@GID) + "^000000! I am here to follow ^5533FF" + getguildmaster(@GID) + "^000000's command only";
return 0;
}
mes "Welcome Master ^5533FF" + getguildmaster(@GID) + "^000000 ! I will assist you in any way I can!";
next;
//Novice Castles. (we don't need ELSE here. Menu has direct labels)
if(getarg(1) == "nguild_prt" || getarg(1) == "nguild_alde" || getarg(1) == "nguild_gef" || getarg(1) == "nguild_pay" )
menu "Kafra Staff Employment / Dismissal",M_Kaf, "Enter Treasure Room",M_Treas, "Cancel",M_End;
//Common WoE Castles
menu "Guild Base Briefing",M_Base, "Commerce Investment",M_Comrc, "Defence Investment",M_Def, "Guardian Installation",M_Guard,
"Kafra Staff Employment / Dismissal",M_Kaf, "Enter Treasure Room",M_Treas, "Cancel",M_End;
//========================
M_Base:
//=========
mes "[ "+getarg(0)+" ]";
mes "Guild Base Investment Information.";
mes " ";
mes "Current Commerce Investment is : ^FF3322" + GetCastleData(getarg(1),2) + "^000000 points.";
mes "^0000ff - You have invested " + GetCastleData(getarg(1),4) + " times today.^000000";
next;
mes "[ "+getarg(0)+" ]";
mes "Current Defence Investment is : ^FF3322" + GetCastleData(getarg(1),3) + "^000000 points.";
mes "^0000ff- You have invested " + GetCastleData(getarg(1),5) + " times today.^000000";
mes " ";
mes "That is about it.";
return 0;
//========================
M_Comrc:
//=========
set @TriggerE,GetCastleData(getarg(1),4);
set @Economy,GetCastleData(getarg(1),2);
if(@Economy < 8) set @eco_invest,10000;
if(@Economy >= 8) set @eco_invest,20000;
if(@Economy >= 16) set @eco_invest,40000;
if(@Economy >= 25) set @eco_invest,80000;
if(@Economy >= 34) set @eco_invest,160000;
if(@Economy >= 44) set @eco_invest,320000;
if(@Economy >= 54) set @eco_invest,640000;
if(@Economy >= 65) set @eco_invest,1280000;
if(@Economy >= 76) set @eco_invest,2560000;
if(@Economy >= 88) set @eco_invest,5120000;
mes "[ "+getarg(0)+" ]";
if(@TriggerE == 2){
mes "^ff0000You have already invested twice today, and that's the limit.^000000 I'm expecting to see our riches grow at a high level.";
return 0;
}
if(@Economy >= 100){
mes "^ff0000This Castle's commerce investment is already maxed at 100 points. You don't have to invest any further.^000000";
return 0;
}
mes "If you improve your Commerce Investment, the guild's productive power increases to produce more goods.";
mes "So an investment will be required if you're considering future growth.";
next;
mes "[ "+getarg(0)+" ]";
if(@TriggerE == 0) {
mes "You can invest up to two times a day, but the second time costs more";
mes "The needed investment amount is ^5533FF" + @eco_invest + "^000000 zeny.";
} else {
set @eco_invest,@eco_invest*4;
mes "You've already invested once today, but you can invest again at ^5533FF" + @eco_invest + "^000000 Zeny.";
}
next;
mes "[ "+getarg(0)+" ]";
mes "Would you like to invest?";
next;
menu "Invest Commerce.",-,"Cancel.",M_End;
mes "[ "+getarg(0)+" ]";
if(Zeny < @eco_invest){
mes "Master, you do not have enough money to invest. Investment has been cancelled.";
return 0;
}
set Zeny,Zeny-@eco_invest;
SetCastleData getarg(1),4,@TriggerE+1;
// if we learnt Emsolute Develop there's 50% chance to get +1 investment again
SetCastleData getarg(1),2,@Economy + 1 + (@Economy<99 && rand(2) && getgdskilllv(@GID,10014));
mes "You have invested successfully.";
return 0;
//=========================
M_Def:
//========
set @TriggerD,GetCastleData(getarg(1),5);
set @Defence,GetCastleData(getarg(1),3);
if(@Defence < 8) set @def_invest,20000;
if(@Defence >= 8) set @def_invest,40000;
if(@Defence >= 16) set @def_invest,80000;
if(@Defence >= 25) set @def_invest,160000;
if(@Defence >= 34) set @def_invest,320000;
if(@Defence >= 44) set @def_invest,640000;
if(@Defence >= 54) set @def_invest,1280000;
if(@Defence >= 65) set @def_invest,2560000;
if(@Defence >= 76) set @def_invest,5120000;
if(@Defence >= 88) set @def_invest,10240000;
mes "[ "+getarg(0)+" ]";
if(@TriggerD == 2){
mes "^ff0000You have already invested twice today, and that's the limit.^000000 I'm expecting to see our riches grow at a high level.";
return 0;
}
if(@Defence >= 100){
mes "^ff0000This Castle's Defence Investment is already maxed at 100 points. You don't have to invest any further.^000000";
return 0;
}
mes "If you improve investment of defence, the durability of our Guardians and the Emperium will increase.";
mes "So if you consider our future battles, an investment will be required.";
next;
mes "[ "+getarg(0)+" ]";
if(@TriggerD == 0) {
mes "You can invest up to two times a day, but the second time costs more";
mes "The needed investment amount is ^5533FF" + @def_invest + "^000000 zeny.";
} else {
set @def_invest,@def_invest*4;
mes "You've already invested once today, but you can invest again at ^5533FF" + @def_invest + "^000000 Zeny.";
}
next;
mes "[ "+getarg(0)+" ]";
mes "Would you like to invest?";
next;
menu "Invest Defence.",-, "Cancel",M_End;
mes "[ "+getarg(0)+" ]";
if(Zeny < @def_invest){
mes "Master, you do not have enough money to invest in Defence. Defence investment has been cancelled.";
return 0;
}
set Zeny,Zeny-@def_invest;
SetCastleData getarg(1),5,@TriggerD+1;
SetCastleData getarg(1),3,@Defence+1;
// set new hp values for guardians
set @Defence, @Defence + 1;
set @AGuardian, 28634 + (@Defence*2000);
set @KGuardian, 30214 + (@Defence*2000);
set @SGuardian, 15670 + (@Defence*2000);
//set @AGuardian,strmobinfo(4,1285) + (@Defence*2000);
//set @KGuardian,strmobinfo(4,1286) + (@Defence*2000);
//set @SGuardian,strmobinfo(4,1287) + (@Defence*2000);
if (GetCastleData(getarg(1),10) == 1) SetCastleData getarg(1),18,@SGuardian;
if (GetCastleData(getarg(1),11) == 1) SetCastleData getarg(1),19,@SGuardian;
if (GetCastleData(getarg(1),12) == 1) SetCastleData getarg(1),20,@SGuardian;
if (GetCastleData(getarg(1),13) == 1) SetCastleData getarg(1),21,@AGuardian;
if (GetCastleData(getarg(1),14) == 1) SetCastleData getarg(1),22,@AGuardian;
if (GetCastleData(getarg(1),15) == 1) SetCastleData getarg(1),23,@KGuardian;
if (GetCastleData(getarg(1),16) == 1) SetCastleData getarg(1),24,@KGuardian;
if (GetCastleData(getarg(1),17) == 1) SetCastleData getarg(1),25,@KGuardian;
mes "You have invested successfully.";
return 0;
//=========================
M_Guard:
//=========
mes "[ "+getarg(0)+" ]";
if (getgdskilllv(@GID,10002) == 0){
mes "I'm sorry Master but you cannot install any guardians right now. Your guild must learn the Guild skill ^5533FFGuardian Research^000000 first.";
mes "Guardian Installation has been cancelled.";
return 0;
}
set @Defence,GetCastleData(getarg(1),3);
set @Guardian0,guardianinfo(0);
set @Guardian1,guardianinfo(1);
set @Guardian2,guardianinfo(2);
set @Guardian3,guardianinfo(3);
set @Guardian4,guardianinfo(4);
set @Guardian5,guardianinfo(5);
set @Guardian6,guardianinfo(6);
set @Guardian7,guardianinfo(7);
set @AGuardian, 28634 + (@Defence*2000);
set @KGuardian, 30214 + (@Defence*2000);
set @SGuardian, 15670 + (@Defence*2000);
//set @AGuardian,strmobinfo(4,1285) + (@Defence*2000);
//set @KGuardian,strmobinfo(4,1286) + (@Defence*2000);
//set @SGuardian,strmobinfo(4,1287) + (@Defence*2000);
//uncomment the following line to disable guardians Installation during WoE
//if(agitcheck()) goto L_CantGuard;
mes "Would you like to install a guardian? Guardians will protect the guild base from enemies.";
mes "Please choose a guardian.";
next;
menu "Soldier Guardian (" + @Guardian0 + "/" + @SGuardian + ")",L4_1,
"Soldier Guardian (" + @Guardian1 + "/" + @SGuardian + ")",L4_2,
"Soldier Guardian (" + @Guardian2 + "/" + @SGuardian + ")",L4_3,
"Archer Guardian (" + @Guardian3 + "/" + @AGuardian + ")",L4_4,
"Archer Guardian (" + @Guardian4 + "/" + @AGuardian + ")",L4_5,
"Knight Guardian (" + @Guardian5 + "/" + @KGuardian + ")",L4_6,
"Knight Guardian (" + @Guardian6 + "/" + @KGuardian + ")",L4_7,
"Knight Guardian (" + @Guardian7 + "/" + @KGuardian + ")",L4_8;
L4_1:
if (GetCastleData(getarg(1),10) == 1) goto L_GotGuard;
set @GDnum,10;
set @GDnum2,18;
set @GuardianHP,@SGuardian;
goto L4_9;
L4_2:
if (GetCastleData(getarg(1),11) == 1) goto L_GotGuard;
set @GDnum,11;
set @GDnum2,19;
set @GuardianHP,@SGuardian;
goto L4_9;
L4_3:
if (GetCastleData(getarg(1),12) == 1) goto L_GotGuard;
set @GDnum,12;
set @GDnum2,20;
set @GuardianHP,@SGuardian;
goto L4_9;
L4_4:
if (GetCastleData(getarg(1),13) == 1) goto L_GotGuard;
set @GDnum,13;
set @GDnum2,21;
set @GuardianHP,@AGuardian;
goto L4_9;
L4_5:
if (GetCastleData(getarg(1),14) == 1) goto L_GotGuard;
set @GDnum,14;
set @GDnum2,22;
set @GuardianHP,@AGuardian;
goto L4_9;
L4_6:
if (GetCastleData(getarg(1),15) == 1) goto L_GotGuard;
set @GDnum,15;
set @GDnum2,23;
set @GuardianHP,@KGuardian;
goto L4_9;
L4_7:
if (GetCastleData(getarg(1),16) == 1) goto L_GotGuard;
set @GDnum,16;
set @GDnum2,24;
set @GuardianHP,@KGuardian;
goto L4_9;
L4_8:
if (GetCastleData(getarg(1),17) == 1) goto L_GotGuard;
set @GDnum,17;
set @GDnum2,25;
set @GuardianHP,@KGuardian;
L4_9:
mes "[ "+getarg(0)+" ]";
mes "Would you really like to install a guardian? You need ^5533FF10,000 zeny^000000 to install one....";
next;
menu "Install",-, "Cancel",M_End;
if (Zeny < 10000){
mes "[ "+getarg(0)+" ]";
mes "I'm sorry Master, but you do not have enough zeny for a Guardian.";
return 0;
}
set Zeny,Zeny-10000;
SetCastleData getarg(1),@GDnum,1;
SetCastleData getarg(1),@GDnum2,@GuardianHP;
return 1;
L_GotGuard:
mes "[ "+getarg(0)+" ]";
mes "Excuse me Master, but that guardian has already been installed.....";
emotion 4;
return 0;
L_CantGuard:
mes "Master.... don't you know that we can't install guardians during the War Of Emperium?!!";
emotion 4;
return 0;
//===========================
M_Kaf:
//======
mes "[ "+getarg(0)+" ]";
if (GetCastleData(getarg(1),9) == 1) goto L_Dismiss;
if (getgdskilllv(@GID,10001) == 0){
mes "Master, you don't have a contract with the Kafra Staff Company.";
mes "In order to hire a Kafra, you must first learn the Guild skill ^5533FFContract With Kafra^000000.";
return 0;
}
L_Hire:
mes "Would you like to employ the services of a Kafra? You will need ^5533FF10,000 Zeny^000000 to do so... ";
next;
menu "Employ Kafra.",-,"Cancel",sM_KafEnd;
mes "[ "+getarg(0)+" ]";
if (Zeny < 10000){
mes "Master, you do not have enough money to employ a Kafra. Employment has been cancelled.";
return 0;
}
set Zeny,Zeny-10000;
enablenpc "Kafra Staff#"+getarg(4);
SetCastleData getarg(1),9,1;
mes "You have created a contract with the Kafra Staff Company.";
next;
cutin "kafra_01",2;
mes "[ Kafra Staff ]";
mes "How do you do? I'm here to provide you with helpful service! I'll do the best I can to serve you.";
next;
cutin "kafra_01",255;
mes "[ "+getarg(0)+" ]";
//mes "Your employment contract lasts ^5533FF1 month^000000. After this term is over you will have to create a new contract.";
mes "I think the Kafra Staff will benefit our guild members.";
return 0;
sM_KafEnd:
mes "[ "+getarg(0)+" ]";
mes "As you wish Master. But I suggest we get a Kafra as soon as possible!";
return 0;
L_Dismiss:
mes "Would you like to dismiss the current Kafra?";
next;
menu "Dismissal",-,"Cancel",sM_KafEnd2;
cutin "kafra_01",2;
mes "[ Kafra Staff ]";
mes "Have I done anything wrong? If I did, will you please forgive me?";
next;
menu "Dismiss",-,"Cancel",ssM_KafEnd2;
mes "[ Kafra Staff ]";
mes "It's unfortunate that I won't be able to serve your guild anymore....";
next;
disablenpc "Kafra Staff#"+getarg(4);
SetCastleData getarg(1),9,0;
cutin "kafra_01",255;
mes "[ "+getarg(0)+" ]";
mes "The Kafra has been dismissed. But... we should really get a Kafra as soon as possible!";
return 0;
ssM_KafEnd2:
mes "[ Kafra Staff ]";
mes "Thank you master, I'll do my best! ^^.";
cutin "kafra_01",255;
return 0;
sM_KafEnd2:
mes "[ "+getarg(0)+" ]";
mes "Master, I think you should keep the current Kafra Staff because she is already trying her best to serve us";
return 0;
//=========================
M_Treas:
//========
mes "[ "+getarg(0)+" ]";
mes "Would you to go to our Treasure Room? Only you, the Guild Master, are allowed to enter this room.";
next;
menu "Enter Treasure room.",-,"Cancel",sM_TresEnd;
mes "[ "+getarg(0)+" ]";
mes "Please follow me through the secret passage way.";
mes "You must pull down on the secret switch in order to get out.";
next;
warp getarg(1),getarg(2),getarg(3);
return 0;
sM_TresEnd:
mes "[ "+getarg(0)+" ]";
mes "The goods are produced everyday.";
mes "You should get them whenever you can because they might dissapear if you take them at the wrong time.";
return 0;
//==========================
M_End:
//=======
mes "[ "+getarg(0)+" ]";
mes "As you wish, master.";
return 0;
}