diff options
| author | ccrs <ccrs@users.noreply.github.com> | 2018-06-03 10:06:57 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-03 10:06:57 -0700 |
| commit | 982643cd96790ffc54e7a3e507469649f3b074d2 (patch) | |
| tree | 90e65482d064fc9b2e8d0e215f2dec6e5fe663c9 /src/server/game/AI/SmartScripts | |
| parent | b84348f6fc7746349fdcbd443b32fe5483174442 (diff) | |
Core/Movement: MotionMaster reimplementation (#21888)
Internal structure and handling changes, nothing behavioural (or thats the intention at least).
Diffstat (limited to 'src/server/game/AI/SmartScripts')
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.cpp | 31 | ||||
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 10 | ||||
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 4 | ||||
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.h | 8 |
4 files changed, 34 insertions, 19 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index ccbfdfd0ed6..0fb99e63d9c 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -112,7 +112,7 @@ void SmartAI::PausePath(uint32 delay, bool forced) { if (!HasEscortState(SMART_ESCORT_ESCORTING)) { - me->PauseMovement(delay, MOTION_SLOT_IDLE, forced); + me->PauseMovement(delay, MOTION_SLOT_DEFAULT, forced); if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE) { std::pair<uint32, uint32> waypointInfo = me->GetCurrentWaypointInfo(); @@ -544,8 +544,11 @@ void SmartAI::JustReachedHome() CreatureGroup* formation = me->GetFormation(); if (!formation || formation->GetLeader() == me || !formation->IsFormed()) { - if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_IDLE) != WAYPOINT_MOTION_TYPE && me->GetWaypointPath()) - me->GetMotionMaster()->MovePath(me->GetWaypointPath(), true); + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType(MOTION_SLOT_DEFAULT) != WAYPOINT_MOTION_TYPE) + { + if (me->GetWaypointPath()) + me->GetMotionMaster()->MovePath(me->GetWaypointPath(), true); + } else me->ResumeMovement(); } @@ -591,7 +594,8 @@ void SmartAI::AttackStart(Unit* who) if (who && me->Attack(who, mCanAutoAttack)) { - me->GetMotionMaster()->Clear(MOTION_SLOT_ACTIVE); + me->GetMotionMaster()->Clear(MOTION_PRIORITY_NORMAL); + me->PauseMovement(); if (mCanCombatMove) { @@ -770,13 +774,22 @@ void SmartAI::SetCombatMove(bool on) if (me->IsEngaged()) { - if (on && !me->HasReactState(REACT_PASSIVE) && me->GetVictim() && me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE) == MAX_MOTION_TYPE) + if (on) { - SetRun(mRun); - me->GetMotionMaster()->MoveChase(me->GetVictim()); + if (!me->HasReactState(REACT_PASSIVE) && me->GetVictim() && !me->GetMotionMaster()->HasMovementGenerator([](MovementGenerator const* movement) -> bool + { + return movement->Mode == MOTION_MODE_DEFAULT && movement->Priority == MOTION_PRIORITY_NORMAL; + })) + { + SetRun(mRun); + me->GetMotionMaster()->MoveChase(me->GetVictim()); + } } - else if (!on && me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE) == CHASE_MOTION_TYPE) - me->GetMotionMaster()->Clear(MOTION_SLOT_ACTIVE); + else if (MovementGenerator* movement = me->GetMotionMaster()->GetMovementGenerator([](MovementGenerator const* a) -> bool + { + return a->GetMovementGeneratorType() == CHASE_MOTION_TYPE && a->Mode == MOTION_MODE_DEFAULT && a->Priority == MOTION_PRIORITY_NORMAL; + })) + me->GetMotionMaster()->Remove(movement); } } diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 2a524ae8c5e..2e8d2f72563 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1594,10 +1594,12 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u float attackAngle = float(e.action.setRangedMovement.angle) / 180.0f * float(M_PI); for (WorldObject* target : targets) + { if (Creature* creature = target->ToCreature()) if (IsSmart(creature) && creature->GetVictim()) if (ENSURE_AI(SmartAI, creature->AI())->CanCombatMove()) creature->GetMotionMaster()->MoveChase(creature->GetVictim(), attackDistance, attackAngle); + } break; } @@ -2230,16 +2232,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u target->ToUnit()->RemoveAllGameObjects(); break; } - case SMART_ACTION_STOP_MOTION: + case SMART_ACTION_REMOVE_MOVEMENT: { for (WorldObject* const target : targets) { if (IsUnit(target)) { - if (e.action.stopMotion.stopMovement) + if (e.action.removeMovement.movementType && e.action.removeMovement.movementType < MAX_MOTION_TYPE) + target->ToUnit()->GetMotionMaster()->Remove(MovementGeneratorType(e.action.removeMovement.movementType)); + if (e.action.removeMovement.forced) target->ToUnit()->StopMoving(); - if (e.action.stopMotion.movementExpired) - target->ToUnit()->GetMotionMaster()->MovementExpired(); } } break; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 538df1630ed..8baeca1857b 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -22,7 +22,7 @@ #include "GameEventMgr.h" #include "InstanceScript.h" #include "Log.h" -#include "MotionMaster.h" +#include "MovementDefines.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "SpellInfo.h" @@ -1570,7 +1570,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_ACTION_REMOVE_ALL_GAMEOBJECTS: case SMART_ACTION_SPAWN_SPAWNGROUP: case SMART_ACTION_DESPAWN_SPAWNGROUP: - case SMART_ACTION_STOP_MOTION: + case SMART_ACTION_REMOVE_MOVEMENT: break; default: TC_LOG_ERROR("sql.sql", "SmartAIMgr: Not handled action_type(%u), event_type(%u), Entry %d SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id); diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 2159ed2a8ba..fa2e59f8941 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -574,7 +574,7 @@ enum SMART_ACTION SMART_ACTION_LOAD_EQUIPMENT = 124, // id SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT = 125, // id min range, id max range SMART_ACTION_REMOVE_ALL_GAMEOBJECTS = 126, - SMART_ACTION_STOP_MOTION = 127, // stopMoving, movementExpired + SMART_ACTION_REMOVE_MOVEMENT = 127, // movementType, forced SMART_ACTION_PLAY_ANIMKIT = 128, // don't use on 3.3.5a SMART_ACTION_SCENE_PLAY = 129, // don't use on 3.3.5a SMART_ACTION_SCENE_CANCEL = 130, // don't use on 3.3.5a @@ -1122,9 +1122,9 @@ struct SmartAction struct { - uint32 stopMovement; - uint32 movementExpired; - } stopMotion; + uint32 movementType; + uint32 forced; + } removeMovement; struct { |
