diff --git a/zone/embparser.cpp b/zone/embparser.cpp index 3818f151a..7f6263ad0 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -161,6 +161,8 @@ const char *QuestEventSubroutines[_LargestEventID] = { "EVENT_TASK_BEFORE_UPDATE", "EVENT_AA_BUY", "EVENT_AA_GAIN", + "EVENT_AA_EXP_GAIN", + "EVENT_EXP_GAIN", "EVENT_PAYLOAD", "EVENT_LEVEL_DOWN", "EVENT_GM_COMMAND", @@ -2084,6 +2086,16 @@ void PerlembParser::ExportEventVariables( break; } + case EVENT_AA_EXP_GAIN: { + ExportVar(package_name.c_str(), "aa_exp_gained", data); + break; + } + + case EVENT_EXP_GAIN: { + ExportVar(package_name.c_str(), "exp_gained", data); + break; + } + case EVENT_INSPECT: { ExportVar(package_name.c_str(), "target_id", extradata); if (extra_pointers && extra_pointers->size() == 1) { diff --git a/zone/event_codes.h b/zone/event_codes.h index d0cf7e6aa..df54ba231 100644 --- a/zone/event_codes.h +++ b/zone/event_codes.h @@ -106,6 +106,8 @@ typedef enum { EVENT_TASK_BEFORE_UPDATE, EVENT_AA_BUY, EVENT_AA_GAIN, + EVENT_AA_EXP_GAIN, + EVENT_EXP_GAIN, EVENT_PAYLOAD, EVENT_LEVEL_DOWN, EVENT_GM_COMMAND, diff --git a/zone/exp.cpp b/zone/exp.cpp index 41bb5cfc9..d906b6666 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -804,14 +804,23 @@ void Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool isrezzexp) { } } + if (parse->PlayerHasQuestSub(EVENT_EXP_GAIN) && m_pp.exp != set_exp) { + parse->EventPlayer(EVENT_EXP_GAIN, this, std::to_string(set_exp - m_pp.exp), 0); + } + + if (parse->PlayerHasQuestSub(EVENT_AA_EXP_GAIN) && m_pp.expAA != set_aaxp) { + parse->EventPlayer(EVENT_AA_EXP_GAIN, this, std::to_string(set_aaxp - m_pp.expAA), 0); + } + //set the client's EXP and AAEXP m_pp.exp = set_exp; m_pp.expAA = set_aaxp; if (GetLevel() < 51) { m_epp.perAA = 0; // turn off aa exp if they drop below 51 - } else - SendAlternateAdvancementStats(); //otherwise, send them an AA update + } else { + SendAlternateAdvancementStats(); //otherwise, send them an AA update + } //send the expdata in any case so the xp bar isnt stuck after leveling uint32 tmpxp1 = GetEXPForLevel(GetLevel()+1); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index d12eb0be5..366195e2e 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -4736,7 +4736,9 @@ luabind::scope lua_register_events() { luabind::value("inspect", static_cast(EVENT_INSPECT)), luabind::value("task_before_update", static_cast(EVENT_TASK_BEFORE_UPDATE)), luabind::value("aa_buy", static_cast(EVENT_AA_BUY)), - luabind::value("aa_gain", static_cast(EVENT_AA_GAIN)), + luabind::value("aa_gained", static_cast(EVENT_AA_GAIN)), + luabind::value("aa_exp_gained", static_cast(EVENT_AA_EXP_GAIN)), + luabind::value("exp_gain", static_cast(EVENT_EXP_GAIN)), luabind::value("payload", static_cast(EVENT_PAYLOAD)), luabind::value("level_down", static_cast(EVENT_LEVEL_DOWN)), luabind::value("gm_command", static_cast(EVENT_GM_COMMAND)), diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index ebf95f424..6a82876d3 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -148,6 +148,8 @@ const char *LuaEvents[_LargestEventID] = { "event_task_before_update", "event_aa_buy", "event_aa_gain", + "event_aa_exp_gain", + "event_exp_gain", "event_payload", "event_level_down", "event_gm_command", @@ -275,6 +277,8 @@ LuaParser::LuaParser() { PlayerArgumentDispatch[EVENT_INSPECT] = handle_player_inspect; PlayerArgumentDispatch[EVENT_AA_BUY] = handle_player_aa_buy; PlayerArgumentDispatch[EVENT_AA_GAIN] = handle_player_aa_gain; + PlayerArgumentDispatch[EVENT_AA_EXP_GAIN] = handle_player_aa_exp_gain; + PlayerArgumentDispatch[EVENT_EXP_GAIN] = handle_player_exp_gain; PlayerArgumentDispatch[EVENT_PAYLOAD] = handle_player_payload; PlayerArgumentDispatch[EVENT_LEVEL_UP] = handle_player_level_up; PlayerArgumentDispatch[EVENT_LEVEL_DOWN] = handle_player_level_down; diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index ad7a12c5f..ba2463bdd 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -1181,6 +1181,30 @@ void handle_player_aa_gain( lua_setfield(L, -2, "aa_gained"); } +void handle_player_aa_exp_gain( + QuestInterface *parse, + lua_State* L, + Client* client, + std::string data, + uint32 extra_data, + std::vector *extra_pointers +) { + lua_pushinteger(L, std::stoull(data)); + lua_setfield(L, -2, "aa_exp_gained"); +} + +void handle_player_exp_gain( + QuestInterface *parse, + lua_State* L, + Client* client, + std::string data, + uint32 extra_data, + std::vector *extra_pointers +) { + lua_pushinteger(L, std::stoull(data)); + lua_setfield(L, -2, "exp_gained"); +} + void handle_player_level_up( QuestInterface *parse, lua_State* L, diff --git a/zone/lua_parser_events.h b/zone/lua_parser_events.h index b8399548b..a85dbffe5 100644 --- a/zone/lua_parser_events.h +++ b/zone/lua_parser_events.h @@ -608,6 +608,24 @@ void handle_player_aa_gain( std::vector *extra_pointers ); +void handle_player_aa_exp_gain( + QuestInterface *parse, + lua_State* L, + Client* client, + std::string data, + uint32 extra_data, + std::vector *extra_pointers +); + +void handle_player_exp_gain( + QuestInterface *parse, + lua_State* L, + Client* client, + std::string data, + uint32 extra_data, + std::vector *extra_pointers +); + void handle_player_payload( QuestInterface *parse, lua_State* L,