Core: Combat/threat system rewrite (PR #19930)

- PvE combat is now always mutual. UNIT_FLAG_IN_COMBAT is backed by actual references to the units we're in combat with.
- PvP combat is now also tracked, and almost always mutual; spells like Vanish and Feign Death can break this rule. That means we can easily determine a list of players we're fighting.
- By extension, IsInCombatWith now has sensible behavior when invoked on nonplayers.
- Threat and combat systems are no longer the same.
  - They still have an enforced relationship (threat implies combat - clearing combat clears threat)...
  - ...but we can have combat without threat. A creature (with threat list) isn't considered to be engaged until it has an entry on its threat list...
  - ...which means we can now faithfully replicate retail engage behavior. Combat on projectile launch - engagement start on projectile impact. Yay for progress!
- AI method refactor, as already ported in 6113b9d - `JustEngagedWith`, `JustEnteredCombat` and `JustExitedCombat`.
- Vehicle threat is now properly pooled on the main vehicle body (fixes #16542).
- Various edge case bug fixes for threat redirects (Misdirection "cancelling" Vigilance and similar).
- Target re-selection is now significantly faster.
- Fixed a ton of other smaller edge case bugs, probably.

Closes #7951 and #19998.
This commit is contained in:
Treeston authored and Ovahlord committed 2020-07-22 16:49:37 +02:00
1 parent 280b8dc799
commit 942c3a77da
53 files changed
+1607 -2232

No files matched your search

+4 -4
View File
@@ -99,7 +99,7 @@ enum WarlockSpells
SPELL_WARLOCK_SOUL_HARVEST_ENERGIZE = 101977,
SPELL_WARLOCK_SOUL_SHARD = 87388,
SPELL_WARLOCK_SOUL_SHARD_ENERGIZE = 95810,
SPELL_WARLOCK_SOULSHATTER = 32835,
SPELL_WARLOCK_SOULSHATTER_EFFECT = 32835,
SPELL_WARLOCK_SOUL_SWAP_CD_MARKER = 94229,
SPELL_WARLOCK_SOUL_SWAP_OVERRIDE = 86211,
SPELL_WARLOCK_SOUL_SWAP_MOD_COST = 92794,
@@ -1454,15 +1454,15 @@ class spell_warl_soulshatter : public SpellScriptLoader
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_WARLOCK_SOULSHATTER });
return ValidateSpellInfo({ SPELL_WARLOCK_SOULSHATTER_EFFECT });
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
if (Unit* target = GetHitUnit())
if (target->CanHaveThreatList() && target->GetThreatManager().IsThreatenedBy(caster, true))
caster->CastSpell(target, SPELL_WARLOCK_SOULSHATTER, true);
if (target->GetThreatManager().IsThreatenedBy(caster, true))
caster->CastSpell(target, SPELL_WARLOCK_SOULSHATTER_EFFECT, true);
}
void Register() override