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

Method _EventItem

zone/lua_parser.cpp:673–743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

671}
672
673int LuaParser::_EventItem(std::string package_name, QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob,
674 std::string data, uint32 extra_data, std::vector<std::any> *extra_pointers, luabind::adl::object *l_func) {
675 const char *sub_name = LuaEvents[evt];
676
677 int start = lua_gettop(L);
678
679 try {
680 int npop = 2;
681 PushErrorHandler(L);
682 if(l_func != nullptr) {
683 l_func->push(L);
684 } else {
685 lua_getfield(L, LUA_REGISTRYINDEX, package_name.c_str());
686 lua_getfield(L, -1, sub_name);
687 npop = 3;
688 }
689
690 lua_createtable(L, 0, 0);
691 //always push self
692 Lua_ItemInst l_item(item);
693 luabind::adl::object l_item_o = luabind::adl::object(L, l_item);
694 l_item_o.push(L);
695 lua_setfield(L, -2, "self");
696
697 Lua_Client l_client(client);
698 luabind::adl::object l_client_o = luabind::adl::object(L, l_client);
699 l_client_o.push(L);
700 lua_setfield(L, -2, "owner");
701
702 //redo this arg function
703 auto arg_function = ItemArgumentDispatch[evt];
704 arg_function(this, L, client, item, mob, data, extra_data, extra_pointers);
705
706 RunningQuest q;
707
708 q.owner = client;
709 q.initiator = client;
710 q.questitem = item;
711
712 quest_manager.StartQuest(q);
713
714 if(lua_pcall(L, 1, 1, start + 1)) {
715 std::string error = lua_tostring(L, -1);
716 AddError(error);
717 quest_manager.EndQuest();
718 lua_pop(L, npop);
719 return 0;
720 }
721 quest_manager.EndQuest();
722
723 if(lua_isnumber(L, -1)) {
724 int ret = static_cast<int>(lua_tointeger(L, -1));
725 lua_pop(L, npop);
726 return ret;
727 }
728
729 lua_pop(L, npop);
730 } catch(std::exception &ex) {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected