mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
Added Spawn object to lua and functions to manipulate them
This commit is contained in:
parent
0dc66b3dd7
commit
b904689a98
@ -49,6 +49,7 @@ SET(zone_sources
|
||||
lua_parser.cpp
|
||||
lua_parser_events.cpp
|
||||
lua_raid.cpp
|
||||
lua_spawn.cpp
|
||||
lua_spell.cpp
|
||||
embperl.cpp
|
||||
embxs.cpp
|
||||
@ -157,6 +158,7 @@ SET(zone_headers
|
||||
lua_parser_events.h
|
||||
lua_ptr.h
|
||||
lua_raid.h
|
||||
lua_spawn.h
|
||||
lua_spell.h
|
||||
map.h
|
||||
masterentity.h
|
||||
|
||||
@ -1874,6 +1874,23 @@ Corpse* EntityList::GetCorpseByName(const char* name){
|
||||
return 0;
|
||||
}
|
||||
|
||||
Spawn2* EntityList::GetSpawnByID(uint32 id) {
|
||||
if(!zone)
|
||||
return nullptr;
|
||||
|
||||
LinkedListIterator<Spawn2*> iterator(zone->spawn2_list);
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements())
|
||||
{
|
||||
if(iterator.GetData()->GetID() == id) {
|
||||
return iterator.GetData();
|
||||
}
|
||||
iterator.Advance();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void EntityList::RemoveAllCorpsesByCharID(uint32 charid)
|
||||
{
|
||||
LinkedListIterator<Corpse*> iterator(corpse_list);
|
||||
@ -4796,6 +4813,21 @@ void EntityList::GetDoorsList(std::list<Doors*> &o_list)
|
||||
}
|
||||
}
|
||||
|
||||
void EntityList::GetSpawnList(std::list<Spawn2*> &o_list)
|
||||
{
|
||||
o_list.clear();
|
||||
if(zone) {
|
||||
LinkedListIterator<Spawn2*> iterator(zone->spawn2_list);
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements())
|
||||
{
|
||||
Spawn2 *ent = iterator.GetData();
|
||||
o_list.push_back(ent);
|
||||
iterator.Advance();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EntityList::UpdateQGlobal(uint32 qid, QGlobal newGlobal)
|
||||
{
|
||||
LinkedListIterator<Mob*> iterator(mob_list);
|
||||
|
||||
@ -159,6 +159,8 @@ public:
|
||||
Corpse* GetCorpseByDBID(uint32 dbid);
|
||||
Corpse* GetCorpseByName(const char* name);
|
||||
|
||||
Spawn2* GetSpawnByID(uint32 id);
|
||||
|
||||
Client* FindCorpseDragger(const char *CorpseName);
|
||||
|
||||
Object* GetObjectByID(uint16 id);
|
||||
@ -393,6 +395,7 @@ public:
|
||||
void GetCorpseList(std::list<Corpse*> &c_list);
|
||||
void GetObjectList(std::list<Object*> &o_list);
|
||||
void GetDoorsList(std::list<Doors*> &d_list);
|
||||
void GetSpawnList(std::list<Spawn2*> &d_list);
|
||||
void GetTargetsForConeArea(Mob *start, uint32 radius, uint32 height, std::list<Mob*> &m_list);
|
||||
|
||||
void DepopAll(int NPCTypeID, bool StartSpawnTimer = true);
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include "lua_corpse.h"
|
||||
#include "lua_group.h"
|
||||
#include "lua_raid.h"
|
||||
#include "lua_spawn.h"
|
||||
|
||||
struct Lua_Mob_List {
|
||||
std::vector<Lua_Mob> entries;
|
||||
@ -40,6 +41,10 @@ struct Lua_Doors_List {
|
||||
std::vector<Lua_Door> entries;
|
||||
};
|
||||
|
||||
struct Lua_Spawn_List {
|
||||
std::vector<Lua_Spawn> entries;
|
||||
};
|
||||
|
||||
Lua_Mob Lua_EntityList::GetMobID(int id) {
|
||||
Lua_Safe_Call_Class(Lua_Mob);
|
||||
return Lua_Mob(self->GetMobID(id));
|
||||
@ -170,6 +175,11 @@ Lua_Corpse Lua_EntityList::GetCorpseByName(const char *name) {
|
||||
return Lua_Corpse(self->GetCorpseByName(name));
|
||||
}
|
||||
|
||||
Lua_Spawn Lua_EntityList::GetSpawnByID(uint32 id) {
|
||||
Lua_Safe_Call_Class(Lua_Spawn);
|
||||
return self->GetSpawnByID(id);
|
||||
}
|
||||
|
||||
void Lua_EntityList::ClearClientPetitionQueue() {
|
||||
Lua_Safe_Call_Void();
|
||||
self->ClearClientPetitionQueue();
|
||||
@ -376,6 +386,21 @@ Lua_Doors_List Lua_EntityList::GetDoorsList() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Lua_Spawn_List Lua_EntityList::GetSpawnList() {
|
||||
Lua_Safe_Call_Class(Lua_Spawn_List);
|
||||
Lua_Spawn_List ret;
|
||||
std::list<Spawn2*> t_list;
|
||||
self->GetSpawnList(t_list);
|
||||
|
||||
auto iter = t_list.begin();
|
||||
while(iter != t_list.end()) {
|
||||
ret.entries.push_back(Lua_Spawn(*iter));
|
||||
++iter;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Lua_EntityList::SignalAllClients(int signal) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->SignalAllClients(signal);
|
||||
@ -412,6 +437,7 @@ luabind::scope lua_register_entity_list() {
|
||||
.def("GetCorpseByOwner", (Lua_Corpse(Lua_EntityList::*)(Lua_Client))&Lua_EntityList::GetCorpseByOwner)
|
||||
.def("GetCorpseByID", (Lua_Corpse(Lua_EntityList::*)(int))&Lua_EntityList::GetCorpseByID)
|
||||
.def("GetCorpseByName", (Lua_Corpse(Lua_EntityList::*)(const char*))&Lua_EntityList::GetCorpseByName)
|
||||
.def("GetSpawnByID", (Lua_Spawn(Lua_EntityList::*)(uint32))&Lua_EntityList::GetSpawnByID)
|
||||
.def("ClearClientPetitionQueue", (void(Lua_EntityList::*)(void))&Lua_EntityList::ClearClientPetitionQueue)
|
||||
.def("CanAddHateForMob", (bool(Lua_EntityList::*)(Lua_Mob))&Lua_EntityList::CanAddHateForMob)
|
||||
.def("Message", (void(Lua_EntityList::*)(uint32,uint32,const char*))&Lua_EntityList::Message)
|
||||
@ -440,6 +466,7 @@ luabind::scope lua_register_entity_list() {
|
||||
.def("GetCorpseList", (Lua_Corpse_List(Lua_EntityList::*)(void))&Lua_EntityList::GetCorpseList)
|
||||
.def("GetObjectList", (Lua_Object_List(Lua_EntityList::*)(void))&Lua_EntityList::GetObjectList)
|
||||
.def("GetDoorsList", (Lua_Doors_List(Lua_EntityList::*)(void))&Lua_EntityList::GetDoorsList)
|
||||
.def("GetSpawnList", (Lua_Spawn_List(Lua_EntityList::*)(void))&Lua_EntityList::GetSpawnList)
|
||||
.def("SignalAllClients", (void(Lua_EntityList::*)(int))&Lua_EntityList::SignalAllClients);
|
||||
}
|
||||
|
||||
@ -473,4 +500,9 @@ luabind::scope lua_register_door_list() {
|
||||
.def_readwrite("entries", &Lua_Doors_List::entries, luabind::return_stl_iterator);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_spawn_list() {
|
||||
return luabind::class_<Lua_Spawn_List>("SpawnList")
|
||||
.def_readwrite("entries", &Lua_Spawn_List::entries, luabind::return_stl_iterator);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -13,12 +13,14 @@ class Lua_Corpse;
|
||||
class Lua_Object;
|
||||
class Lua_Group;
|
||||
class Lua_Raid;
|
||||
class Lua_Spawn;
|
||||
struct Lua_Mob_List;
|
||||
struct Lua_Client_List;
|
||||
struct Lua_NPC_List;
|
||||
struct Lua_Corpse_List;
|
||||
struct Lua_Object_List;
|
||||
struct Lua_Doors_List;
|
||||
struct Lua_Spawn_List;
|
||||
|
||||
namespace luabind {
|
||||
struct scope;
|
||||
@ -31,6 +33,7 @@ luabind::scope lua_register_npc_list();
|
||||
luabind::scope lua_register_corpse_list();
|
||||
luabind::scope lua_register_object_list();
|
||||
luabind::scope lua_register_door_list();
|
||||
luabind::scope lua_register_spawn_list();
|
||||
|
||||
class Lua_EntityList : public Lua_Ptr<EntityList>
|
||||
{
|
||||
@ -70,6 +73,7 @@ public:
|
||||
Lua_Corpse GetCorpseByOwner(Lua_Client client);
|
||||
Lua_Corpse GetCorpseByID(int id);
|
||||
Lua_Corpse GetCorpseByName(const char *name);
|
||||
Lua_Spawn GetSpawnByID(uint32 id);
|
||||
void ClearClientPetitionQueue();
|
||||
bool CanAddHateForMob(Lua_Mob p);
|
||||
void Message(uint32 guild_dbid, uint32 type, const char *message);
|
||||
@ -98,6 +102,7 @@ public:
|
||||
Lua_Corpse_List GetCorpseList();
|
||||
Lua_Object_List GetObjectList();
|
||||
Lua_Doors_List GetDoorsList();
|
||||
Lua_Spawn_List GetSpawnList();
|
||||
void SignalAllClients(int signal);
|
||||
};
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ struct Factions { };
|
||||
struct Slots { };
|
||||
struct Materials { };
|
||||
struct ClientVersions { };
|
||||
struct Appearances { };
|
||||
|
||||
struct lua_registered_event {
|
||||
std::string encounter_name;
|
||||
@ -763,6 +764,17 @@ int lua_get_zone_weather() {
|
||||
return zone->zone_weather;
|
||||
}
|
||||
|
||||
luabind::object lua_get_zone_time(lua_State *L) {
|
||||
TimeOfDay_Struct eqTime;
|
||||
zone->zone_time.getEQTimeOfDay(time(0), &eqTime);
|
||||
|
||||
luabind::object ret = luabind::newtable(L);
|
||||
ret["zone_hour"] = eqTime.hour - 1;
|
||||
ret["zone_minute"] = eqTime.minute;
|
||||
ret["zone_time"] = (eqTime.hour - 1) * 100 + eqTime.minute;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void lua_add_area(int id, int type, float min_x, float max_x, float min_y, float max_y, float min_z, float max_z) {
|
||||
entity_list.AddArea(id, type, min_x, max_x, min_y, max_y, min_z, max_z);
|
||||
}
|
||||
@ -775,15 +787,186 @@ void lua_clear_areas() {
|
||||
entity_list.ClearAreas();
|
||||
}
|
||||
|
||||
luabind::object lua_get_zone_time(lua_State *L) {
|
||||
TimeOfDay_Struct eqTime;
|
||||
zone->zone_time.getEQTimeOfDay(time(0), &eqTime);
|
||||
void lua_remove_spawn_point(uint32 spawn2_id) {
|
||||
if(zone) {
|
||||
LinkedListIterator<Spawn2*> iter(zone->spawn2_list);
|
||||
iter.Reset();
|
||||
|
||||
luabind::object ret = luabind::newtable(L);
|
||||
ret["zone_hour"] = eqTime.hour - 1;
|
||||
ret["zone_minute"] = eqTime.minute;
|
||||
ret["zone_time"] = (eqTime.hour - 1) * 100 + eqTime.minute;
|
||||
return ret;
|
||||
while(iter.MoreElements()) {
|
||||
Spawn2* cur = iter.GetData();
|
||||
if(cur->GetID() == spawn2_id) {
|
||||
cur->ForceDespawn();
|
||||
iter.RemoveCurrent(true);
|
||||
return;
|
||||
}
|
||||
|
||||
iter.Advance();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lua_add_spawn_point(luabind::object table) {
|
||||
if(!zone)
|
||||
return;
|
||||
|
||||
if(luabind::type(table) == LUA_TTABLE) {
|
||||
uint32 spawn2_id;
|
||||
uint32 spawngroup_id;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float heading;
|
||||
uint32 respawn;
|
||||
uint32 variance;
|
||||
uint32 timeleft = 0;
|
||||
uint32 grid = 0;
|
||||
int condition_id = 0;
|
||||
int condition_min_value = 0;
|
||||
bool enabled = true;
|
||||
int animation = 0;
|
||||
|
||||
auto cur = table["spawn2_id"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
spawn2_id = luabind::object_cast<uint32>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
cur = table["spawngroup_id"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
spawngroup_id = luabind::object_cast<uint32>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
cur = table["x"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
x = luabind::object_cast<float>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
cur = table["y"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
y = luabind::object_cast<float>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
cur = table["z"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
z = luabind::object_cast<float>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
cur = table["heading"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
heading = luabind::object_cast<float>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
cur = table["respawn"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
respawn = luabind::object_cast<uint32>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
cur = table["variance"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
variance = luabind::object_cast<uint32>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
cur = table["timeleft"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
timeleft = luabind::object_cast<uint32>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
}
|
||||
}
|
||||
|
||||
cur = table["grid"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
grid = luabind::object_cast<uint32>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
}
|
||||
}
|
||||
|
||||
cur = table["condition_id"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
condition_id = luabind::object_cast<int>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
}
|
||||
}
|
||||
|
||||
cur = table["condition_min_value"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
condition_min_value = luabind::object_cast<int>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
}
|
||||
}
|
||||
|
||||
cur = table["enabled"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
enabled = luabind::object_cast<bool>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
}
|
||||
}
|
||||
|
||||
cur = table["animation"];
|
||||
if(luabind::type(cur) != LUA_TNIL) {
|
||||
try {
|
||||
animation = luabind::object_cast<int>(cur);
|
||||
} catch(luabind::cast_failed) {
|
||||
}
|
||||
}
|
||||
|
||||
lua_remove_spawn_point(spawn2_id);
|
||||
|
||||
Spawn2 *t = new Spawn2(spawn2_id, spawngroup_id, x, y, z, heading, respawn, variance, timeleft, grid, condition_id,
|
||||
condition_min_value, enabled, static_cast<EmuAppearance>(animation));
|
||||
zone->spawn2_list.Insert(t);
|
||||
}
|
||||
}
|
||||
|
||||
luabind::scope lua_register_general() {
|
||||
@ -932,7 +1115,9 @@ luabind::scope lua_register_general() {
|
||||
luabind::def("get_zone_time", &lua_get_zone_time),
|
||||
luabind::def("add_area", &lua_add_area),
|
||||
luabind::def("remove_area", &lua_remove_area),
|
||||
luabind::def("clear_areas", &lua_clear_areas)
|
||||
luabind::def("clear_areas", &lua_clear_areas),
|
||||
luabind::def("add_spawn_point", &lua_add_spawn_point),
|
||||
luabind::def("remove_spawn_point", &lua_remove_spawn_point)
|
||||
];
|
||||
}
|
||||
|
||||
@ -1098,4 +1283,16 @@ luabind::scope lua_register_client_version() {
|
||||
];
|
||||
}
|
||||
|
||||
luabind::scope lua_register_appearance() {
|
||||
return luabind::class_<Appearances>("Appearance")
|
||||
.enum_("constants")
|
||||
[
|
||||
luabind::value("Standing", static_cast<int>(eaStanding)),
|
||||
luabind::value("Sitting", static_cast<int>(eaSitting)),
|
||||
luabind::value("Crouching", static_cast<int>(eaCrouching)),
|
||||
luabind::value("Dead", static_cast<int>(eaDead)),
|
||||
luabind::value("Looting", static_cast<int>(eaLooting))
|
||||
];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -8,6 +8,7 @@ luabind::scope lua_register_faction();
|
||||
luabind::scope lua_register_slot();
|
||||
luabind::scope lua_register_material();
|
||||
luabind::scope lua_register_client_version();
|
||||
luabind::scope lua_register_appearance();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@ -27,6 +27,7 @@
|
||||
#include "lua_corpse.h"
|
||||
#include "lua_object.h"
|
||||
#include "lua_door.h"
|
||||
#include "lua_spawn.h"
|
||||
#include "lua_general.h"
|
||||
#include "questmgr.h"
|
||||
#include "zone.h"
|
||||
@ -886,6 +887,7 @@ void LuaParser::MapFunctions(lua_State *L) {
|
||||
lua_register_slot(),
|
||||
lua_register_material(),
|
||||
lua_register_client_version(),
|
||||
lua_register_appearance(),
|
||||
lua_register_entity(),
|
||||
lua_register_mob(),
|
||||
lua_register_npc(),
|
||||
@ -895,6 +897,7 @@ void LuaParser::MapFunctions(lua_State *L) {
|
||||
lua_register_iteminst(),
|
||||
lua_register_item(),
|
||||
lua_register_spell(),
|
||||
lua_register_spawn(),
|
||||
lua_register_hate_entry(),
|
||||
lua_register_hate_list(),
|
||||
lua_register_entity_list(),
|
||||
@ -904,6 +907,7 @@ void LuaParser::MapFunctions(lua_State *L) {
|
||||
lua_register_corpse_list(),
|
||||
lua_register_object_list(),
|
||||
lua_register_door_list(),
|
||||
lua_register_spawn_list(),
|
||||
lua_register_group(),
|
||||
lua_register_raid(),
|
||||
lua_register_corpse(),
|
||||
|
||||
174
zone/lua_spawn.cpp
Normal file
174
zone/lua_spawn.cpp
Normal file
@ -0,0 +1,174 @@
|
||||
#ifdef LUA_EQEMU
|
||||
|
||||
#include "lua.hpp"
|
||||
#include <luabind/luabind.hpp>
|
||||
|
||||
#include "spawn2.h"
|
||||
#include "lua_npc.h"
|
||||
#include "lua_spawn.h"
|
||||
|
||||
void Lua_Spawn::LoadGrid() {
|
||||
Lua_Safe_Call_Void();
|
||||
self->LoadGrid();
|
||||
}
|
||||
|
||||
void Lua_Spawn::Enable() {
|
||||
Lua_Safe_Call_Void();
|
||||
return self->Enable();
|
||||
}
|
||||
|
||||
void Lua_Spawn::Disable() {
|
||||
Lua_Safe_Call_Void();
|
||||
return self->Disable();
|
||||
}
|
||||
|
||||
bool Lua_Spawn::Enabled() {
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->Enabled();
|
||||
}
|
||||
|
||||
void Lua_Spawn::Reset() {
|
||||
Lua_Safe_Call_Void();
|
||||
self->Reset();
|
||||
}
|
||||
|
||||
void Lua_Spawn::Depop() {
|
||||
Lua_Safe_Call_Void();
|
||||
self->Depop();
|
||||
}
|
||||
|
||||
void Lua_Spawn::Repop() {
|
||||
Lua_Safe_Call_Void();
|
||||
self->Repop();
|
||||
}
|
||||
|
||||
void Lua_Spawn::Repop(uint32 delay) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->Repop(delay);
|
||||
}
|
||||
|
||||
void Lua_Spawn::ForceDespawn() {
|
||||
Lua_Safe_Call_Void();
|
||||
self->ForceDespawn();
|
||||
}
|
||||
|
||||
uint32 Lua_Spawn::GetID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetID();
|
||||
}
|
||||
|
||||
float Lua_Spawn::GetX() {
|
||||
Lua_Safe_Call_Real();
|
||||
return self->GetX();
|
||||
}
|
||||
|
||||
float Lua_Spawn::GetY() {
|
||||
Lua_Safe_Call_Real();
|
||||
return self->GetY();
|
||||
}
|
||||
|
||||
float Lua_Spawn::GetZ() {
|
||||
Lua_Safe_Call_Real();
|
||||
return self->GetZ();
|
||||
}
|
||||
|
||||
float Lua_Spawn::GetHeading() {
|
||||
Lua_Safe_Call_Real();
|
||||
return self->GetHeading();
|
||||
}
|
||||
|
||||
void Lua_Spawn::SetRespawnTimer(uint32 newrespawntime) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->SetRespawnTimer(newrespawntime);
|
||||
}
|
||||
|
||||
void Lua_Spawn::SetVariance(uint32 newvariance) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->SetVariance(newvariance);
|
||||
}
|
||||
|
||||
uint32 Lua_Spawn::GetVariance() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetVariance();
|
||||
}
|
||||
|
||||
uint32 Lua_Spawn::RespawnTimer() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->RespawnTimer();
|
||||
}
|
||||
|
||||
uint32 Lua_Spawn::SpawnGroupID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->SpawnGroupID();
|
||||
}
|
||||
|
||||
uint32 Lua_Spawn::CurrentNPCID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->CurrentNPCID();
|
||||
}
|
||||
|
||||
void Lua_Spawn::SetCurrentNPCID(uint32 nid) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->SetCurrentNPCID(nid);
|
||||
}
|
||||
|
||||
uint32 Lua_Spawn::GetSpawnCondition() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetSpawnCondition();
|
||||
}
|
||||
|
||||
bool Lua_Spawn::NPCPointerValid() {
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->NPCPointerValid();
|
||||
}
|
||||
|
||||
void Lua_Spawn::SetNPCPointer(Lua_NPC n) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->SetNPCPointer(n);
|
||||
}
|
||||
|
||||
void Lua_Spawn::SetTimer(uint32 duration) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->SetTimer(duration);
|
||||
}
|
||||
|
||||
uint32 Lua_Spawn::GetKillCount() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetKillCount();
|
||||
}
|
||||
|
||||
|
||||
luabind::scope lua_register_spawn() {
|
||||
return luabind::class_<Lua_Spawn>("Spawn")
|
||||
.def(luabind::constructor<>())
|
||||
.property("null", &Lua_Spawn::Null)
|
||||
.property("valid", &Lua_Spawn::Valid)
|
||||
.def("LoadGrid", (void(Lua_Spawn::*)(void))&Lua_Spawn::LoadGrid)
|
||||
.def("Enable", (void(Lua_Spawn::*)(void))&Lua_Spawn::Enable)
|
||||
.def("Disable", (void(Lua_Spawn::*)(void))&Lua_Spawn::Disable)
|
||||
.def("Enabled", (bool(Lua_Spawn::*)(void))&Lua_Spawn::Enabled)
|
||||
.def("Reset", (void(Lua_Spawn::*)(void))&Lua_Spawn::Reset)
|
||||
.def("Depop", (void(Lua_Spawn::*)(void))&Lua_Spawn::Depop)
|
||||
.def("Repop", (void(Lua_Spawn::*)(void))&Lua_Spawn::Repop)
|
||||
.def("Repop", (void(Lua_Spawn::*)(uint32))&Lua_Spawn::Repop)
|
||||
.def("ForceDespawn", (void(Lua_Spawn::*)(void))&Lua_Spawn::ForceDespawn)
|
||||
.def("GetID", (uint32(Lua_Spawn::*)(void))&Lua_Spawn::GetID)
|
||||
.def("GetX", (float(Lua_Spawn::*)(void))&Lua_Spawn::GetX)
|
||||
.def("GetY", (float(Lua_Spawn::*)(void))&Lua_Spawn::GetY)
|
||||
.def("GetZ", (float(Lua_Spawn::*)(void))&Lua_Spawn::GetZ)
|
||||
.def("GetHeading", (float(Lua_Spawn::*)(void))&Lua_Spawn::GetHeading)
|
||||
.def("SetRespawnTimer", (void(Lua_Spawn::*)(uint32))&Lua_Spawn::SetRespawnTimer)
|
||||
.def("SetVariance", (void(Lua_Spawn::*)(uint32))&Lua_Spawn::SetVariance)
|
||||
.def("GetVariance", (uint32(Lua_Spawn::*)(void))&Lua_Spawn::GetVariance)
|
||||
.def("RespawnTimer", (uint32(Lua_Spawn::*)(void))&Lua_Spawn::RespawnTimer)
|
||||
.def("SpawnGroupID", (uint32(Lua_Spawn::*)(void))&Lua_Spawn::SpawnGroupID)
|
||||
.def("CurrentNPCID", (uint32(Lua_Spawn::*)(void))&Lua_Spawn::CurrentNPCID)
|
||||
.def("SetCurrentNPCID", (void(Lua_Spawn::*)(uint32))&Lua_Spawn::SetCurrentNPCID)
|
||||
.def("GetSpawnCondition", (uint32(Lua_Spawn::*)(void))&Lua_Spawn::GetSpawnCondition)
|
||||
.def("NPCPointerValid", (bool(Lua_Spawn::*)(void))&Lua_Spawn::NPCPointerValid)
|
||||
.def("SetNPCPointer", (void(Lua_Spawn::*)(Lua_NPC))&Lua_Spawn::SetNPCPointer)
|
||||
.def("SetTimer", (void(Lua_Spawn::*)(uint32))&Lua_Spawn::SetTimer)
|
||||
.def("GetKillCount", (uint32(Lua_Spawn::*)(void))&Lua_Spawn::GetKillCount);
|
||||
}
|
||||
|
||||
#endif
|
||||
57
zone/lua_spawn.h
Normal file
57
zone/lua_spawn.h
Normal file
@ -0,0 +1,57 @@
|
||||
#ifndef EQEMU_LUA_SPAWN_H
|
||||
#define EQEMU_LUA_SPAWN_H
|
||||
#ifdef LUA_EQEMU
|
||||
|
||||
#include "lua_ptr.h"
|
||||
|
||||
class Spawn2;
|
||||
class Lua_NPC;
|
||||
|
||||
namespace luabind {
|
||||
struct scope;
|
||||
}
|
||||
|
||||
luabind::scope lua_register_spawn();
|
||||
|
||||
class Lua_Spawn : public Lua_Ptr<Spawn2>
|
||||
{
|
||||
typedef Spawn2 NativeType;
|
||||
public:
|
||||
Lua_Spawn() : Lua_Ptr(nullptr) { }
|
||||
Lua_Spawn(Spawn2 *d) : Lua_Ptr(d) { }
|
||||
virtual ~Lua_Spawn() { }
|
||||
|
||||
operator Spawn2*() {
|
||||
return reinterpret_cast<Spawn2*>(GetLuaPtrData());
|
||||
}
|
||||
|
||||
void LoadGrid();
|
||||
void Enable();
|
||||
void Disable();
|
||||
bool Enabled();
|
||||
void Reset();
|
||||
void Depop();
|
||||
void Repop();
|
||||
void Repop(uint32 delay);
|
||||
void ForceDespawn();
|
||||
uint32 GetID();
|
||||
float GetX();
|
||||
float GetY();
|
||||
float GetZ();
|
||||
float GetHeading();
|
||||
void SetRespawnTimer(uint32 newrespawntime);
|
||||
void SetVariance(uint32 newvariance);
|
||||
uint32 GetVariance();
|
||||
uint32 RespawnTimer();
|
||||
uint32 SpawnGroupID();
|
||||
uint32 CurrentNPCID();
|
||||
void SetCurrentNPCID(uint32 nid);
|
||||
uint32 GetSpawnCondition();
|
||||
bool NPCPointerValid();
|
||||
void SetNPCPointer(Lua_NPC n);
|
||||
void SetTimer(uint32 duration);
|
||||
uint32 GetKillCount();
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@ -64,8 +64,6 @@ public:
|
||||
uint32 CurrentNPCID() { return currentnpcid; }
|
||||
void SetCurrentNPCID(uint32 nid) { currentnpcid = nid; }
|
||||
uint32 GetSpawnCondition() { return condition_id; }
|
||||
uint32 spawn2_id;
|
||||
uint32 respawn_;
|
||||
|
||||
bool NPCPointerValid() { return (npcthis!=nullptr); }
|
||||
void SetNPCPointer(NPC* n) { npcthis = n; }
|
||||
@ -75,6 +73,8 @@ protected:
|
||||
friend class Zone;
|
||||
Timer timer;
|
||||
private:
|
||||
uint32 spawn2_id;
|
||||
uint32 respawn_;
|
||||
uint32 resetTimer();
|
||||
uint32 despawnTimer(uint32 despawn_timer);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user