feat(Core/Misc): change how Position struct is retrieved (#9017)

Update Position::GetPosition() and similar methods signatures to reflect 2a4c9bc changes by return a Position object instead of accepting a Position parameter by reference.

Cherry pick of https://github.com/TrinityCore/TrinityCore/commit/2585e799f95f259dd4b422daf15ef7963173c408
This commit is contained in:
sschepens
2021-11-10 19:43:00 -03:00
committed by GitHub
parent d31d8279ca
commit b7f8083915
36 changed files with 68 additions and 133 deletions
+2 -4
View File
@@ -355,15 +355,13 @@ Creature* CreatureAI::DoSummon(uint32 entry, const Position& pos, uint32 despawn
Creature* CreatureAI::DoSummon(uint32 entry, WorldObject* obj, float radius, uint32 despawnTime, TempSummonType summonType) Creature* CreatureAI::DoSummon(uint32 entry, WorldObject* obj, float radius, uint32 despawnTime, TempSummonType summonType)
{ {
Position pos; Position pos = obj->GetRandomNearPosition(radius);
obj->GetRandomNearPosition(pos, radius);
return me->SummonCreature(entry, pos, summonType, despawnTime); return me->SummonCreature(entry, pos, summonType, despawnTime);
} }
Creature* CreatureAI::DoSummonFlyer(uint32 entry, WorldObject* obj, float flightZ, float radius, uint32 despawnTime, TempSummonType summonType) Creature* CreatureAI::DoSummonFlyer(uint32 entry, WorldObject* obj, float flightZ, float radius, uint32 despawnTime, TempSummonType summonType)
{ {
Position pos; Position pos = obj->GetRandomNearPosition(radius);
obj->GetRandomNearPosition(pos, radius);
pos.m_positionZ += flightZ; pos.m_positionZ += flightZ;
return me->SummonCreature(entry, pos, summonType, despawnTime); return me->SummonCreature(entry, pos, summonType, despawnTime);
} }
@@ -1484,9 +1484,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (uint32 i = 0; i < e.target.randomPoint.amount; i++) for (uint32 i = 0; i < e.target.randomPoint.amount; i++)
{ {
if (e.target.randomPoint.self > 0) if (e.target.randomPoint.self > 0)
me->GetRandomPoint(me->GetPosition(), range, randomPoint); randomPoint = me->GetRandomPoint(me->GetPosition(), range);
else else
me->GetRandomPoint(srcPos, range, randomPoint); randomPoint = me->GetRandomPoint(srcPos, range);
if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, randomPoint, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration)) if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, randomPoint, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration))
{ {
if (unit && e.action.summonCreature.attackInvoker) if (unit && e.action.summonCreature.attackInvoker)
@@ -1854,9 +1854,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (me) if (me)
{ {
float range = (float)e.target.randomPoint.range; float range = (float)e.target.randomPoint.range;
Position randomPoint;
Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o }; Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
me->GetRandomPoint(srcPos, range, randomPoint); Position randomPoint = me->GetRandomPoint(srcPos, range);
me->GetMotionMaster()->MovePoint( me->GetMotionMaster()->MovePoint(
e.action.MoveToPos.pointId, e.action.MoveToPos.pointId,
randomPoint.m_positionX, randomPoint.m_positionX,
@@ -2438,9 +2437,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (me) if (me)
{ {
float range = (float)e.target.randomPoint.range; float range = (float)e.target.randomPoint.range;
Position randomPoint;
Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o }; Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
me->GetRandomPoint(srcPos, range, randomPoint); Position randomPoint = me->GetRandomPoint(srcPos, range);
me->GetMotionMaster()->MoveJump(randomPoint, (float)e.action.jump.speedxy, (float)e.action.jump.speedz); me->GetMotionMaster()->MoveJump(randomPoint, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
} }
@@ -155,8 +155,7 @@ bool BattlefieldWG::SetupBattlefield()
// Spawn turrets and hide them per default // Spawn turrets and hide them per default
for (uint8 i = 0; i < WG_MAX_TURRET; i++) for (uint8 i = 0; i < WG_MAX_TURRET; i++)
{ {
Position towerCannonPos; Position towerCannonPos = WGTurret[i].GetPosition();
WGTurret[i].GetPosition(&towerCannonPos);
if (Creature* creature = SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE)) if (Creature* creature = SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE))
{ {
CanonList.insert(creature->GetGUID()); CanonList.insert(creature->GetGUID());
@@ -1338,8 +1338,7 @@ struct BfWGGameObjectBuilding
// Spawn Turret bottom // Spawn Turret bottom
for (uint8 i = 0; i < TowerCannon[towerid].nbTowerCannonBottom; i++) for (uint8 i = 0; i < TowerCannon[towerid].nbTowerCannonBottom; i++)
{ {
Position turretPos; Position turretPos = TowerCannon[towerid].TowerCannonBottom[i].GetPosition();
TowerCannon[towerid].TowerCannonBottom[i].GetPosition(&turretPos);
if (Creature* turret = m_WG->SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, turretPos, TEAM_ALLIANCE)) if (Creature* turret = m_WG->SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, turretPos, TEAM_ALLIANCE))
{ {
m_TowerCannonBottomList.insert(turret->GetGUID()); m_TowerCannonBottomList.insert(turret->GetGUID());
@@ -1350,8 +1349,7 @@ struct BfWGGameObjectBuilding
// Spawn Turret top // Spawn Turret top
for (uint8 i = 0; i < TowerCannon[towerid].nbTurretTop; i++) for (uint8 i = 0; i < TowerCannon[towerid].nbTurretTop; i++)
{ {
Position towerCannonPos; Position towerCannonPos = TowerCannon[towerid].TurretTop[i].GetPosition();
TowerCannon[towerid].TurretTop[i].GetPosition(&towerCannonPos);
if (Creature* turret = m_WG->SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE)) if (Creature* turret = m_WG->SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE))
{ {
m_TurretTopList.insert(turret->GetGUID()); m_TurretTopList.insert(turret->GetGUID());
@@ -310,11 +310,10 @@ inline void Battleground::_CheckSafePositions(uint32 diff)
{ {
m_ValidStartPositionTimer = 0; m_ValidStartPositionTimer = 0;
Position pos;
float x, y, z, o; float x, y, z, o;
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
{ {
itr->second->GetPosition(&pos); Position pos = itr->second->GetPosition();
GetTeamStartLoc(itr->second->GetBgTeamId(), x, y, z, o); GetTeamStartLoc(itr->second->GetBgTeamId(), x, y, z, o);
if (pos.GetExactDistSq(x, y, z) > maxDist) if (pos.GetExactDistSq(x, y, z) > maxDist)
{ {
+9 -13
View File
@@ -1684,11 +1684,11 @@ void WorldObject::GetRandomPoint(const Position& pos, float distance, float& ran
UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available
} }
void WorldObject::GetRandomPoint(const Position& srcPos, float distance, Position& pos) const Position WorldObject::GetRandomPoint(const Position& srcPos, float distance) const
{ {
float x, y, z; float x, y, z;
GetRandomPoint(srcPos, distance, x, y, z); GetRandomPoint(srcPos, distance, x, y, z);
pos.Relocate(x, y, z, GetOrientation()); return Position(x, y, z, GetOrientation());
} }
void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
@@ -2797,22 +2797,18 @@ bool WorldObject::GetClosePoint(float& x, float& y, float& z, float size, float
return true; return true;
} }
void WorldObject::GetNearPosition(Position& pos, float dist, float angle) Position WorldObject::GetNearPosition(float dist, float angle)
{ {
GetPosition(&pos); Position pos = GetPosition();
MovePosition(pos, dist, angle); MovePosition(pos, dist, angle);
return pos;
} }
void WorldObject::GetFirstCollisionPosition(Position& pos, float dist, float angle) Position WorldObject::GetRandomNearPosition(float radius)
{ {
GetPosition(&pos); Position pos = GetPosition();
MovePositionToFirstCollision(pos, dist, angle);
}
void WorldObject::GetRandomNearPosition(Position& pos, float radius)
{
GetPosition(&pos);
MovePosition(pos, radius * (float) rand_norm(), (float) rand_norm() * static_cast<float>(2 * M_PI)); MovePosition(pos, radius * (float) rand_norm(), (float) rand_norm() * static_cast<float>(2 * M_PI));
return pos;
} }
void WorldObject::GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d) const void WorldObject::GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d) const
@@ -2926,7 +2922,7 @@ Position WorldObject::GetFirstCollisionPosition(float destX, float destY, float
Position WorldObject::GetFirstCollisionPosition(float dist, float angle) Position WorldObject::GetFirstCollisionPosition(float dist, float angle)
{ {
Position pos = GetPosition(); Position pos = GetPosition();
GetFirstCollisionPosition(pos, dist, angle); MovePositionToFirstCollision(pos, dist, angle);
return pos; return pos;
} }
+3 -9
View File
@@ -354,11 +354,6 @@ struct Position
z = m_positionZ; z = m_positionZ;
o = m_orientation; o = m_orientation;
} }
void GetPosition(Position* pos) const
{
if (pos)
pos->Relocate(m_positionX, m_positionY, m_positionZ, m_orientation);
}
[[nodiscard]] Position GetPosition() const { return *this; } [[nodiscard]] Position GetPosition() const { return *this; }
@@ -697,13 +692,12 @@ public:
void GetVoidClosePoint(float& x, float& y, float& z, float size, float distance2d = 0, float relAngle = 0, float controlZ = 0) const; void GetVoidClosePoint(float& x, float& y, float& z, float size, float distance2d = 0, float relAngle = 0, float controlZ = 0) const;
bool GetClosePoint(float& x, float& y, float& z, float size, float distance2d = 0, float angle = 0, const WorldObject* forWho = nullptr, bool force = false) const; bool GetClosePoint(float& x, float& y, float& z, float size, float distance2d = 0, float angle = 0, const WorldObject* forWho = nullptr, bool force = false) const;
void MovePosition(Position& pos, float dist, float angle); void MovePosition(Position& pos, float dist, float angle);
void GetNearPosition(Position& pos, float dist, float angle); Position GetNearPosition(float dist, float angle);
void MovePositionToFirstCollision(Position& pos, float dist, float angle); void MovePositionToFirstCollision(Position& pos, float dist, float angle);
Position GetFirstCollisionPosition(float startX, float startY, float startZ, float destX, float destY); Position GetFirstCollisionPosition(float startX, float startY, float startZ, float destX, float destY);
Position GetFirstCollisionPosition(float destX, float destY, float destZ); Position GetFirstCollisionPosition(float destX, float destY, float destZ);
Position GetFirstCollisionPosition(float dist, float angle); Position GetFirstCollisionPosition(float dist, float angle);
void GetFirstCollisionPosition(Position& pos, float dist, float angle); Position GetRandomNearPosition(float radius);
void GetRandomNearPosition(Position& pos, float radius);
void GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d = CONTACT_DISTANCE) const; void GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d = CONTACT_DISTANCE) const;
void GetChargeContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d = CONTACT_DISTANCE) const; void GetChargeContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d = CONTACT_DISTANCE) const;
@@ -715,7 +709,7 @@ public:
void UpdateAllowedPositionZ(float x, float y, float& z, float* groundZ = nullptr) const; void UpdateAllowedPositionZ(float x, float y, float& z, float* groundZ = nullptr) const;
void GetRandomPoint(const Position& srcPos, float distance, float& rand_x, float& rand_y, float& rand_z) const; void GetRandomPoint(const Position& srcPos, float distance, float& rand_x, float& rand_y, float& rand_z) const;
void GetRandomPoint(const Position& srcPos, float distance, Position& pos) const; Position GetRandomPoint(const Position& srcPos, float distance) const;
[[nodiscard]] uint32 GetInstanceId() const { return m_InstanceId; } [[nodiscard]] uint32 GetInstanceId() const { return m_InstanceId; }
+1 -2
View File
@@ -1439,8 +1439,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// near teleport, triggering send MSG_MOVE_TELEPORT_ACK from client at landing // near teleport, triggering send MSG_MOVE_TELEPORT_ACK from client at landing
if (!GetSession()->PlayerLogout()) if (!GetSession()->PlayerLogout())
{ {
Position oldPos; Position oldPos = GetPosition();
GetPosition(&oldPos);
Relocate(x, y, z, orientation); Relocate(x, y, z, orientation);
SendTeleportAckPacket(); SendTeleportAckPacket();
SendTeleportPacket(oldPos); // this automatically relocates to oldPos in order to broadcast the packet in the right place SendTeleportPacket(oldPos); // this automatically relocates to oldPos in order to broadcast the packet in the right place
+1 -1
View File
@@ -18833,7 +18833,7 @@ void Unit::_ExitVehicle(Position const* exitPosition)
Position pos; Position pos;
if (!exitPosition) // Exit position not specified if (!exitPosition) // Exit position not specified
vehicleBase->GetPosition(&pos); // This should use passenger's current position, leaving it as it is now pos = vehicleBase->GetPosition(); // This should use passenger's current position, leaving it as it is now
// because we calculate positions incorrect (sometimes under map) // because we calculate positions incorrect (sometimes under map)
else else
pos = *exitPosition; pos = *exitPosition;
+7 -18
View File
@@ -2491,7 +2491,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
pos = *destTarget; pos = *destTarget;
else else
// randomize position for multiple summons // randomize position for multiple summons
m_caster->GetRandomPoint(*destTarget, radius, pos); pos = m_caster->GetRandomPoint(*destTarget, radius);
summon = m_originalCaster->SummonCreature(entry, pos, summonType, duration); summon = m_originalCaster->SummonCreature(entry, pos, summonType, duration);
if (!summon) if (!summon)
@@ -4883,8 +4883,7 @@ void Spell::EffectLeap(SpellEffIndex /*effIndex*/)
if (!m_targets.HasDst()) if (!m_targets.HasDst())
return; return;
Position dstpos; Position dstpos = destTarget->GetPosition();
destTarget->GetPosition(&dstpos);
unitTarget->NearTeleportTo(dstpos.GetPositionX(), dstpos.GetPositionY(), dstpos.GetPositionZ(), dstpos.GetOrientation(), unitTarget == m_caster); unitTarget->NearTeleportTo(dstpos.GetPositionX(), dstpos.GetPositionY(), dstpos.GetPositionZ(), dstpos.GetOrientation(), unitTarget == m_caster);
} }
@@ -5118,15 +5117,7 @@ void Spell::EffectCharge(SpellEffIndex /*effIndex*/)
} }
else else
{ {
Position pos; Position pos = unitTarget->GetFirstCollisionPosition(unitTarget->GetObjectSize(), unitTarget->GetRelativeAngle(m_caster));
unitTarget->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
// assume that target is not in water - else should be always in los
if (!m_caster->IsWithinLOS(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()))
{
float angle = m_caster->GetRelativeAngle(&pos);
float dist = m_caster->GetDistance(pos);
m_caster->GetFirstCollisionPosition(pos, dist, angle);
}
m_caster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ + Z_OFFSET_FIND_HEIGHT, SPEED_CHARGE, EVENT_CHARGE, m_caster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ + Z_OFFSET_FIND_HEIGHT, SPEED_CHARGE, EVENT_CHARGE,
nullptr, false, 0.f, targetGUID); nullptr, false, 0.f, targetGUID);
@@ -5156,14 +5147,13 @@ void Spell::EffectChargeDest(SpellEffIndex /*effIndex*/)
if (m_targets.HasDst()) if (m_targets.HasDst())
{ {
Position pos; Position pos = destTarget->GetPosition();
destTarget->GetPosition(&pos);
if (!m_caster->IsWithinLOS(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ())) if (!m_caster->IsWithinLOS(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()))
{ {
float angle = m_caster->GetRelativeAngle(pos.GetPositionX(), pos.GetPositionY()); float angle = m_caster->GetRelativeAngle(pos.GetPositionX(), pos.GetPositionY());
float dist = m_caster->GetDistance(pos); float dist = m_caster->GetDistance(pos);
m_caster->GetFirstCollisionPosition(pos, dist, angle); pos = m_caster->GetFirstCollisionPosition(dist, angle);
} }
m_caster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ); m_caster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ);
@@ -6206,7 +6196,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const*
else else
{ {
// randomize position // randomize position
m_caster->GetRandomPoint(*destTarget, radius, pos); pos = m_caster->GetRandomPoint(*destTarget, radius);
} }
summon = map->SummonCreature(entry, pos, properties, duration, caster, m_spellInfo->Id); summon = map->SummonCreature(entry, pos, properties, duration, caster, m_spellInfo->Id);
@@ -6470,8 +6460,7 @@ void Spell::EffectBind(SpellEffIndex effIndex)
homeLoc.WorldRelocate(*destTarget); homeLoc.WorldRelocate(*destTarget);
else else
{ {
player->GetPosition(&homeLoc); homeLoc = player->GetWorldLocation();
homeLoc.m_mapId = player->GetMapId();
} }
player->SetHomebind(homeLoc, areaId); player->SetHomebind(homeLoc, areaId);
@@ -62,8 +62,7 @@ public:
bool Execute(uint64 /*time*/, uint32 /*diff*/) override bool Execute(uint64 /*time*/, uint32 /*diff*/) override
{ {
_me->SetReactState(REACT_PASSIVE); _me->SetReactState(REACT_PASSIVE);
Position movePos; Position movePos = _me->GetRandomPoint(OrcsRunawayPosition, 10.0f);
_me->GetRandomPoint(OrcsRunawayPosition, 10.0f, movePos);
_me->GetMotionMaster()->MovePoint(1, movePos); _me->GetMotionMaster()->MovePoint(1, movePos);
return true; return true;
} }
@@ -272,8 +272,7 @@ public:
PreventHitDefaultEffect(effIndex); PreventHitDefaultEffect(effIndex);
if (Unit* target = GetHitUnit()) if (Unit* target = GetHitUnit())
{ {
Position pos; Position pos = target->GetFirstCollisionPosition(5.0f, M_PI);
target->GetFirstCollisionPosition(pos, 5.0f, M_PI);
GetCaster()->CastSpell(target, SPELL_GARROTE_DUMMY, true); GetCaster()->CastSpell(target, SPELL_GARROTE_DUMMY, true);
GetCaster()->RemoveAurasDueToSpell(SPELL_VANISH); GetCaster()->RemoveAurasDueToSpell(SPELL_VANISH);
GetCaster()->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), target->GetOrientation()); GetCaster()->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), target->GetOrientation());
@@ -299,7 +299,7 @@ public:
if ((me->GetMapId() == 532)) if ((me->GetMapId() == 532))
{ {
me->GetRandomNearPosition(pos, 40.0); pos = me->GetRandomNearPosition(40.0);
} }
else else
{ {
@@ -778,8 +778,7 @@ public:
if (MoveTimer <= diff) if (MoveTimer <= diff)
{ {
Position pos; Position pos = me->GetRandomNearPosition(10);
me->GetRandomNearPosition(pos, 10);
me->GetMotionMaster()->MovePoint(0, pos); me->GetMotionMaster()->MovePoint(0, pos);
MoveTimer = urand(3000, 5000); MoveTimer = urand(3000, 5000);
} }
@@ -318,8 +318,7 @@ public:
// emerge cast tr false 66947 // emerge cast tr false 66947
case EVENT_SPAWN_WAVE_1: case EVENT_SPAWN_WAVE_1:
{ {
Position spawnPos; Position spawnPos = c->GetPosition();
c->GetPosition(&spawnPos);
spawnPos.m_orientation = 5.80f; spawnPos.m_orientation = 5.80f;
spawnPos.m_positionX += 5.0f * cos(4.5f); spawnPos.m_positionX += 5.0f * cos(4.5f);
spawnPos.m_positionY += 5.0f * sin(4.5f); spawnPos.m_positionY += 5.0f * sin(4.5f);
@@ -333,8 +332,7 @@ public:
break; break;
case EVENT_SPAWN_WAVE_2: case EVENT_SPAWN_WAVE_2:
{ {
Position spawnPos; Position spawnPos = c->GetPosition();
c->GetPosition(&spawnPos);
spawnPos.m_orientation = 5.80f; spawnPos.m_orientation = 5.80f;
spawnPos.m_positionX += 7.0f * cos(4.0f); spawnPos.m_positionX += 7.0f * cos(4.0f);
spawnPos.m_positionY += 7.0f * sin(4.0f); spawnPos.m_positionY += 7.0f * sin(4.0f);
@@ -349,8 +347,7 @@ public:
break; break;
case EVENT_SPAWN_WAVE_3: case EVENT_SPAWN_WAVE_3:
{ {
Position spawnPos; Position spawnPos = c->GetPosition();
c->GetPosition(&spawnPos);
spawnPos.m_orientation = 5.80f; spawnPos.m_orientation = 5.80f;
spawnPos.m_positionX += 8.0f * cos(4.0f); spawnPos.m_positionX += 8.0f * cos(4.0f);
spawnPos.m_positionY += 8.0f * sin(4.0f); spawnPos.m_positionY += 8.0f * sin(4.0f);
+1 -2
View File
@@ -1199,8 +1199,7 @@ public:
events.CancelEvent(EVENT_HORSEMAN_CLEAVE); events.CancelEvent(EVENT_HORSEMAN_CLEAVE);
// Summon Head // Summon Head
Position pos; Position pos = me->GetNearPosition(15.0f, rand_norm() * 2 * M_PI);
me->GetNearPosition(pos, 15.0f, rand_norm() * 2 * M_PI);
if (Creature* cr = me->SummonCreature(NPC_HORSEMAN_HEAD, pos)) if (Creature* cr = me->SummonCreature(NPC_HORSEMAN_HEAD, pos))
{ {
if (health) if (health)
@@ -233,8 +233,7 @@ public:
} }
else else
{ {
Position pos; Position pos = me->GetRandomNearPosition(40);
me->GetRandomNearPosition(pos, 40);
me->GetMotionMaster()->MovePoint(0, pos.m_positionX, pos.m_positionY, pos.m_positionZ); me->GetMotionMaster()->MovePoint(0, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
} }
@@ -301,8 +301,7 @@ public:
if (!instance->GetPlayers().isEmpty()) if (!instance->GetPlayers().isEmpty())
if (Player* player = instance->GetPlayers().getFirst()->GetSource()) if (Player* player = instance->GetPlayers().getFirst()->GetSource())
{ {
Position pos; Position pos = player->GetPosition();
player->GetPosition(&pos);
if (Creature* cr = instance->SummonCreature(NPC_CHROMIE_MIDDLE, pos)) if (Creature* cr = instance->SummonCreature(NPC_CHROMIE_MIDDLE, pos))
{ {
cr->SetVisible(false); cr->SetVisible(false);
@@ -268,8 +268,7 @@ public:
break; break;
} }
Position pos; Position pos = rift->GetNearPosition(10.0f, 2 * M_PI * rand_norm());
rift->GetNearPosition(pos, 10.0f, 2 * M_PI * rand_norm());
if (TempSummon* summon = instance->SummonCreature(abs(entry), pos)) if (TempSummon* summon = instance->SummonCreature(abs(entry), pos))
{ {
@@ -323,8 +323,7 @@ public:
void DoSummonAtRift(uint32 entry) void DoSummonAtRift(uint32 entry)
{ {
Position pos; Position pos = me->GetNearPosition(10.0f, 2 * M_PI * rand_norm());
me->GetNearPosition(pos, 10.0f, 2 * M_PI * rand_norm());
if (Creature* summon = me->SummonCreature(entry, pos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 150000)) if (Creature* summon = me->SummonCreature(entry, pos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 150000))
if (instance) if (instance)
@@ -155,8 +155,7 @@ public:
_phase = PHASE_GROUND; _phase = PHASE_GROUND;
SetCombatMovement(true); SetCombatMovement(true);
me->SetCanFly(false); me->SetCanFly(false);
Position VictimPos; Position VictimPos = me->GetVictim()->GetPosition();
me->GetVictim()->GetPosition(&VictimPos);
me->GetMotionMaster()->MovePoint(POINT_GROUND, VictimPos); me->GetMotionMaster()->MovePoint(POINT_GROUND, VictimPos);
DoResetThreat(); DoResetThreat();
events.ScheduleEvent(EVENT_LASH, urand(5000, 8000)); events.ScheduleEvent(EVENT_LASH, urand(5000, 8000));
@@ -208,8 +207,7 @@ public:
break; break;
case EVENT_SUMMON_SWARMER: case EVENT_SUMMON_SWARMER:
{ {
Position Pos; Position Pos = me->GetRandomPoint(SwarmerPos, 80.0f);
me->GetRandomPoint(SwarmerPos, 80.0f, Pos);
me->SummonCreature(NPC_SWARMER, Pos); me->SummonCreature(NPC_SWARMER, Pos);
events.ScheduleEvent(EVENT_SUMMON_SWARMER, 5000); events.ScheduleEvent(EVENT_SUMMON_SWARMER, 5000);
break; break;
@@ -146,8 +146,7 @@ public:
for (uint8 i = 0; i < NUM_TORNADOS; ++i) for (uint8 i = 0; i < NUM_TORNADOS; ++i)
{ {
Position Point; Position Point = me->GetRandomPoint(RoomCenter, RoomRadius);
me->GetRandomPoint(RoomCenter, RoomRadius, Point);
if (Creature* Tornado = me->GetMap()->SummonCreature(NPC_SAND_VORTEX, Point)) if (Creature* Tornado = me->GetMap()->SummonCreature(NPC_SAND_VORTEX, Point))
Tornado->CastSpell(Tornado, SPELL_SAND_STORM, true); Tornado->CastSpell(Tornado, SPELL_SAND_STORM, true);
} }
@@ -462,8 +462,7 @@ public:
Talk(CAPITIVE_SAY, owner); Talk(CAPITIVE_SAY, owner);
_playerGUID = owner->GetGUID(); _playerGUID = owner->GetGUID();
} }
Position pos; Position pos = me->GetNearPosition(3.0f, 0.0f);
me->GetNearPosition(pos, 3.0f, 0.0f);
me->GetMotionMaster()->MovePoint(POINT_INIT, pos); me->GetMotionMaster()->MovePoint(POINT_INIT, pos);
} }
@@ -1045,8 +1045,7 @@ public:
SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetSpellInfo()->Effects[effIndex].MiscValueB)); SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetSpellInfo()->Effects[effIndex].MiscValueB));
uint32 duration = uint32(GetSpellInfo()->GetDuration()); uint32 duration = uint32(GetSpellInfo()->GetDuration());
Position pos; Position pos = caster->GetPosition();
caster->GetPosition(&pos);
if (Creature* summon = caster->GetMap()->SummonCreature(entry, pos, properties, duration, caster, GetSpellInfo()->Id)) if (Creature* summon = caster->GetMap()->SummonCreature(entry, pos, properties, duration, caster, GetSpellInfo()->Id))
{ {
bool heroic = summon->GetMap()->IsHeroic(); bool heroic = summon->GetMap()->IsHeroic();
@@ -2428,8 +2428,7 @@ public:
if (!si) if (!si)
return; return;
SpellCastTargets targets; SpellCastTargets targets;
Position dest; Position dest = GetExplTargetDest()->GetPosition();
GetExplTargetDest()->GetPosition(&dest);
targets.SetDst(dest); targets.SetDst(dest);
CustomSpellValues values; CustomSpellValues values;
int32 damage = si->Effects[0].CalcValue() + _energyLeft * _energyLeft * 8; int32 damage = si->Effects[0].CalcValue() + _energyLeft * _energyLeft * 8;
@@ -1538,8 +1538,7 @@ public:
SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetSpellInfo()->Effects[effIndex].MiscValueB)); SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetSpellInfo()->Effects[effIndex].MiscValueB));
uint32 duration = uint32(GetSpellInfo()->GetDuration()); uint32 duration = uint32(GetSpellInfo()->GetDuration());
Position pos; Position pos = caster->GetPosition();
caster->GetPosition(&pos);
TempSummon* summon = caster->GetMap()->SummonCreature(entry, pos, properties, duration, caster, GetSpellInfo()->Id); TempSummon* summon = caster->GetMap()->SummonCreature(entry, pos, properties, duration, caster, GetSpellInfo()->Id);
if (!summon || !summon->IsVehicle()) if (!summon || !summon->IsVehicle())
return; return;
@@ -215,8 +215,7 @@ public:
if (!sindragosa->IsAlive()) if (!sindragosa->IsAlive())
return true; return true;
Position pos; Position pos = _owner->GetPosition();
_owner->GetPosition(&pos);
_owner->UpdateGroundPositionZ(pos.m_positionX, pos.m_positionY, pos.m_positionZ); _owner->UpdateGroundPositionZ(pos.m_positionX, pos.m_positionY, pos.m_positionZ);
if (TempSummon* summon = sindragosa->SummonCreature(NPC_ICE_TOMB, pos)) if (TempSummon* summon = sindragosa->SummonCreature(NPC_ICE_TOMB, pos))
@@ -1770,8 +1770,7 @@ public:
{ {
if (spell->Id == 71306 && c->GetTypeId() == TYPEID_UNIT) // Twisted Winds if (spell->Id == 71306 && c->GetTypeId() == TYPEID_UNIT) // Twisted Winds
{ {
Position myPos; Position myPos = me->GetPosition();
me->GetPosition(&myPos);
me->NearTeleportTo(c->GetPositionX(), c->GetPositionY(), c->GetPositionZ(), c->GetOrientation()); me->NearTeleportTo(c->GetPositionX(), c->GetPositionY(), c->GetPositionZ(), c->GetOrientation());
c->NearTeleportTo(myPos.GetPositionX(), myPos.GetPositionY(), myPos.GetPositionZ(), myPos.GetOrientation()); c->NearTeleportTo(myPos.GetPositionX(), myPos.GetPositionY(), myPos.GetPositionZ(), myPos.GetOrientation());
const ThreatContainer::StorageType me_tl = me->getThreatMgr().getThreatList(); const ThreatContainer::StorageType me_tl = me->getThreatMgr().getThreatList();
@@ -2181,9 +2180,7 @@ public:
if (!caster) if (!caster)
return; return;
Position pos; Position pos = caster->GetNearPosition(5.0f, 0.0f);
caster->GetPosition(&pos);
caster->GetNearPosition(pos, 5.0f, 0.0f);
pos.m_positionZ = caster->GetMap()->GetHeight(caster->GetPhaseMask(), pos.GetPositionX(), pos.GetPositionY(), caster->GetPositionZ(), true, 50.0f); pos.m_positionZ = caster->GetMap()->GetHeight(caster->GetPhaseMask(), pos.GetPositionX(), pos.GetPositionY(), caster->GetPositionZ(), true, 50.0f);
pos.m_positionZ += 0.1f; pos.m_positionZ += 0.1f;
caster->SendMeleeAttackStop(caster->GetVictim()); caster->SendMeleeAttackStop(caster->GetVictim());
@@ -3214,8 +3211,7 @@ public:
if (currPipeWP != VENGEFUL_WP_COUNT) if (currPipeWP != VENGEFUL_WP_COUNT)
{ {
Position pos; Position pos = who->GetPosition();
who->GetPosition(&pos);
float angle = who->GetAngle(me); float angle = who->GetAngle(me);
float dist = 3.0f; float dist = 3.0f;
pos.m_positionX += cos(angle) * dist; pos.m_positionX += cos(angle) * dist;
@@ -778,8 +778,7 @@ public:
ACU->DespawnOrUnsummon(7000); ACU->DespawnOrUnsummon(7000);
ACU->SetReactState(REACT_PASSIVE); ACU->SetReactState(REACT_PASSIVE);
Position exitPos; Position exitPos = me->GetPosition();
me->GetPosition(&exitPos);
me->_ExitVehicle(&exitPos); me->_ExitVehicle(&exitPos);
me->AttackStop(); me->AttackStop();
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK);
@@ -1453,8 +1452,7 @@ public:
{ {
if( Creature* trigger = me->SummonCreature(NPC_ROCKET_STRIKE_N, temp->GetPositionX(), temp->GetPositionY(), temp->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 6000) ) if( Creature* trigger = me->SummonCreature(NPC_ROCKET_STRIKE_N, temp->GetPositionX(), temp->GetPositionY(), temp->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 6000) )
trigger->CastSpell(trigger, SPELL_ROCKET_STRIKE_AURA, true); trigger->CastSpell(trigger, SPELL_ROCKET_STRIKE_AURA, true);
Position exitPos; Position exitPos = r->GetPosition();
r->GetPosition(&exitPos);
exitPos.m_positionX += cos(me->GetOrientation()) * 2.35f; exitPos.m_positionX += cos(me->GetOrientation()) * 2.35f;
exitPos.m_positionY += sin(me->GetOrientation()) * 2.35f; exitPos.m_positionY += sin(me->GetOrientation()) * 2.35f;
exitPos.m_positionZ += 2.0f * Phase; exitPos.m_positionZ += 2.0f * Phase;
@@ -585,8 +585,7 @@ public:
case EVENT_BLINK: case EVENT_BLINK:
{ {
DoCast(me, SPELL_IMPROVED_BLINK); DoCast(me, SPELL_IMPROVED_BLINK);
Position pos; Position pos = me->GetRandomNearPosition((urand(15, 40)));
me->GetRandomNearPosition(pos, (urand(15, 40)));
me->GetMotionMaster()->MovePoint(0, pos.m_positionX, pos.m_positionY, pos.m_positionZ); me->GetMotionMaster()->MovePoint(0, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
events.ScheduleEvent(EVENT_DESPAWN, 3 * IN_MILLISECONDS); events.ScheduleEvent(EVENT_DESPAWN, 3 * IN_MILLISECONDS);
events.ScheduleEvent(EVENT_DESPAWN_VISUAL, 2.5 * IN_MILLISECONDS); events.ScheduleEvent(EVENT_DESPAWN_VISUAL, 2.5 * IN_MILLISECONDS);
@@ -118,8 +118,7 @@ public:
break; break;
case EVENT_SUMMON_NETHER_CHARGE: case EVENT_SUMMON_NETHER_CHARGE:
{ {
Position pos; Position pos = me->GetRandomNearPosition(8.0f);
me->GetRandomNearPosition(pos, 8.0f);
me->SummonCreature(NPC_NETHER_CHARGE, pos, TEMPSUMMON_TIMED_DESPAWN, 18000); me->SummonCreature(NPC_NETHER_CHARGE, pos, TEMPSUMMON_TIMED_DESPAWN, 18000);
events.ScheduleEvent(EVENT_SUMMON_NETHER_CHARGE, 5000); events.ScheduleEvent(EVENT_SUMMON_NETHER_CHARGE, 5000);
break; break;
@@ -535,10 +535,10 @@ public:
Position pos; Position pos;
if (Unit* EscapeDummy = me->FindNearestCreature(NPC_ESCAPE_DUMMY, 30)) if (Unit* EscapeDummy = me->FindNearestCreature(NPC_ESCAPE_DUMMY, 30))
EscapeDummy->GetPosition(&pos); pos = EscapeDummy->GetPosition();
else else
{ {
me->GetRandomNearPosition(pos, 20); pos = me->GetRandomNearPosition(20);
pos.m_positionZ += 25; pos.m_positionZ += 25;
} }
+3 -6
View File
@@ -1389,8 +1389,7 @@ public:
float dist = GetSpellInfo()->Effects[EFFECT_0].CalcRadius(GetCaster()); float dist = GetSpellInfo()->Effects[EFFECT_0].CalcRadius(GetCaster());
float angle = frand(0.0f, 2 * M_PI); float angle = frand(0.0f, 2 * M_PI);
Position pos; Position pos = GetCaster()->GetNearPosition(dist, angle);
GetCaster()->GetNearPosition(pos, dist, angle);
dest.Relocate(pos); dest.Relocate(pos);
} }
@@ -1562,8 +1561,7 @@ public:
{ {
if (Unit* caster = GetCaster()) if (Unit* caster = GetCaster())
{ {
Position pos; Position pos = caster->GetRandomNearPosition(5.0f);
caster->GetRandomNearPosition(pos, 5.0f);
if (Creature* haunt = caster->SummonCreature(NPC_SCOURGE_HAUNT, pos, TEMPSUMMON_TIMED_DESPAWN, urand(10, 20) * IN_MILLISECONDS)) if (Creature* haunt = caster->SummonCreature(NPC_SCOURGE_HAUNT, pos, TEMPSUMMON_TIMED_DESPAWN, urand(10, 20) * IN_MILLISECONDS))
{ {
haunt->SetSpeed(MOVE_RUN, 0.5, true); haunt->SetSpeed(MOVE_RUN, 0.5, true);
@@ -1602,8 +1600,7 @@ public:
if (Unit* caster = GetCaster()) if (Unit* caster = GetCaster())
{ {
Position pos; Position pos = caster->GetRandomNearPosition(5.0f);
caster->GetRandomNearPosition(pos, 5.0f);
if (Creature* haunt = caster->SummonCreature(NPC_SCOURGE_HAUNT, pos, TEMPSUMMON_TIMED_DESPAWN, urand(10, 20) * IN_MILLISECONDS)) if (Creature* haunt = caster->SummonCreature(NPC_SCOURGE_HAUNT, pos, TEMPSUMMON_TIMED_DESPAWN, urand(10, 20) * IN_MILLISECONDS))
{ {
haunt->SetSpeed(MOVE_RUN, 0.5, true); haunt->SetSpeed(MOVE_RUN, 0.5, true);
+1 -2
View File
@@ -2171,8 +2171,7 @@ class spell_q12308_escape_from_silverbrook_summon_worgen : public SpellScript
float dist = GetSpellInfo()->Effects[EFFECT_0].CalcRadius(GetCaster()); float dist = GetSpellInfo()->Effects[EFFECT_0].CalcRadius(GetCaster());
float angle = frand(0.75f, 1.25f) * M_PI; float angle = frand(0.75f, 1.25f) * M_PI;
Position pos; Position pos = GetCaster()->GetNearPosition(dist, angle);
GetCaster()->GetNearPosition(pos, dist, angle);
dest.Relocate(pos); dest.Relocate(pos);
} }
@@ -364,8 +364,7 @@ public:
{ {
if (spell->Id == SPELL_DRAW_SPIRIT && target->GetTypeId() == TYPEID_PLAYER) if (spell->Id == SPELL_DRAW_SPIRIT && target->GetTypeId() == TYPEID_PLAYER)
{ {
Position targetPos; Position targetPos = target->GetPosition();
target->GetPosition(&targetPos);
me->SummonCreature(NPC_SPIRIT_SHADE, targetPos, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 50000); me->SummonCreature(NPC_SPIRIT_SHADE, targetPos, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 50000);
} }
} }
@@ -140,8 +140,7 @@ bool NPCStaveQuestAI::ValidThreatlist()
void NPCStaveQuestAI::SetHomePosition() void NPCStaveQuestAI::SetHomePosition()
{ {
Position homePosition; Position homePosition = me->GetPosition();
me->GetPosition(&homePosition);
if (homePosition.IsPositionValid()) if (homePosition.IsPositionValid())
{ {
@@ -564,8 +563,7 @@ public:
void RespawnPet() void RespawnPet()
{ {
Position current; Position current = me->GetNearPosition(-5.0f, 0.0f);
me->GetNearPosition(current, -5.0f, 0.0f);
Precious()->RemoveCorpse(false, false); Precious()->RemoveCorpse(false, false);
Precious()->SetPosition(current); Precious()->SetPosition(current);
Precious()->SetHomePosition(current); Precious()->SetHomePosition(current);
@@ -609,8 +607,7 @@ public:
return; return;
} }
Position petResetPos; Position petResetPos = me->GetNearPosition(-5.0f, 0.0f);
me->GetNearPosition(petResetPos, -5.0f, 0.0f);
if (petResetPos.IsPositionValid()) if (petResetPos.IsPositionValid())
{ {