diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 1bed432c1..4bb701462 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -15228,32 +15228,34 @@ void Client::Handle_OP_Translocate(const EQApplicationPacket *app) zone->GetInstanceID() == PendingTranslocateData.instance_id ); - 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 - // is bound in, use the GoToBind method. If we send OP_Translocate in this case, the client moves itself - // to the bind coords it has from the PlayerProfile, but with the X and Y reversed. I suspect they are - // reversed in the pp, and since spells like Gate are handled serverside, this has not mattered before. - if ( - IsTranslocateSpell(spell_id) && - in_translocate_zone - ) { - PendingTranslocate = false; - GoToBind(); - return; - } + 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 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 + // to the bind coords it has from the PlayerProfile, but with the X and Y reversed. I suspect they are + // reversed in the pp, and since spells like Gate are handled serverside, this has not mattered before. + if ( + IsTranslocateSpell(spell_id) && + in_translocate_zone + ) { + PendingTranslocate = false; + GoToBind(); + return; + } - ////Was sending the packet back to initiate client zone... - ////but that could be abusable, so lets go through proper channels - MovePC( - PendingTranslocateData.zone_id, - PendingTranslocateData.instance_id, - PendingTranslocateData.x, - PendingTranslocateData.y, - PendingTranslocateData.z, - PendingTranslocateData.heading, - 0, - ZoneSolicited - ); + ////Was sending the packet back to initiate client zone... + ////but that could be abusable, so lets go through proper channels + MovePC( + PendingTranslocateData.zone_id, + PendingTranslocateData.instance_id, + PendingTranslocateData.x, + PendingTranslocateData.y, + PendingTranslocateData.z, + PendingTranslocateData.heading, + 0, + ZoneSolicited + ); + } } } diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index fa95593c0..88aab2ea2 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -162,28 +162,47 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove } } - std::string export_string = fmt::format( - "{} {} {} {}", - caster ? caster->GetID() : 0, - buffslot >= 0 ? buffs[buffslot].ticsremaining : 0, - caster ? caster->GetLevel() : 0, - buffslot - ); - if (IsClient()) { - if (parse->EventSpell(EVENT_SPELL_EFFECT_CLIENT, nullptr, CastToClient(), spell_id, export_string, 0) != 0) { - CalcBonuses(); - return true; + if (parse->SpellHasQuestSub(spell_id, EVENT_SPELL_EFFECT_CLIENT)) { + 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_CLIENT, nullptr, CastToClient(), spell_id, export_string, 0) != 0) { + CalcBonuses(); + return true; + } } } else if (IsNPC()) { - if (parse->EventSpell(EVENT_SPELL_EFFECT_NPC, this, nullptr, spell_id, export_string, 0) != 0) { - CalcBonuses(); - return true; + 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) { + CalcBonuses(); + return true; + } } } else if (IsBot()) { - if (parse->EventSpell(EVENT_SPELL_EFFECT_BOT, this, nullptr, spell_id, export_string, 0) != 0) { - CalcBonuses(); - return true; + 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) { + CalcBonuses(); + return true; + } } } @@ -3791,7 +3810,7 @@ void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster) const SPDat_Spell_Struct &spell = spells[buff.spellid]; - std::string export_string = fmt::format( + const auto& export_string = fmt::format( "{} {} {} {}", caster ? caster->GetID() : 0, buffs[slot].ticsremaining, @@ -3800,16 +3819,22 @@ void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster) ); if (IsClient()) { - if (parse->EventSpell(EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT, nullptr, CastToClient(), buff.spellid, export_string, 0) != 0) { - return; + 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) { + return; + } } } else if (IsNPC()) { - if (parse->EventSpell(EVENT_SPELL_EFFECT_BUFF_TIC_NPC, this, nullptr, buff.spellid, export_string, 0) != 0) { - return; + 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) { + return; + } } } else if (IsBot()) { - if (parse->EventSpell(EVENT_SPELL_EFFECT_BUFF_TIC_BOT, this, nullptr, buff.spellid, export_string, 0) != 0) { - return; + 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) { + return; + } } } @@ -4142,25 +4167,35 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses) LogSpells("Fading buff [{}] from slot [{}]", buffs[slot].spellid, slot); - std::string export_string = fmt::format( - "{} {} {} {}", - buffs[slot].casterid, - buffs[slot].ticsremaining, - buffs[slot].casterlevel, - slot - ); + 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].ticsremaining, + buffs[slot].casterlevel, + slot + ); + } if (IsClient()) { - if (parse->EventSpell(EVENT_SPELL_FADE, nullptr, CastToClient(), buffs[slot].spellid, export_string, 0) != 0) { - return; + if (has_fade_event) { + if (parse->EventSpell(EVENT_SPELL_FADE, nullptr, CastToClient(), buffs[slot].spellid, export_string, 0) != 0) { + return; + } } } else if (IsNPC()) { - if (parse->EventSpell(EVENT_SPELL_FADE, this, nullptr, buffs[slot].spellid, export_string, 0) != 0) { - return; + if (has_fade_event) { + if (parse->EventSpell(EVENT_SPELL_FADE, this, nullptr, buffs[slot].spellid, export_string, 0) != 0) { + return; + } } } else if (IsBot()) { - if (parse->EventSpell(EVENT_SPELL_FADE, this, nullptr, buffs[slot].spellid, export_string, 0) != 0) { - return; + if (has_fade_event) { + if (parse->EventSpell(EVENT_SPELL_FADE, this, nullptr, buffs[slot].spellid, export_string, 0) != 0) { + return; + } } } diff --git a/zone/spells.cpp b/zone/spells.cpp index c16cfa6af..17cfe5ce6 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -238,25 +238,44 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, } } - std::string export_string = fmt::format( - "{} {} {}", - spell_id, - GetID(), - GetCasterLevel(spell_id) - ); if (IsClient()) { - if (parse->EventPlayer(EVENT_CAST_BEGIN, CastToClient(), export_string, 0) != 0) { - if (IsDiscipline(spell_id)) { - CastToClient()->SendDisciplineTimer(spells[spell_id].timer_id, 0); - } else { - CastToClient()->SendSpellBarEnable(spell_id); + if (parse->PlayerHasQuestSub(EVENT_CAST_BEGIN)) { + const auto& export_string = fmt::format( + "{} {} {}", + spell_id, + GetID(), + GetCasterLevel(spell_id) + ); + if (parse->EventPlayer(EVENT_CAST_BEGIN, CastToClient(), export_string, 0) != 0) { + if (IsDiscipline(spell_id)) { + CastToClient()->SendDisciplineTimer(spells[spell_id].timer_id, 0); + } + else { + CastToClient()->SendSpellBarEnable(spell_id); + } + return false; } - return false; } } else if (IsNPC()) { - parse->EventNPC(EVENT_CAST_BEGIN, CastToNPC(), nullptr, export_string, 0); + 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); + } } else if (IsBot()) { - parse->EventBot(EVENT_CAST_BEGIN, CastToBot(), nullptr, export_string, 0); + 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); + } } //To prevent NPC ghosting when spells are cast from scripts @@ -1635,18 +1654,25 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo // at this point the spell has successfully been cast // - std::string export_string = fmt::format( + const auto& export_string = fmt::format( "{} {} {}", spell_id, GetID(), GetCasterLevel(spell_id) ); + if (IsClient()) { - parse->EventPlayer(EVENT_CAST, CastToClient(), export_string, 0); + if (parse->PlayerHasQuestSub(EVENT_CAST)) { + parse->EventPlayer(EVENT_CAST, CastToClient(), export_string, 0); + } } else if (IsNPC()) { - parse->EventNPC(EVENT_CAST, CastToNPC(), nullptr, export_string, 0); + if (parse->HasQuestSub(GetNPCTypeID(), EVENT_CAST)) { + parse->EventNPC(EVENT_CAST, CastToNPC(), nullptr, export_string, 0); + } } else if (IsBot()) { - parse->EventBot(EVENT_CAST, CastToBot(), nullptr, export_string, 0); + if (parse->BotHasQuestSub(EVENT_CAST)) { + parse->EventBot(EVENT_CAST, CastToBot(), nullptr, export_string, 0); + } } if(bard_song_mode) @@ -3639,20 +3665,36 @@ bool Mob::SpellOnTarget( (spellOwner->IsClient() ? FilterPCSpells : FilterNPCSpells) /* EQ Filter Type: (8 or 9) */ ); - /* Send the EVENT_CAST_ON event */ - const auto export_string = fmt::format( - "{} {} {}", - spell_id, - GetID(), - caster_level - ); - if (spelltar->IsNPC()) { - parse->EventNPC(EVENT_CAST_ON, spelltar->CastToNPC(), this, export_string, 0); + if (parse->HasQuestSub(spelltar->GetNPCTypeID(), EVENT_CAST_ON)) { + const auto& export_string = fmt::format( + "{} {} {}", + spell_id, + GetID(), + caster_level + ); + parse->EventNPC(EVENT_CAST_ON, spelltar->CastToNPC(), this, export_string, 0); + } } else if (spelltar->IsClient()) { - parse->EventPlayer(EVENT_CAST_ON, spelltar->CastToClient(), export_string, 0); + 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); + } } else if (spelltar->IsBot()) { - parse->EventBot(EVENT_CAST_ON, spelltar->CastToBot(), this, export_string, 0); + 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); + } } mod_spell_cast(spell_id, spelltar, reflect_effectiveness, use_resist_adjust, resist_adjust, isproc);