*Allow to force to respawn creatures.

*Save creature data for vehicles.
*Change some visibility update sequence of respawned creatures.
*Fix bugs of quest 12687: dark rider may not be on horse / horse cannot be used twice / horse does not respawn at correct phase

--HG--
branch : trunk
This commit is contained in:
megamage
2009-06-17 01:01:39 -05:00
parent 30195348ac
commit c6765f9365
7 changed files with 68 additions and 59 deletions
@@ -532,9 +532,7 @@ struct TRINITY_DLL_DECL npc_salanar_the_horsemanAI : public ScriptedAI
return;
}
CAST_PLR(charmer)->ExitVehicle();
//without this we can see npc kill the horse
who->setDeathState(DEAD);
CAST_CRE(who)->Respawn();
CAST_CRE(who)->Respawn(true);
}
}
}
@@ -554,18 +552,6 @@ struct TRINITY_DLL_DECL npc_ros_dark_riderAI : public ScriptedAI
{
npc_ros_dark_riderAI(Creature *c) : ScriptedAI(c) {}
void MoveInLineOfSight(Unit *who)
{
if(me->getVictim())
return;
// this should be before next one otherwise he may enter vehicle again
if(!me->m_Vehicle && who->GetEntry() == 28782 && CAST_CRE(who)->isVehicle() && CAST_VEH(who)->HasEmptySeat(0))
me->EnterVehicle(CAST_VEH(who));
ScriptedAI::MoveInLineOfSight(who);
}
void EnterCombat(Unit *who)
{
me->ExitVehicle();
+14 -13
View File
@@ -1780,7 +1780,7 @@ void Creature::setDeathState(DeathState s)
LoadCreaturesAddon(true);
Motion_Initialize();
if(GetCreatureData() && GetPhaseMask() != GetCreatureData()->phaseMask)
SetPhaseMask(GetCreatureData()->phaseMask, true);
SetPhaseMask(GetCreatureData()->phaseMask, false);
}
}
@@ -1802,16 +1802,19 @@ bool Creature::FallGround()
return true;
}
void Creature::Respawn()
void Creature::Respawn(bool force)
{
RemoveCorpse();
DestroyForNearbyPlayers();
// forced recreate creature object at clients
UnitVisibility currentVis = GetVisibility();
SetVisibility(VISIBILITY_RESPAWN);
ObjectAccessor::UpdateObjectVisibility(this);
SetVisibility(currentVis); // restore visibility state
ObjectAccessor::UpdateObjectVisibility(this);
if(force)
{
if(isAlive())
setDeathState(JUST_DIED);
else if(getDeathState() != CORPSE)
setDeathState(CORPSE);
}
RemoveCorpse();
if(getDeathState()==DEAD)
{
@@ -1846,11 +1849,9 @@ void Creature::Respawn()
uint16 poolid = poolhandler.IsPartOfAPool(GetGUIDLow(), GetTypeId());
if (poolid)
poolhandler.UpdatePool(poolid, GetGUIDLow(), GetTypeId());
//GetMap()->Add(this);
}
SetToNotify();
}
bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo)
+4 -3
View File
@@ -672,7 +672,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
time_t const& GetRespawnTime() const { return m_respawnTime; }
time_t GetRespawnTimeEx() const;
void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
void Respawn();
void Respawn(bool force = false);
void SaveRespawnTime();
uint32 GetRespawnDelay() const { return m_respawnDelay; }
@@ -786,6 +786,9 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool DisableReputationGain;
CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry())
CreatureData const* m_creatureData;
private:
//WaypointMovementGenerator vars
uint32 m_waypointID;
@@ -795,8 +798,6 @@ class TRINITY_DLL_SPEC Creature : public Unit
CreatureGroup *m_formation;
GridReference<Creature> m_gridRef;
CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry())
CreatureData const* m_creatureData;
};
class AssistDelayEvent : public BasicEvent
+2 -2
View File
@@ -18366,8 +18366,8 @@ bool Player::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList, bool
return false;
// forbidden to seen (at GM respawn command)
if(u->GetVisibility() == VISIBILITY_RESPAWN)
return false;
//if(u->GetVisibility() == VISIBILITY_RESPAWN)
// return false;
// Grid dead/alive checks
// non visible at grid for any stealth state
+44 -23
View File
@@ -45,26 +45,6 @@ void Vehicle::AddToWorld()
m_zoneScript->OnCreatureCreate(this, true);
ObjectAccessor::Instance().AddObject(this);
switch(GetEntry())
{
//case 27850:InstallAccessory(27905,1);break;
case 28312:InstallAccessory(28319,7);break;
case 32627:InstallAccessory(32629,7);break;
case 33109:InstallAccessory(33167,1);break;
case 33060:InstallAccessory(33067,7);break;
case 33113:
InstallAccessory(33114,0);
InstallAccessory(33114,1);
InstallAccessory(33114,2);
InstallAccessory(33114,3);
InstallAccessory(33139,7);
break;
case 33114:
InstallAccessory(33143,1);
//InstallAccessory(33142,0);
InstallAccessory(33142,2);
break;
}
for(uint32 i = 0; i < MAX_SPELL_VEHICLE; ++i)
{
if(!m_spells[i])
@@ -85,11 +65,38 @@ void Vehicle::AddToWorld()
}
}
InstallAllAccessories();
Unit::AddToWorld();
AIM_Initialize();
}
}
void Vehicle::InstallAllAccessories()
{
switch(GetEntry())
{
//case 27850:InstallAccessory(27905,1);break;
case 28782:InstallAccessory(28768,0);break; // Acherus Deathcharger
case 28312:InstallAccessory(28319,7);break;
case 32627:InstallAccessory(32629,7);break;
case 33109:InstallAccessory(33167,1);break;
case 33060:InstallAccessory(33067,7);break;
case 33113:
InstallAccessory(33114,0);
InstallAccessory(33114,1);
InstallAccessory(33114,2);
InstallAccessory(33114,3);
InstallAccessory(33139,7);
break;
case 33114:
InstallAccessory(33143,1);
//InstallAccessory(33142,0);
InstallAccessory(33142,2);
break;
}
}
void Vehicle::RemoveFromWorld()
{
if(IsInWorld())
@@ -110,7 +117,7 @@ void Vehicle::setDeathState(DeathState s) // overwrite vir
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())
if(passenger->GetOwnerGUID() == GetGUID())
{
passenger->ExitVehicle();
((Vehicle*)passenger)->setDeathState(s);
@@ -118,12 +125,15 @@ void Vehicle::setDeathState(DeathState s) // overwrite vir
}
RemoveAllPassengers();
}
else if(s == JUST_ALIVED)
Creature::setDeathState(s);
if(s == JUST_ALIVED)
{
InstallAllAccessories();
if(m_usableSeatNum)
SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
}
Creature::setDeathState(s);
}
void Vehicle::Update(uint32 diff)
@@ -226,6 +236,15 @@ int8 Vehicle::GetNextEmptySeat(int8 seatId, bool next) const
void Vehicle::InstallAccessory(uint32 entry, int8 seatId)
{
if(Unit *passenger = GetPassenger(seatId))
{
// already installed
if(passenger->GetEntry() == entry)
return;
passenger->ExitVehicle(); // this should not happen
}
const CreatureInfo *cInfo = objmgr.GetCreatureTemplate(entry);
if(!cInfo)
return;
@@ -421,5 +440,7 @@ bool Vehicle::LoadFromDB(uint32 guid, Map *map)
// checked at creature_template loading
m_defaultMovementType = MovementGeneratorType(data->movementType);
m_creatureData = data;
return true;
}
+2 -1
View File
@@ -57,7 +57,7 @@ class TRINITY_DLL_SPEC Vehicle : public Creature
int8 GetNextEmptySeat(int8 seatId, bool next) const;
bool AddPassenger(Unit *passenger, int8 seatId = -1);
void RemovePassenger(Unit *passenger);
void InstallAccessory(uint32 entry, int8 seatId);
void InstallAllAccessories();
void Dismiss();
bool LoadFromDB(uint32 guid, Map *map);
@@ -68,6 +68,7 @@ class TRINITY_DLL_SPEC Vehicle : public Creature
uint32 m_usableSeatNum;
void RemoveAllPassengers();
void InstallAccessory(uint32 entry, int8 seatId);
private:
void SaveToDB(uint32, uint8) // overwrited of Creature::SaveToDB - don't must be called
+1 -2
View File
@@ -300,8 +300,7 @@ bool OPvPWintergrasp::UpdateCreatureInfo(Creature *creature)
if(entry != creature->GetEntry())
{
creature->SetOriginalEntry(entry);
creature->setDeathState(DEAD);
creature->Respawn();
creature->Respawn(true);
}
}