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

Method _EventBot

zone/lua_parser.cpp:1782–1852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1780}
1781
1782int LuaParser::_EventBot(
1783 std::string package_name,
1784 QuestEventID evt,
1785 Bot *bot,
1786 Mob *init,
1787 std::string data,
1788 uint32 extra_data,
1789 std::vector<std::any> *extra_pointers,
1790 luabind::adl::object *l_func
1791) {
1792 const char *sub_name = LuaEvents[evt];
1793 int start = lua_gettop(L);
1794
1795 try {
1796 int npop = 2;
1797 PushErrorHandler(L);
1798 if(l_func != nullptr) {
1799 l_func->push(L);
1800 } else {
1801 lua_getfield(L, LUA_REGISTRYINDEX, package_name.c_str());
1802 lua_getfield(L, -1, sub_name);
1803 npop = 3;
1804 }
1805
1806 lua_createtable(L, 0, 0);
1807 //push self
1808 Lua_Bot l_bot(bot);
1809 luabind::adl::object l_bot_o = luabind::adl::object(L, l_bot);
1810 l_bot_o.push(L);
1811 lua_setfield(L, -2, "self");
1812
1813 auto arg_function = BotArgumentDispatch[evt];
1814 arg_function(this, L, bot, init, data, extra_data, extra_pointers);
1815 auto* c = (init && init->IsClient()) ? init->CastToClient() : nullptr;
1816
1817 RunningQuest q;
1818
1819 q.owner = bot;
1820 q.initiator = c;
1821
1822 quest_manager.StartQuest(q);
1823
1824 if(lua_pcall(L, 1, 1, start + 1)) {
1825 std::string error = lua_tostring(L, -1);
1826 AddError(error);
1827 quest_manager.EndQuest();
1828 lua_pop(L, npop);
1829 return 0;
1830 }
1831 quest_manager.EndQuest();
1832
1833 if(lua_isnumber(L, -1)) {
1834 int ret = static_cast<int>(lua_tointeger(L, -1));
1835 lua_pop(L, npop);
1836 return ret;
1837 }
1838
1839 lua_pop(L, npop);

Callers

nothing calls this directly

Calls 10

PushErrorHandlerFunction · 0.85
StartQuestMethod · 0.80
EndQuestMethod · 0.80
objectClass · 0.70
pushMethod · 0.45
c_strMethod · 0.45
IsClientMethod · 0.45
CastToClientMethod · 0.45
GetBotIDMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected