feat(Core/Movement): Improved pathfinding, collisions and movements (#4220)

Npc positioning
Implemented slope check to avoid unwanted climbing for some kind of movements (backwards, repositioning etc.)
Implemented backwards movement
Re-implemented circle repositioning algorithm (smartest than retail, but with the same feeling)
Fixed random position of summoned minions
Improved pet following movement. Also, they attack NPC from behind now. Thanks to @Footman

Swimming creatures
Fixed max_z coordinate for swimming creatures. Now only part of their body is allowed to be out of the water level
Fixed pathfinder for swimming creatures creating shortcuts for specific segments, now they swim underwater to reach the seashore instead of flying above the water level.
Creatures with water InhabitType but no swimming flag now, when not in combat, will walk on water depth instead of swimming. Thanks @jackpoz for the original code
UNIT_FLAG_SWIMMING in UpdateEnvironmentIfNeeded to show the swimming animation correctly when underwater
Implemented HasEnoughWater check to avoid swimming creatures to go where the water level is too low but also to properly enable swimming animation only when a creature has enough water to swim.

Walking creatures
Extended the DetourNavMeshQuery adding area cost based on walkability (slope angle + source height) to find better paths at runtime instead of completely remove them from mmaps
improve Z height in certain conditions (see #4205, #4203, #4247 )

Flying creatures
Rewriting of the hover system
Removed hacks and improved the UpdateEnvironmentIfNeeded. Now creatures can properly switch from flying to walk etc.
Spells
LOS on spell effect must be calculated on CollisionHeight and HitSpherePoint instead of position coords.
Improved position for object/creature spawned via spells
Improved checks for Fleeing movements (fear spells)

Other improvements
Implemented method to calculate the CollisionWidth from dbc (used by repositioning algorithm etc.)
Improved raycast and collision checks

Co-authored-by: Footman <p.alexej@freenet.de>
Co-authored-by: Helias <stefanoborzi32@gmail.com>
Co-authored-by: Francesco Borzì <borzifrancesco@gmail.com>
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
Yehonal
2021-02-01 01:34:27 +01:00
committed by GitHub
parent fcad2b56ae
commit c8f43d8584
79 changed files with 3025 additions and 2199 deletions

View File

@@ -57,259 +57,259 @@ enum Misc
class boss_anub_arak : public CreatureScript
{
public:
boss_anub_arak() : CreatureScript("boss_anub_arak") { }
public:
boss_anub_arak() : CreatureScript("boss_anub_arak") { }
struct boss_anub_arakAI : public BossAI
{
boss_anub_arakAI(Creature* creature) : BossAI(creature, DATA_ANUBARAK_EVENT)
struct boss_anub_arakAI : public BossAI
{
me->m_SightDistance = 120.0f;
intro = false;
}
bool intro;
void EnterEvadeMode() override
{
me->DisableRotate(false);
BossAI::EnterEvadeMode();
}
void MoveInLineOfSight(Unit* who) override
{
if (!intro && who->GetTypeId() == TYPEID_PLAYER)
boss_anub_arakAI(Creature* creature) : BossAI(creature, DATA_ANUBARAK_EVENT)
{
intro = true;
Talk(SAY_INTRO);
me->m_SightDistance = 120.0f;
intro = false;
}
BossAI::MoveInLineOfSight(who);
}
void JustDied(Unit* killer) override
{
Talk(SAY_DEATH);
BossAI::JustDied(killer);
}
bool intro;
void KilledUnit(Unit* /*victim*/) override
{
if (events.GetNextEventTime(EVENT_KILL_TALK) == 0)
void EnterEvadeMode() override
{
Talk(SAY_SLAY);
events.ScheduleEvent(EVENT_KILL_TALK, 6000);
me->DisableRotate(false);
BossAI::EnterEvadeMode();
}
}
void JustSummoned(Creature* summon) override
{
summons.Summon(summon);
if (!summon->IsTrigger())
summon->SetInCombatWithZone();
}
void Reset() override
{
BossAI::Reset();
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
void EnterCombat(Unit* ) override
{
Talk(SAY_AGGRO);
instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
events.ScheduleEvent(EVENT_CARRION_BEETELS, 6500);
events.ScheduleEvent(EVENT_LEECHING_SWARM, 20000);
events.ScheduleEvent(EVENT_POUND, 15000);
events.ScheduleEvent(EVENT_CHECK_HEALTH_75, 1000);
events.ScheduleEvent(EVENT_CHECK_HEALTH_50, 1000);
events.ScheduleEvent(EVENT_CHECK_HEALTH_25, 1000);
events.ScheduleEvent(EVENT_CLOSE_DOORS, 5000);
}
void SummonHelpers(float x, float y, float z, uint32 spellId)
{
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
me->SummonCreature(spellInfo->Effects[EFFECT_0].MiscValue, x, y, z);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
switch (uint32 eventId = events.ExecuteEvent())
void MoveInLineOfSight(Unit* who) override
{
case EVENT_CLOSE_DOORS:
_EnterCombat();
break;
case EVENT_CARRION_BEETELS:
me->CastSpell(me, SPELL_CARRION_BEETLES, false);
events.ScheduleEvent(EVENT_CARRION_BEETELS, 25000);
break;
case EVENT_LEECHING_SWARM:
Talk(SAY_LOCUST);
me->CastSpell(me, SPELL_LEECHING_SWARM, false);
events.ScheduleEvent(EVENT_LEECHING_SWARM, 20000);
break;
case EVENT_POUND:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 10.0f))
{
me->CastSpell(me, SPELL_SELF_ROOT, true);
me->DisableRotate(true);
me->SendMovementFlagUpdate();
events.ScheduleEvent(EVENT_ENABLE_ROTATE, 3300);
me->CastSpell(target, SPELL_POUND, false);
}
events.ScheduleEvent(EVENT_POUND, 18000);
break;
case EVENT_ENABLE_ROTATE:
me->RemoveAurasDueToSpell(SPELL_SELF_ROOT);
me->DisableRotate(false);
break;
case EVENT_CHECK_HEALTH_25:
case EVENT_CHECK_HEALTH_50:
case EVENT_CHECK_HEALTH_75:
if (me->HealthBelowPct(eventId * 25))
{
Talk(SAY_SUBMERGE);
me->CastSpell(me, SPELL_IMPALE_PERIODIC, true);
me->CastSpell(me, SPELL_SUBMERGE, false);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
if (!intro && who->GetTypeId() == TYPEID_PLAYER)
{
intro = true;
Talk(SAY_INTRO);
}
BossAI::MoveInLineOfSight(who);
}
events.DelayEvents(46000, 0);
events.ScheduleEvent(EVENT_EMERGE, 45000);
events.ScheduleEvent(EVENT_SUMMON_ASSASSINS, 2000);
events.ScheduleEvent(EVENT_SUMMON_GUARDIAN, 4000);
events.ScheduleEvent(EVENT_SUMMON_ASSASSINS, 15000);
events.ScheduleEvent(EVENT_SUMMON_VENOMANCER, 20000);
events.ScheduleEvent(EVENT_SUMMON_DARTER, 30000);
events.ScheduleEvent(EVENT_SUMMON_ASSASSINS, 35000);
void JustDied(Unit* killer) override
{
Talk(SAY_DEATH);
BossAI::JustDied(killer);
}
void KilledUnit(Unit* /*victim*/) override
{
if (events.GetNextEventTime(EVENT_KILL_TALK) == 0)
{
Talk(SAY_SLAY);
events.ScheduleEvent(EVENT_KILL_TALK, 6000);
}
}
void JustSummoned(Creature* summon) override
{
summons.Summon(summon);
if (!summon->IsTrigger())
summon->SetInCombatWithZone();
}
void Reset() override
{
BossAI::Reset();
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
void EnterCombat(Unit* ) override
{
Talk(SAY_AGGRO);
instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
events.ScheduleEvent(EVENT_CARRION_BEETELS, 6500);
events.ScheduleEvent(EVENT_LEECHING_SWARM, 20000);
events.ScheduleEvent(EVENT_POUND, 15000);
events.ScheduleEvent(EVENT_CHECK_HEALTH_75, 1000);
events.ScheduleEvent(EVENT_CHECK_HEALTH_50, 1000);
events.ScheduleEvent(EVENT_CHECK_HEALTH_25, 1000);
events.ScheduleEvent(EVENT_CLOSE_DOORS, 5000);
}
void SummonHelpers(float x, float y, float z, uint32 spellId)
{
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
me->SummonCreature(spellInfo->Effects[EFFECT_0].MiscValue, x, y, z);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
switch (uint32 eventId = events.ExecuteEvent())
{
case EVENT_CLOSE_DOORS:
_EnterCombat();
break;
}
events.ScheduleEvent(eventId, 500);
break;
case EVENT_EMERGE:
me->CastSpell(me, SPELL_EMERGE, true);
me->RemoveAura(SPELL_SUBMERGE);
me->RemoveAura(SPELL_IMPALE_PERIODIC);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
break;
case EVENT_SUMMON_ASSASSINS:
SummonHelpers(509.32f, 247.42f, 239.48f, SPELL_SUMMON_ASSASSIN);
SummonHelpers(589.51f, 240.19f, 236.0f, SPELL_SUMMON_ASSASSIN);
break;
case EVENT_SUMMON_DARTER:
SummonHelpers(509.32f, 247.42f, 239.48f, SPELL_SUMMON_DARTER);
SummonHelpers(589.51f, 240.19f, 236.0f, SPELL_SUMMON_DARTER);
break;
case EVENT_SUMMON_GUARDIAN:
SummonHelpers(550.34f, 316.00f, 234.30f, SPELL_SUMMON_GUARDIAN);
break;
case EVENT_SUMMON_VENOMANCER:
SummonHelpers(550.34f, 316.00f, 234.30f, SPELL_SUMMON_VENOMANCER);
break;
case EVENT_CARRION_BEETELS:
me->CastSpell(me, SPELL_CARRION_BEETLES, false);
events.ScheduleEvent(EVENT_CARRION_BEETELS, 25000);
break;
case EVENT_LEECHING_SWARM:
Talk(SAY_LOCUST);
me->CastSpell(me, SPELL_LEECHING_SWARM, false);
events.ScheduleEvent(EVENT_LEECHING_SWARM, 20000);
break;
case EVENT_POUND:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 10.0f))
{
me->CastSpell(me, SPELL_SELF_ROOT, true);
me->DisableRotate(true);
me->SendMovementFlagUpdate();
events.ScheduleEvent(EVENT_ENABLE_ROTATE, 3300);
me->CastSpell(target, SPELL_POUND, false);
}
events.ScheduleEvent(EVENT_POUND, 18000);
break;
case EVENT_ENABLE_ROTATE:
me->RemoveAurasDueToSpell(SPELL_SELF_ROOT);
me->DisableRotate(false);
break;
case EVENT_CHECK_HEALTH_25:
case EVENT_CHECK_HEALTH_50:
case EVENT_CHECK_HEALTH_75:
if (me->HealthBelowPct(eventId*25))
{
Talk(SAY_SUBMERGE);
me->CastSpell(me, SPELL_IMPALE_PERIODIC, true);
me->CastSpell(me, SPELL_SUBMERGE, false);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
events.DelayEvents(46000, 0);
events.ScheduleEvent(EVENT_EMERGE, 45000);
events.ScheduleEvent(EVENT_SUMMON_ASSASSINS, 2000);
events.ScheduleEvent(EVENT_SUMMON_GUARDIAN, 4000);
events.ScheduleEvent(EVENT_SUMMON_ASSASSINS, 15000);
events.ScheduleEvent(EVENT_SUMMON_VENOMANCER, 20000);
events.ScheduleEvent(EVENT_SUMMON_DARTER, 30000);
events.ScheduleEvent(EVENT_SUMMON_ASSASSINS, 35000);
break;
}
events.ScheduleEvent(eventId, 500);
break;
case EVENT_EMERGE:
me->CastSpell(me, SPELL_EMERGE, true);
me->RemoveAura(SPELL_SUBMERGE);
me->RemoveAura(SPELL_IMPALE_PERIODIC);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
break;
case EVENT_SUMMON_ASSASSINS:
SummonHelpers(509.32f, 247.42f, 239.48f, SPELL_SUMMON_ASSASSIN);
SummonHelpers(589.51f, 240.19f, 236.0f, SPELL_SUMMON_ASSASSIN);
break;
case EVENT_SUMMON_DARTER:
SummonHelpers(509.32f, 247.42f, 239.48f, SPELL_SUMMON_DARTER);
SummonHelpers(589.51f, 240.19f, 236.0f, SPELL_SUMMON_DARTER);
break;
case EVENT_SUMMON_GUARDIAN:
SummonHelpers(550.34f, 316.00f, 234.30f, SPELL_SUMMON_GUARDIAN);
break;
case EVENT_SUMMON_VENOMANCER:
SummonHelpers(550.34f, 316.00f, 234.30f, SPELL_SUMMON_VENOMANCER);
break;
}
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
DoMeleeAttackIfReady();
}
};
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
DoMeleeAttackIfReady();
CreatureAI* GetAI(Creature* creature) const override
{
return new boss_anub_arakAI(creature);
}
};
CreatureAI* GetAI(Creature* creature) const override
{
return new boss_anub_arakAI(creature);
}
};
class spell_azjol_nerub_carrion_beetels : public SpellScriptLoader
{
public:
spell_azjol_nerub_carrion_beetels() : SpellScriptLoader("spell_azjol_nerub_carrion_beetels") { }
public:
spell_azjol_nerub_carrion_beetels() : SpellScriptLoader("spell_azjol_nerub_carrion_beetels") { }
class spell_azjol_nerub_carrion_beetelsAuraScript : public AuraScript
{
PrepareAuraScript(spell_azjol_nerub_carrion_beetelsAuraScript)
void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
class spell_azjol_nerub_carrion_beetelsAuraScript : public AuraScript
{
// Xinef: 2 each second
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SUMMON_CARRION_BEETLES, true);
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SUMMON_CARRION_BEETLES, true);
}
PrepareAuraScript(spell_azjol_nerub_carrion_beetelsAuraScript)
void Register() override
void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
{
// Xinef: 2 each second
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SUMMON_CARRION_BEETLES, true);
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SUMMON_CARRION_BEETLES, true);
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_azjol_nerub_carrion_beetelsAuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
}
};
AuraScript *GetAuraScript() const override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_azjol_nerub_carrion_beetelsAuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
return new spell_azjol_nerub_carrion_beetelsAuraScript();
}
};
AuraScript* GetAuraScript() const override
{
return new spell_azjol_nerub_carrion_beetelsAuraScript();
}
};
class spell_azjol_nerub_pound : public SpellScriptLoader
{
public:
spell_azjol_nerub_pound() : SpellScriptLoader("spell_azjol_nerub_pound") { }
public:
spell_azjol_nerub_pound() : SpellScriptLoader("spell_azjol_nerub_pound") { }
class spell_azjol_nerub_pound_SpellScript : public SpellScript
{
PrepareSpellScript(spell_azjol_nerub_pound_SpellScript);
void HandleApplyAura(SpellEffIndex /*effIndex*/)
class spell_azjol_nerub_pound_SpellScript : public SpellScript
{
if (Unit* unitTarget = GetHitUnit())
GetCaster()->CastSpell(unitTarget, SPELL_POUND_DAMAGE, true);
}
PrepareSpellScript(spell_azjol_nerub_pound_SpellScript);
void Register() override
void HandleApplyAura(SpellEffIndex /*effIndex*/)
{
if (Unit* unitTarget = GetHitUnit())
GetCaster()->CastSpell(unitTarget, SPELL_POUND_DAMAGE, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_azjol_nerub_pound_SpellScript::HandleApplyAura, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
}
};
SpellScript* GetSpellScript() const override
{
OnEffectHitTarget += SpellEffectFn(spell_azjol_nerub_pound_SpellScript::HandleApplyAura, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
return new spell_azjol_nerub_pound_SpellScript();
}
};
SpellScript* GetSpellScript() const override
{
return new spell_azjol_nerub_pound_SpellScript();
}
};
class spell_azjol_nerub_impale_summon : public SpellScriptLoader
{
public:
spell_azjol_nerub_impale_summon() : SpellScriptLoader("spell_azjol_nerub_impale_summon") { }
public:
spell_azjol_nerub_impale_summon() : SpellScriptLoader("spell_azjol_nerub_impale_summon") { }
class spell_azjol_nerub_impale_summon_SpellScript : public SpellScript
{
PrepareSpellScript(spell_azjol_nerub_impale_summon_SpellScript);
void SetDest(SpellDestination& dest)
class spell_azjol_nerub_impale_summon_SpellScript : public SpellScript
{
// Adjust effect summon position
float floorZ = GetCaster()->GetMap()->GetHeight(GetCaster()->GetPositionX(), GetCaster()->GetPositionY(), GetCaster()->GetPositionZ(), true);
if (floorZ > INVALID_HEIGHT)
dest._position.m_positionZ = floorZ;
}
PrepareSpellScript(spell_azjol_nerub_impale_summon_SpellScript);
void Register() override
void SetDest(SpellDestination& dest)
{
// Adjust effect summon position
float floorZ = GetCaster()->GetMapHeight(GetCaster()->GetPositionX(), GetCaster()->GetPositionY(), GetCaster()->GetPositionZ(), true);
if (floorZ > INVALID_HEIGHT)
dest._position.m_positionZ = floorZ;
}
void Register() override
{
OnDestinationTargetSelect += SpellDestinationTargetSelectFn(spell_azjol_nerub_impale_summon_SpellScript::SetDest, EFFECT_0, TARGET_DEST_CASTER);
}
};
SpellScript* GetSpellScript() const override
{
OnDestinationTargetSelect += SpellDestinationTargetSelectFn(spell_azjol_nerub_impale_summon_SpellScript::SetDest, EFFECT_0, TARGET_DEST_CASTER);
return new spell_azjol_nerub_impale_summon_SpellScript();
}
};
SpellScript* GetSpellScript() const override
{
return new spell_azjol_nerub_impale_summon_SpellScript();
}
};
void AddSC_boss_anub_arak()

View File

@@ -1376,7 +1376,7 @@ public:
me->GetPosition(x, y, z);
_x = x;
_y = y;
_groundZ = me->GetMap()->GetHeight(me->GetPhaseMask(), x, y, z, true, 500.0f);
_groundZ = me->GetMapHeight(x, y, z, true, 500.0f);
me->GetMotionMaster()->MoveCharge(_x, _y, _groundZ, me->GetSpeed(MOVE_WALK));
}
@@ -1748,7 +1748,7 @@ public:
float destY = summoner->GetPositionY() + sin(angle + a * M_PI) * i * 10.0f;
if (summoner->GetMap()->isInLineOfSight(summoner->GetPositionX(), summoner->GetPositionY(), summoner->GetPositionZ() + 10.0f, destX, destY, summoner->GetPositionZ() + 10.0f, summoner->GetPhaseMask(), LINEOFSIGHT_ALL_CHECKS) && destX > 4585.0f && destY > 2716.0f && destY < 2822.0f)
{
float destZ = summoner->GetMap()->GetHeight(summoner->GetPhaseMask(), destX, destY, summoner->GetPositionZ() + 10.0f);
float destZ = summoner->GetMapHeight(summoner->GetPhaseMask(), destX, destY, summoner->GetPositionZ());
if (fabs(destZ - summoner->GetPositionZ()) < 10.0f) // valid z found
{
dest._position.Relocate(destX, destY, destZ);

View File

@@ -2532,7 +2532,8 @@ public:
bool operator()(WorldObject* unit)
{
return unit->GetTypeId() != TYPEID_PLAYER || unit->GetPositionZ() > 478.0f || !unit->GetTransport() || unit->GetTransport()->GetEntry() != _entry || unit->GetMap()->GetHeight(unit->GetPhaseMask(), unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()) < 465.0f;
return unit->GetTypeId() != TYPEID_PLAYER || unit->GetPositionZ() > 478.0f || !unit->GetTransport() || unit->GetTransport()->GetEntry() != _entry
|| unit->GetMapHeight(unit->GetPhaseMask(), unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()) < 465.0f;
}
private:
@@ -2566,7 +2567,9 @@ public:
void HandleScript(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetCaster()->CastSpell(GetHitUnit()->GetPositionX(), GetHitUnit()->GetPositionY(), GetHitUnit()->GetMap()->GetHeight(GetCaster()->GetPhaseMask(), GetHitUnit()->GetPositionX(), GetHitUnit()->GetPositionY(), GetHitUnit()->GetPositionZ()), uint32(GetEffectValue()), TRIGGERED_NONE);
GetCaster()->CastSpell(GetHitUnit()->GetPositionX(), GetHitUnit()->GetPositionY(),
GetHitUnit()->GetMapHeight(GetCaster()->GetPhaseMask(), GetHitUnit()->GetPositionX(), GetHitUnit()->GetPositionY(), GetHitUnit()->GetPositionZ()),
uint32(GetEffectValue()), TRIGGERED_NONE);
}
void Register() override

View File

@@ -201,18 +201,16 @@ public:
{
if (!sindragosa->IsAlive())
return true;
Position pos;
_owner->GetPosition(&pos);
_owner->m_positionZ -= 1.0f; // +2.0f in UpdateGroundPositionZ, prevent going over GO model of another ice block, because new would be spawned on top of the old one xd
_owner->UpdateGroundPositionZ(pos.m_positionX, pos.m_positionY, pos.m_positionZ);
if (pos.GetPositionZ() < 203.0f)
pos.m_positionZ = 203.0f;
if (TempSummon* summon = sindragosa->SummonCreature(NPC_ICE_TOMB, pos))
{
summon->m_positionZ = summon->GetPositionZ() + 5.0f;
summon->AI()->SetGUID(_owner->GetGUID(), DATA_TRAPPED_PLAYER);
_owner->CastSpell(_owner, SPELL_ICE_TOMB_UNTARGETABLE, true);
if (GameObject* go = summon->SummonGameObject(GO_ICE_BLOCK, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() - 3.5f, pos.GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0))
if (GameObject* go = summon->SummonGameObject(GO_ICE_BLOCK, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0))
{
go->SetSpellId(SPELL_ICE_TOMB_DAMAGE);
summon->AddGameObject(go);
@@ -661,7 +659,7 @@ public:
me->GetMotionMaster()->MoveLand(POINT_LAND_GROUND, SindragosaLandPos, 10.0f);
break;
case EVENT_THIRD_PHASE_CHECK:
if (!me->HasByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_HOVER))
if (!me->HasByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, UNIT_BYTE1_FLAG_HOVER))
{
Talk(SAY_PHASE_2);
events.ScheduleEvent(EVENT_ICE_TOMB, urand(7000, 10000));
@@ -1654,7 +1652,7 @@ public:
me->SetDisableGravity(true);
me->SetHover(true);
me->SendMovementFlagUpdate();
float floorZ = me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 2.0f);
float floorZ = me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
float destZ;
if (floorZ > 190.0f) destZ = floorZ + 25.0f;
else destZ = me->GetPositionZ() + 25.0f;
@@ -1676,7 +1674,7 @@ public:
}
else
{
float floorZ = me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 2.0f);
float floorZ = me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
float destZ;
if (floorZ > 190.0f) destZ = floorZ;
else destZ = me->GetPositionZ() - 25.0f;

View File

@@ -798,13 +798,13 @@ public:
if (_phase == PHASE_OUTRO)
{
if (!me->HasByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_HOVER))
if (!me->HasByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, UNIT_BYTE1_FLAG_HOVER))
damage = me->GetHealth() > 1 ? 1 : 0;
else if (damage >= me->GetHealth()) // dying...
{
damage = me->GetHealth() - 1;
me->SetDisableGravity(false);
me->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER);
me->RemoveByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER);
me->SendMonsterMove(me->GetPositionX() + 0.25f, me->GetPositionY(), 840.86f, 300, SPLINEFLAG_FALLING);
me->m_positionZ = 840.86f;
me->SetOrientation(0.0f);
@@ -1546,7 +1546,7 @@ public:
theLichKing->CastSpell((Unit*)NULL, SPELL_SOUL_BARRAGE, TRIGGERED_IGNORE_CAST_IN_PROGRESS);
sCreatureTextMgr->SendSound(theLichKing, SOUND_PAIN, CHAT_MSG_MONSTER_YELL, 0, TEXT_RANGE_NORMAL, TEAM_NEUTRAL, false);
theLichKing->SetDisableGravity(true);
theLichKing->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER);
theLichKing->SetByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER);
theLichKing->GetMotionMaster()->MovePoint(0, OutroFlying);
_events.ScheduleEvent(EVENT_OUTRO_AFTER_SOUL_BARRAGE, 3000);

View File

@@ -146,14 +146,14 @@ public:
for (uint8 j = 0; j < 8; ++j)
{
float angle = M_PI * 2 / 8 * j;
me->SummonCreature(NPC_SOLDIER_OF_THE_FROZEN_WASTES, SummonPositions[i].GetPositionX() + 6 * cos(angle), SummonPositions[i].GetPositionY() + 6 * sin(angle), SummonPositions[i].GetPositionZ() + 0.5f, SummonPositions[i].GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
me->SummonCreature(NPC_SOLDIER_OF_THE_FROZEN_WASTES, SummonPositions[i].GetPositionX() + 6 * cos(angle), SummonPositions[i].GetPositionY() + 6 * sin(angle), SummonPositions[i].GetPositionZ(), SummonPositions[i].GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
}
for (uint8 i = 6; i < 12; ++i)
for (uint8 j = 1; j < 4; ++j)
{
float dist = j == 2 ? 0.0f : 8.0f; // second in middle
float angle = SummonPositions[i].GetOrientation() + M_PI * 2 / 4 * j;
me->SummonCreature(NPC_UNSTOPPABLE_ABOMINATION, SummonPositions[i].GetPositionX() + dist * cos(angle), SummonPositions[i].GetPositionY() + dist * sin(angle), SummonPositions[i].GetPositionZ() + 0.5f, SummonPositions[i].GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
me->SummonCreature(NPC_UNSTOPPABLE_ABOMINATION, SummonPositions[i].GetPositionX() + dist * cos(angle), SummonPositions[i].GetPositionY() + dist * sin(angle), SummonPositions[i].GetPositionZ(), SummonPositions[i].GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
}
for (uint8 i = 6; i < 12; ++i)
for (uint8 j = 0; j < 1; ++j)

View File

@@ -153,7 +153,7 @@ public:
float o = rand_norm() * 2.0f * M_PI;
float x = me->GetPositionX() + 5.0f * _spikesCount * cos(o);
float y = me->GetPositionY() + 5.0f * _spikesCount * sin(o);
float h = me->GetMap()->GetHeight(x, y, me->GetPositionZ() + 5.0f);
float h = me->GetMapHeight(x, y, me->GetPositionZ());
if (h != INVALID_HEIGHT)
me->SummonCreature(NPC_CRYSTAL_SPIKE, x, y, h, 0, TEMPSUMMON_TIMED_DESPAWN, 7000);

View File

@@ -1383,7 +1383,7 @@ public:
{
float x, y, z;
me->GetPosition(x, y, z);
z = me->GetMap()->GetHeight(me->GetPhaseMask(), x, y, z);
z = me->GetMapHeight(x, y, z);
me->GetMotionMaster()->MovePoint(me->GetEntry(), x, y, z);
me->SetPosition(x, y, z, 0);
}

View File

@@ -387,16 +387,16 @@ public:
{
me->MonsterYell("Children, assist me!", LANG_UNIVERSAL, 0);
me->PlayDirectSound(SOUND_TRIO);
me->SummonCreature(NPC_ANCIENT_WATER_SPIRIT, me->GetPositionX() + urand(5, 15), me->GetPositionY() + urand(5, 15), me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), MAX_HEIGHT));
me->SummonCreature(NPC_STORM_LASHER, me->GetPositionX() + urand(5, 15), me->GetPositionY() + urand(5, 15), me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), MAX_HEIGHT));
me->SummonCreature(NPC_SNAPLASHER, me->GetPositionX() + urand(5, 15), me->GetPositionY() + urand(5, 15), me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), MAX_HEIGHT));
me->SummonCreature(NPC_ANCIENT_WATER_SPIRIT, me->GetPositionX() + urand(5, 15), me->GetPositionY() + urand(5, 15), me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
me->SummonCreature(NPC_STORM_LASHER, me->GetPositionX() + urand(5, 15), me->GetPositionY() + urand(5, 15), me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
me->SummonCreature(NPC_SNAPLASHER, me->GetPositionX() + urand(5, 15), me->GetPositionY() + urand(5, 15), me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
}
// Ancient Conservator
else if (_waveNumber == 2)
{
me->MonsterYell("Eonar, your servant requires aid!", LANG_UNIVERSAL, 0);
me->PlayDirectSound(SOUND_CONSERVATOR);
me->SummonCreature(NPC_ANCIENT_CONSERVATOR, me->GetPositionX() + urand(5, 15), me->GetPositionY() + urand(5, 15), me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), MAX_HEIGHT), 0, TEMPSUMMON_CORPSE_DESPAWN);
me->SummonCreature(NPC_ANCIENT_CONSERVATOR, me->GetPositionX() + urand(5, 15), me->GetPositionY() + urand(5, 15), me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()), 0, TEMPSUMMON_CORPSE_DESPAWN);
}
// Detonating Lashers
else if (_waveNumber == 3)
@@ -404,7 +404,7 @@ public:
me->MonsterYell("The swarm of the elements shall overtake you!", LANG_UNIVERSAL, 0);
me->PlayDirectSound(SOUND_DETONATING);
for (uint8 i = 0; i < 10; ++i)
me->SummonCreature(NPC_DETONATING_LASHER, me->GetPositionX() + urand(5, 20), me->GetPositionY() + urand(5, 20), me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), MAX_HEIGHT), 0, TEMPSUMMON_CORPSE_DESPAWN);
me->SummonCreature(NPC_DETONATING_LASHER, me->GetPositionX() + urand(5, 20), me->GetPositionY() + urand(5, 20), me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()), 0, TEMPSUMMON_CORPSE_DESPAWN);
}
}
@@ -586,7 +586,7 @@ public:
{
x = me->GetPositionX() + urand(7, 25);
y = me->GetPositionY() + urand(7, 25);
z = me->GetMap()->GetHeight(x, y, MAX_HEIGHT) + 0.5f;
z = me->GetMapHeight(x, y, me->GetPositionZ());
if (me->IsWithinLOS(x, y, z))
{
me->CastSpell(x, y, z, SPELL_SUMMON_LIFEBINDER, true);
@@ -641,11 +641,11 @@ public:
events.RepeatEvent(45000 + urand(0, 10000));
break;
case EVENT_FREYA_UNSTABLE_SUN_BEAM:
me->SummonCreature(NPC_FREYA_UNSTABLE_SUN_BEAM, me->GetPositionX() + urand(7, 25), me->GetPositionY() + urand(7, 25), me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), MAX_HEIGHT), 0, TEMPSUMMON_TIMED_DESPAWN, 10000);
me->SummonCreature(NPC_FREYA_UNSTABLE_SUN_BEAM, me->GetPositionX() + urand(7, 25), me->GetPositionY() + urand(7, 25), me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()), 0, TEMPSUMMON_TIMED_DESPAWN, 10000);
if (Is25ManRaid())
{
me->SummonCreature(NPC_FREYA_UNSTABLE_SUN_BEAM, me->GetPositionX() + urand(7, 25), me->GetPositionY() + urand(7, 25), me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), MAX_HEIGHT), 0, TEMPSUMMON_TIMED_DESPAWN, 10000);
me->SummonCreature(NPC_FREYA_UNSTABLE_SUN_BEAM, me->GetPositionX() + urand(7, 25), me->GetPositionY() + urand(7, 25), me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), MAX_HEIGHT), 0, TEMPSUMMON_TIMED_DESPAWN, 10000);
me->SummonCreature(NPC_FREYA_UNSTABLE_SUN_BEAM, me->GetPositionX() + urand(7, 25), me->GetPositionY() + urand(7, 25), me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()), 0, TEMPSUMMON_TIMED_DESPAWN, 10000);
me->SummonCreature(NPC_FREYA_UNSTABLE_SUN_BEAM, me->GetPositionX() + urand(7, 25), me->GetPositionY() + urand(7, 25), me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()), 0, TEMPSUMMON_TIMED_DESPAWN, 10000);
}
events.RepeatEvent(38000 + urand(0, 10000));
break;

View File

@@ -152,7 +152,7 @@ public:
_nerfAchievement = true;
_gravityAchievement = true;
me->SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_STAND); // emerge
me->SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE, UNIT_STAND_STATE_STAND); // emerge
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
me->SetControlled(false, UNIT_STATE_STUNNED);
@@ -262,7 +262,7 @@ public:
me->SetLootMode(3); // hard mode + normal loot
me->SetMaxHealth(me->GetMaxHealth());
me->SetHealth(me->GetMaxHealth());
me->SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_STAND); // emerge
me->SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE, UNIT_STAND_STATE_STAND); // emerge
me->CastSpell(me, SPELL_HEARTBREAK, true);
@@ -314,7 +314,7 @@ public:
{
_healthCheck -= 25;
me->SetControlled(true, UNIT_STATE_STUNNED);
me->SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_SUBMERGED); // submerge with animation
me->SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE, UNIT_STAND_STATE_SUBMERGED); // submerge with animation
me->MonsterYell("So tired. I will rest for just a moment!", LANG_UNIVERSAL, 0);
me->PlayDirectSound(XT_SOUND_HEART_OPEN);
@@ -373,7 +373,7 @@ public:
me->MonsterYell("I'm ready to play!", LANG_UNIVERSAL, 0);
me->PlayDirectSound(XT_SOUND_HEART_CLOSED);
me->SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_STAND); // emerge
me->SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE, UNIT_STAND_STATE_STAND); // emerge
// Hide heart
if (Unit* heart = me->GetVehicleKit() ? me->GetVehicleKit()->GetPassenger(HEART_VEHICLE_SEAT) : nullptr)
heart->GetAI()->DoAction(ACTION_HIDE_HEART);

View File

@@ -358,7 +358,7 @@ public:
break;
case EVENT_AXE_RETURN:
if (Creature* c = ObjectAccessor::GetCreature(*me, ThrowGUID))
c->GetMotionMaster()->MoveCharge(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 0.5f);
c->GetMotionMaster()->MoveCharge(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
events.RescheduleEvent(EVENT_AXE_PICKUP, 1500);
break;
case EVENT_AXE_PICKUP:

View File

@@ -148,7 +148,7 @@ public:
Talk(SAY_DEATH);
if (pInstance)
pInstance->SetData(DATA_BOSS_DIED, 0);
float h = me->GetMap()->GetHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 2.0f);
float h = me->GetMapHeight(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
if (h != INVALID_HEIGHT && me->GetPositionZ() - h > 3.0f)
{
me->UpdatePosition(me->GetPositionX(), me->GetPositionY(), h, me->GetOrientation(), true); // move to ground

View File

@@ -1289,7 +1289,7 @@ public:
Unit::Kill(bird, bird);
crunchy->GetMotionMaster()->MovePoint(0, bird->GetPositionX(), bird->GetPositionY(),
bird->GetMap()->GetWaterOrGroundLevel(bird->GetPhaseMask(), bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ()));
bird->GetMapWaterOrGroundLevel(bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ()));
/// @todo Make crunchy perform emote eat when he reaches the bird
break;