mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-20 23:11:56 -04:00
Core/Unit: Standardize SetFacingTo and SetFacingToObject behavior while moving. Both now fail while moving unless arg2 bool is true.
Movement/SplineChain: Bump value range for DB chainId up to uint16 (0 to 65535) from uint8 (0 to 255). Turns out sniffs generate far more chains than I expected.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
-- uint8 -> uint16 for chain ID
|
||||
ALTER TABLE `script_spline_chain_meta` MODIFY COLUMN `chainId` SMALLINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE `script_spline_chain_waypoints` MODIFY COLUMN `chainId` SMALLINT UNSIGNED NOT NULL;
|
||||
@@ -162,7 +162,7 @@ void CreatureAI::TriggerAlert(Unit const* who) const
|
||||
me->SendAIReaction(AI_REACTION_ALERT);
|
||||
|
||||
// Face the unit (stealthed player) and set distracted state for 5 seconds
|
||||
me->SetFacingTo(me->GetAngle(who->GetPositionX(), who->GetPositionY()));
|
||||
me->SetFacingTo(me->GetAngle(who->GetPositionX(), who->GetPositionY()), true);
|
||||
me->StopMoving();
|
||||
me->GetMotionMaster()->MoveDistract(5 * IN_MILLISECONDS);
|
||||
}
|
||||
|
||||
@@ -2873,10 +2873,10 @@ void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target)
|
||||
bool canTurnDuringCast = !focusSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST);
|
||||
// Face the target - we need to do this before the unit state is modified for no-turn spells
|
||||
if (target)
|
||||
SetFacingTo(GetAngle(target));
|
||||
SetFacingToObject(target);
|
||||
else if (!canTurnDuringCast)
|
||||
if (Unit* victim = GetVictim())
|
||||
SetFacingTo(GetAngle(victim)); // ensure orientation is correct at beginning of cast
|
||||
SetFacingToObject(victim); // ensure orientation is correct at beginning of cast
|
||||
|
||||
if (!canTurnDuringCast)
|
||||
AddUnitState(UNIT_STATE_CANNOT_TURN);
|
||||
@@ -2922,7 +2922,7 @@ void Creature::ReleaseFocus(Spell const* focusSpell, bool withDelay)
|
||||
if (m_suppressedTarget)
|
||||
{
|
||||
if (WorldObject const* objTarget = ObjectAccessor::GetWorldObject(*this, m_suppressedTarget))
|
||||
SetFacingTo(GetAngle(objTarget));
|
||||
SetFacingToObject(objTarget);
|
||||
}
|
||||
else
|
||||
SetFacingTo(m_suppressedOrientation);
|
||||
|
||||
@@ -17242,8 +17242,11 @@ void Unit::SetInFront(WorldObject const* target)
|
||||
SetOrientation(GetAngle(target));
|
||||
}
|
||||
|
||||
void Unit::SetFacingTo(float ori)
|
||||
void Unit::SetFacingTo(float ori, bool force)
|
||||
{
|
||||
if (!force && !IsStopped())
|
||||
return;
|
||||
|
||||
Movement::MoveSplineInit init(this);
|
||||
init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZMinusOffset(), false);
|
||||
if (HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && GetTransGUID())
|
||||
@@ -17252,10 +17255,10 @@ void Unit::SetFacingTo(float ori)
|
||||
init.Launch();
|
||||
}
|
||||
|
||||
void Unit::SetFacingToObject(WorldObject const* object)
|
||||
void Unit::SetFacingToObject(WorldObject const* object, bool force)
|
||||
{
|
||||
// never face when already moving
|
||||
if (!IsStopped())
|
||||
// do not face when already moving
|
||||
if (!force && !IsStopped())
|
||||
return;
|
||||
|
||||
/// @todo figure out under what conditions creature will move towards object instead of facing it where it currently is.
|
||||
|
||||
@@ -1611,8 +1611,8 @@ class TC_GAME_API Unit : public WorldObject
|
||||
virtual bool SetHover(bool enable, bool packetOnly = false);
|
||||
|
||||
void SetInFront(WorldObject const* target);
|
||||
void SetFacingTo(float ori);
|
||||
void SetFacingToObject(WorldObject const* object);
|
||||
void SetFacingTo(float ori, bool force = false);
|
||||
void SetFacingToObject(WorldObject const* object, bool force = false);
|
||||
|
||||
void SendChangeCurrentVictimOpcode(HostileReference* pHostileReference);
|
||||
void SendClearThreatListOpcode();
|
||||
|
||||
@@ -470,7 +470,7 @@ void MotionMaster::MoveSmoothPath(uint32 pointId, Movement::PointsArray const& p
|
||||
//MovePoint(EVENT_CHARGE_PREPATH, pos, false);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveAlongSplineChain(uint32 pointId, uint32 dbChainId, bool walk)
|
||||
void MotionMaster::MoveAlongSplineChain(uint32 pointId, uint16 dbChainId, bool walk)
|
||||
{
|
||||
Creature* owner = _owner->ToCreature();
|
||||
if (!owner)
|
||||
|
||||
@@ -200,7 +200,7 @@ class TC_GAME_API MotionMaster //: private std::stack<MovementGenerator *>
|
||||
void MoveSmoothPath(uint32 pointId, G3D::Vector3 const* pathPoints, size_t pathSize, bool walk);
|
||||
void MoveSmoothPath(uint32 pointId, Movement::PointsArray const& points, bool walk);
|
||||
// Walk along spline chain stored in DB (script_spline_chain_meta and script_spline_chain_waypoints)
|
||||
void MoveAlongSplineChain(uint32 pointId, uint32 dbChainId, bool walk);
|
||||
void MoveAlongSplineChain(uint32 pointId, uint16 dbChainId, bool walk);
|
||||
void MoveAlongSplineChain(uint32 pointId, SplineChain const& chain, bool walk);
|
||||
void ResumeSplineChain(SplineChainResumeInfo const& info);
|
||||
void MoveFall(uint32 id = 0);
|
||||
|
||||
@@ -106,7 +106,8 @@ void SystemMgr::LoadScriptSplineChains()
|
||||
{
|
||||
Field* fieldsMeta = resultMeta->Fetch();
|
||||
uint32 entry = fieldsMeta[0].GetUInt32();
|
||||
uint8 chainId = fieldsMeta[1].GetUInt8(), splineId = fieldsMeta[2].GetUInt8();
|
||||
uint16 chainId = fieldsMeta[1].GetUInt16();
|
||||
uint8 splineId = fieldsMeta[2].GetUInt8();
|
||||
SplineChain& chain = m_mSplineChainsMap[{entry,chainId}];
|
||||
|
||||
if (splineId != chain.size())
|
||||
@@ -127,7 +128,8 @@ void SystemMgr::LoadScriptSplineChains()
|
||||
{
|
||||
Field* fieldsWP = resultWP->Fetch();
|
||||
uint32 entry = fieldsWP[0].GetUInt32();
|
||||
uint8 chainId = fieldsWP[1].GetUInt8(), splineId = fieldsWP[2].GetUInt8(), wpId = fieldsWP[3].GetUInt8();
|
||||
uint16 chainId = fieldsWP[1].GetUInt16();
|
||||
uint8 splineId = fieldsWP[2].GetUInt8(), wpId = fieldsWP[3].GetUInt8();
|
||||
float posX = fieldsWP[4].GetFloat(), posY = fieldsWP[5].GetFloat(), posZ = fieldsWP[6].GetFloat();
|
||||
auto it = m_mSplineChainsMap.find({entry,chainId});
|
||||
if (it == m_mSplineChainsMap.end())
|
||||
|
||||
@@ -73,9 +73,9 @@ class TC_GAME_API SystemMgr
|
||||
return &itr->second;
|
||||
}
|
||||
|
||||
SplineChain const* GetSplineChain(uint32 entry, uint8 id) const
|
||||
SplineChain const* GetSplineChain(uint32 entry, uint16 chainId) const
|
||||
{
|
||||
auto it = m_mSplineChainsMap.find({ entry, id });
|
||||
auto it = m_mSplineChainsMap.find({ entry, chainId });
|
||||
if (it == m_mSplineChainsMap.end())
|
||||
return nullptr;
|
||||
return &it->second;
|
||||
@@ -85,7 +85,7 @@ class TC_GAME_API SystemMgr
|
||||
|
||||
protected:
|
||||
PointMoveMap m_mPointMoveMap; //coordinates for waypoints
|
||||
typedef std::pair<uint32, uint8> ChainKeyType; // creature entry + chain ID
|
||||
typedef std::pair<uint32, uint16> ChainKeyType; // creature entry + chain ID
|
||||
std::unordered_map<ChainKeyType, SplineChain> m_mSplineChainsMap; // spline chains
|
||||
};
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
{
|
||||
case 4:
|
||||
SetEscortPaused(true);
|
||||
me->SetFacingTo(1.775791f);
|
||||
me->SetFacingTo(1.775791f, true);
|
||||
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
|
||||
Talk(SAY_MORRIDUNE_2);
|
||||
break;
|
||||
|
||||
@@ -246,7 +246,7 @@ public:
|
||||
me->SetCanFly(true);
|
||||
me->SetDisableGravity(true);
|
||||
me->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER);
|
||||
me->SetFacingTo(me->GetOrientation() + float(M_PI));
|
||||
me->SetFacingTo(me->GetOrientation() + float(M_PI), true);
|
||||
if (Creature * trigger = me->SummonCreature(NPC_TRIGGER, MiddleRoomLocation, TEMPSUMMON_CORPSE_DESPAWN))
|
||||
triggerGUID = trigger->GetGUID();
|
||||
me->GetMotionMaster()->MoveTakeoff(11, Phase2Floating);
|
||||
|
||||
@@ -363,7 +363,7 @@ public:
|
||||
me->GetMotionMaster()->MoveIdle();
|
||||
if (Creature* gryshka = ObjectAccessor::GetCreature(*me, gryshkaGUID))
|
||||
{
|
||||
me->SetFacingTo(me->GetAngle(gryshka->GetPositionX(), gryshka->GetPositionY()));
|
||||
me->SetFacingToObject(gryshka);
|
||||
gryshka->AI()->Talk(SAY_GRYSHKA_1);
|
||||
}
|
||||
events.ScheduleEvent(EVENT_SCENE_2, 4500);
|
||||
@@ -631,7 +631,7 @@ public:
|
||||
|
||||
if (Creature* jaina = me->SummonCreature(NPC_JAINA_PROUDMOORE, PortalSpawnPosition))
|
||||
{
|
||||
me->SetFacingTo(me->GetAngle(jaina->GetPositionX(), jaina->GetPositionY()));
|
||||
me->SetFacingToObject(jaina);
|
||||
jainaGUID = jaina->GetGUID();
|
||||
jaina->CastSpell(jaina, SPELL_JAINA_SPAWNIN);
|
||||
}
|
||||
@@ -689,7 +689,7 @@ public:
|
||||
case EVENT_HERALD_SCENE2:
|
||||
Talk(SAY_THRALL_1);
|
||||
if (Creature* jaina = ObjectAccessor::GetCreature(*me, jainaGUID))
|
||||
me->SetFacingTo(me->GetAngle(jaina->GetPositionX(), jaina->GetPositionY()));
|
||||
me->SetFacingToObject(jaina);
|
||||
events.ScheduleEvent(EVENT_HERALD_SCENE3, 3500);
|
||||
break;
|
||||
case EVENT_HERALD_SCENE3:
|
||||
|
||||
@@ -306,7 +306,7 @@ class boss_devourer_of_souls : public CreatureScript
|
||||
|
||||
case EVENT_WAILING_SOULS_TICK:
|
||||
beamAngle += beamAngleDiff;
|
||||
me->SetFacingTo(beamAngle);
|
||||
me->SetFacingTo(beamAngle, true);
|
||||
me->StopMoving();
|
||||
|
||||
DoCast(me, SPELL_WAILING_SOULS);
|
||||
|
||||
@@ -361,12 +361,12 @@ class boss_sindragosa : public CreatureScript
|
||||
break;
|
||||
case POINT_AIR_PHASE:
|
||||
me->CastCustomSpell(SPELL_ICE_TOMB_TARGET, SPELLVALUE_MAX_TARGETS, RAID_MODE<int32>(2, 5, 2, 6), NULL, TRIGGERED_FULL_MASK);
|
||||
me->SetFacingTo(float(M_PI));
|
||||
me->SetFacingTo(float(M_PI), true);
|
||||
events.ScheduleEvent(EVENT_AIR_MOVEMENT_FAR, 1);
|
||||
events.ScheduleEvent(EVENT_FROST_BOMB, 9000);
|
||||
break;
|
||||
case POINT_AIR_PHASE_FAR:
|
||||
me->SetFacingTo(float(M_PI));
|
||||
me->SetFacingTo(float(M_PI), true);
|
||||
events.ScheduleEvent(EVENT_LAND, 30000);
|
||||
break;
|
||||
case POINT_LAND:
|
||||
@@ -723,7 +723,7 @@ class npc_spinestalker : public CreatureScript
|
||||
me->SetDisableGravity(false);
|
||||
me->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER);
|
||||
me->SetHomePosition(SpinestalkerLandPos);
|
||||
me->SetFacingTo(SpinestalkerLandPos.GetOrientation());
|
||||
me->SetFacingTo(SpinestalkerLandPos.GetOrientation(), true);
|
||||
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
|
||||
me->SetReactState(REACT_AGGRESSIVE);
|
||||
}
|
||||
@@ -860,7 +860,7 @@ class npc_rimefang : public CreatureScript
|
||||
me->SetDisableGravity(false);
|
||||
me->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER);
|
||||
me->SetHomePosition(RimefangLandPos);
|
||||
me->SetFacingTo(RimefangLandPos.GetOrientation());
|
||||
me->SetFacingTo(RimefangLandPos.GetOrientation(), true);
|
||||
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
|
||||
me->SetReactState(REACT_AGGRESSIVE);
|
||||
}
|
||||
|
||||
@@ -834,7 +834,7 @@ class boss_the_lich_king : public CreatureScript
|
||||
events.ScheduleEvent(EVENT_INTRO_TALK_1, 9000, 0, PHASE_INTRO);
|
||||
break;
|
||||
case POINT_CENTER_1:
|
||||
me->SetFacingTo(0.0f);
|
||||
me->SetFacingTo(0.0f, true);
|
||||
Talk(SAY_LK_REMORSELESS_WINTER);
|
||||
me->GetMap()->SetZoneMusic(AREA_THE_FROZEN_THRONE, MUSIC_SPECIAL);
|
||||
DoCast(me, SPELL_REMORSELESS_WINTER_1);
|
||||
@@ -849,7 +849,7 @@ class boss_the_lich_king : public CreatureScript
|
||||
events.ScheduleEvent(EVENT_SOUL_REAPER, 94000, 0, PHASE_TWO);
|
||||
break;
|
||||
case POINT_CENTER_2:
|
||||
me->SetFacingTo(0.0f);
|
||||
me->SetFacingTo(0.0f, true);
|
||||
Talk(SAY_LK_REMORSELESS_WINTER);
|
||||
me->GetMap()->SetZoneMusic(AREA_THE_FROZEN_THRONE, MUSIC_SPECIAL);
|
||||
DoCast(me, SPELL_REMORSELESS_WINTER_2);
|
||||
|
||||
@@ -437,7 +437,7 @@ class boss_algalon_the_observer : public CreatureScript
|
||||
me->SetDisableGravity(false);
|
||||
else if (pointId == POINT_ALGALON_OUTRO)
|
||||
{
|
||||
me->SetFacingTo(1.605703f);
|
||||
me->SetFacingTo(1.605703f, true);
|
||||
events.ScheduleEvent(EVENT_OUTRO_3, 1200);
|
||||
events.ScheduleEvent(EVENT_OUTRO_4, 2400);
|
||||
events.ScheduleEvent(EVENT_OUTRO_5, 8500);
|
||||
|
||||
@@ -75,7 +75,7 @@ class boss_erekem : public CreatureScript
|
||||
void MovementInform(uint32 type, uint32 pointId) override
|
||||
{
|
||||
if (type == EFFECT_MOTION_TYPE && pointId == POINT_INTRO)
|
||||
me->SetFacingTo(4.921828f);
|
||||
me->SetFacingTo(4.921828f, true);
|
||||
}
|
||||
|
||||
void JustReachedHome() override
|
||||
|
||||
@@ -430,6 +430,8 @@ class npc_sinclari_vh : public CreatureScript
|
||||
me->GetCreatureListWithEntryInGrid(guardList, NPC_VIOLET_HOLD_GUARD, 100.0f);
|
||||
for (Creature* guard : guardList)
|
||||
{
|
||||
if (!guard->IsAlive())
|
||||
continue;
|
||||
guard->SetReactState(REACT_PASSIVE);
|
||||
guard->SetWalk(false);
|
||||
guard->GetMotionMaster()->MovePoint(0, GuardsMovePosition);
|
||||
|
||||
@@ -174,7 +174,7 @@ class npc_commander_eligor_dawnbringer : public CreatureScript
|
||||
{
|
||||
if (id == 1)
|
||||
{
|
||||
me->SetFacingTo(PosTalkLocations[talkWing].GetOrientation());
|
||||
me->SetFacingTo(PosTalkLocations[talkWing].GetOrientation(), true);
|
||||
TurnAudience();
|
||||
|
||||
switch (talkWing)
|
||||
|
||||
@@ -444,7 +444,7 @@ public:
|
||||
else if (pointId == AKAMA_INTRO_WAYPOINT)
|
||||
{
|
||||
me->SetWalk(false);
|
||||
me->SetFacingTo(0.08726646f);
|
||||
me->SetFacingTo(0.08726646f, true);
|
||||
_events.ScheduleEvent(EVENT_START_SOUL_EXPEL, Seconds(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,7 +595,7 @@ class boss_kaelthas : public CreatureScript
|
||||
events.ScheduleEvent(EVENT_TRANSITION_1, 1000);
|
||||
break;
|
||||
case POINT_TRANSITION_CENTER_ASCENDING:
|
||||
me->SetFacingTo(float(M_PI));
|
||||
me->SetFacingTo(float(M_PI), true);
|
||||
Talk(SAY_PHASE5_NUTS);
|
||||
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
|
||||
me->SetDisableGravity(true);
|
||||
|
||||
Reference in New Issue
Block a user