aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/scripts/zone/undercity/undercity.cpp4
-rw-r--r--src/game/DestinationHolderImp.h19
-rw-r--r--src/game/GridNotifiers.cpp8
-rw-r--r--src/game/Player.cpp6
-rw-r--r--src/game/Traveller.h43
-rw-r--r--src/game/Unit.cpp28
-rw-r--r--src/game/Unit.h2
-rw-r--r--src/game/World.cpp2
-rw-r--r--src/shared/revision_nr.h2
9 files changed, 71 insertions, 43 deletions
diff --git a/src/bindings/scripts/scripts/zone/undercity/undercity.cpp b/src/bindings/scripts/scripts/zone/undercity/undercity.cpp
index d000db35ed2..d1b7386ff31 100644
--- a/src/bindings/scripts/scripts/zone/undercity/undercity.cpp
+++ b/src/bindings/scripts/scripts/zone/undercity/undercity.cpp
@@ -174,8 +174,8 @@ struct TRINITY_DLL_DECL npc_highborne_lamenterAI : public ScriptedAI
{
if( EventMove_Timer < diff )
{
- m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT | MOVEMENTFLAG_LEVITATING);
- m_creature->SendMonsterMoveWithSpeed(m_creature->GetPositionX(),m_creature->GetPositionY(),HIGHBORNE_LOC_Y_NEW,MOVEMENTFLAG_ONTRANSPORT,5000);
+ m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
+ m_creature->SendMonsterMoveWithSpeed(m_creature->GetPositionX(),m_creature->GetPositionY(),HIGHBORNE_LOC_Y_NEW,5000);
m_creature->GetMap()->CreatureRelocation(m_creature,m_creature->GetPositionX(),m_creature->GetPositionY(),HIGHBORNE_LOC_Y_NEW,m_creature->GetOrientation());
EventMove = false;
}else EventMove_Timer -= diff;
diff --git a/src/game/DestinationHolderImp.h b/src/game/DestinationHolderImp.h
index 54d087d3f2f..c61dadba263 100644
--- a/src/game/DestinationHolderImp.h
+++ b/src/game/DestinationHolderImp.h
@@ -85,24 +85,7 @@ DestinationHolder<TRAVELLER>::StartTravel(TRAVELLER &traveller, bool sendMove)
i_fromY = traveller.GetPositionY();
i_fromZ = traveller.GetPositionZ();
- float dx = i_destX - i_fromX;
- float dy = i_destY - i_fromY;
- float dz = i_destZ - i_fromZ;
-
- float dist;
- //Should be for Creature Flying and Swimming.
- if(traveller.GetTraveller().hasUnitState(UNIT_STAT_IN_FLIGHT))
- dist = sqrt((dx*dx) + (dy*dy) + (dz*dz));
- else //Walking on the ground
- dist = sqrt((dx*dx) + (dy*dy));
-
- float speed;
- if(traveller.GetTraveller().hasUnitState(UNIT_STAT_CHARGING))
- speed = SPEED_CHARGE * 0.001f;
- else
- speed = traveller.Speed() * 0.001f; // speed is in seconds so convert from second to millisecond
- i_totalTravelTime = static_cast<uint32>(dist/speed);
-
+ i_totalTravelTime = traveller.GetTotalTrevelTimeTo(i_destX,i_destY,i_destZ);
i_timeElapsed = 0;
if(sendMove)
traveller.MoveTo(i_destX, i_destY, i_destZ, i_totalTravelTime);
diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp
index 638de03fe45..c6119617f33 100644
--- a/src/game/GridNotifiers.cpp
+++ b/src/game/GridNotifiers.cpp
@@ -142,11 +142,17 @@ VisibleNotifier::Notify()
// Now do operations that required done at object visibility change to visible
- // target aura duration for caster show only if target exist at caster client
// send data at target visibility change (adding to client)
for(std::set<WorldObject*>::const_iterator vItr = i_visibleNow.begin(); vItr != i_visibleNow.end(); ++vItr)
+ {
+ // target aura duration for caster show only if target exist at caster client
if((*vItr)!=&i_player && (*vItr)->isType(TYPEMASK_UNIT))
i_player.SendAurasForTarget((Unit*)(*vItr));
+
+ // non finished movements show to player
+ if((*vItr)->GetTypeId()==TYPEID_UNIT && ((Creature*)(*vItr))->isAlive())
+ ((Creature*)(*vItr))->SendMonsterMoveWithSpeedToCurrentDestination(&i_player);
+ }
}
void
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 97df3168a3d..bc0c5c59bfa 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -18495,7 +18495,7 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType&
}
}
-template<>
+/*template<>
void Player::UpdateVisibilityOf<Creature>(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow)
{
if(HaveAtClient(target))
@@ -18528,10 +18528,10 @@ void Player::UpdateVisibilityOf<Creature>(Creature* target, UpdateData& data, Up
#endif
}
}
-}
+}*/
template void Player::UpdateVisibilityOf(Player* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
-//template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
+template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
template void Player::UpdateVisibilityOf(Corpse* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
template void Player::UpdateVisibilityOf(GameObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
template void Player::UpdateVisibilityOf(DynamicObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
diff --git a/src/game/Traveller.h b/src/game/Traveller.h
index ff9c426e967..89af68154e2 100644
--- a/src/game/Traveller.h
+++ b/src/game/Traveller.h
@@ -53,11 +53,27 @@ struct TRINITY_DLL_DECL Traveller
T& GetTraveller(void) { return i_traveller; }
float Speed(void) { assert(false); return 0.0f; }
+ float GetMoveDestinationTo(float x, float y, float z);
+ uint32 GetTotalTrevelTimeTo(float x, float y, float z);
+
void Relocation(float x, float y, float z, float orientation) {}
void Relocation(float x, float y, float z) { Relocation(x, y, z, i_traveller.GetOrientation()); }
void MoveTo(float x, float y, float z, uint32 t) {}
};
+template<class T>
+inline uint32 Traveller<T>::GetTotalTrevelTimeTo(float x, float y, float z)
+{
+ float dist = GetMoveDestinationTo(x,y,z);
+ float speed = 0.001f;
+ if(GetTraveller().hasUnitState(UNIT_STAT_CHARGING))
+ speed *= SPEED_CHARGE;
+ else
+ speed *= Speed(); // speed is in seconds so convert from second to millisecond
+
+ return static_cast<uint32>(dist/speed);
+}
+
// specialization for creatures
template<>
inline float Traveller<Creature>::Speed()
@@ -77,6 +93,20 @@ inline void Traveller<Creature>::Relocation(float x, float y, float z, float ori
}
template<>
+inline float Traveller<Creature>::GetMoveDestinationTo(float x, float y, float z)
+{
+ float dx = x - GetPositionX();
+ float dy = y - GetPositionY();
+ float dz = z - GetPositionZ();
+
+ if(i_traveller.hasUnitState(UNIT_STAT_IN_FLIGHT))
+ return sqrt((dx*dx) + (dy*dy) + (dz*dz));
+ else //Walking on the ground
+ return sqrt((dx*dx) + (dy*dy));
+}
+
+
+template<>
inline void Traveller<Creature>::MoveTo(float x, float y, float z, uint32 t)
{
//Call for creature group update
@@ -98,6 +128,19 @@ inline float Traveller<Player>::Speed()
}
template<>
+inline float Traveller<Player>::GetMoveDestinationTo(float x, float y, float z)
+{
+ float dx = x - GetPositionX();
+ float dy = y - GetPositionY();
+ float dz = z - GetPositionZ();
+
+ if (i_traveller.isInFlight())
+ return sqrt((dx*dx) + (dy*dy) + (dz*dz));
+ else //Walking on the ground
+ return sqrt((dx*dx) + (dy*dy));
+}
+
+template<>
inline void Traveller<Player>::Relocation(float x, float y, float z, float orientation)
{
MapManager::Instance().GetMap(i_traveller.GetMapId(), &i_traveller)->PlayerRelocation(&i_traveller, x, y, z, orientation);
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 92bf97e9e02..b31eab7572c 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -47,6 +47,7 @@
#include "CellImpl.h"
#include "Path.h"
#include "CreatureGroups.h"
+#include "Traveller.h"
#include <math.h>
@@ -276,28 +277,23 @@ void Unit::SendMonsterMoveWithSpeedToCurrentDestination(Player* player)
{
float x, y, z;
if(GetMotionMaster()->GetDestination(x, y, z))
- SendMonsterMoveWithSpeed(x, y, z, GetUnitMovementFlags(), 0, player);
+ SendMonsterMoveWithSpeed(x, y, z, 0, player);
}
-void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 MovementFlags, uint32 transitTime, Player* player)
+void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime, Player* player)
{
if (!transitTime)
{
- float dx = x - GetPositionX();
- float dy = y - GetPositionY();
- float dz = z - GetPositionZ();
-
- float dist = ((dx*dx) + (dy*dy) + (dz*dz));
- if(dist<0)
- dist = 0;
+ if(GetTypeId()==TYPEID_PLAYER)
+ {
+ Traveller<Player> traveller(*(Player*)this);
+ transitTime = traveller.GetTotalTrevelTimeTo(x,y,z);
+ }
else
- dist = sqrt(dist);
-
- double speed = GetSpeed((MovementFlags & MOVEMENTFLAG_WALK_MODE) ? MOVE_WALK : MOVE_RUN);
- if(speed<=0)
- speed = 2.5f;
- speed *= 0.001f;
- transitTime = static_cast<uint32>(dist / speed + 0.5);
+ {
+ Traveller<Creature> traveller(*(Creature*)this);
+ transitTime = traveller.GetTotalTrevelTimeTo(x,y,z);
+ }
}
//float orientation = (float)atan2((double)dy, (double)dx);
SendMonsterMove(x, y, z, transitTime, player);
diff --git a/src/game/Unit.h b/src/game/Unit.h
index c2c8c4bf403..3b43f3ba4cb 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1143,7 +1143,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 Time, Player* player = NULL);
//void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL);
void SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end);
- void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 MovementFlags, uint32 transitTime = 0, Player* player = NULL);
+ void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
virtual void MoveOutOfRange(Player &) { };
diff --git a/src/game/World.cpp b/src/game/World.cpp
index 052a536c859..e073633fc26 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -1959,7 +1959,7 @@ void World::ScriptsProcess()
sLog.outError("SCRIPT_COMMAND_MOVE_TO call for non-creature (TypeId: %u), skipping.",source->GetTypeId());
break;
}
- ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 );
+ ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, step.script->datalong2 );
((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0);
break;
case SCRIPT_COMMAND_FLAG_SET:
diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h
index 78f402f3cca..90e21aa91e5 100644
--- a/src/shared/revision_nr.h
+++ b/src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "7332"
+ #define REVISION_NR "7334"
#endif // __REVISION_NR_H__