bool LuaParser::ItemHasQuestSub(ItemInst *itm, QuestEventID evt) { evt = ConvertLuaEvent(evt); if(evt >= _LargestEventID) { return false; } std::string package_name = "item_"; package_name += std::to_string(static_cast<long long>(itm->GetID())); const char *subname = LuaEvents[evt]; return HasFunction(subname, package_name); }
int LuaParser::EventEncounter(QuestEventID evt, std::string encounter_name, uint32 extra_data, std::vector<void*> *extra_pointers) { evt = ConvertLuaEvent(evt); if(evt >= _LargestEventID) { return 0; } std::string package_name = "encounter_" + encounter_name; if(!EncounterHasQuestSub(encounter_name, evt)) { return 0; } return _EventEncounter(package_name, evt, encounter_name, extra_data, extra_pointers); }
int LuaParser::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data, std::vector<void*> *extra_pointers) { evt = ConvertLuaEvent(evt); if(evt >= _LargestEventID) { return 0; } std::string package_name = "spell_" + std::to_string(static_cast<long long>(spell_id)); if(!SpellHasQuestSub(spell_id, evt)) { return 0; } return _EventSpell(package_name, evt, npc, client, spell_id, extra_data, extra_pointers); }
bool LuaParser::ItemHasQuestSub(EQEmu::ItemInstance *itm, QuestEventID evt) { if (itm == nullptr) { return false; } evt = ConvertLuaEvent(evt); if(evt >= _LargestEventID) { return false; } std::string package_name = "item_"; package_name += std::to_string(itm->GetID()); const char *subname = LuaEvents[evt]; return HasFunction(subname, package_name); }
int LuaParser::EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data, std::vector<void*> *extra_pointers) { evt = ConvertLuaEvent(evt); if(evt >= _LargestEventID) { return 0; } if(!client) { return 0; } if(!GlobalPlayerHasQuestSub(evt)) { return 0; } return _EventPlayer("global_player", evt, client, data, extra_data, extra_pointers); }
int LuaParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, std::vector<void*> *extra_pointers) { evt = ConvertLuaEvent(evt); if(evt >= _LargestEventID) { return 0; } if(!npc) { return 0; } if(!HasGlobalQuestSub(evt)) { return 0; } return _EventNPC("global_npc", evt, npc, init, data, extra_data, extra_pointers); }
int LuaParser::DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, std::vector<void*> *extra_pointers) { evt = ConvertLuaEvent(evt); if(evt >= _LargestEventID) { return 0; } if(!npc) return 0; std::string package_name = "npc_" + std::to_string(static_cast<long long>(npc->GetNPCTypeID())); int ret = 0; auto iter = lua_encounter_events_registered.find(package_name); if(iter != lua_encounter_events_registered.end()) { auto riter = iter->second.begin(); while(riter != iter->second.end()) { if(riter->event_id == evt) { std::string package_name = "encounter_" + riter->encounter_name; int i = _EventNPC(package_name, evt, npc, init, data, extra_data, extra_pointers, &riter->lua_reference); if(i != 0) ret = i; } ++riter; } } iter = lua_encounter_events_registered.find("npc_-1"); if(iter == lua_encounter_events_registered.end()) { return ret; } auto riter = iter->second.begin(); while(riter != iter->second.end()) { if(riter->event_id == evt) { std::string package_name = "encounter_" + riter->encounter_name; int i = _EventNPC(package_name, evt, npc, init, data, extra_data, extra_pointers, &riter->lua_reference); if(i != 0) ret = i; } ++riter; } return ret; }
int LuaParser::DispatchEventItem(QuestEventID evt, Client *client, ItemInst *item, Mob *mob, std::string data, uint32 extra_data, std::vector<void*> *extra_pointers) { evt = ConvertLuaEvent(evt); if(evt >= _LargestEventID) { return 0; } if(!item) return 0; std::string package_name = "item_"; package_name += std::to_string(static_cast<long long>(item->GetID())); int ret = 0; auto iter = lua_encounter_events_registered.find(package_name); if(iter != lua_encounter_events_registered.end()) { auto riter = iter->second.begin(); while(riter != iter->second.end()) { if(riter->event_id == evt) { std::string package_name = "encounter_" + riter->encounter_name; int i = _EventItem(package_name, evt, client, item, mob, data, extra_data, extra_pointers, &riter->lua_reference); if(i != 0) ret = i; } ++riter; } } iter = lua_encounter_events_registered.find("item_-1"); if(iter == lua_encounter_events_registered.end()) { return ret; } auto riter = iter->second.begin(); while(riter != iter->second.end()) { if(riter->event_id == evt) { std::string package_name = "encounter_" + riter->encounter_name; int i = _EventItem(package_name, evt, client, item, mob, data, extra_data, extra_pointers, &riter->lua_reference); if(i != 0) ret = i; } ++riter; } return ret; }
int LuaParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, std::vector<void*> *extra_pointers) { evt = ConvertLuaEvent(evt); if(evt >= _LargestEventID) { return 0; } if(!npc) { return 0; } if(!HasQuestSub(npc->GetNPCTypeID(), evt)) { return 0; } std::string package_name = "npc_" + std::to_string(static_cast<long long>(npc->GetNPCTypeID())); return _EventNPC(package_name, evt, npc, init, data, extra_data, extra_pointers); }
int LuaParser::EventItem(QuestEventID evt, Client *client, ItemInst *item, Mob *mob, std::string data, uint32 extra_data, std::vector<void*> *extra_pointers) { evt = ConvertLuaEvent(evt); if(evt >= _LargestEventID) { return 0; } if(!item) { return 0; } if(!ItemHasQuestSub(item, evt)) { return 0; } std::string package_name = "item_"; package_name += std::to_string(static_cast<long long>(item->GetID())); return _EventItem(package_name, evt, client, item, mob, data, extra_data, extra_pointers); }
int LuaParser::DispatchEventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data, std::vector<void*> *extra_pointers) { evt = ConvertLuaEvent(evt); if(evt >= _LargestEventID) { return 0; } std::string package_name = "spell_" + std::to_string(static_cast<long long>(spell_id)); int ret = 0; auto iter = lua_encounter_events_registered.find(package_name); if(iter != lua_encounter_events_registered.end()) { auto riter = iter->second.begin(); while(riter != iter->second.end()) { if(riter->event_id == evt) { std::string package_name = "encounter_" + riter->encounter_name; int i = _EventSpell(package_name, evt, npc, client, spell_id, extra_data, extra_pointers, &riter->lua_reference); if(i != 0) { ret = i; } } ++riter; } } iter = lua_encounter_events_registered.find("spell_-1"); if(iter == lua_encounter_events_registered.end()) { return ret; } auto riter = iter->second.begin(); while(riter != iter->second.end()) { if(riter->event_id == evt) { std::string package_name = "encounter_" + riter->encounter_name; int i = _EventSpell(package_name, evt, npc, client, spell_id, extra_data, extra_pointers, &riter->lua_reference); if(i != 0) ret = i; } ++riter; } return ret; }