From a6c753ac32411d60f23fed14a959eb47bd0966e7 Mon Sep 17 00:00:00 2001 From: WinterSolstice8 <60417494+WinterSolstice8@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:03:31 -0600 Subject: [PATCH 1/3] [core] Add hook for lua to get primary target of an action --- src/map/lua/lua_action.cpp | 12 ++++++++++++ src/map/lua/lua_action.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/map/lua/lua_action.cpp b/src/map/lua/lua_action.cpp index 930eba6fefd..fe202a92058 100644 --- a/src/map/lua/lua_action.cpp +++ b/src/map/lua/lua_action.cpp @@ -43,6 +43,17 @@ void CLuaAction::ID(uint32 actionTargetID, uint32 newActionTargetID) } } +// Get the first (primary) target's long ID, if available. +uint32 CLuaAction::getPrimaryTargetID() +{ + if (m_PLuaAction->actionLists.size() > 0) + { + return m_PLuaAction->actionLists[0].ActionTargetID; + } + + return 0; +} + void CLuaAction::setRecast(uint16 recast) { m_PLuaAction->recast = recast; @@ -225,6 +236,7 @@ void CLuaAction::Register() { SOL_USERTYPE("CAction", CLuaAction); SOL_REGISTER("ID", CLuaAction::ID); + SOL_REGISTER("getPrimaryTargetID", CLuaAction::getPrimaryTargetID); SOL_REGISTER("getRecast", CLuaAction::getRecast); SOL_REGISTER("setRecast", CLuaAction::setRecast); SOL_REGISTER("actionID", CLuaAction::actionID); diff --git a/src/map/lua/lua_action.h b/src/map/lua/lua_action.h index 37662d5cddc..a513d237b10 100644 --- a/src/map/lua/lua_action.h +++ b/src/map/lua/lua_action.h @@ -42,6 +42,7 @@ class CLuaAction friend std::ostream& operator<<(std::ostream& out, const CLuaAction& action); void ID(uint32 actionTargetID, uint32 newActionTargetID); + uint32 getPrimaryTargetID(); void setRecast(uint16 recast); uint16 getRecast(); void actionID(uint16 actionid); From 11bf9f31b5ef040206251025015b2246cc7b6e08 Mon Sep 17 00:00:00 2001 From: WinterSolstice8 <60417494+WinterSolstice8@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:04:11 -0600 Subject: [PATCH 2/3] [msg] Add JA_GAIN_EFFECT_2 message --- scripts/enum/msg.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/enum/msg.lua b/scripts/enum/msg.lua index fcbd8850d94..426acdbb711 100644 --- a/scripts/enum/msg.lua +++ b/scripts/enum/msg.lua @@ -137,6 +137,7 @@ xi.msg.basic = JA_MISS = 158, -- uses , but misses. (no name included) USES_JA_TAKE_DAMAGE = 317, -- The uses .. takes .. points of damage. JA_GAIN_EFFECT = 266, -- gains the effect of . + JA_GAIN_EFFECT_2 = 316, -- uses . gains the effect of . JA_REMOVE_EFFECT_2 = 321, -- uses . 's wears off. JA_NO_EFFECT_2 = 323, -- uses . No effect on . (2 line msg) JA_MISS_2 = 324, -- uses , but misses . (includes target name) From c2d7decb2e00cd6bd96189256ef06acee34bcbcc Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Sun, 22 Oct 2023 14:52:25 +0100 Subject: [PATCH 3/3] Use not empty instead of size --- src/map/lua/lua_action.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map/lua/lua_action.cpp b/src/map/lua/lua_action.cpp index fe202a92058..18ae7b409bd 100644 --- a/src/map/lua/lua_action.cpp +++ b/src/map/lua/lua_action.cpp @@ -46,7 +46,7 @@ void CLuaAction::ID(uint32 actionTargetID, uint32 newActionTargetID) // Get the first (primary) target's long ID, if available. uint32 CLuaAction::getPrimaryTargetID() { - if (m_PLuaAction->actionLists.size() > 0) + if (!m_PLuaAction->actionLists.empty()) { return m_PLuaAction->actionLists[0].ActionTargetID; }