Merge branch 'azerothcore:master' into Playerbot

This commit is contained in:
ZhengPeiRu21
2022-06-27 09:06:46 -06:00
committed by GitHub
29 changed files with 459 additions and 129 deletions

View File

@@ -487,7 +487,7 @@ bool Creature::InitEntry(uint32 Entry, const CreatureData* data)
return true;
}
bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changelevel)
bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changelevel, bool updateAI)
{
if (!InitEntry(Entry, data))
return false;
@@ -596,6 +596,12 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele
SetDetectionDistance(cInfo->detection_range);
LoadSpellTemplateImmunity();
if (updateAI)
{
AIM_Initialize();
}
return true;
}

View File

@@ -169,7 +169,8 @@ public:
void UpdateMovementFlags();
uint32 GetRandomId(uint32 id1, uint32 id2, uint32 id3);
bool UpdateEntry(uint32 entry, const CreatureData* data = nullptr, bool changelevel = true );
bool UpdateEntry(uint32 entry, const CreatureData* data = nullptr, bool changelevel = true, bool updateAI = false);
bool UpdateEntry(uint32 entry, bool updateAI) { return UpdateEntry(entry, nullptr, true, updateAI); }
bool UpdateStats(Stats stat) override;
bool UpdateAllStats() override;
void UpdateResistances(uint32 school) override;

View File

@@ -553,8 +553,10 @@ void Pet::SavePetToDB(PetSaveMode mode)
// save pet
std::string actionBar = GenerateActionBarData();
ASSERT(owner->GetPetStable()->CurrentPet && owner->GetPetStable()->CurrentPet->PetNumber == m_charmInfo->GetPetNumber());
FillPetInfo(&owner->GetPetStable()->CurrentPet.value());
if (owner->GetPetStable()->CurrentPet && owner->GetPetStable()->CurrentPet->PetNumber == m_charmInfo->GetPetNumber())
{
FillPetInfo(&owner->GetPetStable()->CurrentPet.value());
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_PET);
stmt->SetData(0, m_charmInfo->GetPetNumber());

View File

@@ -8975,16 +8975,18 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
// only if current pet in slot
pet->SavePetToDB(mode);
ASSERT(m_petStable->CurrentPet && m_petStable->CurrentPet->PetNumber == pet->GetCharmInfo()->GetPetNumber());
if (mode == PET_SAVE_NOT_IN_SLOT)
if (m_petStable->CurrentPet && m_petStable->CurrentPet->PetNumber == pet->GetCharmInfo()->GetPetNumber())
{
m_petStable->UnslottedPets.push_back(std::move(*m_petStable->CurrentPet));
m_petStable->CurrentPet.reset();
if (mode == PET_SAVE_NOT_IN_SLOT)
{
m_petStable->UnslottedPets.push_back(std::move(*m_petStable->CurrentPet));
m_petStable->CurrentPet.reset();
}
else if (mode == PET_SAVE_AS_DELETED)
m_petStable->CurrentPet.reset();
// else if (stable slots) handled in opcode handlers due to required swaps
// else (current pet) doesnt need to do anything
}
else if (mode == PET_SAVE_AS_DELETED)
m_petStable->CurrentPet.reset();
// else if (stable slots) handled in opcode handlers due to required swaps
// else (current pet) doesnt need to do anything
SetMinion(pet, false);
@@ -10594,7 +10596,7 @@ void Player::AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 ite
// cooldown information stored in item prototype
// This used in same way in WorldSession::HandleItemQuerySingleOpcode data sending to client.
bool useSpellCooldown = false;
bool useSpellCooldown = spellInfo->HasAttribute(SPELL_ATTR7_CAN_BE_MULTI_CAST);
if (itemId)
{
if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId))

View File

@@ -2330,14 +2330,14 @@ void Unit::CalcHealAbsorb(HealInfo& healInfo)
healInfo.AbsorbHeal(absorbAmount);
}
void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extra)
void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType /*= BASE_ATTACK*/, bool extra /*= false*/, bool ignoreCasting /*= false*/)
{
if (HasUnitFlag(UNIT_FLAG_PACIFIED))
{
return;
}
if (HasUnitState(UNIT_STATE_CANNOT_AUTOATTACK) && !extra)
if (HasUnitState(UNIT_STATE_CANNOT_AUTOATTACK) && !extra && !ignoreCasting)
{
return;
}
@@ -7845,13 +7845,9 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, 0x10000000, 0x0, 0x0, GetGUID()))
{
Aura* flameShock = aurEff->GetBase();
int32 maxDuration = flameShock->GetMaxDuration();
int32 newDuration = flameShock->GetDuration() + 2 * aurEff->GetAmplitude();
flameShock->SetDuration(newDuration);
// is it blizzlike to change max duration for FS?
if (newDuration > maxDuration)
flameShock->SetMaxDuration(newDuration);
int32 extraTime = 2 * aurEff->GetAmplitude();
flameShock->SetMaxDuration(flameShock->GetMaxDuration() + extraTime);
flameShock->SetDuration(flameShock->GetDuration() + extraTime);
return true;
}
@@ -17994,8 +17990,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
GetMotionMaster()->MoveIdle();
StopMoving();
if (charmer->GetTypeId() == TYPEID_PLAYER &&
charmer->getClass() == CLASS_WARLOCK)
if (charmer->GetTypeId() == TYPEID_PLAYER && charmer->getClass() == CLASS_WARLOCK && ToCreature()->GetCreatureTemplate()->type == CREATURE_TYPE_DEMON)
{
// Disable CreatureAI/SmartAI and switch to CharmAI when charmed by warlock
Creature* charmed = ToCreature();
@@ -18649,23 +18644,38 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
}
}
WorldObject::SetPhaseMask(newPhaseMask, update);
WorldObject::SetPhaseMask(newPhaseMask, false);
if (!IsInWorld())
{
return;
}
for (ControlSet::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); )
{
Unit* controlled = *itr;
++itr;
if (controlled->GetTypeId() == TYPEID_UNIT)
{
controlled->SetPhaseMask(newPhaseMask, true);
}
}
for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
{
if (m_SummonSlot[i])
{
if (Creature* summon = GetMap()->GetCreature(m_SummonSlot[i]))
{
summon->SetPhaseMask(newPhaseMask, true);
}
}
}
if (update)
{
UpdateObjectVisibility();
}
}
void Unit::UpdateObjectVisibility(bool forced, bool /*fromUpdate*/)

View File

@@ -1534,7 +1534,7 @@ public:
void TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, std::list<AuraApplication*>& procAuras);
void HandleEmoteCommand(uint32 emoteId);
void AttackerStateUpdate (Unit* victim, WeaponAttackType attType = BASE_ATTACK, bool extra = false);
void AttackerStateUpdate (Unit* victim, WeaponAttackType attType = BASE_ATTACK, bool extra = false, bool ignoreCasting = false);
void CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* damageInfo, WeaponAttackType attackType = BASE_ATTACK, const bool sittingVictim = false);
void DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss);