MCPcopy Create free account
hub / github.com/EQEmu/EQEmu / _EventSpell

Method _EventSpell

zone/lua_parser.cpp:761–831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759}
760
761int LuaParser::_EventSpell(std::string package_name, QuestEventID evt, Mob* mob, Client *client, uint32 spell_id, std::string data, uint32 extra_data,
762 std::vector<std::any> *extra_pointers, luabind::adl::object *l_func) {
763 const char *sub_name = LuaEvents[evt];
764
765 int start = lua_gettop(L);
766
767 try {
768 int npop = 2;
769 PushErrorHandler(L);
770 if(l_func != nullptr) {
771 l_func->push(L);
772 } else {
773 lua_getfield(L, LUA_REGISTRYINDEX, package_name.c_str());
774 lua_getfield(L, -1, sub_name);
775 npop = 3;
776 }
777
778 lua_createtable(L, 0, 0);
779
780 //always push self even if invalid
781 if(IsValidSpell(spell_id)) {
782 Lua_Spell l_spell(&spells[spell_id]);
783 luabind::adl::object l_spell_o = luabind::adl::object(L, l_spell);
784 l_spell_o.push(L);
785 } else {
786 Lua_Spell l_spell(nullptr);
787 luabind::adl::object l_spell_o = luabind::adl::object(L, l_spell);
788 l_spell_o.push(L);
789 }
790 lua_setfield(L, -2, "self");
791
792 auto arg_function = SpellArgumentDispatch[evt];
793 arg_function(this, L, mob, client, spell_id, data, extra_data, extra_pointers);
794
795 RunningQuest q;
796
797 q.owner = client;
798 q.initiator = client;
799 q.questspell = const_cast<SPDat_Spell_Struct*>(&spells[spell_id]);
800
801 quest_manager.StartQuest(q);
802
803 if(lua_pcall(L, 1, 1, start + 1)) {
804 std::string error = lua_tostring(L, -1);
805 AddError(error);
806 quest_manager.EndQuest();
807 lua_pop(L, npop);
808 return 0;
809 }
810 quest_manager.EndQuest();
811
812 if(lua_isnumber(L, -1)) {
813 int ret = static_cast<int>(lua_tointeger(L, -1));
814 lua_pop(L, npop);
815 return ret;
816 }
817
818 lua_pop(L, npop);

Callers

nothing calls this directly

Calls 8

PushErrorHandlerFunction · 0.85
IsValidSpellFunction · 0.85
StartQuestMethod · 0.80
EndQuestMethod · 0.80
objectClass · 0.70
pushMethod · 0.45
c_strMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected