2013-05-05 23:36:15 -07:00
|
|
|
#ifndef _EQE_LUA_PARSER_H
|
|
|
|
|
#define _EQE_LUA_PARSER_H
|
|
|
|
|
#ifdef LUA_EQEMU
|
|
|
|
|
|
2014-08-21 23:46:01 -07:00
|
|
|
#include "quest_parser_collection.h"
|
|
|
|
|
#include "quest_interface.h"
|
2013-05-10 20:13:35 -07:00
|
|
|
#include <string>
|
2013-05-19 12:13:44 -07:00
|
|
|
#include <list>
|
2013-05-10 20:13:35 -07:00
|
|
|
#include <map>
|
2017-04-22 16:40:01 -07:00
|
|
|
#include <exception>
|
2013-05-05 23:36:15 -07:00
|
|
|
|
2016-05-20 21:03:34 -05:00
|
|
|
#include "zone_config.h"
|
2017-04-30 00:30:23 -07:00
|
|
|
#include "lua_mod.h"
|
2016-05-20 21:03:34 -05:00
|
|
|
|
|
|
|
|
extern const ZoneConfig *Config;
|
|
|
|
|
|
2013-05-10 20:13:35 -07:00
|
|
|
struct lua_State;
|
2013-05-05 23:36:15 -07:00
|
|
|
class Client;
|
|
|
|
|
class NPC;
|
|
|
|
|
|
2020-05-17 18:36:06 -07:00
|
|
|
namespace EQ
|
2016-10-16 05:10:54 -04:00
|
|
|
{
|
|
|
|
|
class ItemInstance;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-16 15:35:55 -07:00
|
|
|
#include "lua_parser_events.h"
|
|
|
|
|
|
2013-05-19 12:13:44 -07:00
|
|
|
struct lua_registered_event;
|
|
|
|
|
namespace luabind {
|
2014-06-23 16:56:37 -07:00
|
|
|
namespace adl {
|
|
|
|
|
class object;
|
|
|
|
|
}
|
2013-05-19 12:13:44 -07:00
|
|
|
}
|
|
|
|
|
|
2013-05-08 20:18:39 -07:00
|
|
|
class LuaParser : public QuestInterface {
|
2013-05-05 23:36:15 -07:00
|
|
|
public:
|
2013-05-10 20:13:35 -07:00
|
|
|
~LuaParser();
|
|
|
|
|
|
2013-06-05 16:47:49 -07:00
|
|
|
virtual int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
2013-06-05 16:47:49 -07:00
|
|
|
virtual int EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
2013-06-19 22:56:46 -07:00
|
|
|
virtual int EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
2013-06-19 22:56:46 -07:00
|
|
|
virtual int EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
|
|
|
|
virtual int EventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
|
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
2013-06-19 22:56:46 -07:00
|
|
|
virtual int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
2015-06-02 12:25:09 -07:00
|
|
|
virtual int EventEncounter(QuestEventID evt, std::string encounter_name, std::string data, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
2013-05-10 20:13:35 -07:00
|
|
|
|
2013-06-12 15:04:26 -07:00
|
|
|
virtual bool HasQuestSub(uint32 npc_id, QuestEventID evt);
|
|
|
|
|
virtual bool HasGlobalQuestSub(QuestEventID evt);
|
|
|
|
|
virtual bool PlayerHasQuestSub(QuestEventID evt);
|
|
|
|
|
virtual bool GlobalPlayerHasQuestSub(QuestEventID evt);
|
|
|
|
|
virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt);
|
2020-05-17 18:36:06 -07:00
|
|
|
virtual bool ItemHasQuestSub(EQ::ItemInstance *itm, QuestEventID evt);
|
2013-06-12 15:04:26 -07:00
|
|
|
virtual bool EncounterHasQuestSub(std::string encounter_name, QuestEventID evt);
|
2013-05-10 20:13:35 -07:00
|
|
|
|
|
|
|
|
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);
|
2020-05-17 18:36:06 -07:00
|
|
|
virtual void LoadItemScript(std::string filename, EQ::ItemInstance *item);
|
2013-05-10 20:13:35 -07:00
|
|
|
virtual void LoadSpellScript(std::string filename, uint32 spell_id);
|
2013-05-19 12:13:44 -07:00
|
|
|
virtual void LoadEncounterScript(std::string filename, std::string encounter_name);
|
2013-05-10 20:13:35 -07:00
|
|
|
|
|
|
|
|
virtual void AddVar(std::string name, std::string val);
|
|
|
|
|
virtual std::string GetVar(std::string name);
|
2013-05-27 17:24:31 -07:00
|
|
|
virtual void Init();
|
2013-05-10 20:13:35 -07:00
|
|
|
virtual void ReloadQuests();
|
2013-05-05 23:36:15 -07:00
|
|
|
virtual uint32 GetIdentifier() { return 0xb0712acc; }
|
2013-05-19 12:13:44 -07:00
|
|
|
|
2013-06-26 09:26:19 -07:00
|
|
|
virtual int DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
2013-06-26 09:26:19 -07:00
|
|
|
virtual int DispatchEventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
|
|
|
|
virtual int DispatchEventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
|
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
2013-06-26 09:26:19 -07:00
|
|
|
virtual int DispatchEventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
2013-05-10 20:13:35 -07:00
|
|
|
|
2017-04-22 16:40:01 -07:00
|
|
|
static LuaParser* Instance() {
|
|
|
|
|
static LuaParser inst;
|
|
|
|
|
return &inst;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-30 00:30:23 -07:00
|
|
|
bool HasFunction(std::string function, std::string package_name);
|
|
|
|
|
|
2017-04-22 16:40:01 -07:00
|
|
|
//Mod Extensions
|
2017-04-26 22:56:18 -07:00
|
|
|
void MeleeMitigation(Mob *self, Mob *attacker, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault);
|
|
|
|
|
void ApplyDamageTable(Mob *self, DamageHitInfo &hit, bool &ignoreDefault);
|
|
|
|
|
bool AvoidDamage(Mob *self, Mob *other, DamageHitInfo &hit, bool &ignoreDefault);
|
|
|
|
|
bool CheckHitChance(Mob *self, Mob* other, DamageHitInfo &hit, bool &ignoreDefault);
|
2017-05-19 22:50:08 -07:00
|
|
|
void TryCriticalHit(Mob *self, Mob *defender, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault);
|
2017-06-12 13:01:01 -07:00
|
|
|
void CommonOutgoingHitSuccess(Mob *self, Mob* other, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault);
|
2017-06-10 15:12:31 -07:00
|
|
|
uint32 GetRequiredAAExperience(Client *self, bool &ignoreDefault);
|
|
|
|
|
uint32 GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault);
|
|
|
|
|
uint32 GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefault);
|
2017-04-22 16:40:01 -07:00
|
|
|
|
2013-05-05 23:36:15 -07:00
|
|
|
private:
|
2017-04-22 16:40:01 -07:00
|
|
|
LuaParser();
|
|
|
|
|
LuaParser(const LuaParser&);
|
|
|
|
|
LuaParser& operator=(const LuaParser&);
|
|
|
|
|
|
2013-05-19 12:13:44 -07:00
|
|
|
int _EventNPC(std::string package_name, QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
2013-05-19 12:13:44 -07:00
|
|
|
int _EventPlayer(std::string package_name, QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
|
|
|
|
int _EventItem(std::string package_name, QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data,
|
|
|
|
|
uint32 extra_data, std::vector<EQ::Any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
2013-05-19 12:13:44 -07:00
|
|
|
int _EventSpell(std::string package_name, QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
2015-06-02 12:25:09 -07:00
|
|
|
int _EventEncounter(std::string package_name, QuestEventID evt, std::string encounter_name, std::string data, uint32 extra_data,
|
2020-05-17 18:36:06 -07:00
|
|
|
std::vector<EQ::Any> *extra_pointers);
|
2013-05-19 12:13:44 -07:00
|
|
|
|
2013-05-10 20:13:35 -07:00
|
|
|
void LoadScript(std::string filename, std::string package_name);
|
|
|
|
|
void MapFunctions(lua_State *L);
|
2013-06-12 15:04:26 -07:00
|
|
|
QuestEventID ConvertLuaEvent(QuestEventID evt);
|
2013-05-10 20:13:35 -07:00
|
|
|
|
|
|
|
|
std::map<std::string, std::string> vars_;
|
2013-05-15 13:00:46 -07:00
|
|
|
std::map<std::string, bool> loaded_;
|
2017-04-30 00:30:23 -07:00
|
|
|
std::vector<LuaMod> mods_;
|
2013-05-15 13:00:46 -07:00
|
|
|
lua_State *L;
|
2013-05-16 15:35:55 -07:00
|
|
|
|
|
|
|
|
NPCArgumentHandler NPCArgumentDispatch[_LargestEventID];
|
|
|
|
|
PlayerArgumentHandler PlayerArgumentDispatch[_LargestEventID];
|
|
|
|
|
ItemArgumentHandler ItemArgumentDispatch[_LargestEventID];
|
|
|
|
|
SpellArgumentHandler SpellArgumentDispatch[_LargestEventID];
|
2015-06-02 12:25:09 -07:00
|
|
|
EncounterArgumentHandler EncounterArgumentDispatch[_LargestEventID];
|
|
|
|
|
|
2013-05-05 23:36:15 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|