Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose the bank vault to the script engine #1717

Merged
merged 1 commit into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ allows you to replace lots of numbered arguments for many commands with
easier to read text. The special variables most commonly used are all
permanent character-based variables:

Zeny - Amount of Zeny.
Zeny - Amount of Zeny in the inventory.
BankVault - Amount of Zeny in the bank.
Hp - Current amount of hit points.
MaxHp - Maximum amount of hit points.
Sp - Current spell points.
Expand Down Expand Up @@ -707,7 +708,8 @@ MAX_STORAGE - Maximum storage items
MAX_GUILD_STORAGE - Maximum guild storage items
MAX_CART - Maximum cart items
MAX_INVENTORY - Maximum inventory items
MAX_ZENY - Maximum Zeny
MAX_ZENY - Maximum Zeny in the inventory
MAX_BANK_ZENY - Maximum Zeny in the bank
MAX_BG_MEMBERS - Maximum BattleGround members
MAX_CHAT_USERS - Maximum Chat users
MAX_REFINE - Maximum Refine level
Expand Down
1 change: 1 addition & 0 deletions src/map/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ enum status_point_types { //we better clean up this enum and change it name [Hem
SP_MOD_EXP=125,
SP_MOD_DROP=126,
SP_MOD_DEATH=127,
SP_BANKVAULT=128,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure is possible add any custom contants here. I think they related to aegis or client constants?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first 100 are used by client, all constant above 100 are not related to client/aegis.


// Mercenaries
SP_MERCFLEE=165, SP_MERCKILLS=189, SP_MERCFAITH=190,
Expand Down
15 changes: 15 additions & 0 deletions src/map/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8141,6 +8141,7 @@ int pc_readparam(const struct map_session_data *sd, int type)
case SP_SKILLPOINT: val = sd->status.skill_point; break;
case SP_STATUSPOINT: val = sd->status.status_point; break;
case SP_ZENY: val = sd->status.zeny; break;
case SP_BANKVAULT: val = sd->status.bank_vault; break;
case SP_BASELEVEL: val = sd->status.base_level; break;
case SP_JOBLEVEL: val = sd->status.job_level; break;
case SP_CLASS: val = sd->status.class; break;
Expand Down Expand Up @@ -8285,6 +8286,7 @@ int pc_readparam(const struct map_session_data *sd, int type)
*------------------------------------------*/
int pc_setparam(struct map_session_data *sd,int type,int val)
{
int delta;
nullpo_ret(sd);

switch(type){
Expand Down Expand Up @@ -8335,6 +8337,19 @@ int pc_setparam(struct map_session_data *sd,int type,int val)
logs->zeny(sd, LOG_TYPE_SCRIPT, sd, -(sd->status.zeny - cap_value(val, 0, MAX_ZENY)));
sd->status.zeny = cap_value(val, 0, MAX_ZENY);
break;
case SP_BANKVAULT:
val = cap_value(val, 0, MAX_BANK_ZENY);
delta = (val - sd->status.bank_vault);
sd->status.bank_vault = val;
if (map->save_settings & 256) {
chrif->save(sd, 0); // send to char server
}
if (delta > 0) {
clif->bank_deposit(sd, BDA_SUCCESS);
} else if (delta < 0) {
clif->bank_withdraw(sd, BWA_SUCCESS);
}
return 1; // the vault uses a different packet
case SP_BASEEXP:
if(pc->nextbaseexp(sd) > 0) {
sd->status.base_exp = val;
Expand Down
2 changes: 2 additions & 0 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -2384,6 +2384,7 @@ void script_load_parameters(void)
{"SkillPoint", SP_SKILLPOINT},
{"Class", SP_CLASS},
{"Zeny", SP_ZENY},
{"BankVault", SP_BANKVAULT},
{"Sex", SP_SEX},
{"NextBaseExp", SP_NEXTBASEEXP},
{"NextJobExp", SP_NEXTJOBEXP},
Expand Down Expand Up @@ -23679,6 +23680,7 @@ void script_hardcoded_constants(void)
script->set_constant("MAX_CART",MAX_INVENTORY,false, false);
script->set_constant("MAX_INVENTORY",MAX_INVENTORY,false, false);
script->set_constant("MAX_ZENY",MAX_ZENY,false, false);
script->set_constant("MAX_BANK_ZENY", MAX_BANK_ZENY, false, false);
script->set_constant("MAX_BG_MEMBERS",MAX_BG_MEMBERS,false, false);
script->set_constant("MAX_CHAT_USERS",MAX_CHAT_USERS,false, false);
script->set_constant("MAX_REFINE",MAX_REFINE,false, false);
Expand Down