From a768af85ee5adf368cd59e7c288f3239418e62b9 Mon Sep 17 00:00:00 2001 From: Atemo Date: Thu, 14 Mar 2024 14:08:45 +0100 Subject: [PATCH] Updated geteleminfo script command (#8168) * Updated geteleminfo script command * Added a new "2" that returns the class ID of the elemental spirit * Fixed Dimensions Elemental* combos: item descriptions require high elemental spirit check * Added new constants for geteleminfo Thanks to @aleos89 @Badarosk0 ! --- db/re/item_combos.yml | 6 ++++-- doc/script_commands.txt | 5 +++-- src/map/script.cpp | 22 +++++++++++++++------- src/map/script.hpp | 7 +++++++ src/map/script_constants.hpp | 5 +++++ 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/db/re/item_combos.yml b/db/re/item_combos.yml index c0ca3044de..6d7b29491d 100644 --- a/db/re/item_combos.yml +++ b/db/re/item_combos.yml @@ -46814,7 +46814,8 @@ Body: bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_WIND",2*.@sum; bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_POISON",2*.@sum; bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_GROUND",2*.@sum; - if (getskilllv("EM_ELEMENTAL_BUSTER") > 0) { + .@class_ = geteleminfo(ELEMINFO_CLASS); + if (getskilllv("EM_ELEMENTAL_BUSTER") > 0 && .@class_ >= 20816 && .@class_ <= 20820) { bonus4 bAutoSpellOnSkill,"EM_DIAMOND_STORM","EM_ELEMENTAL_BUSTER",getskilllv("EM_ELEMENTAL_BUSTER"),1000; } } @@ -46835,7 +46836,8 @@ Body: bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_WIND",2*.@sum; bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_POISON",2*.@sum; bonus2 bSkillAtk,"EM_ELEMENTAL_BUSTER_GROUND",2*.@sum; - if (getskilllv("EM_ELEMENTAL_BUSTER") > 0 && geteleminfo(0) > 0) { + .@class_ = geteleminfo(ELEMINFO_CLASS); + if (getskilllv("EM_ELEMENTAL_BUSTER") > 0 && .@class_ >= 20816 && .@class_ <= 20820) { bonus4 bAutoSpellOnSkill,"EM_TERRA_DRIVE","EM_ELEMENTAL_BUSTER",getskilllv("EM_ELEMENTAL_BUSTER"),1000; } } diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 911015cf27..1b0a1c9602 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -8966,8 +8966,9 @@ Get info of elemental of attached player or player by char_id. Other info can be obtained by 'getunitdata' command. Valid types are: - 0: Elemental ID - 1: Elemental Game ID + ELEMINFO_ID Elemental ID (ID unique to elementals unit type) + ELEMINFO_GAMEID Elemental Game ID + ELEMINFO_CLASS Elemental Class (ID defined in elemental_db.yml) --------------------------------------- \\ diff --git a/src/map/script.cpp b/src/map/script.cpp index dd27f28d97..692703029f 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -24038,24 +24038,32 @@ BUILDIN_FUNC(ignoretimeout) * geteleminfo {,}; **/ BUILDIN_FUNC(geteleminfo) { - TBL_ELEM *ed = NULL; - TBL_PC *sd = NULL; - int type = script_getnum(st,2); + map_session_data *sd = nullptr; if (!script_charid2sd(3, sd)) { script_pushint(st, 0); - return SCRIPT_CMD_SUCCESS; + return SCRIPT_CMD_FAILURE; } + s_elemental_data *ed = nullptr; + if (!(ed = sd->ed)) { - //ShowDebug("buildin_geteleminfo: Player doesn't have Elemental.\n"); script_pushint(st, 0); return SCRIPT_CMD_SUCCESS; } + int type = script_getnum(st,2); + switch (type) { - case 0: script_pushint(st, ed->elemental.elemental_id); break; - case 1: script_pushint(st, ed->bl.id); break; + case ELEMINFO_ID: + script_pushint(st, ed->elemental.elemental_id); + break; + case ELEMINFO_GAMEID: + script_pushint(st, ed->bl.id); + break; + case ELEMINFO_CLASS: + script_pushint(st, ed->elemental.class_); + break; default: ShowError("buildin_geteleminfo: Invalid type '%d'.\n", type); script_pushint(st, 0); diff --git a/src/map/script.hpp b/src/map/script.hpp index af086077b4..b7beb8483d 100644 --- a/src/map/script.hpp +++ b/src/map/script.hpp @@ -2185,6 +2185,13 @@ enum e_iteminfo : uint8 { ITEMINFO_SUBTYPE, }; +/* geteleminfo script command */ +enum e_eleminfo : uint8 { + ELEMINFO_ID = 0, + ELEMINFO_GAMEID, + ELEMINFO_CLASS, +}; + class ConstantDatabase : public YamlDatabase { public: ConstantDatabase() : YamlDatabase("CONSTANT_DB", 1) { diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp index 8f63c1d187..dcd2ab17d2 100644 --- a/src/map/script_constants.hpp +++ b/src/map/script_constants.hpp @@ -10196,6 +10196,11 @@ export_constant(ITEMINFO_ARMORLEVEL); export_constant(ITEMINFO_SUBTYPE); + /* geteleminfo script command */ + export_constant(ELEMINFO_ID); + export_constant(ELEMINFO_GAMEID); + export_constant(ELEMINFO_CLASS); + /* refine types */ export_constant(REFINE_TYPE_ARMOR); export_constant(REFINE_TYPE_WEAPON);