mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-03 02:53:48 +00:00
feat(Core/Hook): New PlayerScript hooks (#2639)
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "TemporarySummon.h"
|
||||
#include "Pet.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
TempSummon::TempSummon(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject) :
|
||||
Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN),
|
||||
@@ -147,13 +148,16 @@ void TempSummon::InitStats(uint32 duration)
|
||||
{
|
||||
ASSERT(!IsPet());
|
||||
|
||||
Unit* owner = GetSummoner();
|
||||
if (Player* player = owner->ToPlayer())
|
||||
sScriptMgr->OnBeforeTempSummonInitStats(player, this, duration);
|
||||
|
||||
m_timer = duration;
|
||||
m_lifetime = duration;
|
||||
|
||||
if (m_type == TEMPSUMMON_MANUAL_DESPAWN)
|
||||
m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
|
||||
|
||||
Unit* owner = GetSummoner();
|
||||
if (owner)
|
||||
{
|
||||
if (IsTrigger() && m_spells[0])
|
||||
|
||||
@@ -152,9 +152,12 @@ bool Pet::LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry, ui
|
||||
if (owner->IsSpectator() || owner->GetPet() || !owner->IsInWorld() || !owner->FindMap())
|
||||
return false;
|
||||
|
||||
// DK Pet exception
|
||||
if (owner->getClass() == CLASS_DEATH_KNIGHT && !owner->CanSeeDKPet())
|
||||
return false;
|
||||
bool forceLoadFromDB = false;
|
||||
sScriptMgr->OnBeforeLoadPetFromDB(owner, petentry, petnumber, current, forceLoadFromDB);
|
||||
|
||||
if (!forceLoadFromDB)
|
||||
if (owner->getClass() == CLASS_DEATH_KNIGHT && !owner->CanSeeDKPet()) // DK Pet exception
|
||||
return false;
|
||||
|
||||
uint32 ownerid = owner->GetGUIDLow();
|
||||
PreparedStatement* stmt;
|
||||
@@ -720,20 +723,31 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
|
||||
|
||||
//Determine pet type
|
||||
PetType petType = MAX_PET_TYPE;
|
||||
if (IsPet() && owner->GetTypeId() == TYPEID_PLAYER)
|
||||
if (owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if (owner->getClass() == CLASS_WARLOCK ||
|
||||
owner->getClass() == CLASS_SHAMAN || // Fire Elemental
|
||||
owner->getClass() == CLASS_DEATH_KNIGHT || // Risen Ghoul
|
||||
owner->getClass() == CLASS_MAGE) // Water Elemental with glyph
|
||||
petType = SUMMON_PET;
|
||||
else if (owner->getClass() == CLASS_HUNTER)
|
||||
sScriptMgr->OnBeforeGuardianInitStatsForLevel(owner->ToPlayer(), this, cinfo, petType);
|
||||
|
||||
if (IsPet())
|
||||
{
|
||||
petType = HUNTER_PET;
|
||||
m_unitTypeMask |= UNIT_MASK_HUNTER_PET;
|
||||
if (petType == MAX_PET_TYPE)
|
||||
{
|
||||
// The petType was not overwritten by the hook, continue with default initialization
|
||||
if (owner->getClass() == CLASS_WARLOCK ||
|
||||
owner->getClass() == CLASS_SHAMAN || // Fire Elemental
|
||||
owner->getClass() == CLASS_DEATH_KNIGHT || // Risen Ghoul
|
||||
owner->getClass() == CLASS_MAGE) // Water Elemental with glyph
|
||||
petType = SUMMON_PET;
|
||||
else if (owner->getClass() == CLASS_HUNTER)
|
||||
{
|
||||
petType = HUNTER_PET;
|
||||
}
|
||||
}
|
||||
|
||||
if (petType == HUNTER_PET)
|
||||
m_unitTypeMask |= UNIT_MASK_HUNTER_PET;
|
||||
else if (petType != SUMMON_PET)
|
||||
sLog->outError("Unknown type pet %u is summoned by player class %u", GetEntry(), owner->getClass());
|
||||
}
|
||||
else
|
||||
sLog->outError("Unknown type pet %u is summoned by player class %u", GetEntry(), owner->getClass());
|
||||
}
|
||||
|
||||
uint32 creature_ID = (petType == HUNTER_PET) ? 1 : cinfo->Entry;
|
||||
@@ -1066,8 +1080,8 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
|
||||
SetFullHealth();
|
||||
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
|
||||
|
||||
if (Pet* pet = ToPet())
|
||||
sScriptMgr->OnPetInitStatsForLevel(pet);
|
||||
if (owner->GetTypeId() == TYPEID_PLAYER)
|
||||
sScriptMgr->OnAfterGuardianInitStatsForLevel(owner->ToPlayer(), this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user