mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
Update to encounter timers so they can actually work from hooked events
This commit is contained in:
parent
dbd07106d7
commit
0b17dc73f1
@ -20,7 +20,7 @@ SET(zone_sources
|
|||||||
embparser_api.cpp
|
embparser_api.cpp
|
||||||
embperl.cpp
|
embperl.cpp
|
||||||
embxs.cpp
|
embxs.cpp
|
||||||
encounter.cpp
|
encounter.cpp
|
||||||
entity.cpp
|
entity.cpp
|
||||||
exp.cpp
|
exp.cpp
|
||||||
fearpath.cpp
|
fearpath.cpp
|
||||||
@ -36,6 +36,7 @@ SET(zone_sources
|
|||||||
lua_corpse.cpp
|
lua_corpse.cpp
|
||||||
lua_client.cpp
|
lua_client.cpp
|
||||||
lua_door.cpp
|
lua_door.cpp
|
||||||
|
lua_encounter.cpp
|
||||||
lua_entity.cpp
|
lua_entity.cpp
|
||||||
lua_entity_list.cpp
|
lua_entity_list.cpp
|
||||||
lua_general.cpp
|
lua_general.cpp
|
||||||
@ -138,7 +139,7 @@ SET(zone_headers
|
|||||||
embparser.h
|
embparser.h
|
||||||
embperl.h
|
embperl.h
|
||||||
embxs.h
|
embxs.h
|
||||||
encounter.h
|
encounter.h
|
||||||
entity.h
|
entity.h
|
||||||
errmsg.h
|
errmsg.h
|
||||||
event_codes.h
|
event_codes.h
|
||||||
@ -150,6 +151,7 @@ SET(zone_headers
|
|||||||
lua_bit.h
|
lua_bit.h
|
||||||
lua_client.h
|
lua_client.h
|
||||||
lua_corpse.h
|
lua_corpse.h
|
||||||
|
lua_encounter.h
|
||||||
lua_entity.h
|
lua_entity.h
|
||||||
lua_entity_list.h
|
lua_entity_list.h
|
||||||
lua_general.h
|
lua_general.h
|
||||||
|
|||||||
14
zone/lua_encounter.cpp
Normal file
14
zone/lua_encounter.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifdef LUA_EQEMU
|
||||||
|
|
||||||
|
#include "lua.hpp"
|
||||||
|
#include <luabind/luabind.hpp>
|
||||||
|
#include "lua_encounter.h"
|
||||||
|
#include "encounter.h"
|
||||||
|
|
||||||
|
|
||||||
|
luabind::scope lua_register_encounter() {
|
||||||
|
return luabind::class_<Lua_Encounter>("Encounter")
|
||||||
|
.def(luabind::constructor<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
30
zone/lua_encounter.h
Normal file
30
zone/lua_encounter.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef EQEMU_LUA_ENCOUNTER_H
|
||||||
|
#define EQEMU_LUA_ENCOUNTER_H
|
||||||
|
#ifdef LUA_EQEMU
|
||||||
|
|
||||||
|
#include "lua_ptr.h"
|
||||||
|
|
||||||
|
class Encounter;
|
||||||
|
|
||||||
|
namespace luabind {
|
||||||
|
struct scope;
|
||||||
|
class object;
|
||||||
|
}
|
||||||
|
|
||||||
|
luabind::scope lua_register_encounter();
|
||||||
|
|
||||||
|
class Lua_Encounter : public Lua_Ptr<Encounter>
|
||||||
|
{
|
||||||
|
typedef Encounter NativeType;
|
||||||
|
public:
|
||||||
|
Lua_Encounter() { SetLuaPtrData(nullptr); }
|
||||||
|
Lua_Encounter(Encounter *d) { SetLuaPtrData(reinterpret_cast<Encounter*>(d)); }
|
||||||
|
virtual ~Lua_Encounter() { }
|
||||||
|
|
||||||
|
operator Encounter*() {
|
||||||
|
return reinterpret_cast<Encounter*>(GetLuaPtrData());
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@ -19,6 +19,7 @@
|
|||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
#include "../common/eqemu_logsys.h"
|
#include "../common/eqemu_logsys.h"
|
||||||
#include "encounter.h"
|
#include "encounter.h"
|
||||||
|
#include "lua_encounter.h"
|
||||||
|
|
||||||
struct Events { };
|
struct Events { };
|
||||||
struct Factions { };
|
struct Factions { };
|
||||||
@ -296,6 +297,10 @@ void lua_set_timer(const char *timer, int time_ms, Lua_Mob mob) {
|
|||||||
quest_manager.settimerMS(timer, time_ms, mob);
|
quest_manager.settimerMS(timer, time_ms, mob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lua_set_timer(const char *timer, int time_ms, Lua_Encounter enc) {
|
||||||
|
quest_manager.settimerMS(timer, time_ms, enc);
|
||||||
|
}
|
||||||
|
|
||||||
void lua_stop_timer(const char *timer) {
|
void lua_stop_timer(const char *timer) {
|
||||||
quest_manager.stoptimer(timer);
|
quest_manager.stoptimer(timer);
|
||||||
}
|
}
|
||||||
@ -1457,6 +1462,7 @@ luabind::scope lua_register_general() {
|
|||||||
luabind::def("set_timer", (void(*)(const char*, int))&lua_set_timer),
|
luabind::def("set_timer", (void(*)(const char*, int))&lua_set_timer),
|
||||||
luabind::def("set_timer", (void(*)(const char*, int, Lua_ItemInst))&lua_set_timer),
|
luabind::def("set_timer", (void(*)(const char*, int, Lua_ItemInst))&lua_set_timer),
|
||||||
luabind::def("set_timer", (void(*)(const char*, int, Lua_Mob))&lua_set_timer),
|
luabind::def("set_timer", (void(*)(const char*, int, Lua_Mob))&lua_set_timer),
|
||||||
|
luabind::def("set_timer", (void(*)(const char*, int, Lua_Encounter))&lua_set_timer),
|
||||||
luabind::def("stop_timer", (void(*)(const char*))&lua_stop_timer),
|
luabind::def("stop_timer", (void(*)(const char*))&lua_stop_timer),
|
||||||
luabind::def("stop_timer", (void(*)(const char*, Lua_ItemInst))&lua_stop_timer),
|
luabind::def("stop_timer", (void(*)(const char*, Lua_ItemInst))&lua_stop_timer),
|
||||||
luabind::def("stop_timer", (void(*)(const char*, Lua_Mob))&lua_stop_timer),
|
luabind::def("stop_timer", (void(*)(const char*, Lua_Mob))&lua_stop_timer),
|
||||||
|
|||||||
@ -34,6 +34,7 @@
|
|||||||
#include "questmgr.h"
|
#include "questmgr.h"
|
||||||
#include "zone.h"
|
#include "zone.h"
|
||||||
#include "lua_parser.h"
|
#include "lua_parser.h"
|
||||||
|
#include "lua_encounter.h"
|
||||||
|
|
||||||
const char *LuaEvents[_LargestEventID] = {
|
const char *LuaEvents[_LargestEventID] = {
|
||||||
"event_say",
|
"event_say",
|
||||||
@ -610,10 +611,11 @@ int LuaParser::_EventEncounter(std::string package_name, QuestEventID evt, std::
|
|||||||
lua_pushstring(L, encounter_name.c_str());
|
lua_pushstring(L, encounter_name.c_str());
|
||||||
lua_setfield(L, -2, "name");
|
lua_setfield(L, -2, "name");
|
||||||
|
|
||||||
auto arg_function = EncounterArgumentDispatch[evt];
|
|
||||||
arg_function(this, L, data, extra_data, extra_pointers);
|
|
||||||
|
|
||||||
Encounter *enc = lua_encounters[encounter_name];
|
Encounter *enc = lua_encounters[encounter_name];
|
||||||
|
|
||||||
|
auto arg_function = EncounterArgumentDispatch[evt];
|
||||||
|
arg_function(this, L, enc, data, extra_data, extra_pointers);
|
||||||
|
|
||||||
quest_manager.StartQuest(enc, nullptr, nullptr, encounter_name);
|
quest_manager.StartQuest(enc, nullptr, nullptr, encounter_name);
|
||||||
if(lua_pcall(L, 1, 1, 0)) {
|
if(lua_pcall(L, 1, 1, 0)) {
|
||||||
std::string error = lua_tostring(L, -1);
|
std::string error = lua_tostring(L, -1);
|
||||||
@ -977,6 +979,7 @@ void LuaParser::MapFunctions(lua_State *L) {
|
|||||||
lua_register_client_version(),
|
lua_register_client_version(),
|
||||||
lua_register_appearance(),
|
lua_register_appearance(),
|
||||||
lua_register_entity(),
|
lua_register_entity(),
|
||||||
|
lua_register_encounter(),
|
||||||
lua_register_mob(),
|
lua_register_mob(),
|
||||||
lua_register_special_abilities(),
|
lua_register_special_abilities(),
|
||||||
lua_register_npc(),
|
lua_register_npc(),
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#include "lua_door.h"
|
#include "lua_door.h"
|
||||||
#include "lua_object.h"
|
#include "lua_object.h"
|
||||||
#include "lua_packet.h"
|
#include "lua_packet.h"
|
||||||
|
#include "lua_encounter.h"
|
||||||
#include "zone.h"
|
#include "zone.h"
|
||||||
#include "lua_parser_events.h"
|
#include "lua_parser_events.h"
|
||||||
|
|
||||||
@ -704,14 +705,20 @@ void handle_spell_null(QuestInterface *parse, lua_State* L, NPC* npc, Client* cl
|
|||||||
std::vector<EQEmu::Any> *extra_pointers) {
|
std::vector<EQEmu::Any> *extra_pointers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_encounter_timer(QuestInterface *parse, lua_State* L, std::string data, uint32 extra_data,
|
void handle_encounter_timer(QuestInterface *parse, lua_State* L, Encounter* encounter, std::string data, uint32 extra_data,
|
||||||
std::vector<EQEmu::Any> *extra_pointers) {
|
std::vector<EQEmu::Any> *extra_pointers) {
|
||||||
lua_pushstring(L, data.c_str());
|
lua_pushstring(L, data.c_str());
|
||||||
lua_setfield(L, -2, "timer");
|
lua_setfield(L, -2, "timer");
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_encounter_load(QuestInterface *parse, lua_State* L, std::string data, uint32 extra_data,
|
void handle_encounter_load(QuestInterface *parse, lua_State* L, Encounter* encounter, std::string data, uint32 extra_data,
|
||||||
std::vector<EQEmu::Any> *extra_pointers) {
|
std::vector<EQEmu::Any> *extra_pointers) {
|
||||||
|
if (encounter) {
|
||||||
|
Lua_Encounter l_enc(encounter);
|
||||||
|
luabind::adl::object l_enc_o = luabind::adl::object(L, l_enc);
|
||||||
|
l_enc_o.push(L);
|
||||||
|
lua_setfield(L, -2, "encounter");
|
||||||
|
}
|
||||||
if (extra_pointers) {
|
if (extra_pointers) {
|
||||||
std::string *str = EQEmu::any_cast<std::string*>(extra_pointers->at(0));
|
std::string *str = EQEmu::any_cast<std::string*>(extra_pointers->at(0));
|
||||||
lua_pushstring(L, str->c_str());
|
lua_pushstring(L, str->c_str());
|
||||||
@ -719,7 +726,7 @@ void handle_encounter_load(QuestInterface *parse, lua_State* L, std::string data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_encounter_unload(QuestInterface *parse, lua_State* L, std::string data, uint32 extra_data,
|
void handle_encounter_unload(QuestInterface *parse, lua_State* L, Encounter* encounter, std::string data, uint32 extra_data,
|
||||||
std::vector<EQEmu::Any> *extra_pointers) {
|
std::vector<EQEmu::Any> *extra_pointers) {
|
||||||
if (extra_pointers) {
|
if (extra_pointers) {
|
||||||
std::string *str = EQEmu::any_cast<std::string*>(extra_pointers->at(0));
|
std::string *str = EQEmu::any_cast<std::string*>(extra_pointers->at(0));
|
||||||
@ -728,7 +735,7 @@ void handle_encounter_unload(QuestInterface *parse, lua_State* L, std::string da
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_encounter_null(QuestInterface *parse, lua_State* L, std::string data, uint32 extra_data,
|
void handle_encounter_null(QuestInterface *parse, lua_State* L, Encounter* encounter, std::string data, uint32 extra_data,
|
||||||
std::vector<EQEmu::Any> *extra_pointers) {
|
std::vector<EQEmu::Any> *extra_pointers) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ typedef void(*NPCArgumentHandler)(QuestInterface*, lua_State*, NPC*, Mob*, std::
|
|||||||
typedef void(*PlayerArgumentHandler)(QuestInterface*, lua_State*, Client*, std::string, uint32, std::vector<EQEmu::Any>*);
|
typedef void(*PlayerArgumentHandler)(QuestInterface*, lua_State*, Client*, std::string, uint32, std::vector<EQEmu::Any>*);
|
||||||
typedef void(*ItemArgumentHandler)(QuestInterface*, lua_State*, Client*, ItemInst*, Mob*, std::string, uint32, std::vector<EQEmu::Any>*);
|
typedef void(*ItemArgumentHandler)(QuestInterface*, lua_State*, Client*, ItemInst*, Mob*, std::string, uint32, std::vector<EQEmu::Any>*);
|
||||||
typedef void(*SpellArgumentHandler)(QuestInterface*, lua_State*, NPC*, Client*, uint32, uint32, std::vector<EQEmu::Any>*);
|
typedef void(*SpellArgumentHandler)(QuestInterface*, lua_State*, NPC*, Client*, uint32, uint32, std::vector<EQEmu::Any>*);
|
||||||
typedef void(*EncounterArgumentHandler)(QuestInterface*, lua_State*, std::string, uint32, std::vector<EQEmu::Any>*);
|
typedef void(*EncounterArgumentHandler)(QuestInterface*, lua_State*, Encounter* encounter, std::string, uint32, std::vector<EQEmu::Any>*);
|
||||||
|
|
||||||
//NPC
|
//NPC
|
||||||
void handle_npc_event_say(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
void handle_npc_event_say(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||||
@ -130,13 +130,13 @@ void handle_spell_null(QuestInterface *parse, lua_State* L, NPC* npc, Client* cl
|
|||||||
|
|
||||||
|
|
||||||
//Encounter
|
//Encounter
|
||||||
void handle_encounter_timer(QuestInterface *parse, lua_State* L, std::string data, uint32 extra_data,
|
void handle_encounter_timer(QuestInterface *parse, lua_State* L, Encounter* encounter, std::string data, uint32 extra_data,
|
||||||
std::vector<EQEmu::Any> *extra_pointers);
|
std::vector<EQEmu::Any> *extra_pointers);
|
||||||
void handle_encounter_load(QuestInterface *parse, lua_State* L, std::string data, uint32 extra_data,
|
void handle_encounter_load(QuestInterface *parse, lua_State* L, Encounter* encounter, std::string data, uint32 extra_data,
|
||||||
std::vector<EQEmu::Any> *extra_pointers);
|
std::vector<EQEmu::Any> *extra_pointers);
|
||||||
void handle_encounter_unload(QuestInterface *parse, lua_State* L, std::string data, uint32 extra_data,
|
void handle_encounter_unload(QuestInterface *parse, lua_State* L, Encounter* encounter, std::string data, uint32 extra_data,
|
||||||
std::vector<EQEmu::Any> *extra_pointers);
|
std::vector<EQEmu::Any> *extra_pointers);
|
||||||
void handle_encounter_null(QuestInterface *parse, lua_State* L, std::string data, uint32 extra_data,
|
void handle_encounter_null(QuestInterface *parse, lua_State* L, Encounter* encounter, std::string data, uint32 extra_data,
|
||||||
std::vector<EQEmu::Any> *extra_pointers);
|
std::vector<EQEmu::Any> *extra_pointers);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user