From 19b14ea2d46f18027a092832a9acead2314dc298 Mon Sep 17 00:00:00 2001 From: splose Date: Wed, 16 Jun 2021 10:31:38 -0400 Subject: [PATCH] [Bug Fix] Fixed Invis vs Undead / Invis Vs Animals not breaking charm + Added rule for custom capabilities (#1374) * Fixed Invis vs Undead / Invis Vs Animals not breaking charm Added rule for custom capabilities * Fix logging & remove comments * change logic * change logic * if (RuleB(Pets, LivelikeBreakCharmOnInvis) || IsInvisible(formerpet)) --- common/ruletypes.h | 1 + zone/mob.cpp | 10 +++++++--- zone/spell_effects.cpp | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index ae1625ef5..9047d0d66 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -206,6 +206,7 @@ RULE_REAL(Pets, AttackCommandRange, 150, "Range at which a pet will respond to a RULE_BOOL(Pets, UnTargetableSwarmPet, false, "Setting whether swarm pets should be targetable") RULE_REAL(Pets, PetPowerLevelCap, 10, "Maximum number of levels a player pet can go up with pet power") RULE_BOOL(Pets, CanTakeNoDrop, false, "Setting whether anyone can give no-drop items to pets") +RULE_BOOL(Pets, LivelikeBreakCharmOnInvis, true, "Default: true will break charm on any type of invis (hide/ivu/iva/etc) false will only break if the pet can not see you (ex. you have an undead pet and cast IVU") RULE_CATEGORY_END() RULE_CATEGORY(GM) diff --git a/zone/mob.cpp b/zone/mob.cpp index 84014d2ee..6de62bf9e 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -549,10 +549,14 @@ void Mob::SetInvisible(uint8 state) invisible = state; SendAppearancePacket(AT_Invis, invisible); // Invis and hide breaks charms - auto formerpet = GetPet(); - if (formerpet && formerpet->GetPetType() == petCharmed && (invisible || hidden || improved_hidden)) - formerpet->BuffFadeByEffect(SE_Charm); + if (formerpet && formerpet->GetPetType() == petCharmed && (invisible || hidden || improved_hidden || invisible_animals || invisible_undead)) { + if (RuleB(Pets, LivelikeBreakCharmOnInvis) || IsInvisible(formerpet)) + formerpet->BuffFadeByEffect(SE_Charm); + } + + LogRules("Pets:LivelikeBreakCharmOnInvis for [{}] | Invis [{}] - Hidden [{}] - Shroud of Stealth [{}] - IVA [{}] - IVU [{}]", GetCleanName(), invisible, hidden, improved_hidden, invisible_animals, invisible_undead); + } } //check to see if `this` is invisible to `other` diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index cb2895954..ceffa5f44 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -600,6 +600,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove snprintf(effect_desc, _EDLEN, "Invisibility to Animals"); #endif invisible_animals = true; + SetInvisible(0); break; } @@ -610,6 +611,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove snprintf(effect_desc, _EDLEN, "Invisibility to Undead"); #endif invisible_undead = true; + SetInvisible(0); break; } case SE_SeeInvis: