diff options
author | megamage <none@none> | 2009-06-17 01:01:39 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-06-17 01:01:39 -0500 |
commit | c6765f9365126fbe90d66ca36e2d766a734ce4bb (patch) | |
tree | a5864e4155f4160c3cdee55d814e2c7464a89fd4 /src | |
parent | 30195348ac7e004acf84043c5bf9f1c70f19755e (diff) |
*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
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/scripts/scripts/zone/eastern_plaguelands/the_scarlet_enclave.cpp | 16 | ||||
-rw-r--r-- | src/game/Creature.cpp | 27 | ||||
-rw-r--r-- | src/game/Creature.h | 7 | ||||
-rw-r--r-- | src/game/Player.cpp | 4 | ||||
-rw-r--r-- | src/game/Vehicle.cpp | 67 | ||||
-rw-r--r-- | src/game/Vehicle.h | 3 | ||||
-rw-r--r-- | src/game/Wintergrasp.cpp | 3 |
7 files changed, 68 insertions, 59 deletions
diff --git a/src/bindings/scripts/scripts/zone/eastern_plaguelands/the_scarlet_enclave.cpp b/src/bindings/scripts/scripts/zone/eastern_plaguelands/the_scarlet_enclave.cpp index 066c401049f..3e7137094d2 100644 --- a/src/bindings/scripts/scripts/zone/eastern_plaguelands/the_scarlet_enclave.cpp +++ b/src/bindings/scripts/scripts/zone/eastern_plaguelands/the_scarlet_enclave.cpp @@ -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(); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index eb711a77ab5..be0747f0a89 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -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) diff --git a/src/game/Creature.h b/src/game/Creature.h index b44b5b68ef5..99dd3b3417d 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -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 diff --git a/src/game/Player.cpp b/src/game/Player.cpp index cbcf52789bb..02c7fa18e9f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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 diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp index 0464c52705e..fd1fbae5926 100644 --- a/src/game/Vehicle.cpp +++ b/src/game/Vehicle.cpp @@ -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; } diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h index 309e8a5f02c..9639597bd8f 100644 --- a/src/game/Vehicle.h +++ b/src/game/Vehicle.h @@ -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 diff --git a/src/game/Wintergrasp.cpp b/src/game/Wintergrasp.cpp index d604507a799..dbe086bb761 100644 --- a/src/game/Wintergrasp.cpp +++ b/src/game/Wintergrasp.cpp @@ -300,8 +300,7 @@ bool OPvPWintergrasp::UpdateCreatureInfo(Creature *creature) if(entry != creature->GetEntry()) { creature->SetOriginalEntry(entry); - creature->setDeathState(DEAD); - creature->Respawn(); + creature->Respawn(true); } } |