mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
fix(Scripts/HyjalSummit): Adjust Doomfire Spirit movement logic. (#19469)
* Init. Co-Authored-By: Tereneckla <Tereneckla@pm.me> * Simplify code, add comment. * Adjust scenario in which distance fails at all ranges. * Remove unused variable. * Account for deviation with distance check. Co-Authored-By: Tereneckla <Tereneckla@pm.me> * f Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com> * Rewrite with initial teleport. * Whitespace? * Update function type. * Drop Doomfire spawn timer. Verified with le sniff. Teehee. --------- Co-authored-by: Tereneckla <Tereneckla@pm.me> Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
@@ -145,32 +145,35 @@ struct npc_doomfire_spirit : public ScriptedAI
|
|||||||
{
|
{
|
||||||
npc_doomfire_spirit(Creature* creature) : ScriptedAI(creature){ }
|
npc_doomfire_spirit(Creature* creature) : ScriptedAI(creature){ }
|
||||||
|
|
||||||
float const turnConstant = 0.785402f;
|
float const turnConstant = 0.785402f; // 45 degree turns, verified with sniffs
|
||||||
float fAngle = urand(0, M_PI * 2);
|
|
||||||
|
|
||||||
void Reset() override
|
void Reset() override
|
||||||
{
|
{
|
||||||
scheduler.CancelAll();
|
ScheduleUniqueTimedEvent(10ms, [&] {
|
||||||
ScheduleTimedEvent(0s, [&] {
|
TryTeleportInDirection(1.f, M_PI, 1.f, true); //turns around and teleports 1 unit on spawn, assuming same logic as later teleports applies
|
||||||
float nextOrientation = Position::NormalizeOrientation(me->GetOrientation() + irand(-1, 1) * turnConstant);
|
|
||||||
Position pos = GetFirstRandomAngleCollisionPosition(8.f, nextOrientation); // both orientation and distance verified with sniffs
|
|
||||||
me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), nextOrientation);
|
|
||||||
}, 1600ms);
|
|
||||||
|
|
||||||
fAngle = urand(0, M_PI * 2);
|
ScheduleTimedEvent(10ms, [&] {
|
||||||
|
float angle = irand(-1, 1) * turnConstant;
|
||||||
|
TryTeleportInDirection(8.f, angle, 2.f, false);
|
||||||
|
}, 1600ms);
|
||||||
|
},1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Position GetFirstRandomAngleCollisionPosition(float dist, float angle)
|
void TryTeleportInDirection(float dist, float angle, float step, bool alwaysturn)
|
||||||
{
|
{
|
||||||
Position pos;
|
Position pos;
|
||||||
for (uint32 i = 0; i < 10; ++i)
|
while (dist >= 0)
|
||||||
{
|
{
|
||||||
pos = me->WorldObject::GetFirstCollisionPosition(dist, angle);
|
pos = me->WorldObject::GetFirstCollisionPosition(dist, angle);
|
||||||
if (me->GetDistance(pos) > dist * 0.8f) // if at least 80% distance, good enough
|
if (fabsf(dist - me->GetExactDist2d(pos)) < 0.001) // Account for small deviation
|
||||||
break;
|
break;
|
||||||
angle += (M_PI / 5); // else try slightly different angle
|
dist -= step; // Distance drops with each unsuccessful attempt
|
||||||
}
|
}
|
||||||
return pos;
|
|
||||||
|
if (dist || alwaysturn)
|
||||||
|
me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), Position::NormalizeOrientation(me->GetOrientation() + angle));
|
||||||
|
else // Orientation does not change if not moving, verified with sniffs
|
||||||
|
me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), me->GetOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateAI(uint32 diff) override
|
void UpdateAI(uint32 diff) override
|
||||||
@@ -268,10 +271,10 @@ struct boss_archimonde : public BossAI
|
|||||||
Talk(SAY_AIR_BURST);
|
Talk(SAY_AIR_BURST);
|
||||||
DoCastRandomTarget(SPELL_AIR_BURST);
|
DoCastRandomTarget(SPELL_AIR_BURST);
|
||||||
}, 25s, 40s);
|
}, 25s, 40s);
|
||||||
ScheduleTimedEvent(25s, 35s, [&]
|
ScheduleTimedEvent(8s, [&]
|
||||||
{
|
{
|
||||||
DoCastDoomFire();
|
DoCastDoomFire();
|
||||||
}, 20s);
|
}, 8s);
|
||||||
ScheduleTimedEvent(25s, 35s, [&]
|
ScheduleTimedEvent(25s, 35s, [&]
|
||||||
{
|
{
|
||||||
DoCastRandomTarget(SPELL_GRIP_OF_THE_LEGION);
|
DoCastRandomTarget(SPELL_GRIP_OF_THE_LEGION);
|
||||||
@@ -400,7 +403,7 @@ struct boss_archimonde : public BossAI
|
|||||||
float angle = 2 * M_PI * rand() / RAND_MAX;
|
float angle = 2 * M_PI * rand() / RAND_MAX;
|
||||||
float x = me->GetPositionX() + DOOMFIRE_OFFSET * cos(angle);
|
float x = me->GetPositionX() + DOOMFIRE_OFFSET * cos(angle);
|
||||||
float y = me->GetPositionY() + DOOMFIRE_OFFSET * sin(angle);
|
float y = me->GetPositionY() + DOOMFIRE_OFFSET * sin(angle);
|
||||||
Position spiritPosition = Position(x, y, me->GetPositionZ(), angle);
|
Position spiritPosition = Position(x, y, me->GetPositionZ(), Position::NormalizeOrientation(angle + M_PI)); //spirit faces archimonde on spawn
|
||||||
Position doomfirePosition = Position(x, y, me->GetPositionZ());
|
Position doomfirePosition = Position(x, y, me->GetPositionZ());
|
||||||
if (Creature* doomfireSpirit = me->SummonCreature(CREATURE_DOOMFIRE_SPIRIT, spiritPosition, TEMPSUMMON_TIMED_DESPAWN, 27000))
|
if (Creature* doomfireSpirit = me->SummonCreature(CREATURE_DOOMFIRE_SPIRIT, spiritPosition, TEMPSUMMON_TIMED_DESPAWN, 27000))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user