*Make position as a class;
--HG-- branch : trunk
This commit is contained in:
@@ -2212,7 +2212,7 @@ bool Creature::canCreatureAttack(Unit const *pVictim, bool force) const
|
||||
if(Unit *unit = GetCharmerOrOwner())
|
||||
return pVictim->IsWithinDist(unit, dist);
|
||||
else
|
||||
return pVictim->IsWithinDist3d(mHome_X, mHome_Y, mHome_Z, dist);
|
||||
return pVictim->IsInDist(&m_homePosition, dist);
|
||||
}
|
||||
|
||||
CreatureDataAddon const* Creature::GetCreatureAddon() const
|
||||
|
||||
+4
-6
@@ -690,8 +690,9 @@ class TRINITY_DLL_SPEC Creature : public Unit
|
||||
return m_charmInfo->GetCharmSpell(pos)->GetAction();
|
||||
}
|
||||
|
||||
void SetHomePosition(float x, float y, float z, float ori) { mHome_X = x; mHome_Y = y; mHome_Z = z; mHome_O = ori;}
|
||||
void GetHomePosition(float &x, float &y, float &z, float &ori) { x = mHome_X; y = mHome_Y; z = mHome_Z; ori = mHome_O; }
|
||||
void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); }
|
||||
void SetHomePosition(const Position &pos) { m_homePosition.Relocate(pos);}
|
||||
void GetHomePosition(float &x, float &y, float &z, float &ori) { m_homePosition.GetPosition(x, y, z, ori); }
|
||||
|
||||
uint32 GetGlobalCooldown() const { return m_GlobalCooldown; }
|
||||
|
||||
@@ -766,10 +767,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
|
||||
SpellSchoolMask m_meleeDamageSchoolMask;
|
||||
uint32 m_originalEntry;
|
||||
|
||||
float mHome_X;
|
||||
float mHome_Y;
|
||||
float mHome_Z;
|
||||
float mHome_O;
|
||||
Position m_homePosition;
|
||||
|
||||
bool DisableReputationGain;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
|
||||
|
||||
void SetGazeOn(Unit *target);
|
||||
|
||||
Creature *DoSummon(uint32 uiEntry, const Position fPos, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
||||
Creature *DoSummon(uint32 uiEntry, const Position &pos, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
||||
Creature *DoSummon(uint32 uiEntry, WorldObject *obj, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
||||
Creature *DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float fZ, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
||||
|
||||
|
||||
@@ -311,9 +311,25 @@ inline bool CreatureAI::_EnterEvadeMode()
|
||||
return true;
|
||||
}
|
||||
|
||||
inline Creature *CreatureAI::DoSummon(uint32 uiEntry, const Position fPos, uint32 uiDespawntime, TempSummonType uiType)
|
||||
inline void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered)
|
||||
{
|
||||
return me->SummonCreature(uiEntry, fPos[0], fPos[1], fPos[2], fPos[3], uiType, uiDespawntime);
|
||||
if(!victim || me->hasUnitState(UNIT_STAT_CASTING) && !triggered)
|
||||
return;
|
||||
|
||||
me->CastSpell(victim, spellId, triggered);
|
||||
}
|
||||
|
||||
inline void UnitAI::DoCastAOE(uint32 spellId, bool triggered)
|
||||
{
|
||||
if(!triggered && me->hasUnitState(UNIT_STAT_CASTING))
|
||||
return;
|
||||
|
||||
me->CastSpell((Unit*)NULL, spellId, triggered);
|
||||
}
|
||||
|
||||
inline Creature *CreatureAI::DoSummon(uint32 uiEntry, const Position &pos, uint32 uiDespawntime, TempSummonType uiType)
|
||||
{
|
||||
return me->SummonCreature(uiEntry, pos, uiType, uiDespawntime);
|
||||
}
|
||||
|
||||
inline Creature *CreatureAI::DoSummon(uint32 uiEntry, WorldObject* pGo, float fRadius, uint32 uiDespawntime, TempSummonType uiType)
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "WaypointMovementGenerator.h"
|
||||
#include "CreatureAIFactory.h"
|
||||
|
||||
#include "CreatureAIImpl.h"
|
||||
//#include "CreatureAIImpl.h"
|
||||
namespace AIRegistry
|
||||
{
|
||||
void Initialize()
|
||||
|
||||
@@ -516,9 +516,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
||||
Creature* pCreature = NULL;
|
||||
|
||||
if (action.summon.duration)
|
||||
pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration);
|
||||
pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration);
|
||||
else
|
||||
pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
|
||||
pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
|
||||
|
||||
if (!pCreature)
|
||||
sLog.outErrorDb( "CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, m_creature->GetEntry());
|
||||
|
||||
@@ -774,7 +774,7 @@ bool ChatHandler::HandleDebugSpawnVehicle(const char* args)
|
||||
m_session->GetPlayer()->GetClosePoint(x, y, z, m_session->GetPlayer()->GetObjectSize());
|
||||
|
||||
if(!i)
|
||||
return m_session->GetPlayer()->SummonCreature(entry, x, y, z, o, 0);
|
||||
return m_session->GetPlayer()->SummonCreature(entry, x, y, z, o);
|
||||
|
||||
uint32 id = (uint32)atoi(i);
|
||||
|
||||
|
||||
+3
-6
@@ -4138,14 +4138,11 @@ bool ChatHandler::HandleTempAddSpwCommand(const char* args)
|
||||
|
||||
Player *chr = m_session->GetPlayer();
|
||||
|
||||
float x = chr->GetPositionX();
|
||||
float y = chr->GetPositionY();
|
||||
float z = chr->GetPositionZ();
|
||||
float ang = chr->GetOrientation();
|
||||
|
||||
uint32 id = atoi(charID);
|
||||
if(!id)
|
||||
return false;
|
||||
|
||||
chr->SummonCreature(id,x,y,z,ang,0,TEMPSUMMON_CORPSE_DESPAWN,120);
|
||||
chr->SummonCreature(id, *chr, TEMPSUMMON_CORPSE_DESPAWN, 120);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-1
@@ -50,6 +50,7 @@ class Player;
|
||||
class CreatureGroup;
|
||||
struct ScriptInfo;
|
||||
struct ScriptAction;
|
||||
struct Position;
|
||||
|
||||
|
||||
typedef ACE_RW_Thread_Mutex GridRWLock;
|
||||
@@ -441,7 +442,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
|
||||
double rand_chance() { return mtRand.randExc(100.0); }
|
||||
#endif
|
||||
|
||||
TempSummon *SummonCreature(uint32 entry, float x, float y, float z, float angle = 0, uint32 vehId = 0, SummonPropertiesEntry const *properties = NULL, uint32 duration = 0, Unit *summoner = NULL);
|
||||
TempSummon *SummonCreature(uint32 entry, const Position &pos, SummonPropertiesEntry const *properties = NULL, uint32 duration = 0, Unit *summoner = NULL, uint32 vehId = 0);
|
||||
Creature* GetCreature(uint64 guid);
|
||||
GameObject* GetGameObject(uint64 guid);
|
||||
DynamicObject* GetDynamicObject(uint64 guid);
|
||||
|
||||
@@ -104,7 +104,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
|
||||
|
||||
static bool IsValidMapCoord(WorldLocation const& loc)
|
||||
{
|
||||
return IsValidMapCoord(loc.mapid,loc.coord_x,loc.coord_y,loc.coord_z,loc.orientation);
|
||||
return IsValidMapCoord(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation());
|
||||
}
|
||||
|
||||
void DoDelayedMovesAndRemoves();
|
||||
|
||||
@@ -50,15 +50,15 @@ void WorldSession::HandleMoveWorldportAckOpcode()
|
||||
WorldLocation &loc = GetPlayer()->GetTeleportDest();
|
||||
|
||||
// possible errors in the coordinate validity check
|
||||
if(!MapManager::IsValidMapCoord(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation))
|
||||
if(!MapManager::IsValidMapCoord(loc))
|
||||
{
|
||||
LogoutPlayer(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// get the destination map entry, not the current one, this will fix homebind and reset greeting
|
||||
MapEntry const* mEntry = sMapStore.LookupEntry(loc.mapid);
|
||||
InstanceTemplate const* mInstance = objmgr.GetInstanceTemplate(loc.mapid);
|
||||
MapEntry const* mEntry = sMapStore.LookupEntry(loc.GetMapId());
|
||||
InstanceTemplate const* mInstance = objmgr.GetInstanceTemplate(loc.GetMapId());
|
||||
|
||||
// reset instance validity, except if going to an instance inside an instance
|
||||
if(GetPlayer()->m_InstanceValid == false && !mInstance)
|
||||
@@ -70,22 +70,22 @@ void WorldSession::HandleMoveWorldportAckOpcode()
|
||||
assert(oldMap);
|
||||
if(GetPlayer()->IsInWorld())
|
||||
{
|
||||
sLog.outCrash("Player is still in world when teleported out of map %u! to new map %u", oldMap->GetId(), loc.mapid);
|
||||
sLog.outCrash("Player is still in world when teleported out of map %u! to new map %u", oldMap->GetId(), loc.GetMapId());
|
||||
oldMap->Remove(GetPlayer(), false);
|
||||
}
|
||||
|
||||
// relocate the player to the teleport destination
|
||||
Map * newMap = MapManager::Instance().CreateMap(loc.mapid, GetPlayer(), 0);
|
||||
Map * newMap = MapManager::Instance().CreateMap(loc.GetMapId(), GetPlayer(), 0);
|
||||
// the CanEnter checks are done in TeleporTo but conditions may change
|
||||
// while the player is in transit, for example the map may get full
|
||||
if (!newMap || !newMap->CanEnter(GetPlayer()))
|
||||
{
|
||||
sLog.outError("Map %d could not be created for player %d, porting player to homebind", loc.mapid, GetPlayer()->GetGUIDLow());
|
||||
sLog.outError("Map %d could not be created for player %d, porting player to homebind", loc.GetMapId(), GetPlayer()->GetGUIDLow());
|
||||
GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
|
||||
return;
|
||||
}
|
||||
else
|
||||
GetPlayer()->Relocate(loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation);
|
||||
GetPlayer()->Relocate(&loc);
|
||||
|
||||
GetPlayer()->ResetMap();
|
||||
GetPlayer()->SetMap(newMap);
|
||||
@@ -93,7 +93,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
|
||||
GetPlayer()->SendInitialPacketsBeforeAddToMap();
|
||||
if(!GetPlayer()->GetMap()->Add(GetPlayer()))
|
||||
{
|
||||
sLog.outError("WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid);
|
||||
sLog.outError("WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.GetMapId());
|
||||
GetPlayer()->ResetMap();
|
||||
GetPlayer()->SetMap(oldMap);
|
||||
GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
|
||||
@@ -202,7 +202,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data)
|
||||
|
||||
WorldLocation const& dest = plMover->GetTeleportDest();
|
||||
|
||||
plMover->SetPosition(dest.coord_x, dest.coord_y, dest.coord_z, dest.orientation, true);
|
||||
plMover->SetPosition(dest, true);
|
||||
|
||||
uint32 newzone, newarea;
|
||||
plMover->GetZoneAndAreaId(newzone, newarea);
|
||||
|
||||
+28
-118
@@ -1079,9 +1079,16 @@ bool Object::PrintIndexError(uint32 index, bool set) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Position::IsInLine(const Unit * const target, float distance, float width) const
|
||||
{
|
||||
if(!HasInArc(M_PI, target) || !target->IsWithinDist3d(m_positionX, m_positionY, m_positionZ, distance)) return false;
|
||||
width += target->GetObjectSize();
|
||||
float angle = GetRelativeAngle(target);
|
||||
return abs(sin(angle)) * GetExactDist2d(target->GetPositionX(), target->GetPositionY()) < width;
|
||||
}
|
||||
|
||||
WorldObject::WorldObject()
|
||||
: m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL),
|
||||
m_positionX(0.0f), m_positionY(0.0f), m_positionZ(0.0f), m_orientation(0.0f), m_currMap(NULL)
|
||||
: WorldLocation(), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_currMap(NULL)
|
||||
, m_zoneScript(NULL)
|
||||
, m_isActive(false), m_isWorldObject(false)
|
||||
, m_name("")
|
||||
@@ -1159,74 +1166,6 @@ InstanceData* WorldObject::GetInstanceData()
|
||||
Map *map = GetMap();
|
||||
return map->IsDungeon() ? ((InstanceMap*)map)->GetInstanceData() : NULL;
|
||||
}
|
||||
//slow
|
||||
float WorldObject::GetDistance(const WorldObject* obj) const
|
||||
{
|
||||
float dx = GetPositionX() - obj->GetPositionX();
|
||||
float dy = GetPositionY() - obj->GetPositionY();
|
||||
float dz = GetPositionZ() - obj->GetPositionZ();
|
||||
float sizefactor = GetObjectSize() + obj->GetObjectSize();
|
||||
float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - sizefactor;
|
||||
return ( dist > 0 ? dist : 0);
|
||||
}
|
||||
|
||||
float WorldObject::GetDistance2d(float x, float y) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
float sizefactor = GetObjectSize();
|
||||
float dist = sqrt((dx*dx) + (dy*dy)) - sizefactor;
|
||||
return ( dist > 0 ? dist : 0);
|
||||
}
|
||||
|
||||
float WorldObject::GetExactDistance2d(const float x, const float y) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
return sqrt((dx*dx) + (dy*dy));
|
||||
}
|
||||
|
||||
float WorldObject::GetDistance(float x, float y, float z) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
float dz = GetPositionZ() - z;
|
||||
float sizefactor = GetObjectSize();
|
||||
float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - sizefactor;
|
||||
return ( dist > 0 ? dist : 0);
|
||||
}
|
||||
|
||||
float WorldObject::GetExactDistSq(float x, float y, float z) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
float dz = GetPositionZ() - z;
|
||||
return dx*dx + dy*dy + dz*dz;
|
||||
}
|
||||
|
||||
float WorldObject::GetDistance2dSq(float x, float y) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
return dx*dx + dy*dy;
|
||||
}
|
||||
|
||||
float WorldObject::GetExactDistSq(const WorldObject *obj) const
|
||||
{
|
||||
float dx = GetPositionX() - obj->GetPositionX();
|
||||
float dy = GetPositionY() - obj->GetPositionY();
|
||||
float dz = GetPositionZ() - obj->GetPositionZ();
|
||||
return dx*dx + dy*dy + dz*dz;
|
||||
}
|
||||
|
||||
float WorldObject::GetDistance2d(const WorldObject* obj) const
|
||||
{
|
||||
float dx = GetPositionX() - obj->GetPositionX();
|
||||
float dy = GetPositionY() - obj->GetPositionY();
|
||||
float sizefactor = GetObjectSize() + obj->GetObjectSize();
|
||||
float dist = sqrt((dx*dx) + (dy*dy)) - sizefactor;
|
||||
return ( dist > 0 ? dist : 0);
|
||||
}
|
||||
|
||||
float WorldObject::GetDistanceZ(const WorldObject* obj) const
|
||||
{
|
||||
@@ -1236,29 +1175,6 @@ float WorldObject::GetDistanceZ(const WorldObject* obj) const
|
||||
return ( dist > 0 ? dist : 0);
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist3d(float x, float y, float z, float dist2compare) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
float dz = GetPositionZ() - z;
|
||||
float distsq = dx*dx + dy*dy + dz*dz;
|
||||
|
||||
float maxdist = dist2compare + GetObjectSize();
|
||||
|
||||
return distsq < maxdist * maxdist;
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist2d(float x, float y, float dist2compare) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
float distsq = dx*dx + dy*dy;
|
||||
|
||||
float maxdist = dist2compare + GetObjectSize();
|
||||
|
||||
return distsq < maxdist * maxdist;
|
||||
}
|
||||
|
||||
bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const
|
||||
{
|
||||
float dx = GetPositionX() - obj->GetPositionX();
|
||||
@@ -1380,14 +1296,14 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
|
||||
return distsq < maxdist * maxdist;
|
||||
}
|
||||
|
||||
float WorldObject::GetAngle(const WorldObject* obj) const
|
||||
float Position::GetAngle(const Position *obj) const
|
||||
{
|
||||
if(!obj) return 0;
|
||||
return GetAngle( obj->GetPositionX(), obj->GetPositionY() );
|
||||
}
|
||||
|
||||
// Return angle in range 0..2*pi
|
||||
float WorldObject::GetAngle( const float x, const float y ) const
|
||||
float Position::GetAngle( const float x, const float y ) const
|
||||
{
|
||||
float dx = x - GetPositionX();
|
||||
float dy = y - GetPositionY();
|
||||
@@ -1397,7 +1313,7 @@ float WorldObject::GetAngle( const float x, const float y ) const
|
||||
return ang;
|
||||
}
|
||||
|
||||
void WorldObject::GetSinCos(const float x, const float y, float &vsin, float &vcos)
|
||||
void Position::GetSinCos(const float x, const float y, float &vsin, float &vcos) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
@@ -1416,14 +1332,12 @@ void WorldObject::GetSinCos(const float x, const float y, float &vsin, float &vc
|
||||
}
|
||||
}
|
||||
|
||||
bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const
|
||||
bool Position::HasInArc(float arc, const Position *obj) const
|
||||
{
|
||||
// always have self in arc
|
||||
if(obj == this)
|
||||
return true;
|
||||
|
||||
float arc = arcangle;
|
||||
|
||||
// move arc to range 0.. 2*pi
|
||||
while( arc >= 2.0f * M_PI )
|
||||
arc -= 2.0f * M_PI;
|
||||
@@ -1465,7 +1379,7 @@ bool WorldObject::IsInBetween(const WorldObject *obj1, const WorldObject *obj2,
|
||||
size = GetObjectSize() / 2;
|
||||
|
||||
float angle = obj1->GetAngle(this) - obj1->GetAngle(obj2);
|
||||
return abs(sin(angle)) * GetExactDistance2d(obj1->GetPositionX(), obj1->GetPositionY()) < size;
|
||||
return abs(sin(angle)) * GetExactDist2d(obj1->GetPositionX(), obj1->GetPositionY()) < size;
|
||||
}
|
||||
|
||||
void WorldObject::GetRandomPoint( float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z) const
|
||||
@@ -1498,7 +1412,7 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
|
||||
z = new_z+ 0.05f; // just to be sure that we are not a few pixel under the surface
|
||||
}
|
||||
|
||||
bool WorldObject::IsPositionValid() const
|
||||
bool Position::IsPositionValid() const
|
||||
{
|
||||
return Trinity::IsValidMapCoord(m_positionX,m_positionY,m_positionZ,m_orientation);
|
||||
}
|
||||
@@ -1754,7 +1668,7 @@ void WorldObject::AddObjectToRemoveList()
|
||||
map->AddObjectToRemoveList(this);
|
||||
}
|
||||
|
||||
TempSummon *Map::SummonCreature(uint32 entry, float x, float y, float z, float angle, uint32 vehId, SummonPropertiesEntry const *properties, uint32 duration, Unit *summoner)
|
||||
TempSummon *Map::SummonCreature(uint32 entry, const Position &pos, SummonPropertiesEntry const *properties, uint32 duration, Unit *summoner, uint32 vehId)
|
||||
{
|
||||
uint32 mask = UNIT_MASK_SUMMON;
|
||||
if(properties)
|
||||
@@ -1805,13 +1719,13 @@ TempSummon *Map::SummonCreature(uint32 entry, float x, float y, float z, float a
|
||||
default: return NULL;
|
||||
}
|
||||
|
||||
if(!summon->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, vehId, team, x, y, z, angle))
|
||||
if(!summon->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, vehId, team, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
|
||||
{
|
||||
delete summon;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
summon->SetHomePosition(x, y, z, angle);
|
||||
summon->SetHomePosition(pos);
|
||||
|
||||
summon->InitStats(duration);
|
||||
Add((Creature*)summon);
|
||||
@@ -1833,22 +1747,18 @@ void WorldObject::SetZoneScript()
|
||||
}
|
||||
}
|
||||
|
||||
TempSummon* WorldObject::SummonCreature(uint32 entry, float x, float y, float z, float ang, uint32 vehId, TempSummonType spwtype, uint32 duration)
|
||||
TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempSummonType spwtype, uint32 duration, uint32 vehId) const
|
||||
{
|
||||
Map *map = FindMap();
|
||||
if(!map)
|
||||
return NULL;
|
||||
if(Map *map = FindMap())
|
||||
{
|
||||
if(TempSummon *summon = map->SummonCreature(entry, pos, NULL, duration, isType(TYPEMASK_UNIT) ? (Unit*)this : NULL))
|
||||
{
|
||||
summon->SetTempSummonType(spwtype);
|
||||
return summon;
|
||||
}
|
||||
}
|
||||
|
||||
if (x == 0.0f && y == 0.0f && z == 0.0f)
|
||||
GetClosePoint(x, y, z, GetObjectSize());
|
||||
|
||||
TempSummon *pCreature = map->SummonCreature(entry, x, y, z, ang, vehId, NULL, duration, isType(TYPEMASK_UNIT) ? (Unit*)this : NULL);
|
||||
if(!pCreature)
|
||||
return NULL;
|
||||
|
||||
pCreature->SetTempSummonType(spwtype);
|
||||
|
||||
return pCreature;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration)
|
||||
|
||||
+111
-80
@@ -105,24 +105,10 @@ class TempSummon;
|
||||
class Vehicle;
|
||||
class CreatureAI;
|
||||
class ZoneScript;
|
||||
class Unit;
|
||||
|
||||
typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType;
|
||||
|
||||
struct WorldLocation
|
||||
{
|
||||
uint32 mapid;
|
||||
float coord_x;
|
||||
float coord_y;
|
||||
float coord_z;
|
||||
float orientation;
|
||||
explicit WorldLocation(uint32 _mapid = 0, float _x = 0, float _y = 0, float _z = 0, float _o = 0)
|
||||
: mapid(_mapid), coord_x(_x), coord_y(_y), coord_z(_z), orientation(_o) {}
|
||||
WorldLocation(WorldLocation const &loc)
|
||||
: mapid(loc.mapid), coord_x(loc.coord_x), coord_y(loc.coord_y), coord_z(loc.coord_z), orientation(loc.orientation) {}
|
||||
};
|
||||
|
||||
typedef float Position[4];
|
||||
|
||||
class TRINITY_DLL_SPEC Object
|
||||
{
|
||||
public:
|
||||
@@ -364,7 +350,93 @@ class TRINITY_DLL_SPEC Object
|
||||
Object& operator=(Object const&); // prevent generation assigment operator
|
||||
};
|
||||
|
||||
class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
struct TRINITY_DLL_SPEC Position
|
||||
{
|
||||
float m_positionX;
|
||||
float m_positionY;
|
||||
float m_positionZ;
|
||||
float m_orientation;
|
||||
|
||||
void Relocate(float x, float y)
|
||||
{ m_positionX = x; m_positionY = y;}
|
||||
void Relocate(float x, float y, float z)
|
||||
{ m_positionX = x; m_positionY = y; m_positionZ = z; }
|
||||
void Relocate(float x, float y, float z, float orientation)
|
||||
{ m_positionX = x; m_positionY = y; m_positionZ = z; m_orientation = orientation; }
|
||||
void Relocate(const Position &pos)
|
||||
{ m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; m_orientation = pos.m_orientation; }
|
||||
void Relocate(const Position *pos)
|
||||
{ m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; m_orientation = pos->m_orientation; }
|
||||
void SetOrientation(float orientation)
|
||||
{ m_orientation = orientation; }
|
||||
|
||||
float GetPositionX() const { return m_positionX; }
|
||||
float GetPositionY() const { return m_positionY; }
|
||||
float GetPositionZ() const { return m_positionZ; }
|
||||
float GetOrientation() const { return m_orientation; }
|
||||
|
||||
void GetPosition(float &x, float &y) const
|
||||
{ x = m_positionX; y = m_positionY; }
|
||||
void GetPosition(float &x, float &y, float &z) const
|
||||
{ x = m_positionX; y = m_positionY; z = m_positionZ; }
|
||||
void GetPosition(float &x, float &y, float &z, float &o) const
|
||||
{ x = m_positionX; y = m_positionY; z = m_positionZ; o = m_orientation; }
|
||||
void GetPosition(Position *pos) const
|
||||
{ pos->Relocate(m_positionX, m_positionY, m_positionZ, m_orientation); }
|
||||
|
||||
bool IsPositionValid() const;
|
||||
|
||||
float GetExactDist2dSq(float x, float y) const
|
||||
{ float dx = m_positionX - x; float dy = m_positionY - y; return dx*dx + dy*dy; }
|
||||
float GetExactDist2d(const float x, const float y) const
|
||||
{ return sqrt(GetExactDist2dSq(x, y)); }
|
||||
float GetExactDist2dSq(const Position *pos) const
|
||||
{ float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; return dx*dx + dy*dy; }
|
||||
float GetExactDist2d(const Position *pos) const
|
||||
{ return sqrt(GetExactDist2dSq(pos)); }
|
||||
float GetExactDistSq(float x, float y, float z) const
|
||||
{ float dz = m_positionZ - z; return GetExactDist2dSq(x, y) + dz*dz; }
|
||||
float GetExactDist(float x, float y, float z) const
|
||||
{ return sqrt(GetExactDistSq(x, y, z)); }
|
||||
float GetExactDistSq(const Position *pos) const
|
||||
{ float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; float dz = m_positionZ - pos->m_positionZ; return dx*dx + dy*dy + dz*dz; }
|
||||
float GetExactDist(const Position *pos) const
|
||||
{ return sqrt(GetExactDistSq(pos)); }
|
||||
|
||||
float GetAngle(const Position *pos) const;
|
||||
float GetAngle(float x, float y) const;
|
||||
float GetRelativeAngle(const Position *pos) const { return GetAngle(pos) - m_orientation; }
|
||||
void GetSinCos(float x, float y, float &vsin, float &vcos) const;
|
||||
|
||||
bool IsInDist2d(float x, float y, float dist) const
|
||||
{ return GetExactDist2dSq(x, y) < dist * dist; }
|
||||
bool IsInDist2d(const Position *pos, float dist) const
|
||||
{ return GetExactDist2dSq(pos) < dist * dist; }
|
||||
bool IsInDist(float x, float y, float z, float dist) const
|
||||
{ return GetExactDistSq(x, y, z) < dist * dist; }
|
||||
bool IsInDist(const Position *pos, float dist) const
|
||||
{ return GetExactDistSq(pos) < dist * dist; }
|
||||
bool HasInArc(float arcangle, const Position *pos) const;
|
||||
bool IsInLine(const Unit *target, float distance, float width) const;
|
||||
};
|
||||
|
||||
class WorldLocation : public Position
|
||||
{
|
||||
public:
|
||||
explicit WorldLocation(uint32 _mapid = 0, float _x = 0, float _y = 0, float _z = 0, float _o = 0)
|
||||
: m_mapId(_mapid) { Relocate(_x, _y, _z, _o); }
|
||||
WorldLocation(const WorldLocation &loc)
|
||||
: m_mapId(loc.GetMapId()) { Relocate(&loc); }
|
||||
|
||||
//void GetPosition(const WorldLocation &loc) const
|
||||
// { loc.mapid = GetMapId(); Position::GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); }
|
||||
uint32 GetMapId() const { return m_mapId; }
|
||||
|
||||
protected:
|
||||
uint32 m_mapId;
|
||||
};
|
||||
|
||||
class TRINITY_DLL_SPEC WorldObject : public Object, public WorldLocation
|
||||
{
|
||||
public:
|
||||
virtual ~WorldObject();
|
||||
@@ -373,44 +445,6 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
|
||||
void _Create( uint32 guidlow, HighGuid guidhigh, uint32 phaseMask);
|
||||
|
||||
void Relocate(WorldObject *obj)
|
||||
{
|
||||
m_positionX = obj->GetPositionX();
|
||||
m_positionY = obj->GetPositionY();
|
||||
m_positionZ = obj->GetPositionZ();
|
||||
m_orientation = obj->GetOrientation();
|
||||
}
|
||||
|
||||
void Relocate(float x, float y, float z, float orientation)
|
||||
{
|
||||
m_positionX = x;
|
||||
m_positionY = y;
|
||||
m_positionZ = z;
|
||||
m_orientation = orientation;
|
||||
}
|
||||
|
||||
void Relocate(float x, float y, float z)
|
||||
{
|
||||
m_positionX = x;
|
||||
m_positionY = y;
|
||||
m_positionZ = z;
|
||||
}
|
||||
|
||||
void Relocate(Position pos)
|
||||
{ m_positionX = pos[0]; m_positionY = pos[1]; m_positionZ = pos[2]; m_orientation = pos[3]; }
|
||||
|
||||
void SetOrientation(float orientation) { m_orientation = orientation; }
|
||||
|
||||
float GetPositionX( ) const { return m_positionX; }
|
||||
float GetPositionY( ) const { return m_positionY; }
|
||||
float GetPositionZ( ) const { return m_positionZ; }
|
||||
void GetPosition( float &x, float &y, float &z ) const
|
||||
{ x = m_positionX; y = m_positionY; z = m_positionZ; }
|
||||
void GetPosition( WorldLocation &loc ) const
|
||||
{ loc.mapid = GetMapId(); GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); }
|
||||
void GetPosition(Position pos) const
|
||||
{ pos[0] = m_positionX; pos[1] = m_positionY; pos[2] = m_positionZ; pos[3] = m_orientation; }
|
||||
float GetOrientation( ) const { return m_orientation; }
|
||||
void GetNearPoint2D( float &x, float &y, float distance, float absAngle) const;
|
||||
void GetNearPoint( WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d,float absAngle) const;
|
||||
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d = 0, float angle = 0) const
|
||||
@@ -434,12 +468,10 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
{
|
||||
return ( m_valuesCount > UNIT_FIELD_COMBATREACH ) ? m_floatValues[UNIT_FIELD_COMBATREACH] : DEFAULT_WORLD_OBJECT_SIZE;
|
||||
}
|
||||
bool IsPositionValid() const;
|
||||
void UpdateGroundPositionZ(float x, float y, float &z) const;
|
||||
|
||||
void GetRandomPoint( float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z ) const;
|
||||
|
||||
uint32 GetMapId() const { return m_mapId; }
|
||||
uint32 GetInstanceId() const { return m_InstanceId; }
|
||||
|
||||
virtual void SetPhaseMask(uint32 newPhaseMask, bool update);
|
||||
@@ -458,21 +490,24 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
|
||||
virtual const char* GetNameForLocaleIdx(int32 /*locale_idx*/) const { return GetName(); }
|
||||
|
||||
float GetDistance( const WorldObject* obj ) const;
|
||||
float GetDistance(float x, float y, float z) const;
|
||||
float GetDistance2dSq(float x, float y) const;
|
||||
float GetExactDistSq(float x, float y, float z) const;
|
||||
float GetExactDistSq(const WorldObject *obj) const;
|
||||
float GetDistance2d(const WorldObject* obj) const;
|
||||
float GetDistance2d(float x, float y) const;
|
||||
float GetExactDistance2d(const float x, const float y) const;
|
||||
float GetDistance( const WorldObject* obj ) const
|
||||
{ return GetExactDist(obj) + GetObjectSize() + obj->GetObjectSize(); }
|
||||
float GetDistance(float x, float y, float z) const
|
||||
{ return GetExactDist(x, y, z) + GetObjectSize(); }
|
||||
float GetDistance2d(const WorldObject* obj) const
|
||||
{ return GetExactDist2d(obj) + GetObjectSize() + obj->GetObjectSize(); }
|
||||
float GetDistance2d(float x, float y) const
|
||||
{ return GetExactDist2d(x, y) + GetObjectSize(); }
|
||||
float GetDistanceZ(const WorldObject* obj) const;
|
||||
|
||||
bool IsInMap(const WorldObject* obj) const
|
||||
{
|
||||
return IsInWorld() && obj->IsInWorld() && (GetMap() == obj->GetMap()) && InSamePhase(obj);
|
||||
}
|
||||
bool IsWithinDist3d(float x, float y, float z, float dist2compare) const;
|
||||
bool IsWithinDist2d(float x, float y, float dist2compare) const;
|
||||
bool IsWithinDist3d(float x, float y, float z, float dist) const
|
||||
{ return IsInDist(x, y, z, dist + GetObjectSize()); }
|
||||
bool IsWithinDist2d(float x, float y, float dist) const
|
||||
{ return IsInDist2d(x, y, dist + GetObjectSize()); }
|
||||
bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const;
|
||||
bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true) const
|
||||
// use only if you will sure about placing both object at same map
|
||||
@@ -490,11 +525,6 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
bool IsInRange2d(float x, float y, float minRange, float maxRange) const;
|
||||
bool IsInRange3d(float x, float y, float z, float minRange, float maxRange) const;
|
||||
|
||||
float GetAngle( const WorldObject* obj ) const;
|
||||
float GetAngle( const float x, const float y ) const;
|
||||
float GetRelativeAngle(const WorldObject *obj) const { return GetAngle(obj) - GetOrientation(); }
|
||||
void GetSinCos(const float x, const float y, float &vsin, float &vcos);
|
||||
bool HasInArc( const float arcangle, const WorldObject* obj ) const;
|
||||
bool IsInBetween(const WorldObject *obj1, const WorldObject *obj2, float size = 0) const;
|
||||
|
||||
virtual void CleanupsBeforeDelete(); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units
|
||||
@@ -542,10 +572,16 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
void SetZoneScript();
|
||||
ZoneScript * GetZoneScript() const { return m_zoneScript; }
|
||||
|
||||
TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0, uint32 vehId = 0, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0);
|
||||
TempSummon* SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0) const;
|
||||
TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0)
|
||||
{
|
||||
return SummonCreature(id, x, y, z, ang, 0, spwtype, despwtime);
|
||||
{
|
||||
if(!x && !y && !z)
|
||||
{
|
||||
GetClosePoint(x, y, z, GetObjectSize());
|
||||
ang = GetOrientation();
|
||||
}
|
||||
Position pos = {x, y, z, ang};
|
||||
return SummonCreature(id, pos, spwtype, despwtime, 0);
|
||||
}
|
||||
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime);
|
||||
Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL);
|
||||
@@ -589,14 +625,9 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
private:
|
||||
Map * m_currMap; //current object's Map location
|
||||
|
||||
uint32 m_mapId; // object at map with map_id
|
||||
//uint32 m_mapId; // object at map with map_id
|
||||
uint32 m_InstanceId; // in map copy with instance id
|
||||
uint32 m_phaseMask; // in area phase state
|
||||
|
||||
float m_positionX;
|
||||
float m_positionY;
|
||||
float m_positionZ;
|
||||
float m_orientation;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
+11
-11
@@ -1760,10 +1760,10 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
if(!GetSession()->PlayerLogout())
|
||||
{
|
||||
Position oldPos;
|
||||
GetPosition(oldPos);
|
||||
GetPosition(&oldPos);
|
||||
Relocate(x, y, z, orientation);
|
||||
SendTeleportAckMsg();
|
||||
Relocate(oldPos);
|
||||
Relocate(&oldPos);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -14835,8 +14835,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
{
|
||||
// Do not look for instance if bg not found
|
||||
const WorldLocation& _loc = GetBattleGroundEntryPoint();
|
||||
mapId = _loc.mapid; instanceId = 0;
|
||||
Relocate(_loc.coord_x, _loc.coord_y, _loc.coord_z, _loc.orientation);
|
||||
mapId = _loc.GetMapId(); instanceId = 0;
|
||||
Relocate(&_loc);
|
||||
|
||||
// We are not in BG anymore
|
||||
m_bgData.bgInstanceID = 0;
|
||||
@@ -16313,13 +16313,13 @@ void Player::SaveToDB()
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << GetTeleportDest().mapid << ", "
|
||||
ss << GetTeleportDest().GetMapId() << ", "
|
||||
<< (uint32)0 << ", "
|
||||
<< (uint32)GetDifficulty() << ", "
|
||||
<< finiteAlways(GetTeleportDest().coord_x) << ", "
|
||||
<< finiteAlways(GetTeleportDest().coord_y) << ", "
|
||||
<< finiteAlways(GetTeleportDest().coord_z) << ", "
|
||||
<< finiteAlways(GetTeleportDest().orientation) << ", '";
|
||||
<< finiteAlways(GetTeleportDest().GetPositionX()) << ", "
|
||||
<< finiteAlways(GetTeleportDest().GetPositionY()) << ", "
|
||||
<< finiteAlways(GetTeleportDest().GetPositionZ()) << ", "
|
||||
<< finiteAlways(GetTeleportDest().GetOrientation()) << ", '";
|
||||
}
|
||||
|
||||
uint16 i;
|
||||
@@ -21701,8 +21701,8 @@ void Player::_SaveBGData()
|
||||
{
|
||||
/* guid, bgInstanceID, bgTeam, x, y, z, o, map, taxi[0], taxi[1], mountSpell */
|
||||
CharacterDatabase.PExecute("INSERT INTO character_battleground_data VALUES ('%u', '%u', '%u', '%f', '%f', '%f', '%f', '%u', '%u', '%u', '%u')",
|
||||
GetGUIDLow(), m_bgData.bgInstanceID, m_bgData.bgTeam, m_bgData.joinPos.coord_x, m_bgData.joinPos.coord_y, m_bgData.joinPos.coord_z,
|
||||
m_bgData.joinPos.orientation, m_bgData.joinPos.mapid, m_bgData.taxiPath[0], m_bgData.taxiPath[1], m_bgData.mountSpell);
|
||||
GetGUIDLow(), m_bgData.bgInstanceID, m_bgData.bgTeam, m_bgData.joinPos.GetPositionX(), m_bgData.joinPos.GetPositionY(), m_bgData.joinPos.GetPositionZ(),
|
||||
m_bgData.joinPos.GetOrientation(), m_bgData.joinPos.GetMapId(), m_bgData.taxiPath[0], m_bgData.taxiPath[1], m_bgData.mountSpell);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -946,7 +946,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||
|
||||
bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
|
||||
{
|
||||
return TeleportTo(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation, options);
|
||||
return TeleportTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation(), options);
|
||||
}
|
||||
|
||||
bool TeleportToBGEntryPoint();
|
||||
@@ -1729,6 +1729,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||
void SendResetInstanceFailed(uint32 reason, uint32 MapId);
|
||||
void SendResetFailedNotify(uint32 mapid);
|
||||
|
||||
bool SetPosition(const Position &pos, bool teleport = false) { return SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
|
||||
bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
|
||||
void UpdateUnderwaterState( Map * m, float x, float y, float z );
|
||||
|
||||
|
||||
+1
-1
@@ -6636,7 +6636,7 @@ void Spell::SelectTrajTargets()
|
||||
|
||||
const float size = std::max((*itr)->GetObjectSize() * 0.7f, 1.0f); // 1/sqrt(3)
|
||||
// TODO: all calculation should be based on src instead of m_caster
|
||||
const float objDist2d = (*itr)->GetExactDistance2d(m_targets.m_srcX, m_targets.m_srcY) * cos(m_caster->GetRelativeAngle(*itr));
|
||||
const float objDist2d = (*itr)->GetExactDist2d(m_targets.m_srcX, m_targets.m_srcY) * cos(m_caster->GetRelativeAngle(*itr));
|
||||
const float dz = (*itr)->GetPositionZ() - m_targets.m_srcZ;
|
||||
|
||||
DEBUG_TRAJ(sLog.outError("Spell::SelectTrajTargets: check %u, dist between %f %f, height between %f %f.", (*itr)->GetEntry(), objDist2d - size, objDist2d + size, dz - size, dz + size);)
|
||||
|
||||
+4
-4
@@ -637,8 +637,8 @@ class Spell
|
||||
void SpellDamageWeaponDmg(uint32 i);
|
||||
void SpellDamageHeal(uint32 i);
|
||||
|
||||
void GetSummonPosition(uint32 i, float &x, float &y, float &z, float radius = 0.0f, uint32 count = 0);
|
||||
void SummonGuardian (uint32 entry, SummonPropertiesEntry const *properties);
|
||||
void GetSummonPosition(uint32 i, Position &pos, float radius = 0.0f, uint32 count = 0);
|
||||
void SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const *properties);
|
||||
|
||||
SpellCastResult CanOpenLock(uint32 effIndex, uint32 lockid, SkillType& skillid, int32& reqSkillValue, int32& skillValue);
|
||||
// -------------------------------------------
|
||||
@@ -756,11 +756,11 @@ namespace Trinity
|
||||
i_data->push_back(target);
|
||||
break;
|
||||
case PUSH_IN_LINE:
|
||||
if(i_source->isInLine(target, i_radius, i_source->GetObjectSize()))
|
||||
if(i_source->IsInLine(target, i_radius, i_source->GetObjectSize()))
|
||||
i_data->push_back(target);
|
||||
break;
|
||||
case PUSH_IN_THIN_LINE:
|
||||
if(i_source->isInLine(target, i_radius, 0))
|
||||
if(i_source->IsInLine(target, i_radius, 0))
|
||||
i_data->push_back(target);
|
||||
break;
|
||||
}
|
||||
|
||||
+36
-30
@@ -2325,7 +2325,7 @@ void Spell::EffectJump(uint32 i)
|
||||
speedZ = float(m_spellInfo->EffectMiscValueB[i])/10;
|
||||
else
|
||||
speedZ = 10.0f;
|
||||
float speedXY = m_caster->GetExactDistance2d(x, y) * 10.0f / speedZ;
|
||||
float speedXY = m_caster->GetExactDist2d(x, y) * 10.0f / speedZ;
|
||||
m_caster->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ);
|
||||
}
|
||||
|
||||
@@ -3390,8 +3390,8 @@ void Spell::EffectSummonType(uint32 i)
|
||||
if(Player* modOwner = m_originalCaster->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
|
||||
|
||||
float x, y, z;
|
||||
GetSummonPosition(i, x, y, z);
|
||||
Position pos;
|
||||
GetSummonPosition(i, pos);
|
||||
|
||||
/*//totem must be at same Z in case swimming caster and etc.
|
||||
if( fabs( z - m_caster->GetPositionZ() ) > 5 )
|
||||
@@ -3420,7 +3420,7 @@ void Spell::EffectSummonType(uint32 i)
|
||||
default:
|
||||
if (properties->Flags & 512)
|
||||
{
|
||||
SummonGuardian(entry, properties);
|
||||
SummonGuardian(i, entry, properties);
|
||||
break;
|
||||
}
|
||||
switch(properties->Type)
|
||||
@@ -3428,16 +3428,16 @@ void Spell::EffectSummonType(uint32 i)
|
||||
case SUMMON_TYPE_PET:
|
||||
case SUMMON_TYPE_GUARDIAN:
|
||||
case SUMMON_TYPE_MINION:
|
||||
SummonGuardian(entry, properties);
|
||||
SummonGuardian(i, entry, properties);
|
||||
break;
|
||||
case SUMMON_TYPE_VEHICLE:
|
||||
case SUMMON_TYPE_VEHICLE2:
|
||||
if(m_originalCaster)
|
||||
summon = m_caster->GetMap()->SummonCreature(entry, x, y, z, m_caster->GetOrientation(), 0, properties, duration, m_originalCaster);
|
||||
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster);
|
||||
break;
|
||||
case SUMMON_TYPE_TOTEM:
|
||||
{
|
||||
summon = m_caster->GetMap()->SummonCreature(entry, x, y, z, m_caster->GetOrientation(), 0, properties, duration, m_originalCaster);
|
||||
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster);
|
||||
if(!summon || !summon->isTotem())
|
||||
return;
|
||||
|
||||
@@ -3465,7 +3465,7 @@ void Spell::EffectSummonType(uint32 i)
|
||||
}
|
||||
case SUMMON_TYPE_MINIPET:
|
||||
{
|
||||
summon = m_caster->GetMap()->SummonCreature(entry, x, y, z, m_caster->GetOrientation(), 0, properties, duration, m_originalCaster);
|
||||
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster);
|
||||
if(!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION))
|
||||
return;
|
||||
|
||||
@@ -3492,12 +3492,11 @@ void Spell::EffectSummonType(uint32 i)
|
||||
|
||||
for(uint32 count = 0; count < amount; ++count)
|
||||
{
|
||||
float px, py, pz;
|
||||
GetSummonPosition(i, px, py, pz, radius, count);
|
||||
GetSummonPosition(i, pos, radius, count);
|
||||
|
||||
TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
|
||||
|
||||
TempSummon * summon = m_originalCaster->SummonCreature(entry,px,py,pz,m_caster->GetOrientation(),summonType,duration);
|
||||
TempSummon * summon = m_originalCaster->SummonCreature(entry, pos, summonType, duration);
|
||||
if (!summon)
|
||||
continue;
|
||||
if (properties->Category == SUMMON_CATEGORY_ALLY)
|
||||
@@ -3512,16 +3511,16 @@ void Spell::EffectSummonType(uint32 i)
|
||||
}//switch
|
||||
break;
|
||||
case SUMMON_CATEGORY_PET:
|
||||
SummonGuardian(entry, properties);
|
||||
SummonGuardian(i, entry, properties);
|
||||
break;
|
||||
case SUMMON_CATEGORY_PUPPET:
|
||||
summon = m_caster->GetMap()->SummonCreature(entry, x, y, z, m_caster->GetOrientation(), 0, properties, duration, m_originalCaster);
|
||||
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster);
|
||||
break;
|
||||
case SUMMON_CATEGORY_VEHICLE:
|
||||
{
|
||||
float x, y, z;
|
||||
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
|
||||
summon = m_caster->GetMap()->SummonCreature(entry, x, y, z, m_caster->GetOrientation(), 0, properties, duration, m_caster);
|
||||
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_caster);
|
||||
if(!summon || !summon->IsVehicle())
|
||||
return;
|
||||
|
||||
@@ -4132,7 +4131,7 @@ void Spell::EffectSummonPet(uint32 i)
|
||||
{
|
||||
SummonPropertiesEntry const *properties = sSummonPropertiesStore.LookupEntry(67);
|
||||
if(properties)
|
||||
SummonGuardian(petentry, properties);
|
||||
SummonGuardian(i, petentry, properties);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6955,14 +6954,15 @@ void Spell::EffectWMORepair(uint32 /*i*/)
|
||||
gameObjTarget->Rebuild();
|
||||
}
|
||||
|
||||
void Spell::SummonGuardian(uint32 entry, SummonPropertiesEntry const *properties)
|
||||
void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const *properties)
|
||||
{
|
||||
Unit *caster = m_originalCaster;
|
||||
if(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem())
|
||||
caster = ((Totem*)caster)->GetOwner();
|
||||
if(!caster)
|
||||
return;
|
||||
|
||||
if(caster->isTotem())
|
||||
caster = ((Totem*)caster)->GetOwner();
|
||||
|
||||
// in another case summon new
|
||||
uint32 level = caster->getLevel();
|
||||
|
||||
@@ -6995,10 +6995,10 @@ void Spell::SummonGuardian(uint32 entry, SummonPropertiesEntry const *properties
|
||||
|
||||
for(uint32 count = 0; count < amount; ++count)
|
||||
{
|
||||
float px, py, pz;
|
||||
GetSummonPosition(0, px, py, pz, radius, count);
|
||||
Position pos;
|
||||
GetSummonPosition(i, pos, radius, count);
|
||||
|
||||
TempSummon *summon = map->SummonCreature(entry, px, py, pz, m_caster->GetOrientation(), 0, properties, duration, caster);
|
||||
TempSummon *summon = map->SummonCreature(entry, pos, properties, duration, caster);
|
||||
if(!summon)
|
||||
return;
|
||||
if(summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
|
||||
@@ -7012,17 +7012,13 @@ void Spell::SummonGuardian(uint32 entry, SummonPropertiesEntry const *properties
|
||||
}
|
||||
}
|
||||
|
||||
void Spell::GetSummonPosition(uint32 i, float &x, float &y, float &z, float radius, uint32 count)
|
||||
void Spell::GetSummonPosition(uint32 i, Position &pos, float radius, uint32 count)
|
||||
{
|
||||
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
|
||||
{
|
||||
// Summon 1 unit in dest location
|
||||
if (count == 0)
|
||||
{
|
||||
x = m_targets.m_destX;
|
||||
y = m_targets.m_destY;
|
||||
z = m_targets.m_destZ;
|
||||
}
|
||||
pos.Relocate(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, m_caster->GetOrientation());
|
||||
// Summon in random point all other units if location present
|
||||
else
|
||||
{
|
||||
@@ -7031,23 +7027,33 @@ void Spell::GetSummonPosition(uint32 i, float &x, float &y, float &z, float radi
|
||||
{
|
||||
case TARGET_MINION:
|
||||
case TARGET_DEST_CASTER_RANDOM:
|
||||
{
|
||||
float x, y, z;
|
||||
m_caster->GetGroundPointAroundUnit(x, y, z, radius * rand_norm(), rand_norm()*2*M_PI);
|
||||
pos.Relocate(x, y, z, m_caster->GetOrientation());
|
||||
break;
|
||||
}
|
||||
case TARGET_DEST_DEST_RANDOM:
|
||||
case TARGET_DEST_TARGET_RANDOM:
|
||||
{
|
||||
float x, y, z;
|
||||
m_caster->GetRandomPoint(m_targets.m_destX,m_targets.m_destY,m_targets.m_destZ,radius,x,y,z);
|
||||
pos.Relocate(x, y, z, m_caster->GetOrientation());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
x = m_targets.m_destX;
|
||||
y = m_targets.m_destY;
|
||||
z = m_targets.m_destZ;
|
||||
pos.Relocate(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, m_caster->GetOrientation());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Summon if dest location not present near caster
|
||||
else
|
||||
{
|
||||
float x, y, z;
|
||||
m_caster->GetClosePoint(x,y,z,3.0f);
|
||||
pos.Relocate(x, y, z, m_caster->GetOrientation());
|
||||
}
|
||||
}
|
||||
|
||||
void Spell::EffectRenamePet(uint32 /*eff_idx*/)
|
||||
|
||||
+1
-9
@@ -3479,14 +3479,6 @@ bool Unit::isInBackInMap(Unit const* target, float distance, float arc) const
|
||||
return IsWithinDistInMap(target, distance) && !HasInArc( 2 * M_PI - arc, target );
|
||||
}
|
||||
|
||||
bool Unit::isInLine(Unit const* target, float distance, float width) const
|
||||
{
|
||||
if(!HasInArc(M_PI, target) || !IsWithinDistInMap(target, distance)) return false;
|
||||
width += target->GetObjectSize();
|
||||
float angle = GetRelativeAngle(target);
|
||||
return abs(sin(angle)) * GetExactDistance2d(target->GetPositionX(), target->GetPositionY()) < width;
|
||||
}
|
||||
|
||||
bool Unit::isInAccessiblePlaceFor(Creature const* c) const
|
||||
{
|
||||
if(IsInWater())
|
||||
@@ -14682,7 +14674,7 @@ void Unit::JumpTo(WorldObject *obj, float speedZ)
|
||||
{
|
||||
float x, y, z;
|
||||
obj->GetContactPoint(this, x, y, z);
|
||||
float speedXY = GetExactDistance2d(x, y) * 10.0f / speedZ;
|
||||
float speedXY = GetExactDist2d(x, y) * 10.0f / speedZ;
|
||||
GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ);
|
||||
}
|
||||
|
||||
|
||||
@@ -1597,7 +1597,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
bool isInFrontInMap(Unit const* target,float distance, float arc = M_PI) const;
|
||||
void SetInFront(Unit const* target);
|
||||
bool isInBackInMap(Unit const* target, float distance, float arc = M_PI) const;
|
||||
bool isInLine(Unit const* target, float distance, float width) const;
|
||||
|
||||
// Visibility system
|
||||
UnitVisibility GetVisibility() const { return m_Visibility; }
|
||||
|
||||
@@ -275,22 +275,6 @@ void UnitAI::DoCast(uint32 spellId)
|
||||
me->CastSpell(target, spellId, false);
|
||||
}
|
||||
|
||||
void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered)
|
||||
{
|
||||
if(!victim || me->hasUnitState(UNIT_STAT_CASTING) && !triggered)
|
||||
return;
|
||||
|
||||
me->CastSpell(victim, spellId, triggered);
|
||||
}
|
||||
|
||||
void UnitAI::DoCastAOE(uint32 spellId, bool triggered)
|
||||
{
|
||||
if(!triggered && me->hasUnitState(UNIT_STAT_CASTING))
|
||||
return;
|
||||
|
||||
me->CastSpell((Unit*)NULL, spellId, triggered);
|
||||
}
|
||||
|
||||
#define UPDATE_TARGET(a) {if(AIInfo->target<a) AIInfo->target=a;}
|
||||
|
||||
void UnitAI::FillAISpellInfo()
|
||||
|
||||
@@ -207,7 +207,7 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion)
|
||||
}
|
||||
|
||||
//TODO: accessory should be minion
|
||||
if(Creature *accessory = me->SummonCreature(entry, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000))
|
||||
if(Creature *accessory = me->SummonCreature(entry, *me, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000))
|
||||
{
|
||||
if(minion)
|
||||
accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY);
|
||||
|
||||
Reference in New Issue
Block a user