summaryrefslogtreecommitdiff
path: root/src/emap
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-09-03 13:58:57 -0300
committerJesusaves <cpntb1@ymail.com>2019-09-03 13:58:57 -0300
commit9edc4c2e8a2e3df1706d652caad261b3843830ef (patch)
treeac9c71e186c911a0257ffaa9f999a883e20219dd /src/emap
parent4a6c4e17275bc82c20bb768861ce8918d35b9965 (diff)
downloadevol-hercules-9edc4c2e8a2e3df1706d652caad261b3843830ef.tar.gz
evol-hercules-9edc4c2e8a2e3df1706d652caad261b3843830ef.tar.bz2
evol-hercules-9edc4c2e8a2e3df1706d652caad261b3843830ef.tar.xz
evol-hercules-9edc4c2e8a2e3df1706d652caad261b3843830ef.zip
Add new function: readparam2(-)
Works similar to readparam, but it reads from battle status. It returns stats with the bonuses, defense, and attack, besides MaxHP/MaxMP.
Diffstat (limited to 'src/emap')
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/script_buildins.c66
-rw-r--r--src/emap/script_buildins.h1
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