[9187] Fixed problem with non-attackable pes/totems at arenas

... and other FFA areas. Problem is result chnages in related flags work after old 3.x switch.

* Added high-level functions for FFAPvP state set for unit
* Apply FFA PvP to all controlled units also at set, and at summon/load
This commit is contained in:
VladimirMangos 2010-01-16 05:37:57 +03:00
parent 6704929d56
commit cc062f16ac
9 changed files with 45 additions and 15 deletions

View file

@ -749,7 +749,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
// Set FFA PvP for non GM in non-rest mode // Set FFA PvP for non GM in non-rest mode
if(sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_RESTING) ) if(sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_RESTING) )
pCurrChar->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); pCurrChar->SetFFAPvP(true);
if(pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) if(pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
pCurrChar->SetContestedPvP(); pCurrChar->SetContestedPvP();

View file

@ -771,7 +771,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data)
GetPlayer()->SetRestType(REST_TYPE_IN_TAVERN); GetPlayer()->SetRestType(REST_TYPE_IN_TAVERN);
if(sWorld.IsFFAPvPRealm()) if(sWorld.IsFFAPvPRealm())
GetPlayer()->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); GetPlayer()->SetFFAPvP(false);
return; return;
} }

View file

@ -225,6 +225,9 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
if(owner->IsPvP()) if(owner->IsPvP())
SetPvP(true); SetPvP(true);
if(owner->IsFFAPvP())
SetFFAPvP(true);
SetCanModifyStats(true); SetCanModifyStats(true);
InitStatsForLevel(petlevel); InitStatsForLevel(petlevel);
InitTalentForLevel(); // set original talents points before spell loading InitTalentForLevel(); // set original talents points before spell loading

View file

@ -2231,7 +2231,7 @@ void Player::SetGameMaster(bool on)
CallForAllControlledUnits(SetGameMasterOnHelper(),true,true,true,false); CallForAllControlledUnits(SetGameMasterOnHelper(),true,true,true,false);
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); SetFFAPvP(false);
ResetContestedPvP(); ResetContestedPvP();
getHostileRefManager().setOnlineOfflineState(false); getHostileRefManager().setOnlineOfflineState(false);
@ -2253,7 +2253,7 @@ void Player::SetGameMaster(bool on)
// restore FFA PvP Server state // restore FFA PvP Server state
if(sWorld.IsFFAPvPRealm()) if(sWorld.IsFFAPvPRealm())
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); SetFFAPvP(true);
// restore FFA PvP area state, remove not allowed for GM mounts // restore FFA PvP area state, remove not allowed for GM mounts
UpdateArea(m_areaUpdateId); UpdateArea(m_areaUpdateId);
@ -6312,14 +6312,14 @@ void Player::UpdateArea(uint32 newArea)
if(area && (area->flags & AREA_FLAG_ARENA)) if(area && (area->flags & AREA_FLAG_ARENA))
{ {
if(!isGameMaster()) if(!isGameMaster())
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); SetFFAPvP(true);
} }
else else
{ {
// remove ffa flag only if not ffapvp realm // remove ffa flag only if not ffapvp realm
// removal in sanctuaries and capitals is handled in zone update // removal in sanctuaries and capitals is handled in zone update
if(HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP) && !sWorld.IsFFAPvPRealm()) if(IsFFAPvP() && !sWorld.IsFFAPvPRealm())
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); SetFFAPvP(false);
} }
UpdateAreaDependentAuras(newArea); UpdateAreaDependentAuras(newArea);
@ -6387,7 +6387,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
{ {
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SANCTUARY); SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SANCTUARY);
if(sWorld.IsFFAPvPRealm()) if(sWorld.IsFFAPvPRealm())
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); SetFFAPvP(false);
} }
else else
{ {
@ -6401,7 +6401,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
InnEnter(time(0),GetMapId(),0,0,0); InnEnter(time(0),GetMapId(),0,0,0);
if(sWorld.IsFFAPvPRealm()) if(sWorld.IsFFAPvPRealm())
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); SetFFAPvP(false);
} }
else // anywhere else else // anywhere else
{ {
@ -6415,7 +6415,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
SetRestType(REST_TYPE_NO); SetRestType(REST_TYPE_NO);
if(sWorld.IsFFAPvPRealm()) if(sWorld.IsFFAPvPRealm())
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); SetFFAPvP(true);
} }
} }
else // not in tavern (leave city then) else // not in tavern (leave city then)
@ -6425,7 +6425,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
// Set player to FFA PVP when not in rested environment. // Set player to FFA PVP when not in rested environment.
if(sWorld.IsFFAPvPRealm()) if(sWorld.IsFFAPvPRealm())
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); SetFFAPvP(true);
} }
} }
} }

View file

@ -1170,7 +1170,6 @@ class MANGOS_DLL_SPEC Player : public Unit
template<typename Func> template<typename Func>
bool CheckAllControlledUnits(Func const& func, bool withTotems, bool withGuardians, bool withCharms, bool withMiniPet) const; bool CheckAllControlledUnits(Func const& func, bool withTotems, bool withGuardians, bool withCharms, bool withMiniPet) const;
uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
void Say(const std::string& text, const uint32 language); void Say(const std::string& text, const uint32 language);

View file

@ -4419,6 +4419,9 @@ void Spell::EffectSummonPet(uint32 i)
if(m_caster->IsPvP()) if(m_caster->IsPvP())
NewSummon->SetPvP(true); NewSummon->SetPvP(true);
if(m_caster->IsFFAPvP())
NewSummon->SetFFAPvP(true);
NewSummon->InitStatsForLevel(petlevel, m_caster); NewSummon->InitStatsForLevel(petlevel, m_caster);
NewSummon->InitPetCreateSpells(); NewSummon->InitPetCreateSpells();
NewSummon->InitLevelupSpellsForLevel(); NewSummon->InitLevelupSpellsForLevel();
@ -5934,6 +5937,9 @@ void Spell::EffectSummonTotem(uint32 i, uint8 slot)
if(m_caster->IsPvP()) if(m_caster->IsPvP())
pTotem->SetPvP(true); pTotem->SetPvP(true);
if(m_caster->IsFFAPvP())
pTotem->SetFFAPvP(true);
pTotem->Summon(m_caster); pTotem->Summon(m_caster);
if(slot < MAX_TOTEM && m_caster->GetTypeId() == TYPEID_PLAYER) if(slot < MAX_TOTEM && m_caster->GetTypeId() == TYPEID_PLAYER)

View file

@ -7879,7 +7879,7 @@ bool Unit::IsHostileTo(Unit const* unit) const
return false; return false;
// PvP FFA state // PvP FFA state
if(pTester->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP) && pTarget->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP)) if(pTester->IsFFAPvP() && pTarget->IsFFAPvP())
return true; return true;
//= PvP states //= PvP states
@ -7991,7 +7991,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
return true; return true;
// PvP FFA state // PvP FFA state
if(pTester->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP) && pTarget->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP)) if(pTester->IsFFAPvP() && pTarget->IsFFAPvP())
return false; return false;
//= PvP states //= PvP states
@ -12755,6 +12755,9 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
if(IsPvP()) if(IsPvP())
pet->SetPvP(true); pet->SetPvP(true);
if(IsFFAPvP())
pet->SetFFAPvP(true);
uint32 level = (creatureTarget->getLevel() < (getLevel() - 5)) ? (getLevel() - 5) : creatureTarget->getLevel(); uint32 level = (creatureTarget->getLevel() < (getLevel() - 5)) ? (getLevel() - 5) : creatureTarget->getLevel();
if(!pet->InitStatsForLevel(level)) if(!pet->InitStatsForLevel(level))
@ -12985,6 +12988,23 @@ void Unit::SetPvP( bool state )
CallForAllControlledUnits(SetPvPHelper(state),true,true,true); CallForAllControlledUnits(SetPvPHelper(state),true,true,true);
} }
struct SetFFAPvPHelper
{
explicit SetFFAPvPHelper(bool _state) : state(_state) {}
void operator()(Unit* unit) const { unit->SetFFAPvP(state); }
bool state;
};
void Unit::SetFFAPvP( bool state )
{
if(state)
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
else
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
CallForAllControlledUnits(SetFFAPvPHelper(state),true,true,true);
}
void Unit::KnockBackFrom(Unit* target, float horizintalSpeed, float verticalSpeed) void Unit::KnockBackFrom(Unit* target, float horizintalSpeed, float verticalSpeed)
{ {
float angle = this == target ? GetOrientation() + M_PI : target->GetAngle(this); float angle = this == target ? GetOrientation() + M_PI : target->GetAngle(this);

View file

@ -1009,6 +1009,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
} }
bool IsPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); } bool IsPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); }
void SetPvP(bool state); void SetPvP(bool state);
bool IsFFAPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); }
void SetFFAPvP(bool state);
uint32 GetCreatureType() const; uint32 GetCreatureType() const;
uint32 GetCreatureTypeMask() const uint32 GetCreatureTypeMask() const
{ {

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9186" #define REVISION_NR "9187"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__