mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Add GetReactState to CreatureMethods and GetKnownTaxiNodes, SetKnownTaxiNodes to PlayerMethods (#285)
Co-authored-by: iThorgrim <125808072+iThorgrim@users.noreply.github.com>
This commit is contained in:
@@ -543,6 +543,7 @@ ElunaRegister<Player> PlayerMethods[] =
|
||||
{ "GetPlayerSettingValue", &LuaPlayer::GetPlayerSettingValue },
|
||||
{ "GetTrader", &LuaPlayer::GetTrader },
|
||||
{ "GetBonusTalentCount", &LuaPlayer::GetBonusTalentCount },
|
||||
{ "GetKnownTaxiNodes", &LuaPlayer::GetKnownTaxiNodes },
|
||||
|
||||
// Setters
|
||||
{ "AdvanceSkillsToMax", &LuaPlayer::AdvanceSkillsToMax },
|
||||
@@ -559,6 +560,7 @@ ElunaRegister<Player> PlayerMethods[] =
|
||||
{ "SetLifetimeKills", &LuaPlayer::SetLifetimeKills },
|
||||
{ "SetGameMaster", &LuaPlayer::SetGameMaster },
|
||||
{ "SetGMChat", &LuaPlayer::SetGMChat },
|
||||
{ "SetKnownTaxiNodes", &LuaPlayer::SetKnownTaxiNodes },
|
||||
{ "SetTaxiCheat", &LuaPlayer::SetTaxiCheat },
|
||||
{ "SetGMVisible", &LuaPlayer::SetGMVisible },
|
||||
{ "SetPvPDeath", &LuaPlayer::SetPvPDeath },
|
||||
@@ -785,6 +787,7 @@ ElunaRegister<Creature> CreatureMethods[] =
|
||||
{ "GetShieldBlockValue", &LuaCreature::GetShieldBlockValue },
|
||||
{ "GetDBTableGUIDLow", &LuaCreature::GetDBTableGUIDLow },
|
||||
{ "GetCreatureFamily", &LuaCreature::GetCreatureFamily },
|
||||
{ "GetReactState", &LuaCreature::GetReactState },
|
||||
|
||||
// Setters
|
||||
{ "SetRegeneratingHealth", &LuaCreature::SetRegeneratingHealth },
|
||||
|
||||
@@ -841,6 +841,27 @@ namespace LuaCreature
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Creature]'s current ReactState.
|
||||
*
|
||||
* <pre>
|
||||
* enum ReactState
|
||||
* {
|
||||
* REACT_PASSIVE = 0,
|
||||
* REACT_DEFENSIVE = 1,
|
||||
* REACT_AGGRESSIVE = 2
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @return [ReactState] state
|
||||
*/
|
||||
int GetReactState(lua_State* L, Creature* creature)
|
||||
{
|
||||
ReactStates state = creature->GetReactState();
|
||||
lua_pushinteger(L, (int)state);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the [Creature]'s NPC flags to `flags`.
|
||||
*
|
||||
|
||||
@@ -1659,6 +1659,40 @@ namespace LuaPlayer
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns known taxi nodes (flight paths) that the player has unlocked.
|
||||
*
|
||||
* @return table nodes : A table containing the IDs of the known taxi nodes
|
||||
*/
|
||||
int GetKnownTaxiNodes(lua_State* L, Player* player)
|
||||
{
|
||||
if (!player)
|
||||
return 0;
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
ByteBuffer data;
|
||||
player->m_taxi.AppendTaximaskTo(data, false);
|
||||
|
||||
for (uint8 i = 0; i < TaxiMaskSize; i++)
|
||||
{
|
||||
uint32 mask;
|
||||
data >> mask;
|
||||
|
||||
for (uint8 bit = 0; bit < 32; bit++)
|
||||
{
|
||||
if (mask & (1 << bit))
|
||||
{
|
||||
uint8 nodeId = (i * 32) + bit + 1;
|
||||
lua_pushinteger(L, nodeId);
|
||||
lua_rawseti(L, -2, lua_rawlen(L, -2) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*int GetRecruiterId(lua_State* L, Player* player)
|
||||
{
|
||||
Eluna::Push(L, player->GetSession()->GetRecruiterId());
|
||||
@@ -1893,6 +1927,34 @@ namespace LuaPlayer
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the player's known taxi nodes (flight paths).
|
||||
*
|
||||
* @param table nodes : A table containing the taxi node IDs to set as known
|
||||
*/
|
||||
int SetKnownTaxiNodes(lua_State* L, Player* player)
|
||||
{
|
||||
if (!player)
|
||||
return 0;
|
||||
|
||||
if (!lua_istable(L, 2))
|
||||
return 0;
|
||||
|
||||
lua_pushnil(L);
|
||||
|
||||
while (lua_next(L, 2) != 0)
|
||||
{
|
||||
uint32 nodeId = luaL_checkinteger(L, -1);
|
||||
|
||||
if (nodeId > 0)
|
||||
player->m_taxi.SetTaximaskNode(nodeId);
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles whether the [Player] has taxi cheat enabled or not
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user