From 5d522b149ba410c0babf8b8706db902618d2f5fe Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Sat, 16 Oct 2021 08:56:38 -0400 Subject: [PATCH] [Bug Fix] Allow invisible to be cast on Raid Group members. (#1607) When `Spells:InvisRequiresGroup` was true, you could only cast on Group members, intended functionality is to cast on Group members and/or people in your Raid Group. --- zone/spells.cpp | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/zone/spells.cpp b/zone/spells.cpp index 49b430c6f..f379dbc8c 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -432,22 +432,37 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, casting_spell_targetid = target_id; if (RuleB(Spells, InvisRequiresGroup) && IsInvisSpell(spell_id)) { - if (GetTarget() && GetTarget()->IsClient()) { - Client *spell_target = entity_list.GetClientByID(target_id); + if (IsClient() && GetTarget() && GetTarget()->IsClient()) { + Client* spell_caster = this->CastToClient(); + Client* spell_target = entity_list.GetClientByID(target_id); if (spell_target && spell_target->GetID() != GetID()) { - if (!spell_target->IsGrouped()) { - InterruptSpell(spell_id); - Message(Chat::Red, "You cannot invis someone who is not in your group."); - return false; - } - else if (spell_target->IsGrouped()) { + bool cast_failed = true; + if (spell_target->IsGrouped()) { Group *target_group = spell_target->GetGroup(); - Group *my_group = GetGroup(); - if (target_group && my_group && (target_group->GetID() != my_group->GetID())) { - InterruptSpell(spell_id); - Message(Chat::Red, "You cannot invis someone who is not in your group."); - return false; + Group *my_group = GetGroup(); + if ( + target_group && + my_group && + (target_group->GetID() == my_group->GetID()) + ) { + cast_failed = false; } + } else if (spell_target->IsRaidGrouped()) { + Raid *target_raid = spell_target->GetRaid(); + Raid *my_raid = GetRaid(); + if ( + target_raid && + my_raid && + (target_raid->GetGroup(spell_target) == my_raid->GetGroup(spell_caster)) + ) { + cast_failed = false; + } + } + + if (cast_failed) { + InterruptSpell(spell_id); + MessageString(Chat::Red, TARGET_GROUP_MEMBER); + return false; } } }