diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-10-31 20:20:00 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-10-31 20:20:00 +0100 |
commit | 9894f6b802c974bb36acd7fbb0d083455a1f0f1b (patch) | |
tree | 458f167a846d70d4b2391c805423d9342b36f89a /src/server/scripts/Northrend | |
parent | a0fdac0ecc119b4ba85d41f86891b3cd35f7acde (diff) |
Core/Random: Changed random functions returning doubles to return floats
* They were all cast to float at use anyway
* Improves roll_chance_f performance (rand32() is now called internally by uniform_real_distribution once instead of twice)
Diffstat (limited to 'src/server/scripts/Northrend')
3 files changed, 10 insertions, 10 deletions
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index d6ab270a5fc..86c9ee09c49 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -522,8 +522,8 @@ struct boss_sindragosa : public BossAI case EVENT_FROST_BOMB: { float destX, destY, destZ; - destX = float(rand_norm()) * 75.0f + 4350.0f; - destY = float(rand_norm()) * 75.0f + 2450.0f; + destX = rand_norm() * 75.0f + 4350.0f; + destY = rand_norm() * 75.0f + 2450.0f; destZ = 205.0f; // random number close to ground, get exact in next call me->UpdateGroundPositionZ(destX, destY, destZ); me->CastSpell(Position{ destX, destY, destZ }, SPELL_FROST_BOMB_TRIGGER, false); @@ -1025,13 +1025,13 @@ class spell_sindragosa_s_fury : public SpellScript void SelectDest() { - if (Position* dest = const_cast<WorldLocation*>(GetExplTargetDest())) + if (WorldLocation const* dest = GetExplTargetDest()) { - float destX = float(rand_norm()) * 75.0f + 4350.0f; - float destY = float(rand_norm()) * 75.0f + 2450.0f; + float destX = rand_norm() * 75.0f + 4350.0f; + float destY = rand_norm() * 75.0f + 2450.0f; float destZ = 205.0f; // random number close to ground, get exact in next call GetCaster()->UpdateGroundPositionZ(destX, destY, destZ); - dest->Relocate(destX, destY, destZ); + SetExplTargetDest(WorldLocation(dest->GetMapId(), destX, destY, destZ)); } } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 1a30c3c5bee..ba5dcb80c28 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -1642,7 +1642,7 @@ struct npc_strangulate_vehicle : public ScriptedAI { if (me->GetExactDist(lichKing) > 10.0f) { - Position pos = lichKing->GetNearPosition(float(rand_norm()) * 5.0f + 7.5f, lichKing->GetAbsoluteAngle(me)); + Position pos = lichKing->GetNearPosition(rand_norm() * 5.0f + 7.5f, lichKing->GetAbsoluteAngle(me)); me->GetMotionMaster()->MovePoint(0, pos); } } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp index 72e07397e3e..85572114efc 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp @@ -159,11 +159,11 @@ static inline Position const& GetRandomMinionSpawnPoint() // uniformly distribute on the circle static Position GetRandomPositionOnCircle(Position const& center, float radius) { - double angle = rand_norm() * 2.0 * M_PI; - double relDistance = rand_norm() + rand_norm(); + float angle = float(M_PI * rand_norm() * 2.0); + float relDistance = rand_norm() + rand_norm(); if (relDistance > 1) relDistance = 1 - relDistance; - return Position(center.GetPositionX() + std::sin(angle)*relDistance*radius, center.GetPositionY() + std::cos(angle)*relDistance*radius, center.GetPositionZ()); + return Position(center.GetPositionX() + std::sin(angle) * relDistance * radius, center.GetPositionY() + std::cos(angle) * relDistance * radius, center.GetPositionZ()); } class KelThuzadCharmedPlayerAI : public SimpleCharmedPlayerAI |