mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
[Quest API] (Performance) Check spell or cast events exist before export and execute (#2897)
* [Quest API] Optionally parse spell/cast events # Notes - Optionally parses `EVENT_CAST`, `EVENT_CAST_BEGIN`, `EVENT_CAST_ON`, `EVENT_SPELL_EFFECT_NPC`, `EVENT_SPELL_EFFECT_CLIENT`, `EVENT_SPELL_EFFECT_BOT`, `EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT`, `EVENT_SPELL_EFFECT_BUFF_TIC_NPC`, `EVENT_SPELL_EFFECT_BUFF_TIC_BOT`, `EVENT_SPELL_FADE`, and `EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE`. * Cleanup * PR comment fixes --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
parent
805a9c5f59
commit
9f619859d1
@ -15228,6 +15228,7 @@ void Client::Handle_OP_Translocate(const EQApplicationPacket *app)
|
|||||||
zone->GetInstanceID() == PendingTranslocateData.instance_id
|
zone->GetInstanceID() == PendingTranslocateData.instance_id
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (parse->SpellHasQuestSub(spell_id, EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE)) {
|
||||||
if (parse->EventSpell(EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE, nullptr, this, spell_id, "", 0) == 0) {
|
if (parse->EventSpell(EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE, nullptr, this, spell_id, "", 0) == 0) {
|
||||||
// If the spell has a translocate to bind effect, AND we are already in the zone the client
|
// If the spell has a translocate to bind effect, AND we are already in the zone the client
|
||||||
// is bound in, use the GoToBind method. If we send OP_Translocate in this case, the client moves itself
|
// is bound in, use the GoToBind method. If we send OP_Translocate in this case, the client moves itself
|
||||||
@ -15256,6 +15257,7 @@ void Client::Handle_OP_Translocate(const EQApplicationPacket *app)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PendingTranslocate = false;
|
PendingTranslocate = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,30 +162,49 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string export_string = fmt::format(
|
if (IsClient()) {
|
||||||
|
if (parse->SpellHasQuestSub(spell_id, EVENT_SPELL_EFFECT_CLIENT)) {
|
||||||
|
const auto &export_string = fmt::format(
|
||||||
"{} {} {} {}",
|
"{} {} {} {}",
|
||||||
caster ? caster->GetID() : 0,
|
caster ? caster->GetID() : 0,
|
||||||
buffslot >= 0 ? buffs[buffslot].ticsremaining : 0,
|
buffslot >= 0 ? buffs[buffslot].ticsremaining : 0,
|
||||||
caster ? caster->GetLevel() : 0,
|
caster ? caster->GetLevel() : 0,
|
||||||
buffslot
|
buffslot
|
||||||
);
|
);
|
||||||
|
|
||||||
if (IsClient()) {
|
|
||||||
if (parse->EventSpell(EVENT_SPELL_EFFECT_CLIENT, nullptr, CastToClient(), spell_id, export_string, 0) != 0) {
|
if (parse->EventSpell(EVENT_SPELL_EFFECT_CLIENT, nullptr, CastToClient(), spell_id, export_string, 0) != 0) {
|
||||||
CalcBonuses();
|
CalcBonuses();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (IsNPC()) {
|
} else if (IsNPC()) {
|
||||||
|
if (parse->SpellHasQuestSub(spell_id, EVENT_SPELL_EFFECT_NPC)) {
|
||||||
|
const auto &export_string = fmt::format(
|
||||||
|
"{} {} {} {}",
|
||||||
|
caster ? caster->GetID() : 0,
|
||||||
|
buffslot >= 0 ? buffs[buffslot].ticsremaining : 0,
|
||||||
|
caster ? caster->GetLevel() : 0,
|
||||||
|
buffslot
|
||||||
|
);
|
||||||
if (parse->EventSpell(EVENT_SPELL_EFFECT_NPC, this, nullptr, spell_id, export_string, 0) != 0) {
|
if (parse->EventSpell(EVENT_SPELL_EFFECT_NPC, this, nullptr, spell_id, export_string, 0) != 0) {
|
||||||
CalcBonuses();
|
CalcBonuses();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (IsBot()) {
|
} else if (IsBot()) {
|
||||||
|
if (parse->SpellHasQuestSub(spell_id, EVENT_SPELL_EFFECT_BOT)) {
|
||||||
|
const auto &export_string = fmt::format(
|
||||||
|
"{} {} {} {}",
|
||||||
|
caster ? caster->GetID() : 0,
|
||||||
|
buffslot >= 0 ? buffs[buffslot].ticsremaining : 0,
|
||||||
|
caster ? caster->GetLevel() : 0,
|
||||||
|
buffslot
|
||||||
|
);
|
||||||
if (parse->EventSpell(EVENT_SPELL_EFFECT_BOT, this, nullptr, spell_id, export_string, 0) != 0) {
|
if (parse->EventSpell(EVENT_SPELL_EFFECT_BOT, this, nullptr, spell_id, export_string, 0) != 0) {
|
||||||
CalcBonuses();
|
CalcBonuses();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(IsVirusSpell(spell_id)) {
|
if(IsVirusSpell(spell_id)) {
|
||||||
|
|
||||||
@ -3791,7 +3810,7 @@ void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster)
|
|||||||
|
|
||||||
const SPDat_Spell_Struct &spell = spells[buff.spellid];
|
const SPDat_Spell_Struct &spell = spells[buff.spellid];
|
||||||
|
|
||||||
std::string export_string = fmt::format(
|
const auto& export_string = fmt::format(
|
||||||
"{} {} {} {}",
|
"{} {} {} {}",
|
||||||
caster ? caster->GetID() : 0,
|
caster ? caster->GetID() : 0,
|
||||||
buffs[slot].ticsremaining,
|
buffs[slot].ticsremaining,
|
||||||
@ -3800,18 +3819,24 @@ void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster)
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (IsClient()) {
|
if (IsClient()) {
|
||||||
|
if (parse->SpellHasQuestSub(buff.spellid, EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT)) {
|
||||||
if (parse->EventSpell(EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT, nullptr, CastToClient(), buff.spellid, export_string, 0) != 0) {
|
if (parse->EventSpell(EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT, nullptr, CastToClient(), buff.spellid, export_string, 0) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (IsNPC()) {
|
} else if (IsNPC()) {
|
||||||
|
if (parse->SpellHasQuestSub(buff.spellid, EVENT_SPELL_EFFECT_BUFF_TIC_NPC)) {
|
||||||
if (parse->EventSpell(EVENT_SPELL_EFFECT_BUFF_TIC_NPC, this, nullptr, buff.spellid, export_string, 0) != 0) {
|
if (parse->EventSpell(EVENT_SPELL_EFFECT_BUFF_TIC_NPC, this, nullptr, buff.spellid, export_string, 0) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (IsBot()) {
|
} else if (IsBot()) {
|
||||||
|
if (parse->SpellHasQuestSub(buff.spellid, EVENT_SPELL_EFFECT_BUFF_TIC_BOT)) {
|
||||||
if (parse->EventSpell(EVENT_SPELL_EFFECT_BUFF_TIC_BOT, this, nullptr, buff.spellid, export_string, 0) != 0) {
|
if (parse->EventSpell(EVENT_SPELL_EFFECT_BUFF_TIC_BOT, this, nullptr, buff.spellid, export_string, 0) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < EFFECT_COUNT; i++) {
|
for (int i = 0; i < EFFECT_COUNT; i++) {
|
||||||
if (IsBlankSpellEffect(buff.spellid, i))
|
if (IsBlankSpellEffect(buff.spellid, i))
|
||||||
@ -4142,27 +4167,37 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
|
|||||||
|
|
||||||
LogSpells("Fading buff [{}] from slot [{}]", buffs[slot].spellid, slot);
|
LogSpells("Fading buff [{}] from slot [{}]", buffs[slot].spellid, slot);
|
||||||
|
|
||||||
std::string export_string = fmt::format(
|
const auto has_fade_event = parse->SpellHasQuestSub(buffs[slot].spellid, EVENT_SPELL_FADE);
|
||||||
|
std::string export_string = "";
|
||||||
|
if (has_fade_event) {
|
||||||
|
export_string = fmt::format(
|
||||||
"{} {} {} {}",
|
"{} {} {} {}",
|
||||||
buffs[slot].casterid,
|
buffs[slot].casterid,
|
||||||
buffs[slot].ticsremaining,
|
buffs[slot].ticsremaining,
|
||||||
buffs[slot].casterlevel,
|
buffs[slot].casterlevel,
|
||||||
slot
|
slot
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (IsClient()) {
|
if (IsClient()) {
|
||||||
|
if (has_fade_event) {
|
||||||
if (parse->EventSpell(EVENT_SPELL_FADE, nullptr, CastToClient(), buffs[slot].spellid, export_string, 0) != 0) {
|
if (parse->EventSpell(EVENT_SPELL_FADE, nullptr, CastToClient(), buffs[slot].spellid, export_string, 0) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (IsNPC()) {
|
} else if (IsNPC()) {
|
||||||
|
if (has_fade_event) {
|
||||||
if (parse->EventSpell(EVENT_SPELL_FADE, this, nullptr, buffs[slot].spellid, export_string, 0) != 0) {
|
if (parse->EventSpell(EVENT_SPELL_FADE, this, nullptr, buffs[slot].spellid, export_string, 0) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (IsBot()) {
|
} else if (IsBot()) {
|
||||||
|
if (has_fade_event) {
|
||||||
if (parse->EventSpell(EVENT_SPELL_FADE, this, nullptr, buffs[slot].spellid, export_string, 0) != 0) {
|
if (parse->EventSpell(EVENT_SPELL_FADE, this, nullptr, buffs[slot].spellid, export_string, 0) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0; i < EFFECT_COUNT; i++)
|
for (int i=0; i < EFFECT_COUNT; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -238,26 +238,45 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string export_string = fmt::format(
|
if (IsClient()) {
|
||||||
|
if (parse->PlayerHasQuestSub(EVENT_CAST_BEGIN)) {
|
||||||
|
const auto& export_string = fmt::format(
|
||||||
"{} {} {}",
|
"{} {} {}",
|
||||||
spell_id,
|
spell_id,
|
||||||
GetID(),
|
GetID(),
|
||||||
GetCasterLevel(spell_id)
|
GetCasterLevel(spell_id)
|
||||||
);
|
);
|
||||||
if (IsClient()) {
|
|
||||||
if (parse->EventPlayer(EVENT_CAST_BEGIN, CastToClient(), export_string, 0) != 0) {
|
if (parse->EventPlayer(EVENT_CAST_BEGIN, CastToClient(), export_string, 0) != 0) {
|
||||||
if (IsDiscipline(spell_id)) {
|
if (IsDiscipline(spell_id)) {
|
||||||
CastToClient()->SendDisciplineTimer(spells[spell_id].timer_id, 0);
|
CastToClient()->SendDisciplineTimer(spells[spell_id].timer_id, 0);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
CastToClient()->SendSpellBarEnable(spell_id);
|
CastToClient()->SendSpellBarEnable(spell_id);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (IsNPC()) {
|
} else if (IsNPC()) {
|
||||||
|
if (parse->HasQuestSub(GetNPCTypeID(), EVENT_CAST_BEGIN)) {
|
||||||
|
const auto& export_string = fmt::format(
|
||||||
|
"{} {} {}",
|
||||||
|
spell_id,
|
||||||
|
GetID(),
|
||||||
|
GetCasterLevel(spell_id)
|
||||||
|
);
|
||||||
parse->EventNPC(EVENT_CAST_BEGIN, CastToNPC(), nullptr, export_string, 0);
|
parse->EventNPC(EVENT_CAST_BEGIN, CastToNPC(), nullptr, export_string, 0);
|
||||||
|
}
|
||||||
} else if (IsBot()) {
|
} else if (IsBot()) {
|
||||||
|
if (parse->BotHasQuestSub(EVENT_CAST_BEGIN)) {
|
||||||
|
const auto& export_string = fmt::format(
|
||||||
|
"{} {} {}",
|
||||||
|
spell_id,
|
||||||
|
GetID(),
|
||||||
|
GetCasterLevel(spell_id)
|
||||||
|
);
|
||||||
parse->EventBot(EVENT_CAST_BEGIN, CastToBot(), nullptr, export_string, 0);
|
parse->EventBot(EVENT_CAST_BEGIN, CastToBot(), nullptr, export_string, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//To prevent NPC ghosting when spells are cast from scripts
|
//To prevent NPC ghosting when spells are cast from scripts
|
||||||
if (IsNPC() && IsMoving() && cast_time > 0) {
|
if (IsNPC() && IsMoving() && cast_time > 0) {
|
||||||
@ -1635,19 +1654,26 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
|
|||||||
// at this point the spell has successfully been cast
|
// at this point the spell has successfully been cast
|
||||||
//
|
//
|
||||||
|
|
||||||
std::string export_string = fmt::format(
|
const auto& export_string = fmt::format(
|
||||||
"{} {} {}",
|
"{} {} {}",
|
||||||
spell_id,
|
spell_id,
|
||||||
GetID(),
|
GetID(),
|
||||||
GetCasterLevel(spell_id)
|
GetCasterLevel(spell_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (IsClient()) {
|
if (IsClient()) {
|
||||||
|
if (parse->PlayerHasQuestSub(EVENT_CAST)) {
|
||||||
parse->EventPlayer(EVENT_CAST, CastToClient(), export_string, 0);
|
parse->EventPlayer(EVENT_CAST, CastToClient(), export_string, 0);
|
||||||
|
}
|
||||||
} else if (IsNPC()) {
|
} else if (IsNPC()) {
|
||||||
|
if (parse->HasQuestSub(GetNPCTypeID(), EVENT_CAST)) {
|
||||||
parse->EventNPC(EVENT_CAST, CastToNPC(), nullptr, export_string, 0);
|
parse->EventNPC(EVENT_CAST, CastToNPC(), nullptr, export_string, 0);
|
||||||
|
}
|
||||||
} else if (IsBot()) {
|
} else if (IsBot()) {
|
||||||
|
if (parse->BotHasQuestSub(EVENT_CAST)) {
|
||||||
parse->EventBot(EVENT_CAST, CastToBot(), nullptr, export_string, 0);
|
parse->EventBot(EVENT_CAST, CastToBot(), nullptr, export_string, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(bard_song_mode)
|
if(bard_song_mode)
|
||||||
{
|
{
|
||||||
@ -3639,21 +3665,37 @@ bool Mob::SpellOnTarget(
|
|||||||
(spellOwner->IsClient() ? FilterPCSpells : FilterNPCSpells) /* EQ Filter Type: (8 or 9) */
|
(spellOwner->IsClient() ? FilterPCSpells : FilterNPCSpells) /* EQ Filter Type: (8 or 9) */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Send the EVENT_CAST_ON event */
|
if (spelltar->IsNPC()) {
|
||||||
const auto export_string = fmt::format(
|
if (parse->HasQuestSub(spelltar->GetNPCTypeID(), EVENT_CAST_ON)) {
|
||||||
|
const auto& export_string = fmt::format(
|
||||||
"{} {} {}",
|
"{} {} {}",
|
||||||
spell_id,
|
spell_id,
|
||||||
GetID(),
|
GetID(),
|
||||||
caster_level
|
caster_level
|
||||||
);
|
);
|
||||||
|
|
||||||
if (spelltar->IsNPC()) {
|
|
||||||
parse->EventNPC(EVENT_CAST_ON, spelltar->CastToNPC(), this, export_string, 0);
|
parse->EventNPC(EVENT_CAST_ON, spelltar->CastToNPC(), this, export_string, 0);
|
||||||
|
}
|
||||||
} else if (spelltar->IsClient()) {
|
} else if (spelltar->IsClient()) {
|
||||||
|
if (parse->PlayerHasQuestSub(EVENT_CAST_ON)) {
|
||||||
|
const auto& export_string = fmt::format(
|
||||||
|
"{} {} {}",
|
||||||
|
spell_id,
|
||||||
|
GetID(),
|
||||||
|
caster_level
|
||||||
|
);
|
||||||
parse->EventPlayer(EVENT_CAST_ON, spelltar->CastToClient(), export_string, 0);
|
parse->EventPlayer(EVENT_CAST_ON, spelltar->CastToClient(), export_string, 0);
|
||||||
|
}
|
||||||
} else if (spelltar->IsBot()) {
|
} else if (spelltar->IsBot()) {
|
||||||
|
if (parse->BotHasQuestSub(EVENT_CAST_ON)) {
|
||||||
|
const auto& export_string = fmt::format(
|
||||||
|
"{} {} {}",
|
||||||
|
spell_id,
|
||||||
|
GetID(),
|
||||||
|
caster_level
|
||||||
|
);
|
||||||
parse->EventBot(EVENT_CAST_ON, spelltar->CastToBot(), this, export_string, 0);
|
parse->EventBot(EVENT_CAST_ON, spelltar->CastToBot(), this, export_string, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mod_spell_cast(spell_id, spelltar, reflect_effectiveness, use_resist_adjust, resist_adjust, isproc);
|
mod_spell_cast(spell_id, spelltar, reflect_effectiveness, use_resist_adjust, resist_adjust, isproc);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user