(PlayerMethods): Taxi Node Improvements (#357)

This commit is contained in:
Aldori
2026-02-13 03:39:54 -05:00
committed by GitHub
parent a9bc344db5
commit fe47a5d9c3
2 changed files with 31 additions and 2 deletions

View File

@@ -707,6 +707,7 @@ ALERegister<Player> PlayerMethods[] =
{ "IsAtLootRewardDistance", &LuaPlayer::IsAtLootRewardDistance },
{ "CanTeleport", &LuaPlayer::CanTeleport },
{ "IsSpectator", &LuaPlayer::IsSpectator },
{ "HasKnownTaxiNode", &LuaPlayer::HasKnownTaxiNode },
// { "HasSpellMod", &LuaPlayer::HasSpellMod },
// Gossip

View File

@@ -1634,6 +1634,8 @@ namespace LuaPlayer
ByteBuffer data;
player->m_taxi.AppendTaximaskTo(data, false);
uint32 idx = 1;
for (uint8 i = 0; i < TaxiMaskSize; i++)
{
uint32 mask;
@@ -1641,11 +1643,11 @@ namespace LuaPlayer
for (uint8 bit = 0; bit < 32; bit++)
{
if (mask & (1 << bit))
if (mask & (1u << bit))
{
uint32 nodeId = (i * 32) + bit + 1;
lua_pushinteger(L, nodeId);
lua_rawseti(L, -2, lua_rawlen(L, -2) + 1);
lua_rawseti(L, -2, idx++);
}
}
}
@@ -4981,6 +4983,32 @@ namespace LuaPlayer
player->ApplyRatingMod(CombatRating(stat), value, apply);
return 0;
}
/**
* Returns `true` if the [Player] knows the given taxi node, `false` otherwise.
*
* @param uint32 nodeId
* @return bool known
*/
int HasKnownTaxiNode(lua_State* L, Player* player)
{
if (!player)
{
ALE::Push(L, false);
return 1;
}
uint32 nodeId = ALE::CHECKVAL<uint32>(L, 2);
if (nodeId == 0)
{
ALE::Push(L, false);
return 1;
}
ALE::Push(L, player->m_taxi.IsTaximaskNodeKnown(nodeId));
return 1;
}
};
#endif