Core/Misc: Apply random position selection improvements from ed2a08dc70 to WorldObject::GetRandomPoint and WorldObject::GetRandomNearPosition
This commit is contained in:
+1
-4
@@ -403,10 +403,7 @@ class instance_culling_of_stratholme : public InstanceMapScript
|
||||
if (player->GetGUID() == guid || !player->IsGameMaster())
|
||||
{
|
||||
player->CombatStop(true);
|
||||
constexpr float offsetDist = 10.0f;
|
||||
float myAngle = rand_norm() * static_cast<float>(2.0f * M_PI);
|
||||
Position myTarget(target.GetPositionX() + std::sin(myAngle) * offsetDist, target.GetPositionY() + std::sin(myAngle) * offsetDist, target.GetPositionZ(), myAngle + M_PI);
|
||||
player->NearTeleportTo(myTarget);
|
||||
player->NearTeleportTo(player->GetRandomPoint(target, 10.0f));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -211,10 +211,7 @@ class spell_waycrest_manor_wildfire : public AuraScript
|
||||
{
|
||||
static constexpr Position CircleCenterPos = { -422.13f, -258.28f, 233.8286f, 0.0f };
|
||||
|
||||
Position randomPos = CircleCenterPos;
|
||||
GetTarget()->MovePosition(randomPos, 30.0f * rand_norm(), rand_norm() * static_cast<float>(2 * M_PI));
|
||||
|
||||
return randomPos;
|
||||
return GetTarget()->GetRandomPoint(CircleCenterPos, 30.0f);
|
||||
}
|
||||
|
||||
Position GetRandomPositionInRectangle()
|
||||
|
||||
@@ -455,14 +455,6 @@ struct npc_anubarak_anub_ar_assassin : public npc_anubarak_pet_template
|
||||
{
|
||||
npc_anubarak_anub_ar_assassin(Creature* creature) : npc_anubarak_pet_template(creature, false){ }
|
||||
|
||||
Position GetRandomPositionAround(Creature* anubarak)
|
||||
{
|
||||
static float DISTANCE_MIN = 10.0f;
|
||||
static float DISTANCE_MAX = 30.0f;
|
||||
double angle = rand_norm() * 2.0 * M_PI;
|
||||
return { anubarak->GetPositionX() + (float)(frand(DISTANCE_MIN, DISTANCE_MAX)*std::sin(angle)), anubarak->GetPositionY() + (float)(frand(DISTANCE_MIN, DISTANCE_MAX)*std::cos(angle)), anubarak->GetPositionZ() };
|
||||
}
|
||||
|
||||
void InitializeAI() override
|
||||
{
|
||||
npc_anubarak_pet_template::InitializeAI();
|
||||
@@ -470,9 +462,10 @@ struct npc_anubarak_anub_ar_assassin : public npc_anubarak_pet_template
|
||||
if (Creature* anubarak = _instance->GetCreature(DATA_ANUBARAK))
|
||||
{
|
||||
Position jumpTo;
|
||||
uint32 attempts = 0;
|
||||
do
|
||||
jumpTo = GetRandomPositionAround(anubarak);
|
||||
while (!CreatureAI::IsInBounds(*boundary, &jumpTo));
|
||||
jumpTo = anubarak->GetRandomPoint(anubarak->GetPosition(), 10.f, 30.0f);
|
||||
while (!CreatureAI::IsInBounds(*boundary, &jumpTo) && attempts < 10);
|
||||
me->GetMotionMaster()->MoveJump(EVENT_JUMP, jumpTo, 24.0f, 20.0f, 30.0f);
|
||||
DoCastSelf(SPELL_ASSASSIN_VISUAL, true);
|
||||
}
|
||||
|
||||
@@ -156,16 +156,6 @@ static inline Position const& GetRandomMinionSpawnPoint()
|
||||
return minionSpawnPoints[urand(0, nMinionSpawnPoints - 1)];
|
||||
}
|
||||
|
||||
// uniformly distribute on the circle
|
||||
static Position GetRandomPositionOnCircle(Position const& center, float radius)
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
class KelThuzadCharmedPlayerAI : public SimpleCharmedPlayerAI
|
||||
{
|
||||
public:
|
||||
@@ -664,7 +654,7 @@ struct npc_kelthuzad_minionAI : public ScriptedAI
|
||||
if (_movementTimer <= diff)
|
||||
{
|
||||
_movementTimer = 0;
|
||||
me->GetMotionMaster()->MovePoint(MOVEMENT_MINION_RANDOM, GetRandomPositionOnCircle(_home, 3.0f));
|
||||
me->GetMotionMaster()->MovePoint(MOVEMENT_MINION_RANDOM, me->GetRandomPoint(_home, 3.0f));
|
||||
}
|
||||
else
|
||||
_movementTimer -= diff;
|
||||
|
||||
Reference in New Issue
Block a user