mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Quest API] Add EVENT_SKILL_UP & EVENT_LANGUAGE_SKILL_UP to Perl/Lua (#2076)
Added EVENT_SKILL_UP to Perl/Lua
Adds sub EVENT_SKILL_UP output for use.
Exports:
$skill_id - ID of the skill being exported. Will export skill or language as the same so check below.
$skill_value - New skill level
$skill_max - Maximum value of skill
$is_tradeskill - 0 for non-tradeskill, 1 for tradeskill
Example usage:
sub EVENT_SKILL_UP {
if($is_tradeskill == 0) {
quest::shout("Skill Increase! " . $client->GetCleanName() . " has increased their " . quest::getskillname($skill_id) . " to " . $skill_value . " of " . $skill_max . "!"); #deleteme
}
if ($is_tradeskill == 1) {
quest::shout("Tradeskill Increase! " . $client->GetCleanName() . " has increased their " . quest::getskillname($skill_id) . " to " . $skill_value . " of " . $skill_max . "!"); #deleteme
}
}
Adds sub EVENT_LANGUAGE_SKILL_UP output for use.
Exports:
$skill_id - ID of the skill being exported. Will export skill or language as the same so check below.
$skill_value - New skill level
$skill_max - Maximum value of skill
Example usage:
sub EVENT_LANGUAGE_SKILL_UP {
quest::shout("Language Increase! " . $client->GetCleanName() . " has increased their " . quest::getlanguagename($skill_id) . " to " . $skill_value . " of " . $skill_max . "!"); #deleteme
}
Co-authored-by: toxin06 <53322305+toxin06@users.noreply.github.com>
This commit is contained in:
parent
0d734a0837
commit
b1311780a7
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -4230,7 +4230,9 @@ luabind::scope lua_register_events() {
|
||||
luabind::value("consider_corpse", static_cast<int>(EVENT_CONSIDER_CORPSE)),
|
||||
luabind::value("loot_zone", static_cast<int>(EVENT_LOOT_ZONE)),
|
||||
luabind::value("equip_item_client", static_cast<int>(EVENT_EQUIP_ITEM_CLIENT)),
|
||||
luabind::value("unequip_item_client", static_cast<int>(EVENT_UNEQUIP_ITEM_CLIENT))
|
||||
luabind::value("unequip_item_client", static_cast<int>(EVENT_UNEQUIP_ITEM_CLIENT)),
|
||||
luabind::value("skill_up", static_cast<int>(EVENT_SKILL_UP)),
|
||||
luabind::value("language_skill_up", static_cast<int>(EVENT_LANGUAGE_SKILL_UP))
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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<EQ::Any>* 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<EQ::Any>* 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
|
||||
|
||||
@ -115,6 +115,10 @@ void handle_player_consider_corpse(QuestInterface* parse, lua_State* L, Client*
|
||||
std::vector<EQ::Any>* extra_pointers);
|
||||
void handle_player_equip_item(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data,
|
||||
std::vector<EQ::Any>* extra_pointers);
|
||||
void handle_player_skill_up(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data,
|
||||
std::vector<EQ::Any>* extra_pointers);
|
||||
void handle_player_language_skill_up(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data,
|
||||
std::vector<EQ::Any>* 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,
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user