add PlayerisMoving/Swimming/Rooted functions

This commit is contained in:
avitasia
2026-02-15 10:36:21 -08:00
parent f4a4ce5bb4
commit 13b2bd0d3c
9 changed files with 10074 additions and 9893 deletions
+1
View File
@@ -153,6 +153,7 @@ This includes functions for:
- Cooldown tracking (GetSpellIdCooldown, GetItemIdCooldown), including item metadata on cooldown detail tables
- Inventory helpers (GetTrinketCooldown, GetTrinkets, GetAmmo)
- Aura duration tracking and cancel helpers (GetPlayerAuraDuration, CancelPlayerAuraSlot, CancelPlayerAuraSpellId)
- Player movement state queries (PlayerIsMoving, PlayerIsRooted, PlayerIsSwimming)
- Talent helpers (LearnTalentRank)
- Spell lookups and utilities
+55
View File
@@ -47,6 +47,10 @@ For custom events, see [EVENTS.md](EVENTS.md). For installation, configuration,
- [GetTrinkets](#gettrinketscopy)
- [GetTrinketCooldown](#gettrinketcooldownslotitemidorname)
- [UseTrinket](#usetrinketslotitemidorname-target)
- [Player State](#player-state)
- [PlayerIsMoving](#playerismoving)
- [PlayerIsRooted](#playerisrooted)
- [PlayerIsSwimming](#playerisswimming)
- [Utility Functions](#utility-functions)
- [DisenchantAll](#disenchantallitemidorname-includesoulbound-or-disenchantallquality-includesoulbound)
---
@@ -1068,6 +1072,57 @@ Will stop channeling early on the next tick if you have queue channeling spells
---
### Player State
#### PlayerIsMoving()
Returns whether the active player is currently moving.
**Returns:**
- `1` if the player is moving (forward, backward, strafing, jumping, falling, pitching, or on spline elevation)
- `nil` if the player is stationary
**Examples:**
```lua
-- Check if player is moving
if PlayerIsMoving() == 1 then
print("Player is moving")
else
print("Player is stationary")
end
```
#### PlayerIsRooted()
Returns whether the active player is currently rooted (unable to move).
**Returns:**
- `1` if the player is rooted
- `nil` if the player is not rooted
**Examples:**
```lua
-- Check if player is rooted
if PlayerIsRooted() == 1 then
print("Player is rooted!")
end
```
#### PlayerIsSwimming()
Returns whether the active player is currently swimming.
**Returns:**
- `1` if the player is swimming
- `nil` if the player is not swimming
**Examples:**
```lua
-- Check if player is swimming
if PlayerIsSwimming() == 1 then
print("Player is swimming")
end
```
---
### Utility Functions
#### DisenchantAll(itemIdOrName, [includeSoulbound]) or DisenchantAll(quality, [includeSoulbound])
+9900 -9892
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -43,6 +43,8 @@ set(SOURCE_FILES
lua_refs.cpp
autoattack.hpp
autoattack.cpp
player_scripts.hpp
player_scripts.cpp
)
add_library(${DLL_NAME} SHARED ${SOURCE_FILES})
+28
View File
@@ -1641,6 +1641,34 @@ namespace game {
__int32 m_CastTime2; //0x000C
}; //Size=0x0010
enum MovementFlags : uint32_t {
MOVEFLAG_NONE = 0x00000000,
MOVEFLAG_FORWARD = 0x00000001,
MOVEFLAG_BACKWARD = 0x00000002,
MOVEFLAG_STRAFE_LEFT = 0x00000004,
MOVEFLAG_STRAFE_RIGHT = 0x00000008,
MOVEFLAG_TURN_LEFT = 0x00000010,
MOVEFLAG_TURN_RIGHT = 0x00000020,
MOVEFLAG_PITCH_UP = 0x00000040,
MOVEFLAG_PITCH_DOWN = 0x00000080,
MOVEFLAG_WALK_MODE = 0x00000100,
MOVEFLAG_LEVITATING = 0x00000400,
MOVEFLAG_FIXED_Z = 0x00000800,
MOVEFLAG_ROOT = 0x00001000,
MOVEFLAG_JUMPING = 0x00002000,
MOVEFLAG_FALLINGFAR = 0x00004000,
MOVEFLAG_SWIMMING = 0x00200000,
MOVEFLAG_SPLINE_ENABLED = 0x00400000,
MOVEFLAG_CAN_FLY = 0x00800000,
MOVEFLAG_FLYING = 0x01000000,
MOVEFLAG_ONTRANSPORT = 0x02000000,
MOVEFLAG_SPLINE_ELEVATION = 0x04000000,
MOVEFLAG_WATERWALKING = 0x10000000,
MOVEFLAG_SAFE_FALL = 0x20000000,
MOVEFLAG_HOVER = 0x40000000,
MOVEFLAG_INTERNAL = 0x80000000,
};
enum UnitFlags {
UNIT_FLAG_NONE = 0x00000000,
UNIT_FLAG_UNK_0 = 0x00000001, // Movement checks disabled, likely paired with loss of client control packet.
+10
View File
@@ -35,6 +35,7 @@
#include "spellcast.hpp"
#include "misc_scripts.hpp"
#include "spell_scripts.hpp"
#include "player_scripts.hpp"
#include "spellchannel.hpp"
#include "helper.hpp"
#include "items.hpp"
@@ -1701,6 +1702,15 @@ namespace Nampower {
char learnTalentRank[] = "LearnTalentRank";
RegisterLuaFunction(learnTalentRank, reinterpret_cast<uintptr_t *>(Script_LearnTalentRank));
char playerIsMoving[] = "PlayerIsMoving";
RegisterLuaFunction(playerIsMoving, reinterpret_cast<uintptr_t *>(Script_PlayerIsMoving));
char playerIsRooted[] = "PlayerIsRooted";
RegisterLuaFunction(playerIsRooted, reinterpret_cast<uintptr_t *>(Script_PlayerIsRooted));
char playerIsSwimming[] = "PlayerIsSwimming";
RegisterLuaFunction(playerIsSwimming, reinterpret_cast<uintptr_t *>(Script_PlayerIsSwimming));
}
void load() {
+1 -1
View File
@@ -25,7 +25,7 @@ namespace Nampower {
constexpr uint32_t DISENCHANT_QUALITY_PURPLE = 0x04; // Epic
constexpr uint32_t MAJOR_VERSION = 2;
constexpr uint32_t MINOR_VERSION = 35;
constexpr uint32_t MINOR_VERSION = 36;
constexpr uint32_t PATCH_VERSION = 0;
constexpr int32_t LUA_REGISTRYINDEX = -10000;
+63
View File
@@ -0,0 +1,63 @@
//
// Created by pmacc on 2/15/2026.
//
#include "player_scripts.hpp"
#include "helper.hpp"
#include "offsets.hpp"
namespace Nampower {
static uint32_t GetPlayerMovementFlags() {
auto playerGuid = game::ClntObjMgrGetActivePlayerGuid();
if (playerGuid == 0) return 0;
auto unit = game::GetObjectPtr(playerGuid);
if (!unit) return 0;
// Movement flags are at offset 0x9E8 from unit base (divide by 4 for uintptr_t* indexing)
return *(unit + 0x27A);
}
uint32_t Script_PlayerIsMoving(uintptr_t *luaState) {
luaState = GetLuaStatePtr();
auto movementFlags = GetPlayerMovementFlags();
constexpr uint32_t MOVEFLAG_MASK_MOVING =
game::MOVEFLAG_FORWARD | game::MOVEFLAG_BACKWARD |
game::MOVEFLAG_STRAFE_LEFT | game::MOVEFLAG_STRAFE_RIGHT |
game::MOVEFLAG_PITCH_UP | game::MOVEFLAG_PITCH_DOWN |
game::MOVEFLAG_JUMPING | game::MOVEFLAG_FALLINGFAR |
game::MOVEFLAG_SPLINE_ELEVATION;
if (movementFlags & MOVEFLAG_MASK_MOVING) {
lua_pushnumber(luaState, 1);
} else {
lua_pushnil(luaState);
}
return 1;
}
uint32_t Script_PlayerIsRooted(uintptr_t *luaState) {
luaState = GetLuaStatePtr();
auto movementFlags = GetPlayerMovementFlags();
if (movementFlags & game::MOVEFLAG_ROOT) {
lua_pushnumber(luaState, 1);
} else {
lua_pushnil(luaState);
}
return 1;
}
uint32_t Script_PlayerIsSwimming(uintptr_t *luaState) {
luaState = GetLuaStatePtr();
auto movementFlags = GetPlayerMovementFlags();
if (movementFlags & game::MOVEFLAG_SWIMMING) {
lua_pushnumber(luaState, 1);
} else {
lua_pushnil(luaState);
}
return 1;
}
}
+14
View File
@@ -0,0 +1,14 @@
//
// Created by pmacc on 2/15/2026.
//
#pragma once
#include <Windows.h>
#include "main.hpp"
namespace Nampower {
uint32_t Script_PlayerIsMoving(uintptr_t *luaState);
uint32_t Script_PlayerIsRooted(uintptr_t *luaState);
uint32_t Script_PlayerIsSwimming(uintptr_t *luaState);
}