diff --git a/zone/client.cpp b/zone/client.cpp index e245bbc9a..c64ac6557 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -1500,7 +1500,6 @@ void Client::SetSkill(EQ::skills::SkillType skillid, uint16 value) { m_pp.skills[skillid] = value; // We need to be able to #setskill 254 and 255 to reset skills database.SaveCharacterSkill(this->CharacterID(), skillid, value); - auto outapp = new EQApplicationPacket(OP_SkillUpdate, sizeof(SkillUpdate_Struct)); SkillUpdate_Struct* skill = (SkillUpdate_Struct*)outapp->pBuffer; skill->skillId=skillid; @@ -2468,6 +2467,14 @@ bool Client::CheckIncreaseSkill(EQ::skills::SkillType skillid, Mob *against_who, if(zone->random.Real(0, 99) < Chance) { SetSkill(skillid, GetRawSkill(skillid) + 1); + std::string export_string = fmt::format( + "{} {} {} {}", + skillid, + skillval+1, + maxskill, + 0 + ); + parse->EventPlayer(EVENT_SKILL_UP, this, export_string, 0); LogSkills("Skill [{}] at value [{}] successfully gain with [{}] chance (mod [{}])", skillid, skillval, Chance, chancemodi); return true; } else { @@ -2495,6 +2502,13 @@ void Client::CheckLanguageSkillIncrease(uint8 langid, uint8 TeacherSkill) { if(zone->random.Real(0,100) < Chance) { // if they make the roll IncreaseLanguageSkill(langid); // increase the language skill by 1 + std::string export_string = fmt::format( + "{} {} {}", + langid, + LangSkill + 1, + 100 + ); + parse->EventPlayer(EVENT_LANGUAGE_SKILL_UP, this, export_string, 0); LogSkills("Language [{}] at value [{}] successfully gain with [{}] % chance", langid, LangSkill, Chance); } else diff --git a/zone/embparser.cpp b/zone/embparser.cpp index d77571baf..85665f1c4 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -127,7 +127,9 @@ const char *QuestEventSubroutines[_LargestEventID] = { "EVENT_CONSIDER_CORPSE", "EVENT_LOOT_ZONE", "EVENT_EQUIP_ITEM_CLIENT", - "EVENT_UNEQUIP_ITEM_CLIENT" + "EVENT_UNEQUIP_ITEM_CLIENT", + "EVENT_SKILL_UP", + "EVENT_LANGUAGE_SKILL_UP" }; PerlembParser::PerlembParser() : perl(nullptr) @@ -1709,6 +1711,23 @@ void PerlembParser::ExportEventVariables( break; } + case EVENT_SKILL_UP: { + Seperator sep(data); + ExportVar(package_name.c_str(), "skill_id", sep.arg[0]); + ExportVar(package_name.c_str(), "skill_value", sep.arg[1]); + ExportVar(package_name.c_str(), "skill_max", sep.arg[2]); + ExportVar(package_name.c_str(), "is_tradeskill", sep.arg[3]); + break; + } + + case EVENT_LANGUAGE_SKILL_UP: { + Seperator sep(data); + ExportVar(package_name.c_str(), "skill_id", sep.arg[0]); + ExportVar(package_name.c_str(), "skill_value", sep.arg[1]); + ExportVar(package_name.c_str(), "skill_max", sep.arg[2]); + break; + } + default: { break; } diff --git a/zone/event_codes.h b/zone/event_codes.h index e808091ff..9044a9bf4 100644 --- a/zone/event_codes.h +++ b/zone/event_codes.h @@ -96,6 +96,8 @@ typedef enum { EVENT_LOOT_ZONE, EVENT_EQUIP_ITEM_CLIENT, EVENT_UNEQUIP_ITEM_CLIENT, + EVENT_SKILL_UP, + EVENT_LANGUAGE_SKILL_UP, _LargestEventID } QuestEventID; diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index d794e6d09..b6362df7c 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -4230,7 +4230,9 @@ luabind::scope lua_register_events() { luabind::value("consider_corpse", static_cast(EVENT_CONSIDER_CORPSE)), luabind::value("loot_zone", static_cast(EVENT_LOOT_ZONE)), luabind::value("equip_item_client", static_cast(EVENT_EQUIP_ITEM_CLIENT)), - luabind::value("unequip_item_client", static_cast(EVENT_UNEQUIP_ITEM_CLIENT)) + luabind::value("unequip_item_client", static_cast(EVENT_UNEQUIP_ITEM_CLIENT)), + luabind::value("skill_up", static_cast(EVENT_SKILL_UP)), + luabind::value("language_skill_up", static_cast(EVENT_LANGUAGE_SKILL_UP)) ]; } diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index f1b66b1c7..34ef62fbd 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -138,7 +138,9 @@ const char *LuaEvents[_LargestEventID] = { "event_consider_corpse", "event_loot_zone", "event_equip_item_client", - "event_unequip_item_client" + "event_unequip_item_client", + "event_skill_up", + "event_language_skill_up" }; extern Zone *zone; @@ -232,6 +234,8 @@ LuaParser::LuaParser() { PlayerArgumentDispatch[EVENT_CONSIDER_CORPSE] = handle_player_consider_corpse; PlayerArgumentDispatch[EVENT_EQUIP_ITEM_CLIENT] = handle_player_equip_item; PlayerArgumentDispatch[EVENT_UNEQUIP_ITEM_CLIENT] = handle_player_equip_item; + PlayerArgumentDispatch[EVENT_SKILL_UP] = handle_player_skill_up; + PlayerArgumentDispatch[EVENT_LANGUAGE_SKILL_UP] = handle_player_skill_up; ItemArgumentDispatch[EVENT_ITEM_CLICK] = handle_item_click; ItemArgumentDispatch[EVENT_ITEM_CLICK_CAST] = handle_item_click; diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index 973723985..a286586fd 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -828,4 +828,31 @@ void handle_encounter_null(QuestInterface *parse, lua_State* L, Encounter* encou } +void handle_player_skill_up(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector* extra_pointers) { + Seperator sep(data.c_str()); + lua_pushinteger(L, std::stoi(sep.arg[0])); + lua_setfield(L, -2, "skill_id"); + + lua_pushinteger(L, std::stoi(sep.arg[1])); + lua_setfield(L, -2, "skill_value"); + + lua_pushinteger(L, std::stoi(sep.arg[2])); + lua_setfield(L, -2, "skill_max"); + + lua_pushinteger(L, std::stoi(sep.arg[3])); + lua_setfield(L, -2, "is_tradeskill"); +} + +void handle_player_language_skill_up(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector* extra_pointers) { + Seperator sep(data.c_str()); + lua_pushinteger(L, std::stoi(sep.arg[0])); + lua_setfield(L, -2, "skill_id"); + + lua_pushinteger(L, std::stoi(sep.arg[1])); + lua_setfield(L, -2, "skill_value"); + + lua_pushinteger(L, std::stoi(sep.arg[2])); + lua_setfield(L, -2, "skill_max"); +} + #endif diff --git a/zone/lua_parser_events.h b/zone/lua_parser_events.h index bae1b11b8..2b6848def 100644 --- a/zone/lua_parser_events.h +++ b/zone/lua_parser_events.h @@ -115,6 +115,10 @@ void handle_player_consider_corpse(QuestInterface* parse, lua_State* L, Client* std::vector* extra_pointers); void handle_player_equip_item(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector* extra_pointers); +void handle_player_skill_up(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, + std::vector* extra_pointers); +void handle_player_language_skill_up(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, + std::vector* extra_pointers); //Item void handle_item_click(QuestInterface *parse, lua_State* L, Client* client, EQ::ItemInstance* item, Mob *mob, std::string data, uint32 extra_data, diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 1ae5056c1..8e25b7fc3 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -1148,6 +1148,7 @@ void Client::CheckIncreaseTradeskill(int16 bonusstat, int16 stat_modifier, float if(!CanIncreaseTradeskill(tradeskill)) return; //not allowed to go higher. + uint16 maxskill = MaxSkill(tradeskill); float chance_stage2 = 0; @@ -1176,7 +1177,14 @@ void Client::CheckIncreaseTradeskill(int16 bonusstat, int16 stat_modifier, float if (chance_stage2 > zone->random.Real(0, 99)) { //Only if stage1 and stage2 succeeded you get a skillup. SetSkill(tradeskill, current_raw_skill + 1); - + std::string export_string = fmt::format( + "{} {} {} {}", + tradeskill, + current_raw_skill + 1, + maxskill, + 1 + ); + parse->EventPlayer(EVENT_SKILL_UP, this, export_string, 0); if(title_manager.IsNewTradeSkillTitleAvailable(tradeskill, current_raw_skill + 1)) NotifyNewTitlesAvailable(); }