mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 22:01:30 +00:00
[Quest API] (Performance) Check event EVENT_LANGUAGE_SKILL_UP, EVENT_SKILL_UP, or EVENT_USE_SKILL exist before export and execute (#2894)
* [Quest API] Optionally parse EVENT_LANGUAGE_SKILL_UP, EVENT_SKILL_UP, and EVENT_USE_SKILL - Optionally parse these events instead of always doing so. * Cleanup
This commit is contained in:
parent
3d6b0e5f74
commit
3474c00e7a
@ -1451,15 +1451,18 @@ void Mob::DoAttack(Mob *other, DamageHitInfo &hit, ExtraAttackOptions *opts, boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsBot()) {
|
if (IsBot()) {
|
||||||
const auto export_string = fmt::format(
|
if (parse->BotHasQuestSub(EVENT_USE_SKILL)) {
|
||||||
|
const auto& export_string = fmt::format(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
hit.skill,
|
hit.skill,
|
||||||
GetSkill(hit.skill)
|
GetSkill(hit.skill)
|
||||||
);
|
);
|
||||||
|
|
||||||
parse->EventBot(EVENT_USE_SKILL, CastToBot(), nullptr, export_string, 0);
|
parse->EventBot(EVENT_USE_SKILL, CastToBot(), nullptr, export_string, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//note: throughout this method, setting `damage` to a negative is a way to
|
//note: throughout this method, setting `damage` to a negative is a way to
|
||||||
//stop the attack calculations
|
//stop the attack calculations
|
||||||
|
|||||||
@ -2508,22 +2508,35 @@ uint64 Client::GetAllMoney() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Client::CheckIncreaseSkill(EQ::skills::SkillType skillid, Mob *against_who, int chancemodi) {
|
bool Client::CheckIncreaseSkill(EQ::skills::SkillType skillid, Mob *against_who, int chancemodi) {
|
||||||
if (IsDead() || IsUnconscious())
|
if (IsDead() || IsUnconscious()) {
|
||||||
return false;
|
return false;
|
||||||
if (IsAIControlled()) // no skillups while chamred =p
|
}
|
||||||
|
|
||||||
|
if (IsAIControlled()) { // no skillups while chamred =p
|
||||||
return false;
|
return false;
|
||||||
if (against_who != nullptr && against_who->IsCorpse()) // no skillups on corpses
|
}
|
||||||
|
|
||||||
|
if (against_who && against_who->IsCorpse()) { // no skillups on corpses
|
||||||
return false;
|
return false;
|
||||||
if (skillid > EQ::skills::HIGHEST_SKILL)
|
}
|
||||||
|
|
||||||
|
if (skillid > EQ::skills::HIGHEST_SKILL) {
|
||||||
return false;
|
return false;
|
||||||
int skillval = GetRawSkill(skillid);
|
}
|
||||||
int maxskill = GetMaxSkillAfterSpecializationRules(skillid, MaxSkill(skillid));
|
|
||||||
std::string export_string = fmt::format(
|
auto skillval = GetRawSkill(skillid);
|
||||||
|
auto maxskill = GetMaxSkillAfterSpecializationRules(skillid, MaxSkill(skillid));
|
||||||
|
|
||||||
|
if (parse->PlayerHasQuestSub(EVENT_USE_SKILL)) {
|
||||||
|
const auto& export_string = fmt::format(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
skillid,
|
skillid,
|
||||||
skillval
|
skillval
|
||||||
);
|
);
|
||||||
|
|
||||||
parse->EventPlayer(EVENT_USE_SKILL, this, export_string, 0);
|
parse->EventPlayer(EVENT_USE_SKILL, this, export_string, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (against_who) {
|
if (against_who) {
|
||||||
if (
|
if (
|
||||||
against_who->GetSpecialAbility(IMMUNE_AGGRO) ||
|
against_who->GetSpecialAbility(IMMUNE_AGGRO) ||
|
||||||
@ -2557,23 +2570,27 @@ bool Client::CheckIncreaseSkill(EQ::skills::SkillType skillid, Mob *against_who,
|
|||||||
if(zone->random.Real(0, 99) < Chance)
|
if(zone->random.Real(0, 99) < Chance)
|
||||||
{
|
{
|
||||||
SetSkill(skillid, GetRawSkill(skillid) + 1);
|
SetSkill(skillid, GetRawSkill(skillid) + 1);
|
||||||
std::string export_string = fmt::format(
|
|
||||||
|
if (player_event_logs.IsEventEnabled(PlayerEvent::SKILL_UP)) {
|
||||||
|
auto e = PlayerEvent::SkillUpEvent{
|
||||||
|
.skill_id = static_cast<uint32>(skillid),
|
||||||
|
.value = static_cast<int>((skillval + 1)),
|
||||||
|
.max_skill = static_cast<int16>(maxskill),
|
||||||
|
.against_who = (against_who) ? against_who->GetCleanName() : GetCleanName(),
|
||||||
|
};
|
||||||
|
RecordPlayerEventLog(PlayerEvent::SKILL_UP, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parse->PlayerHasQuestSub(EVENT_SKILL_UP)) {
|
||||||
|
const auto& export_string = fmt::format(
|
||||||
"{} {} {} {}",
|
"{} {} {} {}",
|
||||||
skillid,
|
skillid,
|
||||||
skillval + 1,
|
skillval + 1,
|
||||||
maxskill,
|
maxskill,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
parse->EventPlayer(EVENT_SKILL_UP, this, export_string, 0);
|
|
||||||
|
|
||||||
if (player_event_logs.IsEventEnabled(PlayerEvent::SKILL_UP)) {
|
parse->EventPlayer(EVENT_SKILL_UP, this, export_string, 0);
|
||||||
auto e = PlayerEvent::SkillUpEvent{
|
|
||||||
.skill_id = static_cast<uint32>(skillid),
|
|
||||||
.value = (skillval + 1),
|
|
||||||
.max_skill = static_cast<int16>(maxskill),
|
|
||||||
.against_who = (against_who) ? against_who->GetCleanName() : GetCleanName(),
|
|
||||||
};
|
|
||||||
RecordPlayerEventLog(PlayerEvent::SKILL_UP, e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LogSkills("Skill [{}] at value [{}] successfully gain with [{}] chance (mod [{}])", skillid, skillval, Chance, chancemodi);
|
LogSkills("Skill [{}] at value [{}] successfully gain with [{}] chance (mod [{}])", skillid, skillval, Chance, chancemodi);
|
||||||
@ -2603,13 +2620,18 @@ void Client::CheckLanguageSkillIncrease(uint8 langid, uint8 TeacherSkill) {
|
|||||||
|
|
||||||
if(zone->random.Real(0,100) < Chance) { // if they make the roll
|
if(zone->random.Real(0,100) < Chance) { // if they make the roll
|
||||||
IncreaseLanguageSkill(langid); // increase the language skill by 1
|
IncreaseLanguageSkill(langid); // increase the language skill by 1
|
||||||
std::string export_string = fmt::format(
|
|
||||||
|
if (parse->PlayerHasQuestSub(EVENT_LANGUAGE_SKILL_UP)) {
|
||||||
|
const auto& export_string = fmt::format(
|
||||||
"{} {} {}",
|
"{} {} {}",
|
||||||
langid,
|
langid,
|
||||||
LangSkill + 1,
|
LangSkill + 1,
|
||||||
100
|
100
|
||||||
);
|
);
|
||||||
|
|
||||||
parse->EventPlayer(EVENT_LANGUAGE_SKILL_UP, this, export_string, 0);
|
parse->EventPlayer(EVENT_LANGUAGE_SKILL_UP, this, export_string, 0);
|
||||||
|
}
|
||||||
|
|
||||||
LogSkills("Language [{}] at value [{}] successfully gain with [{}] % chance", langid, LangSkill, Chance);
|
LogSkills("Language [{}] at value [{}] successfully gain with [{}] % chance", langid, LangSkill, Chance);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user