Expanded script command setbattleflag

* Fixes #1945.
* Adds an optional flag to reload the monster database for specific map flags that are EXP/drop related.
* This resolves having to add atcommand reloadmobdb after setting the battle configs.
* Adjusted atcommand setbattleflag to also have the optional parameter.
* The reload should only have to be called on the final setbattleflag use.
This commit is contained in:
aleos 2017-02-11 20:55:35 -05:00
parent ca051d185e
commit 0c20c596e0
6 changed files with 54 additions and 12 deletions

View File

@ -1238,7 +1238,7 @@
1230: Please enter a player name (usage: @trade <char name>).
// @setbattleflag
1231: Usage: @setbattleflag <flag> <value>
1231: Usage: @setbattleflag <flag> <value> {<reload>}
1232: Unknown battle_config flag.
1233: Set battle_config as requested.

View File

@ -1374,9 +1374,11 @@ Note that the value of a string variable may be typed with or without double quo
---------------------------------------
@setbattleflag <flag> <value>
@setbattleflag <flag> <value> {<reload>}
Changes a battle_config flag without rebooting the server.
If a value is given for reload, then the server will attempt to reload the mob database
if the config being changed is EXP/drop related.
---------------------------------------

View File

@ -6715,16 +6715,22 @@ The optional parameter 'type' is used in the 'skill_damage' mapflag:
---------------------------------------
*setbattleflag "<battle flag>",<value>;
*setbattleflag "<battle flag>",<value>{,<reload>};
*getbattleflag("<battle flag>")
Sets or gets the value of the given battle flag.
Battle flags are the flags found in the battle / *.conf files and is also used in Lupus' variable rates script.
If the reload value is given then the server will attempt to reload monster data
to properly apply the new rates. This applies to EXP/Drop type configs. The server
will only attempt to reload specific configs.
Examples:
// Will set the base experience rate to 20x (2000%)
// Will set the base experience rate to 20x (2000%) - Monster data will continue to use previous rates at server start
setBattleFlag "base_exp_rate",2000;
// Will set the base experience rate to 20x (2000%) - Monster data will be reloaded to new value
setBattleFlag "base_exp_rate",2000,true;
// Will return the value of the base experience rate (when used after the above example, it would print 2000).
mes getBattleFlag("base_exp_rate");

View File

@ -34,9 +34,8 @@ OnHour18:
setbattleflag("item_rate_common",$@drate);
setbattleflag("item_rate_heal",$@drate);
setbattleflag("item_rate_use",$@drate);
setbattleflag("item_rate_equip",$@drate);
setbattleflag("item_rate_equip",$@drate,true); // Apply new rates to configs set above
//we don't change card drops rate, because these values won't change them anyway
atcommand "@reloadmobdb";
announce "Current Rune-Midgard rates are: 1."+($@brate-100)+"x 1."+($@jrate-100)+"x 1."+($@drate-100)+"x",bc_all,0xFF6060;
end;

View File

@ -6865,10 +6865,11 @@ ACMD_FUNC(trade)
ACMD_FUNC(setbattleflag)
{
char flag[128], value[128];
int reload = 0;
nullpo_retr(-1, sd);
if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) != 2) {
clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
return -1;
}
@ -6880,6 +6881,9 @@ ACMD_FUNC(setbattleflag)
clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
if (reload)
mob_reload();
return 0;
}

View File

@ -15117,6 +15117,10 @@ BUILDIN_FUNC(autoequip)
return SCRIPT_CMD_SUCCESS;
}
/**
* Set the value of a given battle config
* setbattleflag "<battle flag>",<value>{,<reload>};
*/
BUILDIN_FUNC(setbattleflag)
{
const char *flag, *value;
@ -15126,16 +15130,43 @@ BUILDIN_FUNC(setbattleflag)
if (battle_set_value(flag, value) == 0)
ShowWarning("buildin_setbattleflag: unknown battle_config flag '%s'\n",flag);
else
else {
ShowInfo("buildin_setbattleflag: battle_config flag '%s' is now set to '%s'.\n",flag,value);
if (script_hasdata(st, 4) && script_getnum(st, 4)) { // Only attempt to reload monster data if told to
const char *expdrop_flags[] = { // Only certain flags require a reload, check for those types
"base_exp_rate", "job_exp_rate", "mvp_exp_rate", "quest_exp_rate", "heal_exp", "resurrection_exp",
"item_rate_common", "item_rate_common_boss", "item_rate_common_mvp", "item_drop_common_min", "item_drop_common_max",
"item_rate_heal", "item_rate_heal_boss", "item_rate_heal_mvp", "item_rate_heal_min", "item_rate_heal_max",
"item_rate_use", "item_rate_use_boss", "item_rate_use_mvp", "item_rate_use_min", "item_rate_use_max",
"item_rate_equip", "item_rate_equip_boss", "item_rate_equip_mvp", "item_rate_equip_min", "item_rate_equip_max",
"item_rate_card", "item_rate_card_boss", "item_rate_card_mvp", "item_rate_card_min", "item_rate_card_max",
"item_rate_mvp", "item_rate_mvp_min", "item_rate_mvp_max", "item_rate_mvp_mode",
"item_rate_treasure", "item_rate_treasure_min", "item_rate_treasure_max",
"item_logarithmic_drops", "drop_rate0item", "drop_rateincrease",
};
uint8 i;
for (i = 0; i < ARRAYLENGTH(expdrop_flags); i++) {
if (!strcmpi(flag, expdrop_flags[i])) {
mob_reload();
break;
}
}
}
}
return SCRIPT_CMD_SUCCESS;
}
/**
* Get the value of a given battle config
* getbattleflag("<battle flag>")
*/
BUILDIN_FUNC(getbattleflag)
{
const char *flag;
flag = script_getstr(st,2);
const char *flag = script_getstr(st,2);
script_pushint(st,battle_get_value(flag));
return SCRIPT_CMD_SUCCESS;
}
@ -22551,7 +22582,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(npcshopattach,"s?"),
BUILDIN_DEF(equip,"i?"),
BUILDIN_DEF(autoequip,"ii"),
BUILDIN_DEF(setbattleflag,"si"),
BUILDIN_DEF(setbattleflag,"si?"),
BUILDIN_DEF(getbattleflag,"s"),
BUILDIN_DEF(setitemscript,"is?"), //Set NEW item bonus script. Lupus
BUILDIN_DEF(disguise,"i?"), //disguise player. Lupus