aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-06-15 12:02:55 -0500
committermegamage <none@none>2009-06-15 12:02:55 -0500
commitb9610f27dd2c55f63f9a96f1259a8dce33b71d88 (patch)
tree4920b011dc839e2c4901e31d8996a206bff63808
parent4d6fb6c8b2d84996711fa8bc41e71fa6d483b98c (diff)
*Check movementflag to interrupt casting instead of checking position.
*Also some other fixes about movement flags. --HG-- branch : trunk
-rw-r--r--src/bindings/scripts/scripts/zone/azshara/azshara.cpp4
-rw-r--r--src/bindings/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp4
-rw-r--r--src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/boss_ingvar_the_plunderer.cpp2
-rw-r--r--src/game/Creature.cpp15
-rw-r--r--src/game/Creature.h2
-rw-r--r--src/game/MovementHandler.cpp10
-rw-r--r--src/game/Player.cpp39
-rw-r--r--src/game/Player.h16
-rw-r--r--src/game/PointMovementGenerator.cpp2
-rw-r--r--src/game/RandomMovementGenerator.cpp6
-rw-r--r--src/game/Spell.cpp23
-rw-r--r--src/game/SpellAuras.cpp17
-rw-r--r--src/game/TargetedMovementGenerator.cpp6
-rw-r--r--src/game/Traveller.h4
-rw-r--r--src/game/Unit.cpp54
-rw-r--r--src/game/Unit.h26
-rw-r--r--src/game/Vehicle.cpp2
-rw-r--r--src/game/WaypointMovementGenerator.cpp2
-rw-r--r--src/game/WorldSession.cpp2
19 files changed, 119 insertions, 117 deletions
diff --git a/src/bindings/scripts/scripts/zone/azshara/azshara.cpp b/src/bindings/scripts/scripts/zone/azshara/azshara.cpp
index 5223b6d93c3..6d191db16b2 100644
--- a/src/bindings/scripts/scripts/zone/azshara/azshara.cpp
+++ b/src/bindings/scripts/scripts/zone/azshara/azshara.cpp
@@ -310,7 +310,7 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
Player* player = Unit::GetPlayer(PlayerGUID);
SendText(MSG_ESCAPE_NOTICE, player);
DoCast(m_creature, SPELL_PERIODIC_DEPTH_CHARGE);
- m_creature->SetUnitMovementFlags(MOVEMENTFLAG_FLYING2 | MOVEMENTFLAG_SWIMMING);
+ m_creature->SetUnitMovementFlags(MOVEMENTFLAG_HOVER | MOVEMENTFLAG_SWIMMING);
m_creature->SetSpeed(MOVE_RUN, 0.85f, true);
m_creature->GetMotionMaster()->MovementExpired();
m_creature->GetMotionMaster()->MovePoint(CurrWP, WPs[CurrWP][0], WPs[CurrWP][1], WPs[CurrWP][2]);
@@ -441,7 +441,7 @@ struct TRINITY_DLL_DECL mob_depth_chargeAI : public ScriptedAI
void Reset()
{
- m_creature->SetUnitMovementFlags(MOVEMENTFLAG_FLYING2 | MOVEMENTFLAG_SWIMMING);
+ m_creature->SetUnitMovementFlags(MOVEMENTFLAG_HOVER | MOVEMENTFLAG_SWIMMING);
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
we_must_die = false;
must_die_timer = 1000;
diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp
index 0cf5119f0d8..f0a80248c19 100644
--- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp
+++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp
@@ -400,7 +400,7 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
{
m_creature->SetVisibility(VISIBILITY_OFF);
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- m_creature->AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
+ m_creature->AddUnitMovementFlag(MOVEMENTFLAG_HOVER);
m_creature->SetSpeed(MOVE_WALK,5.0f,true);
wp_reached = false;
count = 0;
@@ -432,7 +432,7 @@ struct TRINITY_DLL_DECL boss_headless_horsemanAI : public ScriptedAI
pInstance->SetData(GAMEOBJECT_PUMPKIN_SHRINE, 0); //hide gameobject
break;
case 19:
- m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING2);break;
+ m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_HOVER);break;
case 20: {
Phase = 1;
IsFlying = false;
diff --git a/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/boss_ingvar_the_plunderer.cpp b/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/boss_ingvar_the_plunderer.cpp
index e3c66109dfc..035df9082c8 100644
--- a/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/boss_ingvar_the_plunderer.cpp
+++ b/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/boss_ingvar_the_plunderer.cpp
@@ -295,7 +295,7 @@ struct TRINITY_DLL_DECL mob_annhylde_the_callerAI : public ScriptedAI
void Reset()
{
- m_creature->AddUnitMovementFlag(MOVEMENTFLAG_FLYING + MOVEMENTFLAG_FLYING2);
+ m_creature->AddUnitMovementFlag(MOVEMENTFLAG_FLYING + MOVEMENTFLAG_HOVER);
m_creature->SetSpeed(MOVE_SWIM , 0.1f);
m_creature->SetSpeed(MOVE_RUN , 0.1f);
m_creature->SetSpeed(MOVE_WALK , 0.1f);
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index bfa185010fd..24fd970bddf 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -1648,9 +1648,13 @@ bool Creature::IsWithinSightDist(Unit const* u) const
bool Creature::canStartAttack(Unit const* who, bool force) const
{
- if(isCivilian()
- || !who->isInAccessiblePlaceFor(this)
- || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
+ if(isCivilian() || !who->isInAccessiblePlaceFor(this))
+ return false;
+
+ if(!canFly() && (GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE))
+ //|| who->IsControlledByPlayer() && who->IsFlying()))
+ // we cannot check flying for other creatures, too much map/vmap calculation
+ // TODO: should switch to range attack
return false;
if(!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who))))
@@ -2190,6 +2194,9 @@ bool Creature::LoadCreaturesAddon(bool reload)
if (cainfo->move_flags != 0)
SetUnitMovementFlags(cainfo->move_flags);
+ if(GetCreatureInfo()->InhabitType & INHABIT_AIR)
+ AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE);
+
if(cainfo->auras)
{
for (CreatureDataAddonAura const* cAura = cainfo->auras; cAura->spell_id; ++cAura)
@@ -2504,4 +2511,4 @@ time_t Creature::GetLinkedCreatureRespawnTime() const
}
return 0;
-} \ No newline at end of file
+}
diff --git a/src/game/Creature.h b/src/game/Creature.h
index d7d070fc526..954259d8846 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -516,7 +516,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool isTrigger() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; }
bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
- bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
+ //bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
void SetReactState(ReactStates st) { m_reactState = st; }
ReactStates GetReactState() { return m_reactState; }
bool HasReactState(ReactStates state) const { return (m_reactState == state); }
diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
index c3c82d552ac..1a483a8869d 100644
--- a/src/game/MovementHandler.cpp
+++ b/src/game/MovementHandler.cpp
@@ -299,9 +299,6 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
plMover->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
plMover->UpdateFallInformationIfNeed(movementInfo, recv_data.GetOpcode());
- if(plMover->isMovingOrTurning())
- plMover->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
-
if(movementInfo.z < -500.0f)
{
if(plMover->InBattleGround()
@@ -339,6 +336,13 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
if(mover->m_Vehicle)
return;
mover->GetMap()->CreatureRelocation((Creature*)mover, movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
+
+ /*if(mover->canFly())
+ {
+ bool flying = mover->IsFlying();
+ if(flying != ((mover->GetByteValue(UNIT_FIELD_BYTES_1, 3) & 0x02) ? true : false))
+ mover->SetFlying(flying);
+ }*/
}
//sLog.outString("Receive Movement Packet %s:", opcodeTable[recv_data.GetOpcode()]);
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 7abe7f67d55..68545b6a379 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -5635,38 +5635,35 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele
return false;
}
- Map *m = GetMap();
+ //if(movementInfo.flags & MOVEMENTFLAG_MOVING)
+ // mover->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE);
+ //if(movementInfo.flags & MOVEMENTFLAG_TURNING)
+ // mover->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING);
+ //AURA_INTERRUPT_FLAG_JUMP not sure
- const float old_x = GetPositionX();
- const float old_y = GetPositionY();
- const float old_z = GetPositionZ();
- const float old_r = GetOrientation();
+ if(GetOrientation() != orientation)
+ RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING);
- if( teleport || old_x != x || old_y != y || old_z != z || old_r != orientation )
+ bool move2d = (teleport || GetPositionX() != x || GetPositionY() != y);
+ if(move2d || GetPositionZ() != z)
{
- if (teleport || old_x != x || old_y != y || old_z != z)
- RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING);
- else
- RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING);
+ RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE);
// move and update visible state if need
- m->PlayerRelocation(this, x, y, z, orientation);
+ GetMap()->PlayerRelocation(this, x, y, z, orientation);
// reread after Map::Relocation
- m = GetMap();
- x = GetPositionX();
- y = GetPositionY();
- z = GetPositionZ();
+ GetPosition(x, y, z);
// group update
- if(GetGroup() && (old_x != x || old_y != y))
+ if(move2d && GetGroup())
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);
- }
- // code block for underwater state update
- UpdateUnderwaterState(m, x, y, z);
+ // code block for underwater state update
+ UpdateUnderwaterState(GetMap(), x, y, z);
- CheckExploreSystem();
+ CheckExploreSystem();
+ }
return true;
}
@@ -6415,7 +6412,7 @@ void Player::CheckDuelDistance(time_t currTime)
bool Player::IsOutdoorPvPActive()
{
- return (isAlive() && !HasInvisibilityAura() && !HasStealthAura() && (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP) || sWorld.IsPvPRealm()) && !HasUnitMovementFlag(MOVEMENTFLAG_FLYING2) && !isInFlight());
+ return (isAlive() && !HasInvisibilityAura() && !HasStealthAura() && (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP) || sWorld.IsPvPRealm()) && !HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && !isInFlight());
}
void Player::DuelComplete(DuelCompleteType type)
diff --git a/src/game/Player.h b/src/game/Player.h
index 9dcad34f0e8..c879222d8d8 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -689,17 +689,6 @@ enum InstanceResetWarningType
RAID_INSTANCE_EXPIRED = 5
};
-// flags that use in movement check for example at spell casting
-MovementFlags const movementFlagsMask = MovementFlags(
- MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT|
- MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FLY_UNK1 |
- MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING |MOVEMENTFLAG_FLY_UP |
- MOVEMENTFLAG_FLYING |MOVEMENTFLAG_SPLINE
-);
-
-MovementFlags const movementOrTurningFlagsMask = MovementFlags(
- movementFlagsMask | MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT
-);
class InstanceSave;
enum RestType
@@ -1951,11 +1940,6 @@ class TRINITY_DLL_SPEC Player : public Unit
}
void HandleFall(MovementInfo const& movementInfo);
- bool isMoving() const { return m_movementInfo.HasMovementFlag(movementFlagsMask); }
- bool isMovingOrTurning() const { return m_movementInfo.HasMovementFlag(movementOrTurningFlagsMask); }
-
- bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); }
- bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING); }
bool IsAllowUseFlyMountsHere() const;
void SetClientControl(Unit* target, uint8 allowMove);
diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp
index c972683ce0b..ed057854aaa 100644
--- a/src/game/PointMovementGenerator.cpp
+++ b/src/game/PointMovementGenerator.cpp
@@ -35,7 +35,7 @@ void PointMovementGenerator<T>::Initialize(T &unit)
i_destinationHolder.SetDestination(traveller,i_x,i_y,i_z, !unit.hasUnitState(UNIT_STAT_JUMPING));
if (unit.GetTypeId() == TYPEID_UNIT && ((Creature*)&unit)->canFly())
- unit.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
+ unit.AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
}
template<class T>
diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp
index 6d3648d51e4..e354e41827c 100644
--- a/src/game/RandomMovementGenerator.cpp
+++ b/src/game/RandomMovementGenerator.cpp
@@ -124,7 +124,7 @@ RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
if (is_air_ok)
{
i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime());
- creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
+ creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
}
//else if (is_water_ok) // Swimming mode to be done with more than this check
else
@@ -151,7 +151,7 @@ RandomMovementGenerator<Creature>::Initialize(Creature &creature)
wander_distance = creature.GetRespawnRadius();
if (creature.canFly())
- creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
+ creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
else if(irand(0,RUNNING_CHANCE_RANDOMMV) > 0)
creature.AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
_setRandomLocation(creature);
@@ -194,7 +194,7 @@ RandomMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff
if(i_nextMoveTime.Passed())
{
if (creature.canFly())
- creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
+ creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
else if(irand(0,RUNNING_CHANCE_RANDOMMV) > 0)
creature.AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
_setRandomLocation(creature);
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 0f2def62271..645c2529433 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -423,7 +423,6 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi
m_spellState = SPELL_STATE_NULL;
- m_castPositionX = m_castPositionY = m_castPositionZ = 0;
m_TriggerSpells.clear();
m_IsTriggeredSpell = triggered;
//m_AreaAura = false;
@@ -2391,9 +2390,6 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect* triggeredByAura
m_spellState = SPELL_STATE_PREPARING;
- m_caster->GetPosition(m_castPositionX, m_castPositionY, m_castPositionZ);
- m_castOrientation = m_caster->GetOrientation();
-
if(triggeredByAura)
m_triggeredByAuraSpell = triggeredByAura->GetSpellProto();
@@ -2920,15 +2916,11 @@ void Spell::update(uint32 difftime)
// check if the player caster has moved before the spell finished
if ((m_caster->GetTypeId() == TYPEID_PLAYER && m_timer != 0) &&
- (m_castPositionX != m_caster->GetPositionX() || m_castPositionY != m_caster->GetPositionY() || m_castPositionZ != m_caster->GetPositionZ()) &&
+ m_caster->isMoving() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT) &&
(m_spellInfo->Effect[0] != SPELL_EFFECT_STUCK || !m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING)))
{
- // always cancel for channeled spells
- //if( m_spellState == SPELL_STATE_CASTING )
- // cancel();
// don't cancel for melee, autorepeat, triggered and instant spells
- //else
- if(!IsNextMeleeSwingSpell() && !IsAutoRepeat() && !m_IsTriggeredSpell && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT))
+ if(!IsNextMeleeSwingSpell() && !IsAutoRepeat() && !m_IsTriggeredSpell)
cancel();
}
@@ -2951,17 +2943,6 @@ void Spell::update(uint32 difftime)
{
if(m_timer > 0)
{
- if( m_caster->GetTypeId() == TYPEID_PLAYER )
- {
- // check if player has jumped before the channeling finished
- if(m_caster->HasUnitMovementFlag(MOVEMENTFLAG_JUMPING))
- cancel();
-
- // check for incapacitating player states
- //if( m_caster->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED))
- // cancel();
- }
-
// check if there are alive targets left
if (!UpdateChanneledTargetList())
{
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 2ebf5b0002d..53a865380d8 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -5668,26 +5668,15 @@ void AuraEffect::HandleAuraAllowFlight(bool apply, bool Real, bool /*changeAmoun
if(!Real)
return;
+ if(m_target->GetTypeId() == TYPEID_UNIT)
+ m_target->SetFlying(apply);
+
// allow fly
WorldPacket data;
if(apply)
- {
data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
- if(m_target->GetTypeId() == TYPEID_UNIT)
- {
- m_target->SetByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02);
- m_target->AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
- }
- }
else
- {
data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
- if(m_target->GetTypeId() == TYPEID_UNIT)
- {
- m_target->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02);
- m_target->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING2);
- }
- }
data.append(m_target->GetPackGUID());
data << uint32(0); // unk
m_target->SendMessageToSet(&data, true);
diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp
index 54c99ee90dd..c40568318d4 100644
--- a/src/game/TargetedMovementGenerator.cpp
+++ b/src/game/TargetedMovementGenerator.cpp
@@ -132,7 +132,7 @@ TargetedMovementGenerator<T>::_setTargetLocation(T &owner)
i_destinationHolder.SetDestination(traveller, x, y, z);
owner.addUnitState(UNIT_STAT_CHASE);
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly())
- owner.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
+ owner.AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
i_destinationHolder.StartTravel(traveller);
return true;
}
@@ -147,7 +147,7 @@ TargetedMovementGenerator<T>::Initialize(T &owner)
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly())
- owner.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
+ owner.AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
_setTargetLocation(owner);
}
@@ -199,7 +199,7 @@ TargetedMovementGenerator<T>::Update(T &owner, const uint32 & time_diff)
{
owner.addUnitState(UNIT_STAT_CHASE);
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly())
- owner.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
+ owner.AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
i_destinationHolder.StartTravel(traveller);
return true;
diff --git a/src/game/Traveller.h b/src/game/Traveller.h
index dfa4913a4cc..b5d0fb28ecc 100644
--- a/src/game/Traveller.h
+++ b/src/game/Traveller.h
@@ -79,7 +79,7 @@ inline float Traveller<Creature>::Speed()
return i_traveller.m_TempSpeed;
else if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
return i_traveller.GetSpeed(MOVE_WALK);
- else if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING2))
+ else if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING))
return i_traveller.GetSpeed(MOVE_FLIGHT);
else
return i_traveller.GetSpeed(MOVE_RUN);
@@ -98,7 +98,7 @@ inline float Traveller<Creature>::GetMoveDestinationTo(float x, float y, float z
float dy = y - GetPositionY();
float dz = z - GetPositionZ();
- if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING2))
+ if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING))
return sqrt((dx*dx) + (dy*dy) + (dz*dz));
else //Walking on the ground
return sqrt((dx*dx) + (dy*dy));
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 89728d586a5..ebeac678c8c 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -13777,13 +13777,13 @@ void Unit::SetStunned(bool apply)
SetUInt64Value(UNIT_FIELD_TARGET, 0);
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
CastStop();
+ AddUnitMovementFlag(MOVEMENTFLAG_ROOT);
// Creature specific
if(GetTypeId() != TYPEID_PLAYER)
((Creature*)this)->StopMoving();
else
SetStandState(UNIT_STAND_STATE_STAND);
- // SetUnitMovementFlags(0); //Clear movement flags
WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8);
data.append(GetPackGUID());
@@ -13806,21 +13806,20 @@ void Unit::SetStunned(bool apply)
data.append(GetPackGUID());
data << uint32(0);
SendMessageToSet(&data,true);
+
+ RemoveUnitMovementFlag(MOVEMENTFLAG_ROOT);
}
}
}
void Unit::SetRooted(bool apply)
{
- uint32 apply_stat = UNIT_STAT_ROOT;
if(apply)
{
- //SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16)); // probably wrong
+ AddUnitMovementFlag(MOVEMENTFLAG_ROOT);
if(GetTypeId() == TYPEID_PLAYER)
{
- //SetUnitMovementFlags(0);
-
WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
data.append(GetPackGUID());
data << (uint32)2;
@@ -13831,8 +13830,6 @@ void Unit::SetRooted(bool apply)
}
else
{
- //RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16)); // probably wrong
-
if(!hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect
{
if(GetTypeId() == TYPEID_PLAYER)
@@ -13842,6 +13839,8 @@ void Unit::SetRooted(bool apply)
data << (uint32)2;
SendMessageToSet(&data,true);
}
+
+ RemoveUnitMovementFlag(MOVEMENTFLAG_ROOT);
}
}
}
@@ -13850,6 +13849,8 @@ void Unit::SetFeared(bool apply)
{
if(apply)
{
+ SetUInt64Value(UNIT_FIELD_TARGET, 0);
+
Unit *caster = NULL;
Unit::AuraEffectList const& fearAuras = GetAurasByType(SPELL_AURA_MOD_FEAR);
if(!fearAuras.empty())
@@ -13860,8 +13861,13 @@ void Unit::SetFeared(bool apply)
}
else
{
- if(isAlive() && GetMotionMaster()->GetCurrentMovementGeneratorType() == FLEEING_MOTION_TYPE)
- GetMotionMaster()->MovementExpired();
+ if(isAlive())
+ {
+ if(GetMotionMaster()->GetCurrentMovementGeneratorType() == FLEEING_MOTION_TYPE)
+ GetMotionMaster()->MovementExpired();
+ if(getVictim())
+ SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
+ }
}
if (GetTypeId() == TYPEID_PLAYER)
@@ -13872,12 +13878,18 @@ void Unit::SetConfused(bool apply)
{
if(apply)
{
+ SetUInt64Value(UNIT_FIELD_TARGET, 0);
GetMotionMaster()->MoveConfused();
}
else
{
- if(isAlive() && GetMotionMaster()->GetCurrentMovementGeneratorType() == CONFUSED_MOTION_TYPE)
- GetMotionMaster()->MovementExpired();
+ if(isAlive())
+ {
+ if(GetMotionMaster()->GetCurrentMovementGeneratorType() == CONFUSED_MOTION_TYPE)
+ GetMotionMaster()->MovementExpired();
+ if(getVictim())
+ SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
+ }
}
if(GetTypeId() == TYPEID_PLAYER)
@@ -14568,7 +14580,7 @@ void Unit::ExitVehicle()
clearUnitState(UNIT_STAT_ONVEHICLE);
SetControlled(false, UNIT_STAT_ROOT);
- RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_FLY_UNK1);
+ RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
m_movementInfo.t_x = 0;
m_movementInfo.t_y = 0;
m_movementInfo.t_z = 0;
@@ -14638,7 +14650,7 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const
}
// 0x02200000
- if((GetUnitMovementFlags() & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2))
+ if((GetUnitMovementFlags() & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING))
|| (m_movementInfo.unk1 & 0x20))
*data << (float)m_movementInfo.s_pitch;
@@ -14669,7 +14681,7 @@ void Unit::OutMovementInfo() const
sLog.outString("MovementInfo for %u: Flag %u, Unk1 %u, Time %u, Pos %f %f %f %f, Fall %u", GetEntry(), m_movementInfo.flags, (uint32)m_movementInfo.unk1, m_movementInfo.time, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), m_movementInfo.fallTime);
if(m_movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT)
sLog.outString("Transport: GUID " UI64FMTD ", Pos %f %f %f %f, Time %u, Seat %d", m_movementInfo.t_guid, m_movementInfo.t_x, m_movementInfo.t_y, m_movementInfo.t_z, m_movementInfo.t_o, m_movementInfo.t_time, (int32)m_movementInfo.t_seat);
- if((m_movementInfo.flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2)) || (m_movementInfo.unk1 & 0x20))
+ if((m_movementInfo.flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (m_movementInfo.unk1 & 0x20))
sLog.outString("Pitch: %f", m_movementInfo.s_pitch);
if(m_movementInfo.flags & MOVEMENTFLAG_JUMPING)
sLog.outString("Jump: speedz %f, sin %f, cos %f, speedxy %f", m_movementInfo.j_zspeed, m_movementInfo.j_sinAngle, m_movementInfo.j_cosAngle, m_movementInfo.j_xyspeed);
@@ -14677,6 +14689,20 @@ void Unit::OutMovementInfo() const
sLog.outString("Spline: %f", m_movementInfo.u_unk1);
}
+void Unit::SetFlying(bool apply)
+{
+ if(apply)
+ {
+ SetByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02);
+ AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
+ }
+ else
+ {
+ RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02);
+ RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
+ }
+}
+
void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool casting /*= false*/ )
{
if(GetTypeId() == TYPEID_PLAYER)
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 9a8b7a51c1e..00478a74acd 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -642,21 +642,29 @@ enum MovementFlags
MOVEMENTFLAG_WALK_MODE = 0x00000100, // Walking
MOVEMENTFLAG_ONTRANSPORT = 0x00000200, // Used for flying on some creatures
MOVEMENTFLAG_LEVITATING = 0x00000400,
- MOVEMENTFLAG_FLY_UNK1 = 0x00000800,
+ MOVEMENTFLAG_ROOT = 0x00000800,
MOVEMENTFLAG_JUMPING = 0x00001000,
- MOVEMENTFLAG_UNK4 = 0x00002000,
+ MOVEMENTFLAG_FALL_DAMAGE = 0x00002000, // newZ < oldZ
MOVEMENTFLAG_FALLING = 0x00004000,
// 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also
- MOVEMENTFLAG_FLY_UP = 0x00400000, // press "space" when flying
+ MOVEMENTFLAG_ASCEND = 0x00400000, // press "space" when flying
MOVEMENTFLAG_CAN_FLY = 0x00800000,
- MOVEMENTFLAG_FLYING = 0x01000000, // fly land
- MOVEMENTFLAG_FLYING2 = 0x02000000, // fly hover
+ MOVEMENTFLAG_FLY_MODE = 0x01000000, // can fly
+ MOVEMENTFLAG_FLYING = 0x02000000, // hover
MOVEMENTFLAG_SPLINE = 0x04000000, // used for flight paths
MOVEMENTFLAG_SPLINE2 = 0x08000000, // used for flight paths
MOVEMENTFLAG_WATERWALKING = 0x10000000, // prevent unit from falling through water
MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive)
- MOVEMENTFLAG_UNK3 = 0x40000000
+ MOVEMENTFLAG_HOVER = 0x40000000, // hover, cannot jump
+
+ MOVEMENTFLAG_MOVING =
+ MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT|
+ MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FALL_DAMAGE|
+ MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING |MOVEMENTFLAG_ASCEND |
+ MOVEMENTFLAG_SPLINE,
+ MOVEMENTFLAG_TURNING =
+ MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT,
};
/*
@@ -1767,6 +1775,12 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void SetTransport(Transport * t) { m_transport = t; }
void BuildMovementPacket(ByteBuffer *data) const;
+
+ bool isMoving() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_MOVING); }
+ bool isTurning() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_TURNING); }
+ bool canFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLY_MODE); }
+ bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING); }
+ void SetFlying(bool apply);
protected:
explicit Unit ();
diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp
index 3fbbd9f922c..0464c52705e 100644
--- a/src/game/Vehicle.cpp
+++ b/src/game/Vehicle.cpp
@@ -284,7 +284,7 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
//SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
- unit->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_FLY_UNK1);
+ unit->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
VehicleSeatEntry const *veSeat = seat->second.seatInfo;
unit->m_movementInfo.t_x = veSeat->m_attachmentOffsetX;
unit->m_movementInfo.t_y = veSeat->m_attachmentOffsetY;
diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp
index 49d38799fe3..d256b01bd5d 100644
--- a/src/game/WaypointMovementGenerator.cpp
+++ b/src/game/WaypointMovementGenerator.cpp
@@ -86,7 +86,7 @@ void WaypointMovementGenerator<Creature>::InitTraveller(Creature &unit, const Wa
unit.SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
if(unit.canFly())
- unit.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
+ unit.AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
unit.addUnitState(UNIT_STAT_ROAMING);
}
diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp
index 6c2b9cd9932..91d1e6e018a 100644
--- a/src/game/WorldSession.cpp
+++ b/src/game/WorldSession.cpp
@@ -654,7 +654,7 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi)
data >> mi->t_seat;
}
- if((mi->flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2)) || (mi->unk1 & 0x20))
+ if((mi->flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (mi->unk1 & 0x20))
{
CHECK_PACKET_SIZE(data, data.rpos()+4);
data >> mi->s_pitch;