diff --git a/src/LuaEngine/GlobalMethods.h b/src/LuaEngine/GlobalMethods.h index fde229b..a1779e8 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 { @@ -3327,5 +3330,58 @@ namespace LuaGlobalFunctions return 0; } + + #ifdef AZEROTHCORE + /** + * Gets the faction which is the current owner of Halaa in Nagrand + * 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 2; + } + + /** + * 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->SetSlider(599); + } + else if (teamId == 1) + { + halaa->SetSlider(-599); + } + else + { + return luaL_argerror(L, 1, "0 for Alliance or 1 for Horde expected"); + } + + return 0; + } + #endif } #endif diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index 68aa08f..0ff5110 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 } };