eluna-scripts-ornfelt/lua/WowEmulationScriptPack/Lua/globals/creatures.ext
2024-09-23 07:59:23 +02:00

34 lines
No EOL
1.5 KiB
Text

-- filename.ext files are loaded before normal .lua files
-- This file will contain functions that will act as shortcuts to commonly used code, but only for Eluna code that affects Creatures.
-- Add a comment on the same line as the function start, AND EXPLAIN WHAT IT DOES AND WHY IT EXISTS!
function GetCreatureXYZ(objectGUID) -- Replace this with a non-DB query as soon as possible.
if (objectGUID == tonumber(objectGUID)) then
local creatureQuery = {}
local creatureQuery = WorldDBQuery("SELECT map,position_x,position_y,position_z,orientation FROM creature WHERE guid = " .. objectGUID .. ";")
local creatureCoords = {
map = creatureQuery:GetFloat(0),
x = creatureQuery:GetFloat(1),
y = creatureQuery:GetFloat(2),
z = creatureQuery:GetFloat(3),
o = creatureQuery:GetFloat(4),
};
return creatureCoords
else
PrintInfo("Something is feeding GetCreatureXYZ invalid GUIDs.")
return false
end
end
function GetCreatureEntryID(objectGUID) -- Replace this with a non-DB query as soon as possible.
if (objectGUID == tonumber(objectGUID)) then
local creatureQuery = {}
local creatureQuery = WorldDBQuery("SELECT id FROM creature WHERE guid = " .. objectGUID .. ";")
local creatureEntryID = creatureQuery:GetUInt32(0)
return creatureEntryID
else
PrintInfo("Something is feeding GetCreatureEntryID invalid GUIDs.")
return false
end
end