feat(core): OnFfaPvpStateUpdate Event (#13023)
* Event for Notification when the Player enters into or Leaves Ffa * Bug and Formatting Fixes
This commit is contained in:
@@ -2088,8 +2088,14 @@ void GameObject::CastSpell(Unit* target, uint32 spellId)
|
|||||||
if (owner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
|
if (owner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
|
||||||
trigger->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
|
trigger->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
|
||||||
if (owner->IsFFAPvP())
|
if (owner->IsFFAPvP())
|
||||||
trigger->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
{
|
||||||
|
if (!HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||||
|
{
|
||||||
|
sScriptMgr->OnFfaPvpStateUpdate(trigger, true);
|
||||||
|
trigger->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
// xinef: Remove Immunity flags
|
// xinef: Remove Immunity flags
|
||||||
trigger->SetImmuneToNPC(false);
|
trigger->SetImmuneToNPC(false);
|
||||||
// xinef: set proper orientation, fixes cast against stealthed targets
|
// xinef: set proper orientation, fixes cast against stealthed targets
|
||||||
|
|||||||
@@ -2179,8 +2179,11 @@ void Player::SetGameMaster(bool on)
|
|||||||
pet->SetFaction(FACTION_FRIENDLY);
|
pet->SetFaction(FACTION_FRIENDLY);
|
||||||
pet->getHostileRefMgr().setOnlineOfflineState(false);
|
pet->getHostileRefMgr().setOnlineOfflineState(false);
|
||||||
}
|
}
|
||||||
|
if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||||
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
{
|
||||||
|
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||||
|
sScriptMgr->OnFfaPvpStateUpdate(this, false);
|
||||||
|
}
|
||||||
ResetContestedPvP();
|
ResetContestedPvP();
|
||||||
|
|
||||||
getHostileRefMgr().setOnlineOfflineState(false);
|
getHostileRefMgr().setOnlineOfflineState(false);
|
||||||
@@ -2212,8 +2215,13 @@ 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);
|
{
|
||||||
|
if (!HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||||
|
{
|
||||||
|
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||||
|
sScriptMgr->OnFfaPvpStateUpdate(this, 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);
|
||||||
|
|
||||||
@@ -2656,8 +2664,12 @@ void Player::InitStatsForLevel(bool reapplyMods)
|
|||||||
RemovePlayerFlag(PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST | PLAYER_ALLOW_ONLY_ABILITY);
|
RemovePlayerFlag(PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST | PLAYER_ALLOW_ONLY_ABILITY);
|
||||||
|
|
||||||
RemoveStandFlags(UNIT_STAND_FLAGS_ALL); // one form stealth modified bytes
|
RemoveStandFlags(UNIT_STAND_FLAGS_ALL); // one form stealth modified bytes
|
||||||
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY);
|
if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||||
|
{
|
||||||
|
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY);
|
||||||
|
sScriptMgr->OnFfaPvpStateUpdate(this, false);
|
||||||
|
|
||||||
|
}
|
||||||
// restore if need some important flags
|
// restore if need some important flags
|
||||||
SetUInt32Value(PLAYER_FIELD_BYTES2, 0); // flags empty by default
|
SetUInt32Value(PLAYER_FIELD_BYTES2, 0); // flags empty by default
|
||||||
|
|
||||||
@@ -15001,7 +15013,11 @@ void Player::SetIsSpectator(bool on)
|
|||||||
AddUnitState(UNIT_STATE_ISOLATED);
|
AddUnitState(UNIT_STATE_ISOLATED);
|
||||||
//SetFaction(1100);
|
//SetFaction(1100);
|
||||||
SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
|
SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
|
||||||
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||||
|
{
|
||||||
|
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||||
|
sScriptMgr->OnFfaPvpStateUpdate(this, false);
|
||||||
|
}
|
||||||
ResetContestedPvP();
|
ResetContestedPvP();
|
||||||
SetDisplayId(23691);
|
SetDisplayId(23691);
|
||||||
}
|
}
|
||||||
@@ -15021,7 +15037,14 @@ void Player::SetIsSpectator(bool on)
|
|||||||
// restore FFA PvP Server state
|
// restore FFA PvP Server state
|
||||||
// Xinef: it will be removed if necessery in UpdateArea called in WorldPortOpcode
|
// Xinef: it will be removed if necessery in UpdateArea called in WorldPortOpcode
|
||||||
if (sWorld->IsFFAPvPRealm())
|
if (sWorld->IsFFAPvPRealm())
|
||||||
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
{
|
||||||
|
if (!HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||||
|
{
|
||||||
|
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||||
|
sScriptMgr->OnFfaPvpStateUpdate(this, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -396,8 +396,11 @@ void Player::UpdateFFAPvPFlag(time_t currTime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pvpInfo.FFAPvPEndTimer = time_t(0);
|
pvpInfo.FFAPvPEndTimer = time_t(0);
|
||||||
|
if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||||
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
{
|
||||||
|
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||||
|
sScriptMgr->OnFfaPvpStateUpdate(this, false);
|
||||||
|
}
|
||||||
for (ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
|
for (ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
|
||||||
(*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
(*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||||
|
|
||||||
|
|||||||
@@ -1401,6 +1401,7 @@ void Player::UpdateFFAPvPState(bool reset /*= true*/)
|
|||||||
{
|
{
|
||||||
if (!IsFFAPvP())
|
if (!IsFFAPvP())
|
||||||
{
|
{
|
||||||
|
sScriptMgr->OnFfaPvpStateUpdate(this, true);
|
||||||
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||||
for (ControlSet::iterator itr = m_Controlled.begin();
|
for (ControlSet::iterator itr = m_Controlled.begin();
|
||||||
itr != m_Controlled.end(); ++itr)
|
itr != m_Controlled.end(); ++itr)
|
||||||
@@ -1419,8 +1420,11 @@ void Player::UpdateFFAPvPState(bool reset /*= true*/)
|
|||||||
!pvpInfo.EndTimer)
|
!pvpInfo.EndTimer)
|
||||||
{
|
{
|
||||||
pvpInfo.FFAPvPEndTimer = time_t(0);
|
pvpInfo.FFAPvPEndTimer = time_t(0);
|
||||||
|
if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||||
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
{
|
||||||
|
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||||
|
sScriptMgr->OnFfaPvpStateUpdate(this, false);
|
||||||
|
}
|
||||||
for (ControlSet::iterator itr = m_Controlled.begin();
|
for (ControlSet::iterator itr = m_Controlled.begin();
|
||||||
itr != m_Controlled.end(); ++itr)
|
itr != m_Controlled.end(); ++itr)
|
||||||
(*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1,
|
(*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1,
|
||||||
|
|||||||
@@ -954,7 +954,11 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder const& 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->HasPlayerFlag(PLAYER_FLAGS_RESTING))
|
if (sWorld->IsFFAPvPRealm() && !pCurrChar->IsGameMaster() && !pCurrChar->HasPlayerFlag(PLAYER_FLAGS_RESTING))
|
||||||
pCurrChar->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
if (!pCurrChar->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||||
|
{
|
||||||
|
sScriptMgr->OnFfaPvpStateUpdate(pCurrChar,true);
|
||||||
|
pCurrChar->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||||
|
}
|
||||||
|
|
||||||
if (pCurrChar->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
|
if (pCurrChar->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -772,8 +772,14 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
|||||||
player->SetRestFlag(REST_FLAG_IN_TAVERN, atEntry->entry);
|
player->SetRestFlag(REST_FLAG_IN_TAVERN, atEntry->entry);
|
||||||
|
|
||||||
if (sWorld->IsFFAPvPRealm())
|
if (sWorld->IsFFAPvPRealm())
|
||||||
player->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
{
|
||||||
|
if (player->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||||
|
{
|
||||||
|
player->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||||
|
sScriptMgr->OnFfaPvpStateUpdate(player, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,6 +170,15 @@ CreatureAI* ScriptMgr::GetCreatureAI(Creature* creature)
|
|||||||
return tempScript ? tempScript->GetAI(creature) : nullptr;
|
return tempScript ? tempScript->GetAI(creature) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Fires whenever the UNIT_BYTE2_FLAG_FFA_PVP bit is Changed on the player
|
||||||
|
void ScriptMgr::OnFfaPvpStateUpdate(Creature* creature, bool InPvp)
|
||||||
|
{
|
||||||
|
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
|
||||||
|
{
|
||||||
|
script->OnFfaPvpStateUpdate(creature, InPvp);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptMgr::OnCreatureUpdate(Creature* creature, uint32 diff)
|
void ScriptMgr::OnCreatureUpdate(Creature* creature, uint32 diff)
|
||||||
{
|
{
|
||||||
ASSERT(creature);
|
ASSERT(creature);
|
||||||
|
|||||||
@@ -1263,6 +1263,7 @@ void ScriptMgr::OnGetArenaTeamId(Player* player, uint8 slot, uint32& result)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Signifies that IsFfaPvp has been called.
|
||||||
void ScriptMgr::OnIsFFAPvP(Player* player, bool& result)
|
void ScriptMgr::OnIsFFAPvP(Player* player, bool& result)
|
||||||
{
|
{
|
||||||
ExecuteScript<PlayerScript>([&](PlayerScript* script)
|
ExecuteScript<PlayerScript>([&](PlayerScript* script)
|
||||||
@@ -1270,6 +1271,14 @@ void ScriptMgr::OnIsFFAPvP(Player* player, bool& result)
|
|||||||
script->OnIsFFAPvP(player, result);
|
script->OnIsFFAPvP(player, result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//Fires whenever the UNIT_BYTE2_FLAG_FFA_PVP bit is Changed
|
||||||
|
void ScriptMgr::OnFfaPvpStateUpdate(Player* player, bool result)
|
||||||
|
{
|
||||||
|
ExecuteScript<PlayerScript>([&](PlayerScript* script)
|
||||||
|
{
|
||||||
|
script->OnFfaPvpStateUpdate(player, result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptMgr::OnIsPvP(Player* player, bool& result)
|
void ScriptMgr::OnIsPvP(Player* player, bool& result)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -619,6 +619,9 @@ public:
|
|||||||
|
|
||||||
// Called when a CreatureAI object is needed for the creature.
|
// Called when a CreatureAI object is needed for the creature.
|
||||||
[[nodiscard]] virtual CreatureAI* GetCreatureAI(Creature* /*creature*/) const { return nullptr; }
|
[[nodiscard]] virtual CreatureAI* GetCreatureAI(Creature* /*creature*/) const { return nullptr; }
|
||||||
|
|
||||||
|
//Called Whenever the UNIT_BYTE2_FLAG_FFA_PVP Bit is set on the creature
|
||||||
|
virtual void OnFfaPvpStateUpdate(Creature* /*creature*/, bool /*InPvp*/) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class AllItemScript : public ScriptObject
|
class AllItemScript : public ScriptObject
|
||||||
@@ -743,6 +746,10 @@ public:
|
|||||||
|
|
||||||
// Called when a CreatureAI object is needed for the creature.
|
// Called when a CreatureAI object is needed for the creature.
|
||||||
virtual CreatureAI* GetAI(Creature* /*creature*/) const { return nullptr; }
|
virtual CreatureAI* GetAI(Creature* /*creature*/) const { return nullptr; }
|
||||||
|
|
||||||
|
//Called whenever the UNIT_BYTE2_FLAG_FFA_PVP bit is Changed on the player
|
||||||
|
virtual void OnFfaPvpStateUpdate(Creature* /*player*/, bool /*result*/) { }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
|
class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
|
||||||
@@ -1307,6 +1314,9 @@ public:
|
|||||||
|
|
||||||
virtual void OnIsFFAPvP(Player* /*player*/, bool& /*result*/) { }
|
virtual void OnIsFFAPvP(Player* /*player*/, bool& /*result*/) { }
|
||||||
|
|
||||||
|
//Fires whenever the UNIT_BYTE2_FLAG_FFA_PVP bit is Changed on the player
|
||||||
|
virtual void OnFfaPvpStateUpdate(Player* /*player*/, bool /*result*/) { }
|
||||||
|
|
||||||
virtual void OnIsPvP(Player* /*player*/, bool& /*result*/) { }
|
virtual void OnIsPvP(Player* /*player*/, bool& /*result*/) { }
|
||||||
|
|
||||||
virtual void OnGetMaxSkillValueForLevel(Player* /*player*/, uint16& /*result*/) { }
|
virtual void OnGetMaxSkillValueForLevel(Player* /*player*/, uint16& /*result*/) { }
|
||||||
@@ -2127,6 +2137,7 @@ public: /* CreatureScript */
|
|||||||
void OnCreatureUpdate(Creature* creature, uint32 diff);
|
void OnCreatureUpdate(Creature* creature, uint32 diff);
|
||||||
void OnCreatureAddWorld(Creature* creature);
|
void OnCreatureAddWorld(Creature* creature);
|
||||||
void OnCreatureRemoveWorld(Creature* creature);
|
void OnCreatureRemoveWorld(Creature* creature);
|
||||||
|
void OnFfaPvpStateUpdate(Creature* creature, bool InPvp);
|
||||||
|
|
||||||
public: /* GameObjectScript */
|
public: /* GameObjectScript */
|
||||||
bool OnGossipHello(Player* player, GameObject* go);
|
bool OnGossipHello(Player* player, GameObject* go);
|
||||||
@@ -2324,6 +2335,7 @@ public: /* PlayerScript */
|
|||||||
bool NotAvoidSatisfy(Player* player, DungeonProgressionRequirements const* ar, uint32 target_map, bool report);
|
bool NotAvoidSatisfy(Player* player, DungeonProgressionRequirements const* ar, uint32 target_map, bool report);
|
||||||
bool NotVisibleGloballyFor(Player* player, Player const* u);
|
bool NotVisibleGloballyFor(Player* player, Player const* u);
|
||||||
void OnGetArenaPersonalRating(Player* player, uint8 slot, uint32& result);
|
void OnGetArenaPersonalRating(Player* player, uint8 slot, uint32& result);
|
||||||
|
void OnFfaPvpStateUpdate(Player* player, bool result);
|
||||||
void OnGetArenaTeamId(Player* player, uint8 slot, uint32& result);
|
void OnGetArenaTeamId(Player* player, uint8 slot, uint32& result);
|
||||||
void OnIsFFAPvP(Player* player, bool& result);
|
void OnIsFFAPvP(Player* player, bool& result);
|
||||||
void OnIsPvP(Player* player, bool& result);
|
void OnIsPvP(Player* player, bool& result);
|
||||||
|
|||||||
Reference in New Issue
Block a user