aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authormegamage <none@none>2009-08-28 11:26:20 -0500
committermegamage <none@none>2009-08-28 11:26:20 -0500
commitab5f515f21d1f9e735e8b2c91a64f2dd02512ed5 (patch)
treebc50ecf26bc74e872d11d21e6e17c86618462e64 /src/game
parent9d28323a55aaca70135c598baaaa340a16cf4540 (diff)
*Update flame levi script. Allow player to shoot down pyrite container and refill the demolishers.
*Other script-related fixes. --HG-- branch : trunk
Diffstat (limited to 'src/game')
-rw-r--r--src/game/Creature.cpp18
-rw-r--r--src/game/CreatureAI.cpp59
-rw-r--r--src/game/CreatureAI.h11
-rw-r--r--src/game/CreatureAIImpl.h73
-rw-r--r--src/game/ObjectMgr.cpp1
-rw-r--r--src/game/PointMovementGenerator.cpp3
-rw-r--r--src/game/Spell.cpp21
-rw-r--r--src/game/SpellEffects.cpp18
-rw-r--r--src/game/ThreatManager.cpp2
-rw-r--r--src/game/Traveller.h12
-rw-r--r--src/game/Unit.cpp17
-rw-r--r--src/game/Vehicle.cpp44
-rw-r--r--src/game/Vehicle.h7
13 files changed, 177 insertions, 109 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 6b018a6254f..e5f99c5f871 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -46,6 +46,7 @@
#include "OutdoorPvPMgr.h"
#include "GameEventMgr.h"
#include "CreatureGroups.h"
+#include "Vehicle.h"
// apply implementation of the singletons
#include "Policies/SingletonImp.h"
@@ -169,7 +170,7 @@ Creature::~Creature()
}
//if(m_uint32Values)
- // sLog.outDetail("Deconstruct Creature Entry = %u", GetEntry());
+ // sLog.outError("Deconstruct Creature Entry = %u", GetEntry());
}
void Creature::AddToWorld()
@@ -183,6 +184,8 @@ void Creature::AddToWorld()
Unit::AddToWorld();
SearchFormationAndPath();
AIM_Initialize();
+ if(IsVehicle())
+ GetVehicleKit()->Install();
}
}
@@ -201,11 +204,12 @@ void Creature::RemoveFromWorld()
void Creature::DisappearAndDie()
{
- //DestroyForNearbyPlayers();
- SetVisibility(VISIBILITY_OFF);
- ObjectAccessor::UpdateObjectVisibility(this);
+ DestroyForNearbyPlayers();
+ //SetVisibility(VISIBILITY_OFF);
+ //ObjectAccessor::UpdateObjectVisibility(this);
if(isAlive())
setDeathState(JUST_DIED);
+ RemoveCorpse();
}
void Creature::SearchFormationAndPath()
@@ -1804,6 +1808,8 @@ void Creature::setDeathState(DeathState s)
ResetPlayerDamageReq();
CreatureInfo const *cinfo = GetCreatureInfo();
AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
+ if(GetCreatureInfo()->InhabitType & INHABIT_AIR)
+ AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE + MOVEMENTFLAG_FLYING);
SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag);
clearUnitState(UNIT_STAT_ALL_STATE);
SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));
@@ -1811,6 +1817,7 @@ void Creature::setDeathState(DeathState s)
Motion_Initialize();
if(GetCreatureData() && GetPhaseMask() != GetCreatureData()->phaseMask)
SetPhaseMask(GetCreatureData()->phaseMask, false);
+ if(m_vehicleKit) m_vehicleKit->Reset();
Unit::setDeathState(ALIVE);
}
}
@@ -1827,7 +1834,10 @@ bool Creature::FallGround()
if (fabs(ground_Z - z) < 0.1f)
return false;
+ SetFlying(false);
RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
+ SendMovementFlagUpdate();
+ //AddUnitMovementFlag(MOVEMENTFLAG_FALLING);
GetMotionMaster()->MovePoint(EVENT_FALL_GROUND, x, y, ground_Z);
Unit::setDeathState(DEAD_FALLING);
return true;
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
index 20acf216c82..53d9286fba7 100644
--- a/src/game/CreatureAI.cpp
+++ b/src/game/CreatureAI.cpp
@@ -125,42 +125,6 @@ void CreatureAI::SelectNearestTarget(Unit *who)
}
}
-void CreatureAI::SetGazeOn(Unit *target)
-{
- if(me->canAttack(target))
- {
- AttackStart(target);
- me->SetReactState(REACT_PASSIVE);
- }
-}
-
-bool CreatureAI::UpdateVictimWithGaze()
-{
- if(!me->isInCombat())
- return false;
-
- if(me->HasReactState(REACT_PASSIVE))
- {
- if(me->getVictim())
- return true;
- else
- me->SetReactState(REACT_AGGRESSIVE);
- }
-
- if(Unit *victim = me->SelectVictim())
- AttackStart(victim);
- return me->getVictim();
-}
-
-bool CreatureAI::UpdateVictim()
-{
- if(!me->isInCombat())
- return false;
- if(Unit *victim = me->SelectVictim())
- AttackStart(victim);
- return me->getVictim();
-}
-
bool CreatureAI::UpdateCombatState()
{
if(!me->isInCombat())
@@ -181,26 +145,13 @@ bool CreatureAI::UpdateCombatState()
return true;
}
-bool CreatureAI::_EnterEvadeMode()
-{
- if(me->IsInEvadeMode() || !me->isAlive())
- return false;
-
- me->RemoveAllAuras();
- me->DeleteThreatList();
- me->CombatStop(true);
- me->LoadCreaturesAddon();
- me->SetLootRecipient(NULL);
- me->ResetPlayerDamageReq();
-
- return true;
-}
-
void CreatureAI::EnterEvadeMode()
{
if(!_EnterEvadeMode())
return;
+ sLog.outDebug("Creature %u enters evade mode.", me->GetEntry());
+
if(!me->GetVehicle()) // otherwise me will be in evade mode forever
{
if(Unit *owner = me->GetCharmerOrOwner())
@@ -212,10 +163,10 @@ void CreatureAI::EnterEvadeMode()
me->GetMotionMaster()->MoveTargetedHome();
}
- if(me->IsVehicle())
- me->GetVehicleKit()->InstallAllAccessories();
-
Reset();
+
+ if(me->IsVehicle()) // use the same sequence of addtoworld, aireset may remove all summons!
+ me->GetVehicleKit()->Reset();
}
/*void CreatureAI::AttackedBy( Unit* attacker )
diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h
index 5a5a7528bf0..7a3fb9137c2 100644
--- a/src/game/CreatureAI.h
+++ b/src/game/CreatureAI.h
@@ -75,6 +75,13 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
bool UpdateCombatState();
void SelectNearestTarget(Unit *who);
+
+ void SetGazeOn(Unit *target);
+
+ Creature *DoSummon(uint32 uiEntry, const Position fPos, 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);
+
public:
explicit CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c), m_creature(c) {}
@@ -151,15 +158,13 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
//virtual bool IsVisible(Unit *) const { return false; }
// Called when victim entered water and creature can not enter water
- virtual bool canReachByRangeAttack(Unit*) { return false; }
+ //virtual bool canReachByRangeAttack(Unit*) { return false; }
///== Fields =======================================
// Pointer to controlled by AI creature
//Creature* const m_creature;
- void SetGazeOn(Unit *target);
-
virtual void PassengerBoarded(Unit *who, int8 seatId, bool apply) {}
protected:
diff --git a/src/game/CreatureAIImpl.h b/src/game/CreatureAIImpl.h
index bcedd108d44..ef3ea285b1f 100644
--- a/src/game/CreatureAIImpl.h
+++ b/src/game/CreatureAIImpl.h
@@ -20,6 +20,8 @@
#include "Common.h"
#include "Platform/Define.h"
+#include "Creature.h"
+#include "CreatureAI.h"
#define HEROIC(n,h) (HeroicMode ? h : n)
@@ -257,5 +259,76 @@ struct AISpellInfoType
TRINITY_DLL_SPEC AISpellInfoType * GetAISpellInfo(uint32 i);
+
+inline void CreatureAI::SetGazeOn(Unit *target)
+{
+ if(me->canAttack(target))
+ {
+ AttackStart(target);
+ me->SetReactState(REACT_PASSIVE);
+ }
+}
+
+inline bool CreatureAI::UpdateVictimWithGaze()
+{
+ if(!me->isInCombat())
+ return false;
+
+ if(me->HasReactState(REACT_PASSIVE))
+ {
+ if(me->getVictim())
+ return true;
+ else
+ me->SetReactState(REACT_AGGRESSIVE);
+ }
+
+ if(Unit *victim = me->SelectVictim())
+ AttackStart(victim);
+ return me->getVictim();
+}
+
+inline bool CreatureAI::UpdateVictim()
+{
+ if(!me->isInCombat())
+ return false;
+ if(Unit *victim = me->SelectVictim())
+ AttackStart(victim);
+ return me->getVictim();
+}
+
+inline bool CreatureAI::_EnterEvadeMode()
+{
+ if(me->IsInEvadeMode() || !me->isAlive())
+ return false;
+
+ me->RemoveAllAuras();
+ me->DeleteThreatList();
+ me->CombatStop(true);
+ me->LoadCreaturesAddon();
+ me->SetLootRecipient(NULL);
+ me->ResetPlayerDamageReq();
+
+ return true;
+}
+
+inline Creature *CreatureAI::DoSummon(uint32 uiEntry, const Position fPos, uint32 uiDespawntime, TempSummonType uiType)
+{
+ return me->SummonCreature(uiEntry, fPos[0], fPos[1], fPos[2], fPos[3], uiType, uiDespawntime);
+}
+
+inline Creature *CreatureAI::DoSummon(uint32 uiEntry, WorldObject* pGo, float fRadius, uint32 uiDespawntime, TempSummonType uiType)
+{
+ float fX, fY, fZ;
+ pGo->GetGroundPointAroundUnit(fX, fY, fZ, fRadius * rand_norm(), rand_norm()*2*M_PI);
+ return me->SummonCreature(uiEntry, fX, fY, fZ, me->GetOrientation(), uiType, uiDespawntime);
+}
+
+inline Creature *CreatureAI::DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float _fZ, float fRadius, uint32 uiDespawntime, TempSummonType uiType)
+{
+ float fX, fY, fZ;
+ obj->GetGroundPointAroundUnit(fX, fY, fZ, fRadius * rand_norm(), rand_norm()*2*M_PI);
+ return me->SummonCreature(uiEntry, fX, fY, fZ + _fZ, me->GetOrientation(), uiType, uiDespawntime);
+}
+
#endif
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 7b97db2eac4..885a8c843f7 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -1033,6 +1033,7 @@ uint32 ObjectMgr::ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const
case 28511: // Eye of Acherus
case 33114: // Flame Leviathan Seat (model 24914 chair)
case 33167: // Salvaged Demolisher Mechanic Seat
+ case 33189: // Liquid Pryite
return cinfo->DisplayID_A[0];
case 33218: // Pyrite Safety Container
return cinfo->DisplayID_A[1];
diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp
index ac5a4568480..a24178ccb99 100644
--- a/src/game/PointMovementGenerator.cpp
+++ b/src/game/PointMovementGenerator.cpp
@@ -80,7 +80,10 @@ void PointMovementGenerator<T>::MovementInform(T &unit)
template <> void PointMovementGenerator<Creature>::MovementInform(Creature &unit)
{
if(id == EVENT_FALL_GROUND)
+ {
unit.setDeathState(JUST_DIED);
+ unit.SetFlying(true);
+ }
unit.AI()->MovementInform(POINT_MOTION_TYPE, id);
}
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index e2adba9043a..5ead8c6fe92 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -6600,7 +6600,9 @@ float tangent(float x)
if(x >= 100000.0f) return 100000.0f;
if(x <= 100000.0f) return -100000.0f;
return 0.0f;
-}
+}
+
+#define DEBUG_TRAJ(a) //a
void Spell::SelectTrajTargets()
{
@@ -6623,24 +6625,25 @@ void Spell::SelectTrajTargets()
float b = tangent(m_targets.m_elevation);
float a = (dz - dist2d * b) / (dist2d * dist2d);
if(a > -0.0001f) a = 0;
- //sLog.outError("Spell::SelectTrajTargets: a %f b %f", a, b);
+ DEBUG_TRAJ(sLog.outError("Spell::SelectTrajTargets: a %f b %f", a, b);)
float bestDist;
UnitList::const_iterator itr = unitList.begin();
for(; itr != unitList.end(); ++itr)
{
- if(m_caster == *itr || m_caster->IsOnVehicle(*itr) || (*itr)->IsOnVehicle(m_caster))
+ if(m_caster == *itr || m_caster->IsOnVehicle(*itr) || (*itr)->GetVehicle())//(*itr)->IsOnVehicle(m_caster))
continue;
const float size = std::max((*itr)->GetObjectSize() * 0.7f, 1.0f); // 1/sqrt(3)
- const float objDist2d = m_caster->GetExactDistance2d((*itr)->GetPositionX(), (*itr)->GetPositionY()) * cos(m_caster->GetRelativeAngle(*itr));
- const float dz = (*itr)->GetPositionZ() - m_caster->GetPositionZ();
+ // 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 dz = (*itr)->GetPositionZ() - m_targets.m_srcZ;
- //sLog.outError("Spell::SelectTrajTargets: check %u, dist between %f %f, height between %f %f.", (*itr)->GetEntry(), objDist2d - size, objDist2d + size, dz - size, dz + size);
+ 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);)
float dist = objDist2d - size;
float height = dist * (a * dist + b);
- //sLog.outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);
+ DEBUG_TRAJ(sLog.outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)
if(height < dz + size && height > dz - size)
{
bestDist = dist > 0 ? dist : 0;
@@ -6648,6 +6651,7 @@ void Spell::SelectTrajTargets()
}
#define CHECK_DIST {\
+ DEBUG_TRAJ(sLog.outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)\
if(dist < objDist2d + size && dist > objDist2d - size)\
{ bestDist = dist; break; }\
}
@@ -6698,9 +6702,11 @@ void Spell::SelectTrajTargets()
float x = m_targets.m_srcX + cos(m_caster->GetOrientation()) * bestDist;
float y = m_targets.m_srcY + sin(m_caster->GetOrientation()) * bestDist;
float z = m_targets.m_srcZ + bestDist * (a * bestDist + b);
+
float distSq = (*itr)->GetExactDistSq(x, y, z);
float sizeSq = (*itr)->GetObjectSize();
sizeSq *= sizeSq;
+ DEBUG_TRAJ(sLog.outError("Initial %f %f %f %f %f", x, y, z, distSq, sizeSq);)
if(distSq > sizeSq)
{
float factor = 1 - sqrt(sizeSq / distSq);
@@ -6709,6 +6715,7 @@ void Spell::SelectTrajTargets()
z += factor * ((*itr)->GetPositionZ() - z);
distSq = (*itr)->GetExactDistSq(x, y, z);
+ DEBUG_TRAJ(sLog.outError("Initial %f %f %f %f %f", x, y, z, distSq, sizeSq);)
}
m_targets.setDestination(x, y, z);
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 433a677e019..1bf992f366d 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -5295,11 +5295,23 @@ void Spell::EffectScriptEffect(uint32 effIndex)
return;
}
case 62428: // Load into Catapult
- if(Unit *demolisher = m_caster->GetVehicleBase())
- if(Vehicle *seat = m_caster->GetVehicleKit())
- if(Unit *passenger = seat->GetPassenger(0))
+ if(Vehicle *seat = m_caster->GetVehicleKit())
+ if(Unit *passenger = seat->GetPassenger(0))
+ if(Unit *demolisher = m_caster->GetVehicleBase())
passenger->CastSpell(demolisher, damage, true);
return;
+ case 62482: // Grab Crate
+ if(unitTarget)
+ {
+ if(Vehicle *seat = m_caster->GetVehicleKit())
+ {
+ if(Creature *oldContainer = dynamic_cast<Creature*>(seat->GetPassenger(1)))
+ oldContainer->DisappearAndDie();
+ unitTarget->CastSpell(seat->GetBase(), 62473, true);
+ unitTarget->EnterVehicle(seat, 1);
+ }
+ }
+ return;
case 60123: // Lightwell
{
if (m_caster->GetTypeId() != TYPEID_UNIT || !((Creature*)m_caster)->isSummon())
diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp
index 001778d7b66..11e4f2ab61e 100644
--- a/src/game/ThreatManager.cpp
+++ b/src/game/ThreatManager.cpp
@@ -136,7 +136,7 @@ void HostilReference::updateOnlineStatus()
online = getTarget()->isInAccessiblePlaceFor(creature);
if(!online)
{
- if(creature->AI()->canReachByRangeAttack(getTarget()))
+ if(creature->IsWithinCombatRange(getTarget(), creature->m_CombatDistance))
online = true; // not accessible but stays online
}
else
diff --git a/src/game/Traveller.h b/src/game/Traveller.h
index e68aa3d6a32..279af30428a 100644
--- a/src/game/Traveller.h
+++ b/src/game/Traveller.h
@@ -98,10 +98,10 @@ inline float Traveller<Creature>::GetMoveDestinationTo(float x, float y, float z
float dy = y - GetPositionY();
float dz = z - GetPositionZ();
- if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING))
+ //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));
+ //else //Walking on the ground
+ // return sqrt((dx*dx) + (dy*dy));
}
@@ -131,10 +131,10 @@ inline float Traveller<Player>::GetMoveDestinationTo(float x, float y, float z)
float dy = y - GetPositionY();
float dz = z - GetPositionZ();
- if (i_traveller.isInFlight())
+ //if (i_traveller.isInFlight())
return sqrt((dx*dx) + (dy*dy) + (dz*dz));
- else //Walking on the ground
- return sqrt((dx*dx) + (dy*dy));
+ //else //Walking on the ground
+ // return sqrt((dx*dx) + (dy*dy));
}
template<>
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 4b18db2c0a1..d6170c323d9 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -11149,7 +11149,6 @@ void Unit::setDeathState(DeathState s)
if (m_deathState != ALIVE && s == ALIVE)
{
//_ApplyAllAuraMods();
- if(m_vehicleKit) m_vehicleKit->Reset();
// Reset display id on resurection - needed by corpse explosion to cleanup after display change
SetDisplayId(GetNativeDisplayId());
}
@@ -12164,8 +12163,6 @@ void Unit::AddToWorld()
assert(m_NotifyListPos < 0); //instance : crash
//m_NotifyListPos = -1;
SetToNotify();
- if(IsVehicle())
- GetVehicleKit()->Install();
}
}
@@ -14642,7 +14639,17 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
{
- if(GetTypeId() == TYPEID_UNIT)
+ Player *player = NULL;
+ if(GetTypeId() == TYPEID_PLAYER)
+ player = (Player*)this;
+ else
+ {
+ player = dynamic_cast<Player*>(GetCharmer());
+ if(player && player->m_mover != this)
+ player = NULL;
+ }
+
+ if(!player)
{
GetMotionMaster()->MoveKnockbackFrom(x, y, speedXY, speedZ);
}
@@ -14659,7 +14666,7 @@ void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
data << float(speedXY); // Horizontal speed
data << float(-speedZ); // Z Movement speed (vertical)
- ((Player*)this)->GetSession()->SendPacket(&data);
+ player->GetSession()->SendPacket(&data);
}
}
diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp
index d666f0f76f9..a81c6bb6629 100644
--- a/src/game/Vehicle.cpp
+++ b/src/game/Vehicle.cpp
@@ -81,7 +81,7 @@ void Vehicle::InstallAllAccessories()
switch(me->GetEntry())
{
//case 27850:InstallAccessory(27905,1);break;
- case 28782:InstallAccessory(28768,0);break; // Acherus Deathcharger
+ case 28782:InstallAccessory(28768,0,false);break; // Acherus Deathcharger
case 28312:InstallAccessory(28319,7);break;
case 32627:InstallAccessory(32629,7);break;
case 32930:
@@ -101,28 +101,33 @@ void Vehicle::InstallAllAccessories()
InstallAccessory(33143,2); // Overload Control Device
InstallAccessory(33142,1); // Leviathan Defense Turret
break;
- case 33214:InstallAccessory(33218,1);break;
+ case 33214:InstallAccessory(33218,1,false);break; // Mechanolift 304-A
}
}
void Vehicle::Uninstall()
{
+ sLog.outDebug("Vehicle::Uninstall %u", me->GetEntry());
+ for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
+ if(Unit *passenger = itr->second.passenger)
+ if(passenger->HasUnitTypeMask(UNIT_MASK_ACCESSORY))
+ ((TempSummon*)passenger)->UnSummon();
RemoveAllPassengers();
}
void Vehicle::Die()
{
+ sLog.outDebug("Vehicle::Die %u", me->GetEntry());
for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
- {
if(Unit *passenger = itr->second.passenger)
if(passenger->HasUnitTypeMask(UNIT_MASK_ACCESSORY))
passenger->setDeathState(JUST_DIED);
- }
RemoveAllPassengers();
}
void Vehicle::Reset()
{
+ sLog.outDebug("Vehicle::Reset");
InstallAllAccessories();
if(m_usableSeatNum)
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
@@ -130,6 +135,7 @@ void Vehicle::Reset()
void Vehicle::RemoveAllPassengers()
{
+ sLog.outDebug("Vehicle::RemoveAllPassengers");
for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
if(Unit *passenger = itr->second.passenger)
{
@@ -185,7 +191,7 @@ int8 Vehicle::GetNextEmptySeat(int8 seatId, bool next) const
return seat->first;
}
-void Vehicle::InstallAccessory(uint32 entry, int8 seatId)
+void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion)
{
if(Unit *passenger = GetPassenger(seatId))
{
@@ -200,13 +206,15 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId)
passenger->ExitVehicle(); // this should not happen
}
- Creature *accessory = me->SummonCreature(entry, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
- if(!accessory)
- return;
- accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY);
- accessory->EnterVehicle(this, seatId);
- // This is not good, we have to send update twice
- accessory->SendMovementFlagUpdate();
+ //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(minion)
+ accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY);
+ accessory->EnterVehicle(this, seatId);
+ // This is not good, we have to send update twice
+ accessory->SendMovementFlagUpdate();
+ }
}
bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
@@ -324,16 +332,8 @@ void Vehicle::RemovePassenger(Unit *unit)
void Vehicle::Dismiss()
{
- for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
- {
- if(Unit *passenger = itr->second.passenger)
- if(passenger->GetTypeId() == TYPEID_UNIT && ((Creature*)passenger)->IsVehicle())
- {
- passenger->ExitVehicle();
- passenger->GetVehicleKit()->Dismiss();
- }
- }
- RemoveAllPassengers();
+ sLog.outDebug("Vehicle::Dismiss %u", me->GetEntry());
+ Uninstall();
me->SendObjectDeSpawnAnim(me->GetGUID());
me->CombatStop();
me->AddObjectToRemoveList();
diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h
index 3a600625c7b..3c1bd3508f5 100644
--- a/src/game/Vehicle.h
+++ b/src/game/Vehicle.h
@@ -42,10 +42,11 @@ class TRINITY_DLL_SPEC Vehicle
void Install();
void Uninstall();
-
void Reset();
void Die();
+ void InstallAllAccessories();
+ Unit *GetBase() const { return me; }
VehicleEntry const *GetVehicleInfo() { return m_vehicleInfo; }
bool HasEmptySeat(int8 seatId) const;
@@ -54,17 +55,15 @@ class TRINITY_DLL_SPEC Vehicle
bool AddPassenger(Unit *passenger, int8 seatId = -1);
void RemovePassenger(Unit *passenger);
void RemoveAllPassengers();
- void InstallAllAccessories();
void Dismiss();
SeatMap m_Seats;
- Unit *GetBase() const { return me; }
protected:
Unit *me;
VehicleEntry const *m_vehicleInfo;
uint32 m_usableSeatNum;
- void InstallAccessory(uint32 entry, int8 seatId);
+ void InstallAccessory(uint32 entry, int8 seatId, bool minion = true);
};
#endif