Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add getter and setter for halaa ownership #79

Merged
merged 5 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions src/LuaEngine/GlobalMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -3322,5 +3325,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
2 changes: 2 additions & 0 deletions src/LuaEngine/LuaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -148,6 +149,7 @@ luaL_Reg GlobalMethods[] =
{ "StartGameEvent", &LuaGlobalFunctions::StartGameEvent },
{ "StopGameEvent", &LuaGlobalFunctions::StopGameEvent },
{ "HttpRequest", &LuaGlobalFunctions::HttpRequest },
{ "SetOwnerHalaa", &LuaGlobalFunctions::SetOwnerHalaa },

{ NULL, NULL }
};
Expand Down