mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[10757] Implement zone limited pets unsummon at leave allowed zones.
* Also remove redundant zone/area args for zone/area update function like UpdateZoneDependentAuras. * Merge Player::*AllControlledUnits functions to Unit version with replace option args by mask arg. * Unit::*AllControlledUnits guardian iteration make working with internal unsummon call suport for guardians case.
This commit is contained in:
parent
1ef8ea1161
commit
b20b3e5ade
7 changed files with 88 additions and 72 deletions
|
|
@ -2359,7 +2359,7 @@ void Player::SetGameMaster(bool on)
|
|||
setFaction(35);
|
||||
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
|
||||
|
||||
CallForAllControlledUnits(SetGameMasterOnHelper(),true,true,true,false);
|
||||
CallForAllControlledUnits(SetGameMasterOnHelper(), CONTROLED_PET|CONTROLED_TOTEMS|CONTROLED_GUARDIANS|CONTROLED_CHARM);
|
||||
|
||||
SetFFAPvP(false);
|
||||
ResetContestedPvP();
|
||||
|
|
@ -2379,7 +2379,7 @@ void Player::SetGameMaster(bool on)
|
|||
setFactionForRace(getRace());
|
||||
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
|
||||
|
||||
CallForAllControlledUnits(SetGameMasterOffHelper(getFaction()),true,true,true,false);
|
||||
CallForAllControlledUnits(SetGameMasterOffHelper(getFaction()), CONTROLED_PET|CONTROLED_TOTEMS|CONTROLED_GUARDIANS|CONTROLED_CHARM);
|
||||
|
||||
// restore FFA PvP Server state
|
||||
if(sWorld.IsFFAPvPRealm())
|
||||
|
|
@ -6708,7 +6708,7 @@ void Player::UpdateArea(uint32 newArea)
|
|||
CastSpell(this, 58730, true); */
|
||||
}
|
||||
|
||||
UpdateAreaDependentAuras(newArea);
|
||||
UpdateAreaDependentAuras();
|
||||
}
|
||||
|
||||
void Player::UpdateZone(uint32 newZone, uint32 newArea)
|
||||
|
|
@ -6801,7 +6801,8 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
|
|||
if(GetGroup())
|
||||
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_ZONE);
|
||||
|
||||
UpdateZoneDependentAuras(newZone);
|
||||
UpdateZoneDependentAuras();
|
||||
UpdateZoneDependentPets();
|
||||
}
|
||||
|
||||
//If players are too far way of duel flag... then player loose the duel
|
||||
|
|
@ -20575,23 +20576,23 @@ void Player::SetClientControl(Unit* target, uint8 allowMove)
|
|||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
void Player::UpdateZoneDependentAuras( uint32 newZone )
|
||||
void Player::UpdateZoneDependentAuras()
|
||||
{
|
||||
// Some spells applied at enter into zone (with subzones), aura removed in UpdateAreaDependentAuras that called always at zone->area update
|
||||
SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAreaMapBounds(newZone);
|
||||
SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAreaMapBounds(m_zoneUpdateId);
|
||||
for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
|
||||
if(itr->second->autocast && itr->second->IsFitToRequirements(this,newZone,0))
|
||||
if(itr->second->autocast && itr->second->IsFitToRequirements(this, m_zoneUpdateId, 0))
|
||||
if (!HasAura(itr->second->spellId, EFFECT_INDEX_0))
|
||||
CastSpell(this,itr->second->spellId,true);
|
||||
}
|
||||
|
||||
void Player::UpdateAreaDependentAuras( uint32 newArea )
|
||||
void Player::UpdateAreaDependentAuras()
|
||||
{
|
||||
// remove auras from spells with area limitations
|
||||
for(SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();)
|
||||
{
|
||||
// use m_zoneUpdateId for speed: UpdateArea called from UpdateZone or instead UpdateZone in both cases m_zoneUpdateId up-to-date
|
||||
if(sSpellMgr.GetSpellAllowedInLocationError(iter->second->GetSpellProto(),GetMapId(),m_zoneUpdateId,newArea,this) != SPELL_CAST_OK)
|
||||
if(sSpellMgr.GetSpellAllowedInLocationError(iter->second->GetSpellProto(), GetMapId(), m_zoneUpdateId, m_areaUpdateId, this) != SPELL_CAST_OK)
|
||||
{
|
||||
RemoveSpellAuraHolder(iter->second);
|
||||
iter = m_spellAuraHolders.begin();
|
||||
|
|
@ -20601,13 +20602,35 @@ void Player::UpdateAreaDependentAuras( uint32 newArea )
|
|||
}
|
||||
|
||||
// some auras applied at subzone enter
|
||||
SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAreaMapBounds(newArea);
|
||||
SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAreaMapBounds(m_areaUpdateId);
|
||||
for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
|
||||
if(itr->second->autocast && itr->second->IsFitToRequirements(this,m_zoneUpdateId,newArea))
|
||||
if(itr->second->autocast && itr->second->IsFitToRequirements(this, m_zoneUpdateId, m_areaUpdateId))
|
||||
if (!HasAura(itr->second->spellId, EFFECT_INDEX_0))
|
||||
CastSpell(this,itr->second->spellId,true);
|
||||
}
|
||||
|
||||
struct UpdateZoneDependentPetsHelper
|
||||
{
|
||||
explicit UpdateZoneDependentPetsHelper(Player* _owner, uint32 zone, uint32 area) : owner(_owner), zone_id(zone), area_id(area) {}
|
||||
void operator()(Unit* unit) const
|
||||
{
|
||||
if (unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->IsPet() && !((Pet*)unit)->IsPermanentPetFor(owner))
|
||||
if (uint32 spell_id = unit->GetUInt32Value(UNIT_CREATED_BY_SPELL))
|
||||
if (SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell_id))
|
||||
if (sSpellMgr.GetSpellAllowedInLocationError(spellEntry, owner->GetMapId(), zone_id, area_id, owner) != SPELL_CAST_OK)
|
||||
((Pet*)unit)->Unsummon(PET_SAVE_AS_DELETED, owner);
|
||||
}
|
||||
Player* owner;
|
||||
uint32 zone_id;
|
||||
uint32 area_id;
|
||||
};
|
||||
|
||||
void Player::UpdateZoneDependentPets()
|
||||
{
|
||||
// check pet (permanent pets ignored), minipet, guardians (including protector)
|
||||
CallForAllControlledUnits(UpdateZoneDependentPetsHelper(this, m_zoneUpdateId, m_areaUpdateId), CONTROLED_PET|CONTROLED_GUARDIANS|CONTROLED_MINIPET);
|
||||
}
|
||||
|
||||
uint32 Player::GetCorpseReclaimDelay(bool pvp) const
|
||||
{
|
||||
if ((pvp && !sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVP)) ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue