Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
WorldObjectMethods.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2010 - 2013 Eluna Lua Engine <http://emudevs.com/>
3
* This program is free software licensed under GPL version 3
4
* Please see the included DOCS/LICENSE.TXT for more information
5
*/
6
7
#include "
WorldObjectMethods.h
"
8
#include "
Includes.h
"
9
10
#include "
Creature.h
"
11
#include "
GameObject.h
"
12
#include "
ObjectAccessor.h
"
13
#include "
Player.h
"
14
15
namespace
LuaWorldObject
16
{
17
int
GetName
(lua_State* L,
WorldObject
* obj)
18
{
19
sEluna
->Push(L, obj->
GetName
());
20
return
1;
21
}
22
23
int
GetMap
(lua_State* L,
WorldObject
* obj)
24
{
25
sEluna
->Push(L, obj->
GetMap
());
26
return
1;
27
}
28
29
int
GetPhaseMask
(lua_State* L,
WorldObject
* obj)
30
{
31
sEluna
->Push(L, obj->
GetPhaseMask
());
32
return
1;
33
}
34
35
int
GetInstanceId
(lua_State* L,
WorldObject
* obj)
36
{
37
sEluna
->Push(L, obj->
GetInstanceId
());
38
return
1;
39
}
40
41
int
GetAreaId
(lua_State* L,
WorldObject
* obj)
42
{
43
sEluna
->Push(L, obj->
GetAreaId
());
44
return
1;
45
}
46
47
int
GetZoneId
(lua_State* L,
WorldObject
* obj)
48
{
49
sEluna
->Push(L, obj->
GetZoneId
());
50
return
1;
51
}
52
53
int
GetMapId
(lua_State* L,
WorldObject
* obj)
54
{
55
sEluna
->Push(L, obj->
GetMapId
());
56
return
1;
57
}
58
59
int
GetX
(lua_State* L,
WorldObject
* obj)
60
{
61
sEluna
->Push(L, obj->
GetPositionX
());
62
return
1;
63
}
64
65
int
GetY
(lua_State* L,
WorldObject
* obj)
66
{
67
sEluna
->Push(L, obj->
GetPositionY
());
68
return
1;
69
}
70
71
int
GetZ
(lua_State* L,
WorldObject
* obj)
72
{
73
sEluna
->Push(L, obj->
GetPositionZ
());
74
return
1;
75
}
76
77
int
GetO
(lua_State* L,
WorldObject
* obj)
78
{
79
sEluna
->Push(L, obj->
GetOrientation
());
80
return
1;
81
}
82
83
int
GetLocation
(lua_State* L,
WorldObject
* obj)
84
{
85
sEluna
->Push(L, obj->
GetPositionX
());
86
sEluna
->Push(L, obj->
GetPositionY
());
87
sEluna
->Push(L, obj->
GetPositionZ
());
88
sEluna
->Push(L, obj->
GetOrientation
());
89
return
4;
90
}
91
92
int
GetNearestPlayer
(lua_State* L,
WorldObject
* obj)
93
{
94
// float range = luaL_optnumber(L, 1, SIZE_OF_GRIDS);
95
96
// Player* target = nullptr;
97
// Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEID_PLAYER);
98
// Trinity::PlayerLastSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, target, checker);
99
100
// sEluna->Push(L, target);
101
return
1;
102
}
103
104
int
GetNearestGameObject
(lua_State* L,
WorldObject
* obj)
// hackfix
105
{
106
// float range = luaL_optnumber(L, 1, SIZE_OF_GRIDS);
107
// uint32 entry = luaL_optunsigned(L, 2, 0);
108
109
// GameObject* target = nullptr;
110
// Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEID_GAMEOBJECT, entry);
111
// Trinity::GameObjectLastSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, target, checker);
112
// obj->VisitNearbyGridObject(range, searcher);
113
114
// sEluna->Push(L, target);
115
return
1;
116
}
117
118
int
GetNearestCreature
(lua_State* L,
WorldObject
* obj)
// hackfix
119
{
120
// float range = luaL_optnumber(L, 1, SIZE_OF_GRIDS);
121
// uint32 entry = luaL_optunsigned(L, 2, 0);
122
123
// Creature* target = nullptr;
124
// Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEID_UNIT, entry);
125
// Trinity::CreatureLastSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, target, checker);
126
// obj->VisitNearbyGridObject(range, searcher);
127
128
// sEluna->Push(L, target);
129
return
1;
130
}
131
132
int
GetPlayersInRange
(lua_State* L,
WorldObject
* obj)
// hackfix
133
{
134
// float range = luaL_optnumber(L, 1, SIZE_OF_GRIDS);
135
136
// std::list<Player*> list;
137
// Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEID_PLAYER);
138
// Trinity::PlayerListSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, list, checker);
139
// obj->VisitNearbyWorldObject(range, searcher);
140
141
// lua_newtable(L);
142
// int tbl = lua_gettop(L);
143
// uint32 i = 0;
144
145
// for (std::list<Player*>::const_iterator it = list.begin(); it != list.end(); ++it)
146
// {
147
// sEluna->Push(L, ++i);
148
// sEluna->Push(L, *it);
149
// lua_settable(L, tbl);
150
// }
151
152
// lua_settop(L, tbl);
153
return
1;
154
}
155
156
int
GetCreaturesInRange
(lua_State* L,
WorldObject
* obj)
// hackfix
157
{
158
// float range = luaL_optnumber(L, 1, SIZE_OF_GRIDS);
159
// uint32 entry = luaL_optunsigned(L, 2, 0);
160
161
// std::list<Creature*> list;
162
// Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEID_UNIT);
163
// Trinity::CreatureListSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, list, checker);
164
// obj->VisitNearbyGridObject(range, searcher);
165
166
// lua_newtable(L);
167
// int tbl = lua_gettop(L);
168
// uint32 i = 0;
169
170
// for (std::list<Creature*>::const_iterator it = list.begin(); it != list.end(); ++it)
171
// {
172
// sEluna->Push(L, ++i);
173
// sEluna->Push(L, *it);
174
// lua_settable(L, tbl);
175
// }
176
177
// lua_settop(L, tbl);
178
return
1;
179
}
180
181
int
GetGameObjectsInRange
(lua_State* L,
WorldObject
* obj)
// hackfix
182
{
183
// float range = luaL_optnumber(L, 1, SIZE_OF_GRIDS);
184
// uint32 entry = luaL_optunsigned(L, 2, 0);
185
186
// float x, y, z;
187
// obj->GetPosition(x, y, z);
188
// std::list<GameObject*> list;
189
// Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEID_GAMEOBJECT);
190
// Trinity::GameObjectListSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, list, checker);
191
// obj->VisitNearbyGridObject(range, searcher);
192
193
// lua_newtable(L);
194
// int tbl = lua_gettop(L);
195
// uint32 i = 0;
196
197
// for (std::list<GameObject*>::const_iterator it = list.begin(); it != list.end(); ++it)
198
// {
199
// sEluna->Push(L, ++i);
200
// sEluna->Push(L, *it);
201
// lua_settable(L, tbl);
202
// }
203
204
// lua_settop(L, tbl);
205
return
1;
206
}
207
208
int
GetWorldObject
(lua_State* L,
WorldObject
* obj)
209
{
210
ObjectGuid
guid(
uint64
(
sEluna
->CHECK_ULONG(L, 1)));
211
212
sEluna
->Push(L,
ElunaGetWorldObject
(*obj, guid));
213
return
1;
214
}
215
216
};
Creature.h
uint64
std::uint64_t uint64
Definition
Define.h:76
ElunaGetWorldObject
WorldObject * ElunaGetWorldObject(WorldObject const &context, uint64 guid)
Definition
ElunaCompatibility.h:43
GameObject.h
Includes.h
sEluna
#define sEluna
Definition
LuaEngine.h:710
ObjectAccessor.h
Player.h
WorldObjectMethods.h
WorldLocation::GetMapId
uint32 GetMapId() const
Definition
Object.h:546
WorldObject
Definition
Object.h:610
WorldObject::GetPhaseMask
uint32 GetPhaseMask() const
Definition
Object.h:643
WorldObject::GetMap
Map * GetMap() const
Definition
Object.h:740
WorldObject::GetInstanceId
uint32 GetInstanceId() const
Definition
Object.h:638
WorldObject::GetName
std::string const & GetName() const
Definition
Object.h:664
WorldObject::GetAreaId
uint32 GetAreaId() const
Definition
Object.cpp:1602
WorldObject::GetZoneId
uint32 GetZoneId() const
Definition
Object.cpp:1597
LuaWorldObject
Definition
WorldObjectMethods.cpp:16
LuaWorldObject::GetGameObjectsInRange
int GetGameObjectsInRange(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:181
LuaWorldObject::GetNearestPlayer
int GetNearestPlayer(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:92
LuaWorldObject::GetX
int GetX(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:59
LuaWorldObject::GetPlayersInRange
int GetPlayersInRange(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:132
LuaWorldObject::GetName
int GetName(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:17
LuaWorldObject::GetNearestCreature
int GetNearestCreature(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:118
LuaWorldObject::GetInstanceId
int GetInstanceId(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:35
LuaWorldObject::GetWorldObject
int GetWorldObject(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:208
LuaWorldObject::GetY
int GetY(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:65
LuaWorldObject::GetMapId
int GetMapId(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:53
LuaWorldObject::GetNearestGameObject
int GetNearestGameObject(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:104
LuaWorldObject::GetPhaseMask
int GetPhaseMask(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:29
LuaWorldObject::GetLocation
int GetLocation(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:83
LuaWorldObject::GetMap
int GetMap(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:23
LuaWorldObject::GetCreaturesInRange
int GetCreaturesInRange(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:156
LuaWorldObject::GetZoneId
int GetZoneId(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:47
LuaWorldObject::GetAreaId
int GetAreaId(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:41
LuaWorldObject::GetZ
int GetZ(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:71
LuaWorldObject::GetO
int GetO(lua_State *L, WorldObject *obj)
Definition
WorldObjectMethods.cpp:77
ObjectGuid
Definition
ByteBuffer.h:66
Position::GetPositionZ
float GetPositionZ() const
Definition
Object.h:330
Position::GetOrientation
float GetOrientation() const
Definition
Object.h:331
Position::GetPositionX
float GetPositionX() const
Definition
Object.h:328
Position::GetPositionY
float GetPositionY() const
Definition
Object.h:329
src
server
game
LuaEngine
WorldObjectMethods.cpp
Generated on
for Project SkyFire Core by
1.17.0