Core/Units: treat CREATURE_FLAG_EXTRA_NO_COMBAT as a pseudo passive react state. Units with that flag will no longer enter combat with potential targets unless they are being engaged by their opponent or explicitely commanded to do so

* apply no combat flag on every creature and their difficulty entries that have been flagged in creaturedifficulty.db2
This commit is contained in:
Ovahlord
2020-08-09 18:02:41 +02:00
parent b36233b8f6
commit a2fa0c2ffa
4 changed files with 15 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@@ -108,7 +108,7 @@ void CreatureAI::MoveInLineOfSight(Unit* who)
if (me->IsEngaged())
return;
if (me->HasReactState(REACT_AGGRESSIVE) && me->CanStartAttack(who, false))
if (me->HasReactState(REACT_AGGRESSIVE) && !me->IsIgnoringCombat() && me->CanStartAttack(who, false))
me->EngageWithTarget(who);
}

View File

@@ -44,9 +44,6 @@
return false;
if (a->HasUnitState(UNIT_STATE_IN_FLIGHT) || b->HasUnitState(UNIT_STATE_IN_FLIGHT))
return false;
// ... both units must not be ignoring combat
if (a->IsIgnoringCombat() || b->IsIgnoringCombat())
return false;
if (a->IsFriendlyTo(b) || b->IsFriendlyTo(a))
return false;
Player const* playerA = a->GetCharmerOrOwnerPlayerOrPlayerItself();

View File

@@ -2713,7 +2713,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
if (missInfo != SPELL_MISS_EVADE && spellHitTarget && !m_caster->IsFriendlyTo(unit) && (!m_spellInfo->IsPositive() || m_spellInfo->HasEffect(SPELL_EFFECT_DISPEL)))
{
if (Unit* unitCaster = m_caster->ToUnit())
unitCaster->AtTargetAttacked(unit, m_spellInfo->HasInitialAggro());
unitCaster->AtTargetAttacked(unit, m_spellInfo->HasInitialAggro() && !unitCaster->IsIgnoringCombat());
if (!unit->IsStandState())
unit->SetStandState(UNIT_STAND_STATE_STAND);
@@ -7691,7 +7691,11 @@ void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier)
return;
// This will only cause combat - the target will engage once the projectile hits (in DoAllEffectOnTarget)
if (m_originalCaster && targetInfo.missCondition != SPELL_MISS_EVADE && !m_originalCaster->IsFriendlyTo(unit) && (!m_spellInfo->IsPositive() || m_spellInfo->HasEffect(SPELL_EFFECT_DISPEL)) && (m_spellInfo->HasInitialAggro() || unit->IsEngaged()))
if (m_originalCaster && targetInfo.missCondition != SPELL_MISS_EVADE
&& !m_originalCaster->IsFriendlyTo(unit)
&& (!m_spellInfo->IsPositive() || m_spellInfo->HasEffect(SPELL_EFFECT_DISPEL))
&& (m_spellInfo->HasInitialAggro() || unit->IsEngaged())
&& !m_originalCaster->IsIgnoringCombat())
m_originalCaster->SetInCombatWith(unit);
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)