diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 9b08f1c0a..b8beef5f0 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -7425,24 +7425,27 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) else if (victim->IsCreature()) victim->ToCreature()->UpdateLeashExtensionTime(); - // set position before any AI calls/assistance - //if (IsCreature()) - // ToCreature()->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); - // player-controlled creatures (pets, charms) enter combat on contact instead - // (melee swing execution or spell launch/hit, see Unit::AtTargetAttacked) - if (creature && !IsControlledByPlayer()) + // Player-controlled creatures (pets, charms) enter combat on contact instead + // (melee swing execution or spell launch/hit, see Unit::AtTargetAttacked). + // Non-controllable guardians (e.g. Shaman Elementals, Infernal) have no attack + // command and must engage immediately so their AI can chase and attack. + + if (creature && (!IsControlledByPlayer() || (IsGuardian() && !IsControllableGuardian()))) { EngageWithTarget(victim); - creature->SendAIReaction(AI_REACTION_HOSTILE); + if (!IsControlledByPlayer()) + { + creature->SendAIReaction(AI_REACTION_HOSTILE); - /// @todo: Implement aggro range, detection range and assistance range templates - if (!(creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_DONT_CALL_ASSISTANCE))) - creature->CallAssistance(); + /// @todo: Implement aggro range, detection range and assistance range templates + if (!(creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_DONT_CALL_ASSISTANCE))) + creature->CallAssistance(); - creature->SetAssistanceTimer(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_PERIOD)); + creature->SetAssistanceTimer(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_PERIOD)); - SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); + SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); + } } // delay offhand weapon attack by 50% of the base attack time