From 7c3ce733e29a8141e341e8757ac7bc1656d89115 Mon Sep 17 00:00:00 2001 From: 55Honey <71938210+55Honey@users.noreply.github.com> Date: Thu, 29 Dec 2022 01:11:29 +0100 Subject: [PATCH 1/5] feat: add getter and setter for halaa ownership --- src/LuaEngine/GlobalMethods.h | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/LuaEngine/GlobalMethods.h b/src/LuaEngine/GlobalMethods.h index 28516d97ee..2e27bc84d6 100644 --- a/src/LuaEngine/GlobalMethods.h +++ b/src/LuaEngine/GlobalMethods.h @@ -13,6 +13,9 @@ #include "BanMgr.h" #include "GameTime.h" +#include "SharedDefines.h" +#include "OutdoorPvPMgr.h" +#include "../../../../src/server/scripts/OutdoorPvP/OutdoorPvPNA.h" enum BanMode { @@ -3322,5 +3325,51 @@ namespace LuaGlobalFunctions return 0; } + + #ifdef AZEROTHCORE + /** + * Gets the faction which is the current owner of Halaa in Nagrand + * 0 = Alliance + * 1 = Horde + * + * @return int16 the ID of the team to own Halaa + */ + int GetOwnerHalaa(lua_State* L) + { + OutdoorPvPNA* nagrandPvp = (OutdoorPvPNA*)sOutdoorPvPMgr->GetOutdoorPvPToZoneId(3518); + OPvPCapturePointNA* halaa = nagrandPvp->GetCapturePoint(); + Eluna::Push(L, halaa->GetControllingFaction()); + + return 1; + } + + /** + * Sets the owner of Halaa in Nagrand to the respective faction + * 0 = Alliance + * 1 = Horde + * + * @param uint16 teamId : the ID of the team to own Halaa + */ + int SetOwnerHalaa(lua_State* L) + { + uint16 teamId = Eluna::CHECKVAL(L, 1); + + OutdoorPvPNA* nagrandPvp = (OutdoorPvPNA*)sOutdoorPvPMgr->GetOutdoorPvPToZoneId(3518); + OPvPCapturePointNA* halaa = nagrandPvp->GetCapturePoint(); + + if (teamId == 0) + { + halaa->FactionTakeOver(TEAM_ALLIANCE); + halaa->m_value = 1024; + } + else if (teamId == 1) + { + halaa->FactionTakeOver(TEAM_HORDE); + halaa->m_value = -1024; + } + + return 0; + } + #endif } #endif From 6235102f8da8fbc5b129fbf597cf7541b993b4d5 Mon Sep 17 00:00:00 2001 From: 55Honey <71938210+55Honey@users.noreply.github.com> Date: Thu, 29 Dec 2022 01:45:57 +0100 Subject: [PATCH 2/5] add missing functions --- src/LuaEngine/LuaFunctions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index 9fef984efc..ca76daa915 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -98,6 +98,7 @@ luaL_Reg GlobalMethods[] = { "GetGUIDType", &LuaGlobalFunctions::GetGUIDType }, { "GetGUIDEntry", &LuaGlobalFunctions::GetGUIDEntry }, { "GetAreaName", &LuaGlobalFunctions::GetAreaName }, + { "GetOwnerHalaa", &LuaGlobalFunctions::GetOwnerHalaa }, { "bit_not", &LuaGlobalFunctions::bit_not }, { "bit_xor", &LuaGlobalFunctions::bit_xor }, { "bit_rshift", &LuaGlobalFunctions::bit_rshift }, @@ -148,6 +149,7 @@ luaL_Reg GlobalMethods[] = { "StartGameEvent", &LuaGlobalFunctions::StartGameEvent }, { "StopGameEvent", &LuaGlobalFunctions::StopGameEvent }, { "HttpRequest", &LuaGlobalFunctions::HttpRequest }, + { "SetOwnerHalaa", &LuaGlobalFunctions::SetOwnerHalaa }, { NULL, NULL } }; From c392fc1331c853491cb0110ded46a6554faf15fe Mon Sep 17 00:00:00 2001 From: 55Honey <71938210+55Honey@users.noreply.github.com> Date: Thu, 29 Dec 2022 23:11:33 +0100 Subject: [PATCH 3/5] switch to setter/getter --- src/LuaEngine/GlobalMethods.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/LuaEngine/GlobalMethods.h b/src/LuaEngine/GlobalMethods.h index 2e27bc84d6..6417563728 100644 --- a/src/LuaEngine/GlobalMethods.h +++ b/src/LuaEngine/GlobalMethods.h @@ -3332,15 +3332,20 @@ namespace LuaGlobalFunctions * 0 = Alliance * 1 = Horde * + * 600 = slider max Alliance + * -600 = slider max Horde + * * @return int16 the ID of the team to own Halaa + * €@return float the slider position. */ int GetOwnerHalaa(lua_State* L) { OutdoorPvPNA* nagrandPvp = (OutdoorPvPNA*)sOutdoorPvPMgr->GetOutdoorPvPToZoneId(3518); OPvPCapturePointNA* halaa = nagrandPvp->GetCapturePoint(); Eluna::Push(L, halaa->GetControllingFaction()); + Eluna::Push(L, halaa->GetSlider()); - return 1; + return 2; } /** @@ -3360,12 +3365,16 @@ namespace LuaGlobalFunctions if (teamId == 0) { halaa->FactionTakeOver(TEAM_ALLIANCE); - halaa->m_value = 1024; + halaa->SetSlider(599); } else if (teamId == 1) { halaa->FactionTakeOver(TEAM_HORDE); - halaa->m_value = -1024; + halaa->SetSlider(-599); + } + else + { + return luaL_argerror(L, 1, "0 for Alliance or 1 for Horde expected"); } return 0; From d3047d32bf8a03d1cef39d4128bc32c16eaa2b76 Mon Sep 17 00:00:00 2001 From: 55Honey <71938210+55Honey@users.noreply.github.com> Date: Thu, 29 Dec 2022 23:25:50 +0100 Subject: [PATCH 4/5] polish --- src/LuaEngine/GlobalMethods.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/LuaEngine/GlobalMethods.h b/src/LuaEngine/GlobalMethods.h index 6417563728..6919b99ab0 100644 --- a/src/LuaEngine/GlobalMethods.h +++ b/src/LuaEngine/GlobalMethods.h @@ -3332,11 +3332,11 @@ namespace LuaGlobalFunctions * 0 = Alliance * 1 = Horde * - * 600 = slider max Alliance - * -600 = slider max Horde + * 1024 = slider max Alliance + * -1024 = slider max Horde * * @return int16 the ID of the team to own Halaa - * €@return float the slider position. + * @return float the slider position. */ int GetOwnerHalaa(lua_State* L) { @@ -3364,12 +3364,10 @@ namespace LuaGlobalFunctions if (teamId == 0) { - halaa->FactionTakeOver(TEAM_ALLIANCE); halaa->SetSlider(599); } else if (teamId == 1) { - halaa->FactionTakeOver(TEAM_HORDE); halaa->SetSlider(-599); } else From 0c172b8bf69f02d74682fd8aee36002daeea3a0f Mon Sep 17 00:00:00 2001 From: 55Honey <71938210+55Honey@users.noreply.github.com> Date: Thu, 29 Dec 2022 23:41:40 +0100 Subject: [PATCH 5/5] polish --- src/LuaEngine/GlobalMethods.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LuaEngine/GlobalMethods.h b/src/LuaEngine/GlobalMethods.h index 6919b99ab0..e9d5470248 100644 --- a/src/LuaEngine/GlobalMethods.h +++ b/src/LuaEngine/GlobalMethods.h @@ -3332,8 +3332,8 @@ namespace LuaGlobalFunctions * 0 = Alliance * 1 = Horde * - * 1024 = slider max Alliance - * -1024 = slider max Horde + * 600 = slider max Alliance + * -600 = slider max Horde * * @return int16 the ID of the team to own Halaa * @return float the slider position.