mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Eluna add GetWorldObject by guid to map methods. Closes #64 requires use of guid
This commit is contained in:
@@ -79,7 +79,7 @@ ENDCALL();
|
||||
#define ENDCALL() \
|
||||
if (_LuaReturnValues != LUA_MULTRET && lua_gettop(L) != _LuaStackTop + _LuaReturnValues) \
|
||||
{ \
|
||||
ELUNA_LOG_ERROR("[Eluna]: Ending event %u, stack top was %i and was supposed to be %i. Report to devs", _LuaEvent, lua_gettop(L), _LuaStackTop); \
|
||||
ELUNA_LOG_ERROR("[Eluna]: Ending event %u, stack top was %i and was supposed to be %i. Report to devs", _LuaEvent, lua_gettop(L), _LuaStackTop + _LuaReturnValues); \
|
||||
} \
|
||||
lua_settop(L, _LuaStackTop);
|
||||
|
||||
|
||||
@@ -1129,6 +1129,7 @@ ElunaRegister<Map> MapMethods[] =
|
||||
{ "GetMapId", &LuaMap::GetMapId }, // :GetMapId() - Returns the map's ID UNDOCUMENTED
|
||||
{ "GetAreaId", &LuaMap::GetAreaId }, // :GetAreaId(x, y, z) - Returns the map's area ID based on coords UNDOCUMENTED
|
||||
{ "GetHeight", &LuaMap::GetHeight }, // :GetHeight(x, y[, phasemask]) - Returns ground Z coordinate. UNDOCUMENTED
|
||||
{ "GetWorldObject", &LuaMap::GetWorldObject }, // :GetWorldObject(guid) - Returns a worldobject (player, creature, gameobject..) from the map by it's guid
|
||||
|
||||
// Booleans
|
||||
#ifndef CLASSIC
|
||||
|
||||
37
MapMethods.h
37
MapMethods.h
@@ -114,6 +114,43 @@ namespace LuaMap
|
||||
Eluna::Push(L, map->GetTerrain()->GetAreaId(x, y, z));
|
||||
#else
|
||||
Eluna::Push(L, map->GetAreaId(x, y, z));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetWorldObject(lua_State* L, Map* map)
|
||||
{
|
||||
uint64 guid = Eluna::CHECKVAL<uint64>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
Eluna::Push(L, map->GetWorldObject(ObjectGuid(guid)));
|
||||
#else
|
||||
switch (GUID_HIPART(guid))
|
||||
{
|
||||
case HIGHGUID_PLAYER:
|
||||
Eluna::Push(L, sObjectAccessor->GetObjectInMap(guid, map, (Player*)NULL));
|
||||
break;
|
||||
case HIGHGUID_TRANSPORT:
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
Eluna::Push(L, sObjectAccessor->GetObjectInMap(guid, map, (GameObject*)NULL));
|
||||
break;
|
||||
case HIGHGUID_VEHICLE:
|
||||
case HIGHGUID_UNIT:
|
||||
Eluna::Push(L, sObjectAccessor->GetObjectInMap(guid, map, (Creature*)NULL));
|
||||
break;
|
||||
case HIGHGUID_PET:
|
||||
Eluna::Push(L, sObjectAccessor->GetObjectInMap(guid, map, (Pet*)NULL));
|
||||
break;
|
||||
case HIGHGUID_DYNAMICOBJECT:
|
||||
Eluna::Push(L, sObjectAccessor->GetObjectInMap(guid, map, (DynamicObject*)NULL));
|
||||
break;
|
||||
case HIGHGUID_CORPSE:
|
||||
Eluna::Push(L, sObjectAccessor->GetObjectInMap(guid, map, (Corpse*)NULL));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user