feat: add getter and setter for halaa ownership (#79)

This commit is contained in:
55Honey
2022-12-30 02:01:40 +01:00
committed by GitHub
parent 67eb2d808d
commit aa6615b23a
2 changed files with 58 additions and 0 deletions

View File

@@ -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<uint16>(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

View File

@@ -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 }
};