mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-31 09:33:47 +00:00
refactor(Core): DespawnOrUnsummon (#23141)
This commit is contained in:
@@ -251,7 +251,7 @@ CreatureBaseStats const* CreatureBaseStats::GetBaseStats(uint8 level, uint8 unit
|
||||
|
||||
bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
{
|
||||
m_owner.DespawnOrUnsummon(0s, m_respawnTimer); // since we are here, we are not TempSummon as object type cannot change during runtime
|
||||
m_owner.DespawnOrUnsummon(0ms, m_respawnTimer); // since we are here, we are not TempSummon as object type cannot change during runtime
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2174,12 +2174,12 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds forceRespawnTimer)
|
||||
// Xinef: Set new respawn time, ignore corpse decay time...
|
||||
RemoveCorpse(true);
|
||||
|
||||
if (forceRespawnTimer > Seconds::zero())
|
||||
if (forceRespawnTimer > 0s)
|
||||
if (GetMap())
|
||||
GetMap()->ScheduleCreatureRespawn(GetGUID(), forceRespawnTimer);
|
||||
}
|
||||
|
||||
void Creature::DespawnOrUnsummon(Milliseconds msTimeToDespawn /*= 0*/, Seconds forcedRespawnTimer)
|
||||
void Creature::DespawnOrUnsummon(Milliseconds msTimeToDespawn /*= 0ms*/, Seconds forcedRespawnTimer /*= 0s*/)
|
||||
{
|
||||
if (TempSummon* summon = this->ToTempSummon())
|
||||
summon->UnSummon(msTimeToDespawn.count());
|
||||
@@ -2204,7 +2204,7 @@ void Creature::DespawnOnEvade(Seconds respawnDelay)
|
||||
return;
|
||||
}
|
||||
|
||||
DespawnOrUnsummon(Milliseconds(0), respawnDelay);
|
||||
DespawnOrUnsummon(0ms, respawnDelay);
|
||||
}
|
||||
|
||||
void Creature::InitializeReactState()
|
||||
|
||||
@@ -283,8 +283,7 @@ public:
|
||||
|
||||
void RemoveCorpse(bool setSpawnTime = true, bool skipVisibility = false);
|
||||
|
||||
void DespawnOrUnsummon(Milliseconds msTimeToDespawn, Seconds forcedRespawnTimer);
|
||||
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0) { DespawnOrUnsummon(Milliseconds(msTimeToDespawn), 0s); };
|
||||
void DespawnOrUnsummon(Milliseconds msTimeToDespawn = 0ms, Seconds forcedRespawnTimer = 0s);
|
||||
void DespawnOnEvade(Seconds respawnDelay = 20s);
|
||||
|
||||
[[nodiscard]] time_t const& GetRespawnTime() const { return m_respawnTime; }
|
||||
|
||||
@@ -929,7 +929,7 @@ void GameObject::AddUniqueUse(Player* player)
|
||||
m_unique_users.insert(player->GetGUID());
|
||||
}
|
||||
|
||||
void GameObject::DespawnOrUnsummon(Milliseconds delay, Seconds forceRespawnTime)
|
||||
void GameObject::DespawnOrUnsummon(Milliseconds delay /*= 0ms*/, Seconds forceRespawnTime /*= 0s*/)
|
||||
{
|
||||
if (delay > 0ms)
|
||||
{
|
||||
|
||||
@@ -692,7 +692,7 @@ void Pet::Update(uint32 diff)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_duration > 0s)
|
||||
if (m_duration > 0ms)
|
||||
{
|
||||
if (m_duration > _diff)
|
||||
m_duration -= _diff;
|
||||
@@ -708,7 +708,7 @@ void Pet::Update(uint32 diff)
|
||||
if (getPowerType() == POWER_FOCUS)
|
||||
{
|
||||
m_petRegenTimer -= _diff;
|
||||
if (m_petRegenTimer <= 0s)
|
||||
if (m_petRegenTimer <= 0ms)
|
||||
{
|
||||
m_petRegenTimer += PET_FOCUS_REGEN_INTERVAL;
|
||||
Regenerate(POWER_FOCUS);
|
||||
@@ -1026,7 +1026,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
|
||||
Unit* owner = GetOwner();
|
||||
if (!owner) // just to be sure, asynchronous now
|
||||
{
|
||||
DespawnOrUnsummon(1000);
|
||||
DespawnOrUnsummon(1s);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
PetType getPetType() const { return m_petType; }
|
||||
void setPetType(PetType type) { m_petType = type; }
|
||||
bool isControlled() const { return getPetType() == SUMMON_PET || getPetType() == HUNTER_PET; }
|
||||
bool isTemporarySummoned() const { return m_duration > 0s; }
|
||||
bool isTemporarySummoned() const { return m_duration > 0ms; }
|
||||
|
||||
bool IsPermanentPetFor(Player* owner) const; // pet have tab in character windows and set UNIT_FIELD_PETNUMBER
|
||||
|
||||
|
||||
@@ -9014,7 +9014,7 @@ Pet* Player::GetPet() const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, Milliseconds duration /*= 0s*/, uint32 healthPct /*= 0*/)
|
||||
Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, Milliseconds duration /*= 0ms*/, uint32 healthPct /*= 0*/)
|
||||
{
|
||||
PetStable& petStable = GetOrInitPetStable();
|
||||
|
||||
@@ -9035,7 +9035,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
|
||||
++itr;
|
||||
}
|
||||
|
||||
if (duration > 0s)
|
||||
if (duration > 0ms)
|
||||
pet->SetDuration(duration);
|
||||
|
||||
// Generate a new name for the newly summoned ghoul
|
||||
@@ -9129,7 +9129,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
|
||||
}
|
||||
}
|
||||
|
||||
if (duration > 0s)
|
||||
if (duration > 0ms)
|
||||
pet->SetDuration(duration);
|
||||
|
||||
if (NeedSendSpectatorData() && pet->GetCreatureTemplate()->family)
|
||||
|
||||
@@ -1210,7 +1210,7 @@ public:
|
||||
[[nodiscard]] PetStable const* GetPetStable() const { return m_petStable.get(); }
|
||||
|
||||
[[nodiscard]] Pet* GetPet() const;
|
||||
Pet* SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, Milliseconds duration = 0s, uint32 healthPct = 0);
|
||||
Pet* SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, Milliseconds duration = 0ms, uint32 healthPct = 0);
|
||||
void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
|
||||
bool CanPetResurrect();
|
||||
bool IsExistPet();
|
||||
|
||||
@@ -19681,7 +19681,7 @@ void Unit::_ExitVehicle(Position const* exitPosition)
|
||||
else if (vehicleBase->IsCreature())
|
||||
{
|
||||
vehicle->Uninstall();
|
||||
vehicleBase->m_Events.AddEvent(new VehicleDespawnEvent(*vehicleBase, 2000), vehicleBase->m_Events.CalculateTime(2000));
|
||||
vehicleBase->m_Events.AddEventAtOffset(new VehicleDespawnEvent(*vehicleBase, 2s), 2s);
|
||||
}
|
||||
|
||||
// xinef: ugly hack, no appripriate hook later to cast spell
|
||||
|
||||
@@ -100,12 +100,12 @@ private:
|
||||
class VehicleDespawnEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
VehicleDespawnEvent(Unit& self, uint32 duration) : _self(self), _duration(duration) { }
|
||||
VehicleDespawnEvent(Unit& self, Milliseconds duration) : _self(self), _duration(duration) { }
|
||||
bool Execute(uint64 e_time, uint32 p_time) override;
|
||||
|
||||
protected:
|
||||
Unit& _self;
|
||||
uint32 _duration;
|
||||
Milliseconds _duration;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user