diff --git a/src/game/Object/Creature.cpp b/src/game/Object/Creature.cpp index 1ec5bc2d..7ba5d7c6 100644 --- a/src/game/Object/Creature.cpp +++ b/src/game/Object/Creature.cpp @@ -589,7 +589,18 @@ void Creature::Update(uint32 update_diff, uint32 diff) } case ALIVE: { - if (m_aggroDelay <= update_diff) + // unsummon pet that lost owner + Unit* charmer = GetCharmer(); + if (GetCharmerGuid() && (!charmer || + (!IsWithinDistInMap(charmer, GetMap()->GetVisibilityDistance()) && + (charmer->GetCharmGuid() == GetObjectGuid())))) + { + if (charmer) + charmer->Uncharm(); + ForcedDespawn(); + return; + } + if (m_aggroDelay <= update_diff) m_aggroDelay = 0; else m_aggroDelay -= update_diff; @@ -663,9 +674,11 @@ void Creature::RegenerateAll(uint32 update_diff) if (m_regenTimer != 0) { return; } - if (!IsInCombat() || IsPolymorphed()) - { RegenerateHealth(); } - + if (!IsInCombat() || IsPolymorphed()) + { + RegenerateHealth(); + } + RegeneratePower(); m_regenTimer = REGEN_TIME_FULL; @@ -744,20 +757,20 @@ void Creature::RegenerateHealth() if (curValue >= maxValue) { return; } - uint32 addvalue; + uint32 addvalue = 0; // Not only pet, but any controlled creature if (GetCharmerOrOwnerGuid()) { float HealthIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_HEALTH); float Spirit = GetStat(STAT_SPIRIT); - if (GetPower(POWER_MANA) > 0) { addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate); } else { addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate); } } - else + + if (addvalue == 0) { addvalue = maxValue / 3; } ModifyHealth(addvalue); diff --git a/src/game/Object/Player.cpp b/src/game/Object/Player.cpp index 3ee5e91b..15fce166 100644 --- a/src/game/Object/Player.cpp +++ b/src/game/Object/Player.cpp @@ -1326,14 +1326,25 @@ void Player::Update(uint32 update_diff, uint32 p_time) UpdateEnchantTime(update_diff); UpdateHomebindTime(update_diff); - // Group update - SendUpdateToOutOfRangeGroupMembers(); + // unsummon pet/charmed that lost owner + Pet* pet = GetPet(); + if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && (GetCharmGuid() && (pet->GetObjectGuid() != GetCharmGuid()))) + { + pet->Unsummon(PET_SAVE_REAGENTS, this); + } - Pet* pet = GetPet(); - if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && (GetCharmGuid() && (pet->GetObjectGuid() != GetCharmGuid()))) - { pet->Unsummon(PET_SAVE_REAGENTS, this); } + Unit* charmed = GetCharm(); + if (charmed && (GetCharmGuid() == charmed->GetObjectGuid()) && + !IsWithinDistInMap(charmed, GetMap()->GetVisibilityDistance())) + { + Uncharm(); + if(charmed->GetTypeId()==TYPEID_UNIT) + ((Creature*)charmed)->ForcedDespawn(); + } - if (IsHasDelayedTeleport()) + // Group update + SendUpdateToOutOfRangeGroupMembers(); + if (IsHasDelayedTeleport()) { TeleportTo(m_teleport_dest, m_teleport_options); } #ifdef ENABLE_PLAYERBOTS diff --git a/src/game/WorldHandlers/Spell.cpp b/src/game/WorldHandlers/Spell.cpp index c9960a61..e0c485a4 100644 --- a/src/game/WorldHandlers/Spell.cpp +++ b/src/game/WorldHandlers/Spell.cpp @@ -2547,7 +2547,7 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura) m_caster->m_Events.AddEvent(Event, m_caster->m_Events.CalculateTime(1)); // Prevent casting at cast another spell (ServerSide check) - if (!m_IsTriggeredSpell && m_caster->IsNonMeleeSpellCasted(false, true, true)) + if (!m_IsTriggeredSpell && m_caster->IsNonMeleeSpellCasted(false,true, true)) { SendCastResult(SPELL_FAILED_SPELL_IN_PROGRESS); finish(false); diff --git a/src/game/WorldHandlers/SpellAuras.cpp b/src/game/WorldHandlers/SpellAuras.cpp index 266b15bd..4a3dc0d3 100644 --- a/src/game/WorldHandlers/SpellAuras.cpp +++ b/src/game/WorldHandlers/SpellAuras.cpp @@ -1127,6 +1127,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) Unit* target = GetTarget(); + if (!target || !target->IsAlive()) + { return; } + // AT APPLY if (apply) { @@ -1209,7 +1212,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) // AT REMOVE else { - if (IsQuestTameSpell(GetId()) && target->IsAlive()) + if (IsQuestTameSpell(GetId()) && (GetAuraDuration() == 0)) { Unit* caster = GetCaster(); if (!caster || !caster->IsAlive()) @@ -2219,6 +2222,8 @@ void Aura::HandleModCharm(bool apply, bool Real) { return; } Unit* target = GetTarget(); + if (!target || !target->IsAlive()) + { return; } // not charm yourself if (GetCasterGuid() == target->GetObjectGuid()) @@ -2277,7 +2282,7 @@ void Aura::HandleModCharm(bool apply, bool Real) else if (Player *plTarget = target->ToPlayer()) plTarget->SetClientControl(plTarget, 0); - if (caster->GetTypeId() == TYPEID_PLAYER) + if (caster->GetTypeId() == TYPEID_PLAYER) { ((Player*)caster)->CharmSpellInitialize(); } } else @@ -2330,7 +2335,7 @@ void Aura::HandleModCharm(bool apply, bool Real) if (target->GetTypeId() == TYPEID_UNIT) { ((Creature*)target)->AIM_Initialize(); - target->AttackedBy(caster); + //target->AttackedBy(caster); } } } @@ -5671,13 +5676,13 @@ void SpellAuraHolder::UpdateAuraDuration() if (GetAuraSlot() >= MAX_AURAS || m_isPassive) { return; } - if (m_target->GetTypeId() == TYPEID_PLAYER) + if (m_target->GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_UPDATE_AURA_DURATION, 5); data << uint8(GetAuraSlot()); data << uint32(GetAuraDuration()); ((Player*)m_target)->SendDirectMessage(&data); - } + } // not send in case player loading (will not work anyway until player not added to map), sent in visibility change code if (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading()) diff --git a/src/game/WorldHandlers/SpellEffects.cpp b/src/game/WorldHandlers/SpellEffects.cpp index 3367697d..b0763239 100644 --- a/src/game/WorldHandlers/SpellEffects.cpp +++ b/src/game/WorldHandlers/SpellEffects.cpp @@ -662,7 +662,8 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) return; } case 15998: // Capture Worg Pup - { + case 19614: // Despawn Caster + { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) { return; }