From 69c487abe51ac655b1f9cd4bc7388fb01e30fb0e Mon Sep 17 00:00:00 2001 From: megamage Date: Sat, 29 Aug 2009 17:14:47 -0500 Subject: *Handle creature rotation using movement generator. Please tell me if this breaks any script. --HG-- branch : trunk --- src/game/Unit.cpp | 53 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 51 deletions(-) (limited to 'src/game/Unit.cpp') diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 29bb1c5bcad..7e4bdb6b88a 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -171,8 +171,6 @@ Unit::Unit() // remove aurastates allowing special moves for(uint8 i=0; i < MAX_REACTIVE; ++i) m_reactiveTimer[i] = 0; - - IsRotating = 0; } Unit::~Unit() @@ -256,10 +254,7 @@ void Unit::Update( uint32 p_time ) ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth()*0.35f); ModifyAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, GetHealth() > GetMaxHealth()*0.75f); - if(!IsUnitRotating()) - i_motionMaster.UpdateMotion(p_time); - else - AutoRotate(p_time); + i_motionMaster.UpdateMotion(p_time); } bool Unit::haveOffhandWeapon() const @@ -503,43 +498,6 @@ void Unit::GetRandomContactPoint( const Unit* obj, float &x, float &y, float &z, , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * (float)attacker_number / combat_reach * 0.3 : 0)); } -void Unit::StartAutoRotate(uint8 type, uint32 fulltime) -{ - if(getVictim()) - RotateAngle = GetAngle(getVictim()); - else - RotateAngle = GetOrientation(); - RotateTimer = fulltime; - RotateTimerFull = fulltime; - IsRotating = type; - LastTargetGUID = GetUInt64Value(UNIT_FIELD_TARGET); - SetUInt64Value(UNIT_FIELD_TARGET, 0); -} - -void Unit::AutoRotate(uint32 time) -{ - if(!IsRotating)return; - if(IsRotating == CREATURE_ROTATE_LEFT) - { - RotateAngle += (double)time/RotateTimerFull*(double)M_PI*2; - if (RotateAngle >= M_PI*2)RotateAngle = 0; - } - else - { - RotateAngle -= (double)time/RotateTimerFull*(double)M_PI*2; - if (RotateAngle < 0)RotateAngle = M_PI*2; - } - SetOrientation(RotateAngle); - StopMoving(); - if(RotateTimer <= time) - { - IsRotating = CREATURE_ROTATE_NONE; - RotateAngle = 0; - RotateTimer = RotateTimerFull; - SetUInt64Value(UNIT_FIELD_TARGET, LastTargetGUID); - }else RotateTimer -= time; -} - void Unit::RemoveMovementImpairingAuras() { RemoveAurasWithMechanic((1<