Add Outdoor PvP handlers to various files

This commit is contained in:
Xfurry 2012-08-17 18:47:59 +02:00 committed by Antz
parent 525ec3ea4c
commit e955c3bc8f
6 changed files with 68 additions and 4 deletions

View file

@ -40,6 +40,7 @@
#include "InstanceData.h" #include "InstanceData.h"
#include "MapPersistentStateMgr.h" #include "MapPersistentStateMgr.h"
#include "BattleGroundMgr.h" #include "BattleGroundMgr.h"
#include "OutdoorPvP/OutdoorPvP.h"
#include "Spell.h" #include "Spell.h"
#include "Util.h" #include "Util.h"
#include "GridNotifiers.h" #include "GridNotifiers.h"
@ -755,6 +756,10 @@ bool Creature::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo cons
if (InstanceData* iData = GetMap()->GetInstanceData()) if (InstanceData* iData = GetMap()->GetInstanceData())
iData->OnCreatureCreate(this); iData->OnCreatureCreate(this);
// Notify the outdoor pvp script
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId()))
outdoorPvP->HandleCreatureCreate(this);
switch (GetCreatureInfo()->rank) switch (GetCreatureInfo()->rank)
{ {
case CREATURE_ELITE_RARE: case CREATURE_ELITE_RARE:

View file

@ -172,6 +172,10 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
if (InstanceData* iData = map->GetInstanceData()) if (InstanceData* iData = map->GetInstanceData())
iData->OnObjectCreate(this); iData->OnObjectCreate(this);
// Notify the outdoor pvp script
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId()))
outdoorPvP->HandleGameObjectCreate(this);
return true; return true;
} }
@ -1152,6 +1156,15 @@ void GameObject::Use(Unit* user)
} }
case GAMEOBJECT_TYPE_GOOBER: // 10 case GAMEOBJECT_TYPE_GOOBER: // 10
{ {
// Handle OutdoorPvP use cases
// Note: this may be also handled by DB spell scripts in the future, when the world state manager is implemented
if (user->GetTypeId() == TYPEID_PLAYER)
{
Player* player = (Player*)user;
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(player->GetCachedZoneId()))
outdoorPvP->HandleGameObjectUse(player, this);
}
GameObjectInfo const* info = GetGOInfo(); GameObjectInfo const* info = GetGOInfo();
TriggerLinkedGameObject(user); TriggerLinkedGameObject(user);
@ -2092,7 +2105,10 @@ void GameObject::TickCapturePoint()
{ {
eventId = info->capturePoint.progressEventID1; eventId = info->capturePoint.progressEventID1;
// TODO handle objective complete // handle objective complete
if (m_captureState == CAPTURE_STATE_NEUTRAL)
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript((*capturingPlayers.begin())->GetCachedZoneId()))
outdoorPvP->HandleObjectiveComplete(eventId, capturingPlayers, progressFaction);
// set capture state to alliance // set capture state to alliance
m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE; m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE;
@ -2102,7 +2118,10 @@ void GameObject::TickCapturePoint()
{ {
eventId = info->capturePoint.progressEventID2; eventId = info->capturePoint.progressEventID2;
// TODO handle objective complete // handle objective complete
if (m_captureState == CAPTURE_STATE_NEUTRAL)
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript((*capturingPlayers.begin())->GetCachedZoneId()))
outdoorPvP->HandleObjectiveComplete(eventId, capturingPlayers, progressFaction);
// set capture state to horde // set capture state to horde
m_captureState = CAPTURE_STATE_PROGRESS_HORDE; m_captureState = CAPTURE_STATE_PROGRESS_HORDE;
@ -2138,6 +2157,14 @@ void GameObject::TickCapturePoint()
if (eventId) if (eventId)
{ {
// Notify the outdoor pvp script
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript((*capturingPlayers.begin())->GetCachedZoneId()))
{
// Allow only certain events to be handled by other script engines
if (outdoorPvP->HandleEvent(eventId, this))
return;
}
// Send script event to SD2 and database as well - this can be used for summoning creatures, casting specific spells or spawning GOs // Send script event to SD2 and database as well - this can be used for summoning creatures, casting specific spells or spawning GOs
if (!sScriptMgr.OnProcessEvent(eventId, this, this, true)) if (!sScriptMgr.OnProcessEvent(eventId, this, this, true))
GetMap()->ScriptsStart(sEventScripts, eventId, this, this); GetMap()->ScriptsStart(sEventScripts, eventId, this, this);

View file

@ -38,6 +38,7 @@
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
#include "Object.h" #include "Object.h"
#include "BattleGround.h" #include "BattleGround.h"
#include "OutdoorPvP/OutdoorPvP.h"
#include "Pet.h" #include "Pet.h"
#include "SocialMgr.h" #include "SocialMgr.h"
#include "DBCEnums.h" #include "DBCEnums.h"
@ -741,6 +742,12 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
return; return;
} }
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(pl->GetCachedZoneId()))
{
if (outdoorPvP->HandleAreaTrigger(pl, Trigger_ID))
return;
}
// NULL if all values default (non teleport trigger) // NULL if all values default (non teleport trigger)
AreaTrigger const* at = sObjectMgr.GetAreaTrigger(Trigger_ID); AreaTrigger const* at = sObjectMgr.GetAreaTrigger(Trigger_ID);
if (!at) if (!at)

View file

@ -52,6 +52,7 @@
#include "BattleGround.h" #include "BattleGround.h"
#include "BattleGroundAV.h" #include "BattleGroundAV.h"
#include "BattleGroundMgr.h" #include "BattleGroundMgr.h"
#include "OutdoorPvP/OutdoorPvP.h"
#include "ArenaTeam.h" #include "ArenaTeam.h"
#include "Chat.h" #include "Chat.h"
#include "Database/DatabaseImpl.h" #include "Database/DatabaseImpl.h"
@ -621,6 +622,10 @@ void Player::CleanupsBeforeDelete()
TradeCancel(false); TradeCancel(false);
DuelComplete(DUEL_INTERUPTED); DuelComplete(DUEL_INTERUPTED);
} }
// notify zone scripts for player logout
sOutdoorPvPMgr.HandlePlayerLeaveZone(this, m_zoneUpdateId);
Unit::CleanupsBeforeDelete(); Unit::CleanupsBeforeDelete();
} }
@ -6870,6 +6875,10 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
if (m_zoneUpdateId != newZone) if (m_zoneUpdateId != newZone)
{ {
// handle outdoor pvp zones
sOutdoorPvPMgr.HandlePlayerLeaveZone(this, m_zoneUpdateId);
sOutdoorPvPMgr.HandlePlayerEnterZone(this, newZone);
SendInitWorldStates(newZone, newArea); // only if really enters to new zone, not just area change, works strange... SendInitWorldStates(newZone, newArea); // only if really enters to new zone, not just area change, works strange...
if (sWorld.getConfig(CONFIG_BOOL_WEATHER)) if (sWorld.getConfig(CONFIG_BOOL_WEATHER))

View file

@ -38,6 +38,7 @@
#include "Creature.h" #include "Creature.h"
#include "Formulas.h" #include "Formulas.h"
#include "BattleGround.h" #include "BattleGround.h"
#include "OutdoorPvP/OutdoorPvP.h"
#include "CreatureAI.h" #include "CreatureAI.h"
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "Util.h" #include "Util.h"
@ -5194,8 +5195,11 @@ void Aura::HandleAuraModEffectImmunity(bool apply, bool /*Real*/)
if( !apply && target->GetTypeId() == TYPEID_PLAYER if( !apply && target->GetTypeId() == TYPEID_PLAYER
&& (GetSpellProto()->GetAuraInterruptFlags() & AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION) ) && (GetSpellProto()->GetAuraInterruptFlags() & AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION) )
{ {
if (BattleGround* bg = ((Player*)target)->GetBattleGround()) Player* player = (Player*)target;
bg->EventPlayerDroppedFlag(((Player*)target)); if (BattleGround* bg = player->GetBattleGround())
bg->EventPlayerDroppedFlag(player);
else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(player->GetCachedZoneId()))
outdoorPvP->HandleDropFlag(player, GetSpellProto()->Id);
} }
target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, m_modifier.m_miscvalue, apply); target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, m_modifier.m_miscvalue, apply);

View file

@ -42,6 +42,7 @@
#include "Vehicle.h" #include "Vehicle.h"
#include "BattleGround.h" #include "BattleGround.h"
#include "InstanceData.h" #include "InstanceData.h"
#include "OutdoorPvP/OutdoorPvP.h"
#include "MapPersistentStateMgr.h" #include "MapPersistentStateMgr.h"
#include "GridNotifiersImpl.h" #include "GridNotifiersImpl.h"
#include "CellImpl.h" #include "CellImpl.h"
@ -1097,6 +1098,13 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
he->DuelComplete(DUEL_INTERUPTED); he->DuelComplete(DUEL_INTERUPTED);
} }
// handle player kill in outdoor pvp
if (player_tap && pVictim->GetTypeId() == TYPEID_PLAYER && pVictim != this)
{
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(player_tap->GetCachedZoneId()))
outdoorPvP->HandlePlayerKill(player_tap, pVictim);
}
// battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill) // battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill)
if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->InBattleGround()) if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->InBattleGround())
{ {
@ -1328,6 +1336,10 @@ void Unit::JustKilledCreature(Creature* victim)
if (InstanceData* mapInstance = victim->GetInstanceData()) if (InstanceData* mapInstance = victim->GetInstanceData())
mapInstance->OnCreatureDeath(victim); mapInstance->OnCreatureDeath(victim);
// Notify the outdoor pvp script
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId()))
outdoorPvP->HandleCreatureDeath(victim);
if (victim->IsLinkingEventTrigger()) if (victim->IsLinkingEventTrigger())
victim->GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_DIE, victim); victim->GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_DIE, victim);