diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-01-13 19:50:27 +0000 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-01-13 19:50:27 +0000 |
commit | 8ba3b9f635ec976e20ac94165c42bde5f12f4be7 (patch) | |
tree | f9ba0bf258b65b125830cf07ecd9dd7e80935761 | |
parent | c687d2d1b2ad48b5b15899f34b73a41ae73f674c (diff) | |
download | plugin-8ba3b9f635ec976e20ac94165c42bde5f12f4be7.tar.gz plugin-8ba3b9f635ec976e20ac94165c42bde5f12f4be7.tar.bz2 plugin-8ba3b9f635ec976e20ac94165c42bde5f12f4be7.tar.xz plugin-8ba3b9f635ec976e20ac94165c42bde5f12f4be7.zip |
New function: readbattleparam( <param> )
Complements with some info only available with getunitdata(), which
only works with non-players. Not everything covered by getunitdata() is
covered by this function.
TEMPORARY COMMIT, should be replaced with getunitdata() when the function is updated upstream to receive player data as well.
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 91 | ||||
-rw-r--r-- | src/emap/script_buildins.h | 1 |
3 files changed, 93 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index d4e8d11..6bfdfa7 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -213,6 +213,7 @@ HPExport void plugin_init (void) addScriptCommand("getitemoptionparambyindex", "ii", getItemOptionParamByIndex); addScriptCommand("setitemoptionbyindex", "iii*", setItemOptionByIndex); addScriptCommand("isinstance", "i", isInstance); + addScriptCommand("readbattleparam","ii",readBattleParam); do_init_langs(); diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index c0a7e1b..2899cc3 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -2348,3 +2348,94 @@ BUILDIN(isInstance) script_pushint(st, instance->valid(instance_id) ? 1 : 0); return true; } + +/*========================================== + * return the battle stats of a structure + * Supported values are most of UDT_* ones + * Not all values are supported; Only those without + * another assessor are (eg. MaxHP vs UDT_MAXHP) + * + * From 1 onwards: Str, Agi, Vit, Int, Dex, Luck + * From 7 onwards: AtkMin, AtkMax, Def, MDef, Hit, Flee + * From 13 onwards: MAtkMin, MatkMax + *------------------------------------------*/ +BUILDIN(readBattleParam) +{ + struct map_session_data *sd; + sd = script->id2sd(st, script_getnum(st, 2)); + int data = script_getnum(st,3); + + // Error + if (sd == NULL) { + ShowError("Target is not player in readbattleparam(%d)\n", data); + script_pushint(st, -1); + return true; + } + + switch (data) { + // * From 1 onwards: Str, Agi, Vit, Int, Dex, Luck + case UDT_STR: + script_pushint(st, sd->battle_status.str); + break; + case UDT_AGI: + script_pushint(st, sd->battle_status.agi); + break; + case UDT_VIT: + script_pushint(st, sd->battle_status.vit); + break; + case UDT_INT: + script_pushint(st, sd->battle_status.int_); + break; + case UDT_DEX: + script_pushint(st, sd->battle_status.dex); + break; + case UDT_LUK: + script_pushint(st, sd->battle_status.luk); + break; + case UDT_ATKRANGE: + script_pushint(st, sd->battle_status.rhw.range); + break; + case UDT_ATKMIN: + script_pushint(st, sd->battle_status.rhw.atk); + break; + case UDT_ATKMAX: + script_pushint(st, sd->battle_status.rhw.atk+sd->battle_status.batk); + break; + case UDT_DEF: + script_pushint(st, sd->battle_status.def); + break; + case UDT_MDEF: + script_pushint(st, sd->battle_status.mdef+sd->battle_status.mdef2); + break; + case UDT_HIT: + script_pushint(st, sd->battle_status.hit); + break; + case UDT_FLEE: + script_pushint(st, sd->battle_status.flee); + break; + case UDT_MATKMIN: + script_pushint(st, sd->battle_status.matk_min); + break; + case UDT_MATKMAX: + script_pushint(st, sd->battle_status.matk_max); + break; + case UDT_CRIT: + script_pushint(st, sd->battle_status.cri); + break; + case UDT_ELETYPE: + script_pushint(st, sd->battle_status.def_ele); + break; + case UDT_ADELAY: + script_pushint(st, sd->battle_status.adelay); + break; + case UDT_DMOTION: + script_pushint(st, sd->battle_status.dmotion); + break; + default: + ShowError("Wrong paramType in readbattleparam(%d)\nAre you sure you used the right constants?\n", data); + script_pushint(st, -1); + break; + } + + return true; +} diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index fab271e..6c31909 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -99,5 +99,6 @@ BUILDIN(getItemOptionValueByIndex); BUILDIN(getItemOptionParamByIndex); BUILDIN(setItemOptionByIndex); BUILDIN(isInstance); +BUILDIN(readBattleParam); #endif // EVOL_MAP_SCRIPT_BUILDINS |