diff options
| author | megamage <none@none> | 2009-01-17 17:46:28 -0600 |
|---|---|---|
| committer | megamage <none@none> | 2009-01-17 17:46:28 -0600 |
| commit | 9f1409c557c4ef6edc2bb9b54c6ad0463beb20db (patch) | |
| tree | aaa732818364d49fa07769b2c22e54ff37fb6f76 /src/game | |
| parent | ff3157eeb3802e06183edb23c2842d152bf79662 (diff) | |
*Fix a crash bug caused by motionmaster.
*Fix charge movement.
--HG--
branch : trunk
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/DestinationHolderImp.h | 12 | ||||
| -rw-r--r-- | src/game/MotionMaster.cpp | 36 | ||||
| -rw-r--r-- | src/game/MotionMaster.h | 1 | ||||
| -rw-r--r-- | src/game/PointMovementGenerator.cpp | 10 | ||||
| -rw-r--r-- | src/game/PointMovementGenerator.h | 2 | ||||
| -rw-r--r-- | src/game/SpellEffects.cpp | 11 | ||||
| -rw-r--r-- | src/game/Unit.h | 3 |
7 files changed, 54 insertions, 21 deletions
diff --git a/src/game/DestinationHolderImp.h b/src/game/DestinationHolderImp.h index 437123f110d..f799c8613e7 100644 --- a/src/game/DestinationHolderImp.h +++ b/src/game/DestinationHolderImp.h @@ -95,10 +95,16 @@ DestinationHolder<TRAVELLER>::StartTravel(TRAVELLER &traveller, bool sendMove) dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)); else //Walking on the ground dist = sqrt((dx*dx) + (dy*dy)); - float speed = traveller.Speed(); - speed *= 0.001f; // speed is in seconds so convert from second to millisecond - i_totalTravelTime = static_cast<uint32>(dist/speed); + if(traveller.GetTraveller().hasUnitState(UNIT_STAT_CHARGING)) + i_totalTravelTime = 1000; + else + { + float speed = traveller.Speed(); + speed *= 0.001f; // speed is in seconds so convert from second to millisecond + i_totalTravelTime = static_cast<uint32>(dist/speed); + } + i_timeElapsed = 0; if(sendMove) traveller.MoveTo(i_destX, i_destY, i_destZ, i_totalTravelTime); diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index 5d9059b468d..afc1940f89b 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -46,8 +46,10 @@ MotionMaster::Initialize() while(!empty()) { MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); + if(!curr) + continue; + curr->Finalize(*i_owner); if( !isStatic( curr ) ) delete curr; } @@ -69,8 +71,10 @@ MotionMaster::~MotionMaster() while(!empty()) { MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); + if(!curr) + continue; + curr->Finalize(*i_owner); if( !isStatic( curr ) ) delete curr; } @@ -92,8 +96,10 @@ MotionMaster::Clear(bool reset) while( !empty() && size() > 1 ) { MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); + if(!curr) + continue; + curr->Finalize(*i_owner); if( !isStatic( curr ) ) delete curr; } @@ -269,6 +275,26 @@ MotionMaster::MovePoint(uint32 id, float x, float y, float z) } void +MotionMaster::MoveCharge(float x, float y, float z) +{ + if(Impl[MOTION_SLOT_CONTROLLED] && Impl[MOTION_SLOT_CONTROLLED]->GetMovementGeneratorType() != DISTRACT_MOTION_TYPE) + return; + + i_owner->addUnitState(UNIT_STAT_CHARGING); + if(i_owner->GetTypeId()==TYPEID_PLAYER) + { + DEBUG_LOG("Player (GUID: %u) charge point (X: %f Y: %f Z: %f)", i_owner->GetGUIDLow(), x, y, z ); + Mutate(new PointMovementGenerator<Player>(0,x,y,z), MOTION_SLOT_CONTROLLED); + } + else + { + DEBUG_LOG("Creature (Entry: %u GUID: %u) charge point (X: %f Y: %f Z: %f)", + i_owner->GetEntry(), i_owner->GetGUIDLow(), x, y, z ); + Mutate(new PointMovementGenerator<Creature>(0,x,y,z), MOTION_SLOT_CONTROLLED); + } +} + +void MotionMaster::MoveFleeing(Unit* enemy) { if(!enemy) @@ -366,14 +392,14 @@ void MotionMaster::MovePath(uint32 path_id, bool repeatable) return; //We set waypoint movement as new default movement generator // clear ALL movement generators (including default) - while(!empty()) + /*while(!empty()) { MovementGenerator *curr = top(); curr->Finalize(*i_owner); pop(); if( !isStatic( curr ) ) delete curr; - } + }*/ //i_owner->GetTypeId()==TYPEID_PLAYER ? //Mutate(new WaypointMovementGenerator<Player>(path_id, repeatable)): diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h index 4d9953c9d15..284c9631cd1 100644 --- a/src/game/MotionMaster.h +++ b/src/game/MotionMaster.h @@ -101,6 +101,7 @@ class TRINITY_DLL_SPEC MotionMaster //: private std::stack<MovementGenerator *> void MoveConfused(); void MoveFleeing(Unit* enemy); void MovePoint(uint32 id, float x,float y,float z); + void MoveCharge(float x, float y, float z); void MoveTaxiFlight(uint32 path, uint32 pathnode); void MoveDistract(uint32 time); void MovePath(uint32 path_id, bool repeatable); diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index 54fcba4898e..31b696bcd3b 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -44,7 +44,12 @@ bool PointMovementGenerator<T>::Update(T &unit, const uint32 &diff) return false; if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED)) - return true; + { + if(unit.hasUnitState(UNIT_STAT_CHARGING)) + return false; + else + return true; + } Traveller<T> traveller(unit); @@ -53,7 +58,8 @@ bool PointMovementGenerator<T>::Update(T &unit, const uint32 &diff) if(i_destinationHolder.HasArrived()) { unit.StopMoving(); - MovementInform(unit); + if(!unit.hasUnitState(UNIT_STAT_CHARGING)) + MovementInform(unit); return false; } diff --git a/src/game/PointMovementGenerator.h b/src/game/PointMovementGenerator.h index 6ef5ab019ed..8a3f0da675f 100644 --- a/src/game/PointMovementGenerator.h +++ b/src/game/PointMovementGenerator.h @@ -35,7 +35,7 @@ class TRINITY_DLL_SPEC PointMovementGenerator i_x(_x), i_y(_y), i_z(_z), i_nextMoveTime(0) {} void Initialize(T &); - void Finalize(T &){} + void Finalize(T &unit){unit.clearUnitState(UNIT_STAT_CHARGING);} void Reset(T &unit){unit.StopMoving();} bool Update(T &, const uint32 &diff); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index d1520fd97ea..ab35c5f3d76 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -5739,17 +5739,10 @@ void Spell::EffectCharge(uint32 /*i*/) float x, y, z; unitTarget->GetContactPoint(m_caster, x, y, z); - if(unitTarget->GetTypeId() != TYPEID_PLAYER) - ((Creature *)unitTarget)->StopMoving(); - - // Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags - m_caster->SendMonsterMove(x, y, z, 0, MOVEMENTFLAG_WALK_MODE, 1); - - if(m_caster->GetTypeId() != TYPEID_PLAYER) - m_caster->GetMap()->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); + m_caster->GetMotionMaster()->MoveCharge(x, y, z); // not all charge effects used in negative spells - if ( !IsPositiveSpell(m_spellInfo->Id)) + if ( !IsPositiveSpell(m_spellInfo->Id) && m_caster->GetTypeId() == TYPEID_PLAYER) m_caster->Attack(unitTarget,true); } diff --git a/src/game/Unit.h b/src/game/Unit.h index 09c7130c92a..9b39254ee1e 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -367,8 +367,9 @@ enum UnitState UNIT_STAT_ATTACK_PLAYER = 0x00004000, UNIT_STAT_CASTING = 0x00008000, UNIT_STAT_POSSESSED = 0x00010000, + UNIT_STAT_CHARGING = 0x00020000, UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FOLLOW), - UNIT_STAT_LOST_CONTROL = (UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING), + UNIT_STAT_LOST_CONTROL = (UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_CHARGING), UNIT_STAT_SIGHTLESS = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_CHASE | UNIT_STAT_SEARCHING), UNIT_STAT_CANNOT_AUTOATTACK = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_CASTING), UNIT_STAT_ALL_STATE = 0xffffffff //(UNIT_STAT_STOPPED | UNIT_STAT_MOVING | UNIT_STAT_IN_COMBAT | UNIT_STAT_IN_FLIGHT) |
