Core/Creatures: Various fixes for creatures, regarding combat conditions, despawning, and few others (#18998)

* Made some changes to kiting mechanics, simplified code and made taunt auras prolong combat no matter the distance from the spawn
Unified some creature despawning code, removed some brutal direct calls in scripts
Don't play death anim on forced despawn
Removed some redundant visibility changes on creature despawn
Fixed possible problem with pet initializing template info from difficulty greater than normal
Properly keep UNIT_FLAG_IN_COMBAT on UpdateEntry call
Moved RegenerateMana function to general Regenerate(Power) function
Fixed increased health regeneration from polymorph for pets
Implemented CREATURE_TYPE_FLAG_GHOST_VISIBLE, those creatures will be properly seen when player is dead also
Removed hackfix from Gaeriyan and Franclorn Forgewright, fixed properly
Simplified ForcedRespawnTime code in ForcedDespawn
Do not allow to assist unit while evading or when enemy is evading
Do not allow to attack other units when evading or when the unit is evading
Corrected distance checking code before creature is allowed to evade, should fix some common problems
Properly return summon position for summoned creatures as their respawn position
Properly stop all moving units on gossip hello, no matter their npc flags

(cherry picked from commit e1f14215d86fc9f0cd041f0e87bf0a689c086329)
This commit is contained in:
xinef1 authored and funjoker committed 2022-02-16 04:49:24 +01:00
1 parent 5a2cdf2d68
commit f431459063
28 files changed
+150 -115

No files matched your search

+1 -2
View File
@@ -99,8 +99,7 @@ public:
return false;
}
creatureTarget->setDeathState(JUST_DIED);
creatureTarget->RemoveCorpse();
creatureTarget->DespawnOrUnsummon();
creatureTarget->SetHealth(0); // just for nice GM-mode view
pet->SetGuidValue(UNIT_FIELD_CREATEDBY, player->GetGUID());
@@ -193,10 +193,7 @@ public:
{
if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr))
{
if (summon->IsAlive())
summon->DisappearAndDie();
else
summon->RemoveCorpse();
summon->DespawnOrUnsummon();
}
}
}
@@ -476,8 +476,7 @@ public:
}
else
{
me->DealDamage(me, me->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
me->RemoveCorpse();
me->DespawnOrUnsummon();
}
}
void JustEngagedWith(Unit* /*who*/) override { }
@@ -499,9 +499,7 @@ public:
me->SummonCreature(NPC_DEAD, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
}
(*i)->SetVisible(false);
(*i)->setDeathState(JUST_DIED);
if ((*i)->getDeathState() == CORPSE)
(*i)->RemoveCorpse();
(*i)->DespawnOrUnsummon();
}
}
};
@@ -1178,7 +1178,7 @@ public:
break;
case 3:
me->KillSelf();
me->RemoveCorpse();
me->DespawnOrUnsummon();
break;
}
} else uiTimer -=diff;
@@ -226,8 +226,8 @@ class instance_uldaman : public InstanceMapScript
Creature* target = instance->GetCreature(*i);
if (!target || target->isDead() || target->GetFaction() != 14)
continue;
target->setDeathState(JUST_DIED);
target->RemoveCorpse();
target->DespawnOrUnsummon();
}
// Vault Walkers
@@ -236,8 +236,8 @@ class instance_uldaman : public InstanceMapScript
Creature* target = instance->GetCreature(*i);
if (!target || target->isDead() || target->GetFaction() != 14)
continue;
target->setDeathState(JUST_DIED);
target->RemoveCorpse();
target->DespawnOrUnsummon();
}
// Earthen Guardians
@@ -246,8 +246,8 @@ class instance_uldaman : public InstanceMapScript
Creature* target = instance->GetCreature(*i);
if (!target || target->isDead() || target->GetFaction() != 14)
continue;
target->setDeathState(JUST_DIED);
target->RemoveCorpse();
target->DespawnOrUnsummon();
}
}
@@ -233,8 +233,7 @@ public:
Creature* boss = ObjectAccessor::GetCreature(*me, AnetheronGUID);
if (!boss || boss->isDead())
{
me->setDeathState(JUST_DIED);
me->RemoveCorpse();
me->DespawnOrUnsummon();
return;
}
}
@@ -239,8 +239,7 @@ public:
Creature* boss = ObjectAccessor::GetCreature(*me, AzgalorGUID);
if (!boss || boss->isDead())
{
me->setDeathState(JUST_DIED);
me->RemoveCorpse();
me->DespawnOrUnsummon();
return;
}
}
@@ -571,8 +571,7 @@ public:
{
if ((faction == 0 && LastOverronPos == 17) || (faction == 1 && LastOverronPos == 21))
{
me->setDeathState(DEAD);
me->RemoveCorpse();
me->DespawnOrUnsummon();
}
}
}
@@ -670,8 +669,7 @@ public:
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_ATTACK_UNARMED);
if ((faction == 0 && LastOverronPos == 17) || (faction == 1 && LastOverronPos == 21))
{
me->setDeathState(DEAD);
me->RemoveCorpse();
me->DespawnOrUnsummon();
}
}
}
@@ -201,8 +201,7 @@ public:
//if we reach this it means event was running but at some point reset.
if (instance->GetData(TYPE_MEDIVH) == NOT_STARTED)
{
me->DealDamage(me, me->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
me->RemoveCorpse();
me->DespawnOrUnsummon();
me->Respawn();
return;
}
@@ -130,7 +130,7 @@ class boss_skeram : public CreatureScript
Talk(SAY_DEATH);
}
else
me->RemoveCorpse();
me->DespawnOrUnsummon();
}
void JustEngagedWith(Unit* who) override
@@ -926,7 +926,7 @@ public:
void npc_qiraj_war_spawn::npc_qiraj_war_spawnAI::JustDied(Unit* /*killer*/)
{
me->RemoveCorpse();
me->DespawnOrUnsummon();
if (!MobGUID)
return;
@@ -246,7 +246,7 @@ class npc_iron_roots : public CreatureScript
target->RemoveAurasDueToSpell(SPELL_ROOTS_FREYA);
}
me->RemoveCorpse(false);
me->DespawnOrUnsummon();
}
private:
@@ -170,10 +170,7 @@ public:
for (uint8 i = 0; i < 2; ++i)
{
if (Creature* mob = ObjectAccessor::GetCreature(*me, beams[i]))
{
mob->setDeathState(DEAD);
mob->RemoveCorpse();
}
mob->DespawnOrUnsummon();
}
}
void JustEngagedWith(Unit* /*who*/) override
@@ -808,9 +808,9 @@ public:
if (!Vashj || !Vashj->IsAlive() || ENSURE_AI(boss_lady_vashj::boss_lady_vashjAI, Vashj->ToCreature()->AI())->Phase != 3)
{
// remove
me->setDeathState(DEAD);
me->RemoveCorpse();
me->SetFaction(FACTION_FRIENDLY);
me->DespawnOrUnsummon();
return;
}
CheckTimer = 1000;
@@ -178,11 +178,7 @@ class boss_warchief_kargath_bladefist : public CreatureScript
{
Creature* creature = ObjectAccessor::GetCreature(*me, *itr);
if (creature && creature->IsAlive())
{
creature->GetMotionMaster()->Clear(true);
me->DealDamage(creature, creature->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
creature->RemoveCorpse();
}
creature->DespawnOrUnsummon();
}
adds.clear();
@@ -190,11 +186,7 @@ class boss_warchief_kargath_bladefist : public CreatureScript
{
Creature* creature = ObjectAccessor::GetCreature(*me, *itr);
if (creature && creature->IsAlive())
{
creature->GetMotionMaster()->Clear(true);
me->DealDamage(creature, creature->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
creature->RemoveCorpse();
}
creature->DespawnOrUnsummon();
}
assassins.clear();
}
@@ -195,8 +195,8 @@ class npc_ragin_flames : public CreatureScript
if (instance->GetData(DATA_NETHERMANCER_SEPRETHREA) != IN_PROGRESS)
{
//remove
me->setDeathState(JUST_DIED);
me->RemoveCorpse();
me->DespawnOrUnsummon();
return;
}
Check_Timer = 1000;
} else Check_Timer -= diff;
@@ -231,8 +231,8 @@ class npc_nether_wraith : public CreatureScript
{
if (Die_Timer <= diff)
{
me->setDeathState(JUST_DIED);
me->RemoveCorpse();
me->DespawnOrUnsummon();
return;
}
else
Die_Timer -= diff;
@@ -121,11 +121,7 @@ public:
return;
if (id == 0)
{
me->setDeathState(JUST_DIED);
me->RemoveCorpse();
me->SetHealth(0);
}
me->DespawnOrUnsummon(1);
}
void SpellHit(Unit* caster, SpellInfo const* spell) override
@@ -153,7 +149,8 @@ public:
EnterEvadeMode();
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
IsNihil = true;
}else
}
else
AttackStart(caster);
}
}
@@ -380,7 +380,6 @@ public:
FlyTimer = 10000;
me->SetDisableGravity(false);
me->SetVisible(true);
}
void SpellHit(Unit* caster, SpellInfo const* spell) override
@@ -422,10 +421,7 @@ public:
PlayerGUID.Clear();
}
me->SetVisible(false);
me->SetDisableGravity(false);
me->DealDamage(me, me->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
me->RemoveCorpse();
me->DespawnOrUnsummon(1);
}
}
@@ -1190,7 +1186,7 @@ public:
void JustDied(Unit* /*killer*/) override
{
me->RemoveCorpse();
me->DespawnOrUnsummon();
if (Creature* LordIllidan = (ObjectAccessor::GetCreature(*me, LordIllidanGUID)))
ENSURE_AI(npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI, LordIllidan->AI())->LiveCounter();
}
@@ -4265,6 +4265,40 @@ class spell_gen_pony_mount_check : public SpellScriptLoader
}
};
class spell_gen_shroud_of_death : public SpellScriptLoader
{
public:
spell_gen_shroud_of_death() : SpellScriptLoader("spell_gen_shroud_of_death") { }
class spell_gen_shroud_of_death_AuraScript : public AuraScript
{
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
PreventDefaultAction();
GetUnitOwner()->m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
GetUnitOwner()->m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
PreventDefaultAction();
GetUnitOwner()->m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
GetUnitOwner()->m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
}
void Register() override
{
OnEffectApply.Register(&spell_gen_shroud_of_death_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove.Register(&spell_gen_shroud_of_death_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_shroud_of_death_AuraScript();
}
};
enum ArmorSpecializationSpells
{
// Warrior
@@ -5524,6 +5558,7 @@ void AddSC_generic_spell_scripts()
new spell_gen_landmine_knockback_achievement();
new spell_gen_clear_debuffs();
new spell_gen_pony_mount_check();
new spell_gen_shroud_of_death();
new spell_gen_armor_specialization();
new spell_gen_pvp_trinket();
new spell_gen_blink();