Working on fixing up QuestInterface to make multiple parsers work together in harmony, need to fix up Embperl parser next

This commit is contained in:
KimLS 2013-05-05 23:36:15 -07:00
parent e1c2657b11
commit 6e9e81a890
10 changed files with 678 additions and 605 deletions

View File

@ -113,6 +113,7 @@ OPTION(EQEMU_BUILD_LOGIN "Build the login server." OFF)
OPTION(EQEMU_BUILD_AZONE "Build azone utility." OFF) OPTION(EQEMU_BUILD_AZONE "Build azone utility." OFF)
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF) OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON) OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
OPTION(EQEMU_BUILD_LUA "Build Lua parser." OFF)
#C++11 stuff #C++11 stuff
IF(NOT MSVC) IF(NOT MSVC)
@ -133,6 +134,10 @@ IF(EQEMU_BUILD_PERL)
ADD_DEFINITIONS(-DEMBPERL) ADD_DEFINITIONS(-DEMBPERL)
ADD_DEFINITIONS(-DEMBPERL_PLUGIN) ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
ENDIF(EQEMU_BUILD_PERL) ENDIF(EQEMU_BUILD_PERL)
IF(EQEMU_BUILD_LUA)
ADD_DEFINITIONS(-DLUA_EQEMU)
ENDIF(EQEMU_BUILD_LUA)
ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL}) ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL})
ADD_DEFINITIONS(-DINVERSEXY) ADD_DEFINITIONS(-DINVERSEXY)
ADD_DEFINITIONS(-DFIELD_ITEMS) ADD_DEFINITIONS(-DFIELD_ITEMS)
@ -145,6 +150,12 @@ IF(EQEMU_BUILD_PERL)
FIND_PACKAGE(PerlLibs REQUIRED) FIND_PACKAGE(PerlLibs REQUIRED)
INCLUDE_DIRECTORIES("${PERL_INCLUDE_PATH}") INCLUDE_DIRECTORIES("${PERL_INCLUDE_PATH}")
ENDIF(EQEMU_BUILD_PERL) ENDIF(EQEMU_BUILD_PERL)
IF(EQEMU_BUILD_LUA)
FIND_PACKAGE(Lua51 REQUIRED)
INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}")
ENDIF(EQEMU_BUILD_LUA)
INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${MySQL_INCLUDE_DIR}") INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${MySQL_INCLUDE_DIR}")
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS) IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)

View File

@ -30,6 +30,7 @@ SET(zone_sources
horse.cpp horse.cpp
inventory.cpp inventory.cpp
loottables.cpp loottables.cpp
lua_parser.cpp
Map.cpp Map.cpp
merc.cpp merc.cpp
mob.cpp mob.cpp
@ -109,6 +110,7 @@ SET(zone_headers
guild_mgr.h guild_mgr.h
hate_list.h hate_list.h
horse.h horse.h
lua_parser.h
map.h map.h
masterentity.h masterentity.h
maxskill.h maxskill.h
@ -155,7 +157,7 @@ ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers})
ADD_DEFINITIONS(-DZONE) ADD_DEFINITIONS(-DZONE)
TARGET_LINK_LIBRARIES(zone Common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(zone Common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY} ${LUA_LIBRARY})
IF(MSVC) IF(MSVC)
SET_TARGET_PROPERTIES(zone PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") SET_TARGET_PROPERTIES(zone PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
@ -175,6 +177,4 @@ IF(UNIX)
ADD_DEFINITIONS(-fPIC) ADD_DEFINITIONS(-fPIC)
ENDIF(UNIX) ENDIF(UNIX)
INCLUDE_DIRECTORIES(${VLD_INCLUDE_DIR})
SET(EXECUTABLE_OUTPUT_PATH ../Bin) SET(EXECUTABLE_OUTPUT_PATH ../Bin)

View File

@ -24,6 +24,13 @@ public:
virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname) { return false; } virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname) { return false; }
virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname) { return false; } virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname) { return false; }
virtual void LoadNPCScript(std::string filename, int npc_id) { }
//virtual void LoadGlobalNPCScript(std::string filename) { }
virtual void LoadPlayerScript(std::string filename) { }
//virtual void LoadGlobalPlayerScript(std::string filename) { }
virtual void LoadItemScript(std::string filename, std::string item_script) { }
virtual void LoadSpellScript(std::string filename, uint32 spell_id) { }
virtual void AddVar(std::string name, std::string val) { } virtual void AddVar(std::string name, std::string val) { }
virtual void ReloadQuests(bool reset_timers = true) { } virtual void ReloadQuests(bool reset_timers = true) { }
virtual uint32 GetIdentifier() { return 0; } virtual uint32 GetIdentifier() { return 0; }

View File

@ -14,8 +14,8 @@ extern Zone* zone;
QuestParserCollection::QuestParserCollection() { QuestParserCollection::QuestParserCollection() {
_player_quest_status = QuestUnloaded; _player_quest_status = QuestUnloaded;
_global_player_quest_status = QuestUnloaded; //_global_player_quest_status = QuestUnloaded;
_global_npc_quest_status = QuestUnloaded; //_global_npc_quest_status = QuestUnloaded;
} }
QuestParserCollection::~QuestParserCollection() { QuestParserCollection::~QuestParserCollection() {
@ -38,8 +38,8 @@ void QuestParserCollection::AddVar(std::string name, std::string val) {
void QuestParserCollection::ReloadQuests(bool reset_timers) { void QuestParserCollection::ReloadQuests(bool reset_timers) {
_npc_quest_status.clear(); _npc_quest_status.clear();
_player_quest_status = QuestUnloaded; _player_quest_status = QuestUnloaded;
_global_player_quest_status = QuestUnloaded; //_global_player_quest_status = QuestUnloaded;
_global_npc_quest_status = QuestUnloaded; //_global_npc_quest_status = QuestUnloaded;
_spell_quest_status.clear(); _spell_quest_status.clear();
_item_quest_status.clear(); _item_quest_status.clear();
std::list<QuestInterface*>::iterator iter = _load_precedence.begin(); std::list<QuestInterface*>::iterator iter = _load_precedence.begin();
@ -61,9 +61,12 @@ bool QuestParserCollection::HasQuestSub(uint32 npcid, const char *subname) {
} }
} }
} else { } else {
QuestInterface *qi = GetQIByNPCQuest(npcid); std::string filename;
QuestInterface *qi = GetQIByNPCQuest(npcid, filename);
if(qi) { if(qi) {
_npc_quest_status[npcid] = qi->GetIdentifier(); _npc_quest_status[npcid] = qi->GetIdentifier();
qi->LoadNPCScript(filename, npcid);
if(qi->HasQuestSub(npcid, subname)) { if(qi->HasQuestSub(npcid, subname)) {
return true; return true;
} }
@ -72,40 +75,45 @@ bool QuestParserCollection::HasQuestSub(uint32 npcid, const char *subname) {
} }
} }
if(_global_npc_quest_status == QuestUnloaded){ //if(_global_npc_quest_status == QuestUnloaded){
QuestInterface *qi = GetQIByGlobalNPCQuest(); // std::string filename;
if(qi) { // QuestInterface *qi = GetQIByGlobalNPCQuest(filename);
_global_npc_quest_status = qi->GetIdentifier(); // if(qi) {
if(qi->HasGlobalQuestSub(subname)) { // qi->LoadGlobalNPCScript(filename);
return true; // _global_npc_quest_status = qi->GetIdentifier();
} // if(qi->HasGlobalQuestSub(subname)) {
} // return true;
} else { // }
if(_global_npc_quest_status != QuestFailedToLoad) { // }
std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(_global_npc_quest_status); //} else {
if(qiter->second->HasGlobalQuestSub(subname)) { // if(_global_npc_quest_status != QuestFailedToLoad) {
return true; // std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(_global_npc_quest_status);
} // if(qiter->second->HasGlobalQuestSub(subname)) {
} // return true;
} // }
// }
//}
return false; return false;
} }
bool QuestParserCollection::PlayerHasQuestSub(const char *subname) { bool QuestParserCollection::PlayerHasQuestSub(const char *subname) {
if(_player_quest_status == QuestUnloaded) { if(_player_quest_status == QuestUnloaded) {
QuestInterface *qi = GetQIByGlobalPlayerQuest(); std::string filename;
if(qi) { //QuestInterface *qi = GetQIByGlobalPlayerQuest(filename);
_global_player_quest_status = qi->GetIdentifier(); //if(qi) {
} // _global_player_quest_status = qi->GetIdentifier();
// qi->LoadGlobalPlayerScript(filename);
//}
qi = GetQIByPlayerQuest(); QuestInterface *qi = GetQIByPlayerQuest(filename);
if(qi) { if(qi) {
_player_quest_status = qi->GetIdentifier(); _player_quest_status = qi->GetIdentifier();
return qi->PlayerHasQuestSub(subname) || qi->GlobalPlayerHasQuestSub(subname); qi->LoadPlayerScript(filename);
return qi->PlayerHasQuestSub(subname); // || qi->GlobalPlayerHasQuestSub(subname);
} }
} else if(_player_quest_status != QuestFailedToLoad) { } else if(_player_quest_status != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator iter = _interfaces.find(_player_quest_status); std::map<uint32, QuestInterface*>::iterator iter = _interfaces.find(_player_quest_status);
return iter->second->PlayerHasQuestSub(subname) || iter->second->GlobalPlayerHasQuestSub(subname); return iter->second->PlayerHasQuestSub(subname); // || iter->second->GlobalPlayerHasQuestSub(subname);
} }
return false; return false;
} }
@ -119,9 +127,11 @@ bool QuestParserCollection::SpellHasQuestSub(uint32 spell_id, const char *subnam
return qiter->second->SpellHasQuestSub(spell_id, subname); return qiter->second->SpellHasQuestSub(spell_id, subname);
} }
} else { } else {
QuestInterface *qi = GetQIBySpellQuest(spell_id); std::string filename;
QuestInterface *qi = GetQIBySpellQuest(spell_id, filename);
if(qi) { if(qi) {
_spell_quest_status[spell_id] = qi->GetIdentifier(); _spell_quest_status[spell_id] = qi->GetIdentifier();
qi->LoadSpellScript(filename, spell_id);
return qi->SpellHasQuestSub(spell_id, subname); return qi->SpellHasQuestSub(spell_id, subname);
} else { } else {
_spell_quest_status[spell_id] = QuestFailedToLoad; _spell_quest_status[spell_id] = QuestFailedToLoad;
@ -149,9 +159,11 @@ bool QuestParserCollection::ItemHasQuestSub(ItemInst *itm, const char *subname)
return qiter->second->ItemHasQuestSub(itm, subname); return qiter->second->ItemHasQuestSub(itm, subname);
} }
} else { } else {
QuestInterface *qi = GetQIByItemQuest(item_script); std::string filename;
QuestInterface *qi = GetQIByItemQuest(item_script, filename);
if(qi) { if(qi) {
_item_quest_status[item_script] = qi->GetIdentifier(); _item_quest_status[item_script] = qi->GetIdentifier();
qi->LoadItemScript(filename, item_script);
return qi->ItemHasQuestSub(itm, subname); return qi->ItemHasQuestSub(itm, subname);
} else { } else {
_item_quest_status[item_script] = QuestFailedToLoad; _item_quest_status[item_script] = QuestFailedToLoad;
@ -169,50 +181,58 @@ void QuestParserCollection::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std:
qiter->second->EventNPC(evt, npc, init, data, extra_data); qiter->second->EventNPC(evt, npc, init, data, extra_data);
} }
} else { } else {
QuestInterface *qi = GetQIByNPCQuest(npc->GetNPCTypeID()); std::string filename;
QuestInterface *qi = GetQIByNPCQuest(npc->GetNPCTypeID(), filename);
if(qi) { if(qi) {
_npc_quest_status[npc->GetNPCTypeID()] = qi->GetIdentifier(); _npc_quest_status[npc->GetNPCTypeID()] = qi->GetIdentifier();
qi->LoadNPCScript(filename, npc->GetNPCTypeID());
qi->EventNPC(evt, npc, init, data, extra_data); qi->EventNPC(evt, npc, init, data, extra_data);
} else { } else {
_npc_quest_status[npc->GetNPCTypeID()] = QuestFailedToLoad; _npc_quest_status[npc->GetNPCTypeID()] = QuestFailedToLoad;
} }
} }
// K, lets also parse templates/global_npc.pl //// K, lets also parse templates/global_npc.pl
if(_global_npc_quest_status != QuestUnloaded && _global_npc_quest_status != QuestFailedToLoad) { //if(_global_npc_quest_status != QuestUnloaded && _global_npc_quest_status != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(_global_npc_quest_status); // std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(_global_npc_quest_status);
qiter->second->EventGlobalNPC(evt, npc, init, data, extra_data); // qiter->second->EventGlobalNPC(evt, npc, init, data, extra_data);
} else { //} else {
QuestInterface *qi = GetQIByGlobalNPCQuest(); // std::string filename;
if(qi) { // QuestInterface *qi = GetQIByGlobalNPCQuest(filename);
_global_npc_quest_status = qi->GetIdentifier(); // if(qi) {
qi->EventGlobalNPC(evt, npc, init, data, extra_data); // _global_npc_quest_status = qi->GetIdentifier();
} else { // qi->LoadGlobalNPCScript(filename);
_global_npc_quest_status = QuestFailedToLoad; // qi->EventGlobalNPC(evt, npc, init, data, extra_data);
} // } else {
} // _global_npc_quest_status = QuestFailedToLoad;
// }
//}
} }
void QuestParserCollection::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { void QuestParserCollection::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
if(_player_quest_status == QuestUnloaded) { if(_player_quest_status == QuestUnloaded) {
QuestInterface *qi = GetQIByGlobalPlayerQuest(); std::string filename;
if(qi) { //QuestInterface *qi = GetQIByGlobalPlayerQuest(filename);
_global_player_quest_status = qi->GetIdentifier(); //if(qi) {
qi->EventGlobalPlayer(evt, client, data, extra_data); // _global_player_quest_status = qi->GetIdentifier();
} // qi->LoadGlobalPlayerScript(filename);
// qi->EventGlobalPlayer(evt, client, data, extra_data);
//}
qi = GetQIByPlayerQuest(); QuestInterface *qi = GetQIByPlayerQuest(filename);
if(qi) { if(qi) {
_player_quest_status = qi->GetIdentifier(); _player_quest_status = qi->GetIdentifier();
qi->LoadPlayerScript(filename);
qi->EventPlayer(evt, client, data, extra_data); qi->EventPlayer(evt, client, data, extra_data);
} }
} else { } else {
if(_global_player_quest_status != QuestFailedToLoad) { //if(_global_player_quest_status != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator iter = _interfaces.find(_global_player_quest_status); // std::map<uint32, QuestInterface*>::iterator iter = _interfaces.find(_global_player_quest_status);
if(iter != _interfaces.end()) // if(iter != _interfaces.end())
iter->second->EventGlobalPlayer(evt, client, data, extra_data); // iter->second->EventGlobalPlayer(evt, client, data, extra_data);
} //}
if(_player_quest_status != QuestFailedToLoad) { if(_player_quest_status != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator iter = _interfaces.find(_player_quest_status); std::map<uint32, QuestInterface*>::iterator iter = _interfaces.find(_player_quest_status);
iter->second->EventPlayer(evt, client, data, extra_data); iter->second->EventPlayer(evt, client, data, extra_data);
@ -239,9 +259,11 @@ void QuestParserCollection::EventItem(QuestEventID evt, Client *client, ItemInst
qiter->second->EventItem(evt, client, item, objid, extra_data); qiter->second->EventItem(evt, client, item, objid, extra_data);
} }
} else { } else {
QuestInterface *qi = GetQIByItemQuest(item_script); std::string filename;
QuestInterface *qi = GetQIByItemQuest(item_script, filename);
if(qi) { if(qi) {
_item_quest_status[item_script] = qi->GetIdentifier(); _item_quest_status[item_script] = qi->GetIdentifier();
qi->LoadItemScript(filename, item_script);
qi->EventItem(evt, client, item, objid, extra_data); qi->EventItem(evt, client, item, objid, extra_data);
} else { } else {
_item_quest_status[item_script] = QuestFailedToLoad; _item_quest_status[item_script] = QuestFailedToLoad;
@ -258,9 +280,11 @@ void QuestParserCollection::EventSpell(QuestEventID evt, NPC* npc, Client *clien
qiter->second->EventSpell(evt, npc, client, spell_id, extra_data); qiter->second->EventSpell(evt, npc, client, spell_id, extra_data);
} }
} else { } else {
QuestInterface *qi = GetQIBySpellQuest(spell_id); std::string filename;
QuestInterface *qi = GetQIBySpellQuest(spell_id, filename);
if(qi) { if(qi) {
_spell_quest_status[spell_id] = qi->GetIdentifier(); _spell_quest_status[spell_id] = qi->GetIdentifier();
qi->LoadSpellScript(filename, spell_id);
qi->EventSpell(evt, npc, client, spell_id, extra_data); qi->EventSpell(evt, npc, client, spell_id, extra_data);
} else { } else {
_spell_quest_status[spell_id] = QuestFailedToLoad; _spell_quest_status[spell_id] = QuestFailedToLoad;
@ -268,9 +292,9 @@ void QuestParserCollection::EventSpell(QuestEventID evt, NPC* npc, Client *clien
} }
} }
QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid) { QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string &filename) {
//first look for /quests/zone/npcid.ext (precedence) //first look for /quests/zone/npcid.ext (precedence)
std::string filename = "quests/"; filename = "quests/";
filename += zone->GetShortName(); filename += zone->GetShortName();
filename += "/"; filename += "/";
filename += itoa(npcid); filename += itoa(npcid);
@ -408,13 +432,13 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid) {
return NULL; return NULL;
} }
QuestInterface *QuestParserCollection::GetQIByPlayerQuest() { QuestInterface *QuestParserCollection::GetQIByPlayerQuest(std::string &filename) {
if(!zone) if(!zone)
return NULL; return NULL;
//first look for /quests/zone/player_v[instance_version].ext (precedence) //first look for /quests/zone/player_v[instance_version].ext (precedence)
std::string filename = "quests/"; filename = "quests/";
filename += zone->GetShortName(); filename += zone->GetShortName();
filename += "/"; filename += "/";
filename += "player_v"; filename += "player_v";
@ -481,9 +505,9 @@ QuestInterface *QuestParserCollection::GetQIByPlayerQuest() {
return NULL; return NULL;
} }
QuestInterface *QuestParserCollection::GetQIByGlobalNPCQuest(){ QuestInterface *QuestParserCollection::GetQIByGlobalNPCQuest(std::string &filename) {
// simply look for templates/global_npc.pl // simply look for templates/global_npc.pl
std::string filename = "quests/"; filename = "quests/";
filename += QUEST_TEMPLATES_DIRECTORY; filename += QUEST_TEMPLATES_DIRECTORY;
filename += "/"; filename += "/";
filename += "global_npc"; filename += "global_npc";
@ -508,9 +532,9 @@ QuestInterface *QuestParserCollection::GetQIByGlobalNPCQuest(){
return NULL; return NULL;
} }
QuestInterface *QuestParserCollection::GetQIByGlobalPlayerQuest() { QuestInterface *QuestParserCollection::GetQIByGlobalPlayerQuest(std::string &filename) {
//first look for /quests/templates/player.ext (precedence) //first look for /quests/templates/player.ext (precedence)
std::string filename = "quests/"; filename = "quests/";
filename += QUEST_TEMPLATES_DIRECTORY; filename += QUEST_TEMPLATES_DIRECTORY;
filename += "/"; filename += "/";
filename += "global_player"; filename += "global_player";
@ -535,9 +559,9 @@ QuestInterface *QuestParserCollection::GetQIByGlobalPlayerQuest() {
return NULL; return NULL;
} }
QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id) { QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::string &filename) {
//first look for /quests/spells/spell_id.ext (precedence) //first look for /quests/spells/spell_id.ext (precedence)
std::string filename = "quests/spells/"; filename = "quests/spells/";
filename += itoa(spell_id); filename += itoa(spell_id);
std::string tmp; std::string tmp;
FILE *f = NULL; FILE *f = NULL;
@ -560,9 +584,9 @@ QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id) {
return NULL; return NULL;
} }
QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script) { QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script, std::string &filename) {
//first look for /quests/items/item_script.ext (precedence) //first look for /quests/items/item_script.ext (precedence)
std::string filename = "quests/items/"; filename = "quests/items/";
filename += item_script; filename += item_script;
std::string tmp; std::string tmp;
FILE *f = NULL; FILE *f = NULL;
@ -580,7 +604,7 @@ QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script)
} }
iter++; iter++;
} }
return NULL; return NULL;
} }

View File

@ -35,12 +35,12 @@ public:
void EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data); void EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data);
private: private:
QuestInterface *GetQIByNPCQuest(uint32 npcid); QuestInterface *GetQIByNPCQuest(uint32 npcid, std::string &filename);
QuestInterface *GetQIByGlobalNPCQuest(); QuestInterface *GetQIByGlobalNPCQuest(std::string &filename);
QuestInterface *GetQIByPlayerQuest(); QuestInterface *GetQIByPlayerQuest(std::string &filename);
QuestInterface *GetQIByGlobalPlayerQuest(); QuestInterface *GetQIByGlobalPlayerQuest(std::string &filename);
QuestInterface *GetQIBySpellQuest(uint32 spell_id); QuestInterface *GetQIBySpellQuest(uint32 spell_id, std::string &filename);
QuestInterface *GetQIByItemQuest(std::string item_script); QuestInterface *GetQIByItemQuest(std::string item_script, std::string &filename);
std::map<uint32, QuestInterface*> _interfaces; std::map<uint32, QuestInterface*> _interfaces;
std::map<uint32, std::string> _extensions; std::map<uint32, std::string> _extensions;

File diff suppressed because it is too large Load Diff

View File

@ -118,12 +118,19 @@ public:
virtual void AddVar(std::string name, std::string val) { Parser::AddVar(name, val); }; virtual void AddVar(std::string name, std::string val) { Parser::AddVar(name, val); };
virtual uint32 GetIdentifier() { return 0xf8b05c11; } virtual uint32 GetIdentifier() { return 0xf8b05c11; }
int LoadScript(int npcid, const char * zone, Mob* activater=0); virtual void LoadNPCScript(std::string filename, int npc_id);
int LoadGlobalNPCScript(); virtual void LoadGlobalNPCScript(std::string filename);
int LoadPlayerScript(const char *zone); virtual void LoadPlayerScript(std::string filename);
int LoadGlobalPlayerScript(); virtual void LoadGlobalPlayerScript(std::string filename);
int LoadItemScript(ItemInst* iteminst, string packagename, itemQuestMode Qtype); virtual void LoadItemScript(std::string filename, std::string item_script);
int LoadSpellScript(uint32 id); virtual void LoadSpellScript(std::string filename, uint32 spell_id);
//int LoadScript(int npcid, const char * zone, Mob* activater=0);
//int LoadGlobalNPCScript();
//int LoadPlayerScript(const char *zone);
//int LoadGlobalPlayerScript();
//int LoadItemScript(ItemInst* iteminst, string packagename, itemQuestMode Qtype);
//int LoadSpellScript(uint32 id);
//expose a var to the script (probably parallels addvar)) //expose a var to the script (probably parallels addvar))
//i.e. exportvar("qst1234", "name", "somemob"); //i.e. exportvar("qst1234", "name", "somemob");

4
zone/lua_parser.cpp Normal file
View File

@ -0,0 +1,4 @@
#ifdef LUA_EQEMU
#include "lua_parser.h"
#endif

40
zone/lua_parser.h Normal file
View File

@ -0,0 +1,40 @@
#ifndef _EQE_LUA_PARSER_H
#define _EQE_LUA_PARSER_H
#ifdef LUA_EQEMU
#include <lua.hpp>
#include "QuestParserCollection.h"
#include "QuestInterface.h"
class ItemInst;
class Client;
class NPC;
class LuaParser {
public:
virtual void EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
virtual void EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
virtual void EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
virtual void EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
virtual void EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data);
virtual void EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data);
virtual bool HasQuestSub(uint32 npcid, const char *subname);
virtual bool HasGlobalQuestSub(const char *subname);
virtual bool PlayerHasQuestSub(const char *subname);
virtual bool GlobalPlayerHasQuestSub(const char *subname);
virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname);
virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname);
virtual void AddVar(std::string name, std::string val);
virtual void ReloadQuests(bool reset_timers = true);
virtual uint32 GetIdentifier() { return 0xb0712acc; }
private:
lua_State* L;
};
#endif
#endif

View File

@ -77,6 +77,7 @@ extern volatile bool ZoneLoaded;
#include "parser.h" #include "parser.h"
#include "embparser.h" #include "embparser.h"
#include "perlparser.h" #include "perlparser.h"
#include "lua_parser.h"
#include "client_logs.h" #include "client_logs.h"
#include "questmgr.h" #include "questmgr.h"
#include "titles.h" #include "titles.h"
@ -288,6 +289,12 @@ int main(int argc, char** argv) {
PerlXSParser *pxs = new PerlXSParser(); PerlXSParser *pxs = new PerlXSParser();
parse->RegisterQuestInterface(pxs, "pl"); parse->RegisterQuestInterface(pxs, "pl");
#endif #endif
#ifdef LUA_EQEMU
LuaParser *lua_parser = new LuaParser();
parse->RegisterQuestInterface(lua_parser, "lua");
#endif
Parser *ps = new Parser(); Parser *ps = new Parser();
//parse->RegisterQuestInterface(ps, "qst"); //parse->RegisterQuestInterface(ps, "qst");
@ -478,6 +485,11 @@ int main(int argc, char** argv) {
#ifdef EMBPERL #ifdef EMBPERL
safe_delete(pxs); safe_delete(pxs);
#endif #endif
#ifdef LUA_EQEMU
safe_delete(lua_parser);
#endif
safe_delete(ps); safe_delete(ps);
safe_delete(mmf); safe_delete(mmf);