Project SkyFire Core
SkyFire 5.4.8 server core API documentation
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
8#include "Includes.h"
9
10#include "Creature.h"
11#include "GameObject.h"
12#include "ObjectAccessor.h"
13#include "Player.h"
14
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};
std::uint64_t uint64
Definition Define.h:76
WorldObject * ElunaGetWorldObject(WorldObject const &context, uint64 guid)
#define sEluna
Definition LuaEngine.h:710
uint32 GetMapId() const
Definition Object.h:546
uint32 GetPhaseMask() const
Definition Object.h:643
Map * GetMap() const
Definition Object.h:740
uint32 GetInstanceId() const
Definition Object.h:638
std::string const & GetName() const
Definition Object.h:664
uint32 GetAreaId() const
Definition Object.cpp:1602
uint32 GetZoneId() const
Definition Object.cpp:1597
int GetGameObjectsInRange(lua_State *L, WorldObject *obj)
int GetNearestPlayer(lua_State *L, WorldObject *obj)
int GetX(lua_State *L, WorldObject *obj)
int GetPlayersInRange(lua_State *L, WorldObject *obj)
int GetName(lua_State *L, WorldObject *obj)
int GetNearestCreature(lua_State *L, WorldObject *obj)
int GetInstanceId(lua_State *L, WorldObject *obj)
int GetWorldObject(lua_State *L, WorldObject *obj)
int GetY(lua_State *L, WorldObject *obj)
int GetMapId(lua_State *L, WorldObject *obj)
int GetNearestGameObject(lua_State *L, WorldObject *obj)
int GetPhaseMask(lua_State *L, WorldObject *obj)
int GetLocation(lua_State *L, WorldObject *obj)
int GetMap(lua_State *L, WorldObject *obj)
int GetCreaturesInRange(lua_State *L, WorldObject *obj)
int GetZoneId(lua_State *L, WorldObject *obj)
int GetAreaId(lua_State *L, WorldObject *obj)
int GetZ(lua_State *L, WorldObject *obj)
int GetO(lua_State *L, WorldObject *obj)
float GetPositionZ() const
Definition Object.h:330
float GetOrientation() const
Definition Object.h:331
float GetPositionX() const
Definition Object.h:328
float GetPositionY() const
Definition Object.h:329