diff options
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 66 | ||||
-rw-r--r-- | src/emap/script_buildins.h | 1 |
3 files changed, 68 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index 266e6cf..2c85e39 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -223,6 +223,7 @@ HPExport void plugin_init (void) addScriptCommand("deployhomunculus","",deployhomunculus); addScriptCommand("recallhomunculus","",recallhomunculus); addScriptCommand("homstatus","",homstatus); + addScriptCommand("readparam2","i?",readparam2); addScriptCommand("npcshopattach","s?",npcshopattach); do_init_langs(); diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 7393da8..26a2dd4 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -2663,3 +2663,69 @@ BUILDIN(homstatus) } +/*========================================== + * return the updated stats of sd (use bonus constants) + * Supported values: bStr~bLuk, bMaxHP, bMaxSP, bDef, bMdef, bAtk + *------------------------------------------*/ +BUILDIN(readparam2) +{ + struct map_session_data *sd; + int data = script_getnum(st,2); + + // Account ID/Player Name is also supported + if (script_hasdata(st, 3)) { + if (script_isstringtype(st, 3)) { + sd = script->nick2sd(st, script_getstr(st, 3)); + } else { + sd = script->id2sd(st, script_getnum(st, 3)); + } + } else { + sd = script->rid2sd(st); + } + + // Error + if (sd == NULL) { + script_pushint(st, -1); + return true; + } + + switch (data) { + case 13: + script_pushint(st, sd->battle_status.str); + break; + case 14: + script_pushint(st, sd->battle_status.agi); + break; + case 15: + script_pushint(st, sd->battle_status.vit); + break; + case 16: + script_pushint(st, sd->battle_status.int_); + break; + case 17: + script_pushint(st, sd->battle_status.dex); + break; + case 18: + script_pushint(st, sd->battle_status.luk); + break; + case 6: + script_pushint(st, sd->battle_status.max_hp); + break; + case 8: + script_pushint(st, sd->battle_status.max_sp); + break; + case 45: + script_pushint(st, sd->battle_status.def); + break; + case 41: + script_pushint(st, sd->battle_status.batk+sd->battle_status.rhw.atk); + break; + default: + ShowError("Wrong paramType in readparam2\nAre you sure you used bonus constants?\nSupported values: bMaxHP, bMaxSP, bStr, bAgi, bVit, bInt, bDex, bLuk, bAtk, bDef\n"); + script_pushint(st, -1); + break; + } + + return true; +} + diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index 96fdf35..04da908 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -113,5 +113,6 @@ BUILDIN(gethomunexp); BUILDIN(deployhomunculus); BUILDIN(recallhomunculus); BUILDIN(homstatus); +BUILDIN(readparam2); #endif // EVOL_MAP_SCRIPT_BUILDINS |