initial commit
This commit is contained in:
@@ -0,0 +1,802 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Game.Chat;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Groups;
|
||||
using Game.Maps;
|
||||
using Game.Misc;
|
||||
using Game.Network;
|
||||
using Game.Network.Packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
|
||||
namespace Game.PvP
|
||||
{
|
||||
// base class for specific outdoor pvp handlers
|
||||
public class OutdoorPvP : ZoneScript
|
||||
{
|
||||
public OutdoorPvP()
|
||||
{
|
||||
m_TypeId = 0;
|
||||
m_sendUpdate = true;
|
||||
m_players[0] = new List<ObjectGuid>();
|
||||
m_players[1] = new List<ObjectGuid>();
|
||||
}
|
||||
|
||||
public virtual void HandlePlayerEnterZone(Player player, uint zone)
|
||||
{
|
||||
m_players[player.GetTeamId()].Add(player.GetGUID());
|
||||
}
|
||||
|
||||
public virtual void HandlePlayerLeaveZone(Player player, uint zone)
|
||||
{
|
||||
// inform the objectives of the leaving
|
||||
foreach (var pair in m_capturePoints)
|
||||
pair.Value.HandlePlayerLeave(player);
|
||||
// remove the world state information from the player (we can't keep everyone up to date, so leave out those who are not in the concerning zones)
|
||||
if (!player.GetSession().PlayerLogout())
|
||||
SendRemoveWorldStates(player);
|
||||
m_players[player.GetTeamId()].Remove(player.GetGUID());
|
||||
Log.outDebug(LogFilter.Outdoorpvp, "Player {0} left an outdoorpvp zone", player.GetName());
|
||||
}
|
||||
|
||||
public virtual void HandlePlayerResurrects(Player player, uint zone) { }
|
||||
|
||||
public virtual bool Update(uint diff)
|
||||
{
|
||||
bool objective_changed = false;
|
||||
foreach (var pair in m_capturePoints)
|
||||
{
|
||||
if (pair.Value.Update(diff))
|
||||
objective_changed = true;
|
||||
}
|
||||
return objective_changed;
|
||||
}
|
||||
|
||||
public void SendUpdateWorldState(uint field, uint value)
|
||||
{
|
||||
if (m_sendUpdate)
|
||||
{
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
foreach (var guid in m_players[i])
|
||||
{
|
||||
Player player = Global.ObjAccessor.FindPlayer(guid);
|
||||
if (player)
|
||||
player.SendUpdateWorldState(field, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void HandleKill(Player killer, Unit killed)
|
||||
{
|
||||
Group group = killer.GetGroup();
|
||||
if (group)
|
||||
{
|
||||
for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.next())
|
||||
{
|
||||
Player groupGuy = refe.GetSource();
|
||||
|
||||
if (!groupGuy)
|
||||
continue;
|
||||
|
||||
// skip if too far away
|
||||
if (!groupGuy.IsAtGroupRewardDistance(killed))
|
||||
continue;
|
||||
|
||||
// creature kills must be notified, even if not inside objective / not outdoor pvp active
|
||||
// player kills only count if active and inside objective
|
||||
if ((groupGuy.IsOutdoorPvPActive() && IsInsideObjective(groupGuy)) || killed.IsTypeId(TypeId.Unit))
|
||||
HandleKillImpl(groupGuy, killed);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// creature kills must be notified, even if not inside objective / not outdoor pvp active
|
||||
if ((killer.IsOutdoorPvPActive() && IsInsideObjective(killer)) || killed.IsTypeId(TypeId.Unit))
|
||||
HandleKillImpl(killer, killed);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsInsideObjective(Player player)
|
||||
{
|
||||
foreach (var pair in m_capturePoints)
|
||||
if (pair.Value.IsInsideObjective(player))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool HandleCustomSpell(Player player, uint spellId, GameObject go)
|
||||
{
|
||||
foreach (var pair in m_capturePoints)
|
||||
if (pair.Value.HandleCustomSpell(player, spellId, go))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool HandleOpenGo(Player player, GameObject go)
|
||||
{
|
||||
foreach (var pair in m_capturePoints)
|
||||
if (pair.Value.HandleOpenGo(player, go) >= 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool HandleGossipOption(Player player, Creature creature, uint id)
|
||||
{
|
||||
foreach (var pair in m_capturePoints)
|
||||
if (pair.Value.HandleGossipOption(player, creature, id))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool CanTalkTo(Player player, Creature c, GossipMenuItems gso)
|
||||
{
|
||||
foreach (var pair in m_capturePoints)
|
||||
if (pair.Value.CanTalkTo(player, c, gso))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool HandleDropFlag(Player player, uint id)
|
||||
{
|
||||
foreach (var pair in m_capturePoints)
|
||||
if (pair.Value.HandleDropFlag(player, id))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool HandleAreaTrigger(Player player, uint trigger, bool entered)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void BroadcastPacket(ServerPacket packet)
|
||||
{
|
||||
// This is faster than sWorld.SendZoneMessage
|
||||
packet.Write();
|
||||
for (int team = 0; team < 2; ++team)
|
||||
{
|
||||
foreach (var guid in m_players[team])
|
||||
{
|
||||
Player player = Global.ObjAccessor.FindPlayer(guid);
|
||||
if (player)
|
||||
player.SendPacket(packet, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterZone(uint zoneId)
|
||||
{
|
||||
Global.OutdoorPvPMgr.AddZone(zoneId, this);
|
||||
}
|
||||
|
||||
public bool HasPlayer(Player player)
|
||||
{
|
||||
return m_players[player.GetTeamId()].Contains(player.GetGUID());
|
||||
}
|
||||
|
||||
public void TeamCastSpell(uint teamIndex, int spellId)
|
||||
{
|
||||
foreach (var guid in m_players[teamIndex])
|
||||
{
|
||||
Player player = Global.ObjAccessor.FindPlayer(guid);
|
||||
if (player)
|
||||
{
|
||||
if (spellId > 0)
|
||||
player.CastSpell(player, (uint)spellId, true);
|
||||
else
|
||||
player.RemoveAura((uint)-spellId); // by stack?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void TeamApplyBuff(uint teamIndex, uint spellId, uint spellId2)
|
||||
{
|
||||
TeamCastSpell(teamIndex, (int)spellId);
|
||||
TeamCastSpell((uint)(teamIndex == TeamId.Alliance ? TeamId.Horde : TeamId.Alliance), spellId2 != 0 ? -(int)spellId2 : -(int)spellId);
|
||||
}
|
||||
|
||||
public override void OnGameObjectCreate(GameObject go)
|
||||
{
|
||||
if (go.GetGoType() != GameObjectTypes.ControlZone)
|
||||
return;
|
||||
|
||||
OPvPCapturePoint cp = GetCapturePoint(go.GetSpawnId());
|
||||
if (cp != null)
|
||||
cp.m_capturePoint = go;
|
||||
}
|
||||
|
||||
public override void OnGameObjectRemove(GameObject go)
|
||||
{
|
||||
if (go.GetGoType() != GameObjectTypes.ControlZone)
|
||||
return;
|
||||
|
||||
OPvPCapturePoint cp = GetCapturePoint(go.GetSpawnId());
|
||||
if (cp != null)
|
||||
cp.m_capturePoint = null;
|
||||
}
|
||||
|
||||
public void SendDefenseMessage(uint zoneId, uint id)
|
||||
{
|
||||
DefenseMessageBuilder builder = new DefenseMessageBuilder(zoneId, id);
|
||||
var localizer = new LocalizedPacketDo(builder);
|
||||
BroadcastWorker(localizer, zoneId);
|
||||
}
|
||||
|
||||
void BroadcastWorker(IDoWork<Player> _worker, uint zoneId)
|
||||
{
|
||||
for (uint i = 0; i < SharedConst.BGTeamsCount; ++i)
|
||||
{
|
||||
foreach (var guid in m_players[i])
|
||||
{
|
||||
Player player = Global.ObjAccessor.FindPlayer(guid);
|
||||
if (player)
|
||||
if (player.GetZoneId() == zoneId)
|
||||
_worker.Invoke(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void FillInitialWorldStates(InitWorldStates data) { }
|
||||
|
||||
// setup stuff
|
||||
public virtual bool SetupOutdoorPvP() { return true; }
|
||||
|
||||
public virtual void HandleKillImpl(Player killer, Unit killed) { }
|
||||
|
||||
// awards rewards for player kill
|
||||
public virtual void AwardKillBonus(Player player) { }
|
||||
|
||||
public OutdoorPvPTypes GetTypeId() { return m_TypeId; }
|
||||
|
||||
public virtual void SendRemoveWorldStates(Player player) { }
|
||||
|
||||
public void AddCapturePoint(OPvPCapturePoint cp)
|
||||
{
|
||||
if (m_capturePoints.ContainsKey(cp.m_capturePointSpawnId))
|
||||
Log.outError(LogFilter.Outdoorpvp, "OutdoorPvP.AddCapturePoint: CapturePoint {0} already exists!", cp.m_capturePointSpawnId);
|
||||
|
||||
m_capturePoints[cp.m_capturePointSpawnId] = cp;
|
||||
}
|
||||
|
||||
OPvPCapturePoint GetCapturePoint(ulong lowguid)
|
||||
{
|
||||
return m_capturePoints.LookupByKey(lowguid);
|
||||
}
|
||||
|
||||
public Map GetMap() { return m_map; }
|
||||
|
||||
// Hack to store map because this code is just shit
|
||||
public void SetMapFromZone(uint zone)
|
||||
{
|
||||
AreaTableRecord areaTable = CliDB.AreaTableStorage.LookupByKey(zone);
|
||||
Contract.Assert(areaTable != null);
|
||||
Map map = Global.MapMgr.CreateBaseMap(areaTable.MapId);
|
||||
Contract.Assert(!map.Instanceable());
|
||||
m_map = map;
|
||||
}
|
||||
|
||||
// the map of the objectives belonging to this outdoorpvp
|
||||
public Dictionary<ulong, OPvPCapturePoint> m_capturePoints = new Dictionary<ulong, OPvPCapturePoint>();
|
||||
List<ObjectGuid>[] m_players = new List<ObjectGuid>[2];
|
||||
public OutdoorPvPTypes m_TypeId;
|
||||
bool m_sendUpdate;
|
||||
|
||||
Map m_map;
|
||||
}
|
||||
|
||||
public class OPvPCapturePoint
|
||||
{
|
||||
public OPvPCapturePoint(OutdoorPvP pvp)
|
||||
{
|
||||
m_team = TeamId.Neutral;
|
||||
m_OldState = ObjectiveStates.Neutral;
|
||||
m_State = ObjectiveStates.Neutral;
|
||||
m_PvP = pvp;
|
||||
|
||||
m_activePlayers[0] = new List<ObjectGuid>();
|
||||
m_activePlayers[1] = new List<ObjectGuid>();
|
||||
}
|
||||
|
||||
public virtual bool HandlePlayerEnter(Player player)
|
||||
{
|
||||
if (m_capturePoint)
|
||||
{
|
||||
player.SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldState1, 1);
|
||||
player.SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldstate2, (uint)Math.Ceiling((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f));
|
||||
player.SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldstate3, m_neutralValuePct);
|
||||
}
|
||||
m_activePlayers[player.GetTeamId()].Add(player.GetGUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void HandlePlayerLeave(Player player)
|
||||
{
|
||||
if (m_capturePoint)
|
||||
player.SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldState1, 0);
|
||||
m_activePlayers[player.GetTeamId()].Remove(player.GetGUID());
|
||||
}
|
||||
|
||||
public virtual void SendChangePhase()
|
||||
{
|
||||
if (!m_capturePoint)
|
||||
return;
|
||||
|
||||
// send this too, sometimes the slider disappears, dunno why :(
|
||||
SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldState1, 1);
|
||||
// send these updates to only the ones in this objective
|
||||
SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldstate2, (uint)Math.Ceiling((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f));
|
||||
// send this too, sometimes it resets :S
|
||||
SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldstate3, m_neutralValuePct);
|
||||
}
|
||||
|
||||
void AddGO(uint type, ulong guid)
|
||||
{
|
||||
GameObjectData data = Global.ObjectMgr.GetGOData(guid);
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
m_Objects[type] = guid;
|
||||
m_ObjectTypes[guid] = type;
|
||||
}
|
||||
|
||||
void AddCre(uint type, ulong guid)
|
||||
{
|
||||
CreatureData data = Global.ObjectMgr.GetCreatureData(guid);
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
m_Creatures[type] = guid;
|
||||
m_CreatureTypes[guid] = type;
|
||||
}
|
||||
|
||||
public bool AddObject(uint type, uint entry, uint map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
|
||||
{
|
||||
ulong guid = Global.ObjectMgr.AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3);
|
||||
if (guid != 0)
|
||||
{
|
||||
AddGO(type, guid);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AddCreature(uint type, uint entry, uint team, uint map, float x, float y, float z, float o, uint spawntimedelay)
|
||||
{
|
||||
ulong guid = Global.ObjectMgr.AddCreatureData(entry, team, map, x, y, z, o, spawntimedelay);
|
||||
if (guid != 0)
|
||||
{
|
||||
AddCre(type, guid);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SetCapturePointData(uint entry, uint map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
|
||||
{
|
||||
Log.outDebug(LogFilter.Outdoorpvp, "Creating capture point {0}", entry);
|
||||
|
||||
// check info existence
|
||||
GameObjectTemplate goinfo = Global.ObjectMgr.GetGameObjectTemplate(entry);
|
||||
if (goinfo == null || goinfo.type != GameObjectTypes.ControlZone)
|
||||
{
|
||||
Log.outError(LogFilter.Outdoorpvp, "OutdoorPvP: GO {0} is not capture point!", entry);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_capturePointSpawnId = Global.ObjectMgr.AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3);
|
||||
if (m_capturePointSpawnId == 0)
|
||||
return false;
|
||||
|
||||
// get the needed values from goinfo
|
||||
m_maxValue = goinfo.ControlZone.maxTime;
|
||||
m_maxSpeed = m_maxValue / (goinfo.ControlZone.minTime != 0 ? goinfo.ControlZone.minTime : 60);
|
||||
m_neutralValuePct = goinfo.ControlZone.neutralPercent;
|
||||
m_minValue = MathFunctions.CalculatePct(m_maxValue, m_neutralValuePct);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DelCreature(uint type)
|
||||
{
|
||||
if (!m_Creatures.ContainsKey(type))
|
||||
{
|
||||
Log.outDebug(LogFilter.Outdoorpvp, "opvp creature type {0} was already deleted", type);
|
||||
return false;
|
||||
}
|
||||
ulong spawnId = m_Creatures[type];
|
||||
|
||||
var bounds = m_PvP.GetMap().GetCreatureBySpawnIdStore().LookupByKey(spawnId);
|
||||
foreach (var creature in bounds)
|
||||
{
|
||||
// Don't save respawn time
|
||||
creature.SetRespawnTime(0);
|
||||
creature.RemoveCorpse();
|
||||
creature.AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
Log.outDebug(LogFilter.Outdoorpvp, "deleting opvp creature type {0}", type);
|
||||
|
||||
// delete respawn time for this creature
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CREATURE_RESPAWN);
|
||||
stmt.AddValue(0, spawnId);
|
||||
stmt.AddValue(1, m_PvP.GetMap().GetId());
|
||||
stmt.AddValue(2, 0); // instance id, always 0 for world maps
|
||||
DB.Characters.Execute(stmt);
|
||||
|
||||
Global.ObjectMgr.DeleteCreatureData(spawnId);
|
||||
m_CreatureTypes.Remove(spawnId);
|
||||
m_Creatures.Remove(type);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DelObject(uint type)
|
||||
{
|
||||
if (!m_Objects.ContainsKey(type))
|
||||
return false;
|
||||
|
||||
ulong spawnId = m_Objects[type];
|
||||
var bounds = m_PvP.GetMap().GetGameObjectBySpawnIdStore().LookupByKey(spawnId);
|
||||
foreach (var gameobject in bounds)
|
||||
{
|
||||
// Don't save respawn time
|
||||
gameobject.SetRespawnTime(0);
|
||||
gameobject.Delete();
|
||||
}
|
||||
|
||||
Global.ObjectMgr.DeleteGOData(spawnId);
|
||||
m_ObjectTypes.Remove(spawnId);
|
||||
m_Objects.Remove(type);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DelCapturePoint()
|
||||
{
|
||||
Global.ObjectMgr.DeleteGOData(m_capturePointSpawnId);
|
||||
m_capturePointSpawnId = 0;
|
||||
|
||||
if (m_capturePoint)
|
||||
{
|
||||
m_capturePoint.SetRespawnTime(0); // not save respawn time
|
||||
m_capturePoint.Delete();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void DeleteSpawns()
|
||||
{
|
||||
foreach (var type in m_Objects.Keys)
|
||||
DelObject(type);
|
||||
|
||||
foreach (var type in m_Creatures.Keys)
|
||||
DelCreature(type);
|
||||
|
||||
DelCapturePoint();
|
||||
}
|
||||
|
||||
public virtual bool Update(uint diff)
|
||||
{
|
||||
if (!m_capturePoint)
|
||||
return false;
|
||||
|
||||
float radius = m_capturePoint.GetGoInfo().ControlZone.radius;
|
||||
|
||||
for (int team = 0; team < 2; ++team)
|
||||
{
|
||||
foreach (var playerGuid in m_activePlayers[team].ToList())
|
||||
{
|
||||
Player player = Global.ObjAccessor.FindPlayer(playerGuid);
|
||||
if (player)
|
||||
if (!m_capturePoint.IsWithinDistInMap(player, radius) || !player.IsOutdoorPvPActive())
|
||||
HandlePlayerLeave(player);
|
||||
}
|
||||
}
|
||||
|
||||
List<Player> players = new List<Player>();
|
||||
var checker = new AnyPlayerInObjectRangeCheck(m_capturePoint, radius);
|
||||
var searcher = new PlayerListSearcher(m_capturePoint, players, checker);
|
||||
Cell.VisitWorldObjects(m_capturePoint, searcher, radius);
|
||||
|
||||
foreach (var player in players)
|
||||
{
|
||||
if (player.IsOutdoorPvPActive())
|
||||
{
|
||||
m_activePlayers[player.GetTeamId()].Add(player.GetGUID());
|
||||
HandlePlayerEnter(player);
|
||||
}
|
||||
}
|
||||
|
||||
// get the difference of numbers
|
||||
float fact_diff = (m_activePlayers[0].Count - m_activePlayers[1].Count) * diff / 1000;
|
||||
if (fact_diff == 0.0f)
|
||||
return false;
|
||||
|
||||
Team Challenger = 0;
|
||||
float maxDiff = m_maxSpeed * diff;
|
||||
|
||||
if (fact_diff < 0)
|
||||
{
|
||||
// horde is in majority, but it's already horde-controlled . no change
|
||||
if (m_State == ObjectiveStates.Horde && m_value <= -m_maxValue)
|
||||
return false;
|
||||
|
||||
if (fact_diff < -maxDiff)
|
||||
fact_diff = -maxDiff;
|
||||
|
||||
Challenger = Team.Horde;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ally is in majority, but it's already ally-controlled . no change
|
||||
if (m_State == ObjectiveStates.Alliance && m_value >= m_maxValue)
|
||||
return false;
|
||||
|
||||
if (fact_diff > maxDiff)
|
||||
fact_diff = maxDiff;
|
||||
|
||||
Challenger = Team.Alliance;
|
||||
}
|
||||
|
||||
float oldValue = m_value;
|
||||
uint oldTeam = m_team;
|
||||
|
||||
m_OldState = m_State;
|
||||
|
||||
m_value += fact_diff;
|
||||
|
||||
if (m_value < -m_minValue) // red
|
||||
{
|
||||
if (m_value < -m_maxValue)
|
||||
m_value = -m_maxValue;
|
||||
m_State = ObjectiveStates.Horde;
|
||||
m_team = TeamId.Horde;
|
||||
}
|
||||
else if (m_value > m_minValue) // blue
|
||||
{
|
||||
if (m_value > m_maxValue)
|
||||
m_value = m_maxValue;
|
||||
m_State = ObjectiveStates.Alliance;
|
||||
m_team = TeamId.Alliance;
|
||||
}
|
||||
else if (oldValue * m_value <= 0) // grey, go through mid point
|
||||
{
|
||||
// if challenger is ally, then n.a challenge
|
||||
if (Challenger == Team.Alliance)
|
||||
m_State = ObjectiveStates.NeutralAllianceChallenge;
|
||||
// if challenger is horde, then n.h challenge
|
||||
else if (Challenger == Team.Horde)
|
||||
m_State = ObjectiveStates.NeutralHordeChallenge;
|
||||
m_team = TeamId.Neutral;
|
||||
}
|
||||
else // grey, did not go through mid point
|
||||
{
|
||||
// old phase and current are on the same side, so one team challenges the other
|
||||
if (Challenger == Team.Alliance && (m_OldState == ObjectiveStates.Horde || m_OldState == ObjectiveStates.NeutralHordeChallenge))
|
||||
m_State = ObjectiveStates.HordeAllianceChallenge;
|
||||
else if (Challenger == Team.Horde && (m_OldState == ObjectiveStates.Alliance || m_OldState == ObjectiveStates.NeutralAllianceChallenge))
|
||||
m_State = ObjectiveStates.AllianceHordeChallenge;
|
||||
m_team = TeamId.Neutral;
|
||||
}
|
||||
|
||||
if (m_value != oldValue)
|
||||
SendChangePhase();
|
||||
|
||||
if (m_OldState != m_State)
|
||||
{
|
||||
if (oldTeam != m_team)
|
||||
ChangeTeam(oldTeam);
|
||||
ChangeState();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SendUpdateWorldState(uint field, uint value)
|
||||
{
|
||||
for (int team = 0; team < 2; ++team)
|
||||
{
|
||||
// send to all players present in the area
|
||||
foreach (var guid in m_activePlayers[team])
|
||||
{
|
||||
Player player = Global.ObjAccessor.FindPlayer(guid);
|
||||
if (player)
|
||||
player.SendUpdateWorldState(field, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SendObjectiveComplete(uint id, ObjectGuid guid)
|
||||
{
|
||||
uint team;
|
||||
switch (m_State)
|
||||
{
|
||||
case ObjectiveStates.Alliance:
|
||||
team = 0;
|
||||
break;
|
||||
case ObjectiveStates.Horde:
|
||||
team = 1;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// send to all players present in the area
|
||||
foreach (var _guid in m_activePlayers[team])
|
||||
{
|
||||
Player player = Global.ObjAccessor.FindPlayer(_guid);
|
||||
if (player)
|
||||
player.KilledMonsterCredit(id, guid);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInsideObjective(Player player)
|
||||
{
|
||||
var plSet = m_activePlayers[player.GetTeamId()];
|
||||
return plSet.Contains(player.GetGUID());
|
||||
}
|
||||
|
||||
public virtual bool HandleCustomSpell(Player player, uint spellId, GameObject go)
|
||||
{
|
||||
if (!player.IsOutdoorPvPActive())
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool HandleGossipOption(Player player, Creature creature, uint id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool CanTalkTo(Player player, Creature c, GossipMenuItems gso)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool HandleDropFlag(Player player, uint id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual int HandleOpenGo(Player player, GameObject go)
|
||||
{
|
||||
var value = m_ObjectTypes.LookupByKey(go.GetSpawnId());
|
||||
if (value != 0)
|
||||
return (int)value;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public virtual void FillInitialWorldStates(InitWorldStates data) { }
|
||||
|
||||
public virtual void ChangeState() { }
|
||||
|
||||
public virtual void ChangeTeam(uint oldTeam) { }
|
||||
|
||||
public ulong m_capturePointSpawnId;
|
||||
public GameObject m_capturePoint;
|
||||
// active players in the area of the objective, 0 - alliance, 1 - horde
|
||||
public List<ObjectGuid>[] m_activePlayers = new List<ObjectGuid>[2];
|
||||
// total shift needed to capture the objective
|
||||
public float m_maxValue;
|
||||
float m_minValue;
|
||||
// maximum speed of capture
|
||||
float m_maxSpeed;
|
||||
// the status of the objective
|
||||
public float m_value;
|
||||
uint m_team;
|
||||
// objective states
|
||||
public ObjectiveStates m_OldState { get; set; }
|
||||
public ObjectiveStates m_State { get; set; }
|
||||
// neutral value on capture bar
|
||||
public uint m_neutralValuePct;
|
||||
// pointer to the OutdoorPvP this objective belongs to
|
||||
public OutdoorPvP m_PvP { get; set; }
|
||||
|
||||
public Dictionary<uint, ulong> m_Objects = new Dictionary<uint, ulong>();
|
||||
public Dictionary<uint, ulong> m_Creatures = new Dictionary<uint, ulong>();
|
||||
Dictionary<ulong, uint> m_ObjectTypes = new Dictionary<ulong, uint>();
|
||||
Dictionary<ulong, uint> m_CreatureTypes = new Dictionary<ulong, uint>();
|
||||
}
|
||||
|
||||
class DefenseMessageBuilder : MessageBuilder
|
||||
{
|
||||
public DefenseMessageBuilder(uint zoneId, uint id)
|
||||
{
|
||||
_zoneId = zoneId;
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
|
||||
{
|
||||
string text = Global.OutdoorPvPMgr.GetDefenseMessage(_zoneId, _id, locale);
|
||||
|
||||
DefenseMessage defenseMessage = new DefenseMessage();
|
||||
defenseMessage.ZoneID = _zoneId;
|
||||
defenseMessage.MessageText = text;
|
||||
return defenseMessage;
|
||||
}
|
||||
|
||||
uint _zoneId; // ZoneId
|
||||
uint _id; // BroadcastTextId
|
||||
}
|
||||
|
||||
public class go_type
|
||||
{
|
||||
public go_type(uint _entry, uint _map, float _x, float _y, float _z, float _o, float _rot0, float _rot1, float _rot2, float _rot3)
|
||||
{
|
||||
entry = _entry;
|
||||
map = _map;
|
||||
x = _x;
|
||||
y = _y;
|
||||
z = _z;
|
||||
o = _o;
|
||||
rot0 = _rot0;
|
||||
rot1 = _rot1;
|
||||
rot2 = _rot2;
|
||||
rot3 = _rot3;
|
||||
}
|
||||
|
||||
public uint entry;
|
||||
public uint map;
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
public float o;
|
||||
public float rot0;
|
||||
public float rot1;
|
||||
public float rot2;
|
||||
public float rot3;
|
||||
}
|
||||
|
||||
class creature_type
|
||||
{
|
||||
public creature_type(uint _entry, uint _map, float _x, float _y, float _z, float _o)
|
||||
{
|
||||
entry = _entry;
|
||||
map = _map;
|
||||
x = _x;
|
||||
y = _y;
|
||||
z = _z;
|
||||
o = _o;
|
||||
}
|
||||
|
||||
public uint entry;
|
||||
public uint map;
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
public float o;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Maps;
|
||||
using Game.Misc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Game.PvP
|
||||
{
|
||||
public class OutdoorPvPManager : Singleton<OutdoorPvPManager>
|
||||
{
|
||||
OutdoorPvPManager() { }
|
||||
|
||||
public void InitOutdoorPvP()
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// 0 1
|
||||
SQLResult result = DB.World.Query("SELECT TypeId, ScriptName FROM outdoorpvp_template");
|
||||
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, ">> Loaded 0 outdoor PvP definitions. DB table `outdoorpvp_template` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
uint count = 0;
|
||||
uint typeId = 0;
|
||||
|
||||
do
|
||||
{
|
||||
typeId = result.Read<byte>(0);
|
||||
|
||||
if (Global.DisableMgr.IsDisabledFor(DisableType.OutdoorPVP, typeId, null))
|
||||
continue;
|
||||
|
||||
if (typeId >= (int)OutdoorPvPTypes.Max)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Invalid OutdoorPvPTypes value {0} in outdoorpvp_template; skipped.", typeId);
|
||||
continue;
|
||||
}
|
||||
|
||||
OutdoorPvPData data = new OutdoorPvPData();
|
||||
OutdoorPvPTypes realTypeId = (OutdoorPvPTypes)typeId;
|
||||
data.TypeId = realTypeId;
|
||||
data.ScriptId = Global.ObjectMgr.GetScriptId(result.Read<string>(1));
|
||||
m_OutdoorPvPDatas[realTypeId] = data;
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result.NextRow());
|
||||
|
||||
OutdoorPvP pvp;
|
||||
for (byte i = 1; i < (int)OutdoorPvPTypes.Max; ++i)
|
||||
{
|
||||
var outdoor = m_OutdoorPvPDatas.LookupByKey((OutdoorPvPTypes)i);
|
||||
if (outdoor == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Could not initialize OutdoorPvP object for type ID {0}; no entry in database.", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
pvp = Global.ScriptMgr.CreateOutdoorPvP(outdoor);
|
||||
if (pvp == null)
|
||||
{
|
||||
Log.outError(LogFilter.Outdoorpvp, "Could not initialize OutdoorPvP object for type ID {0}; got NULL pointer from script.", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!pvp.SetupOutdoorPvP())
|
||||
{
|
||||
Log.outError(LogFilter.Outdoorpvp, "Could not initialize OutdoorPvP object for type ID {0}; SetupOutdoorPvP failed.", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
m_OutdoorPvPSet.Add(pvp);
|
||||
}
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} outdoor PvP definitions in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
public void AddZone(uint zoneid, OutdoorPvP handle)
|
||||
{
|
||||
m_OutdoorPvPMap[zoneid] = handle;
|
||||
}
|
||||
|
||||
public void HandlePlayerEnterZone(Player player, uint zoneid)
|
||||
{
|
||||
var outdoor = GetOutdoorPvPToZoneId(zoneid);
|
||||
if (outdoor == null)
|
||||
return;
|
||||
|
||||
if (outdoor.HasPlayer(player))
|
||||
return;
|
||||
|
||||
outdoor.HandlePlayerEnterZone(player, zoneid);
|
||||
Log.outDebug(LogFilter.Outdoorpvp, "Player {0} entered outdoorpvp id {1}", player.GetGUID().ToString(), outdoor.GetTypeId());
|
||||
}
|
||||
|
||||
public void HandlePlayerLeaveZone(Player player, uint zoneid)
|
||||
{
|
||||
var outdoor = GetOutdoorPvPToZoneId(zoneid);
|
||||
if (outdoor == null)
|
||||
return;
|
||||
|
||||
// teleport: remove once in removefromworld, once in updatezone
|
||||
if (!outdoor.HasPlayer(player))
|
||||
return;
|
||||
|
||||
outdoor.HandlePlayerLeaveZone(player, zoneid);
|
||||
Log.outDebug(LogFilter.Outdoorpvp, "Player {0} left outdoorpvp id {1}", player.GetGUID().ToString(), outdoor.GetTypeId());
|
||||
}
|
||||
|
||||
public OutdoorPvP GetOutdoorPvPToZoneId(uint zoneid)
|
||||
{
|
||||
var outdoor = m_OutdoorPvPMap.LookupByKey(zoneid);
|
||||
if (outdoor == null)
|
||||
{
|
||||
// no handle for this zone, return
|
||||
return null;
|
||||
}
|
||||
return outdoor;
|
||||
}
|
||||
|
||||
public void Update(uint diff)
|
||||
{
|
||||
m_UpdateTimer += diff;
|
||||
if (m_UpdateTimer > 1000)
|
||||
{
|
||||
foreach (var outdoor in m_OutdoorPvPSet)
|
||||
outdoor.Update(m_UpdateTimer);
|
||||
m_UpdateTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HandleCustomSpell(Player player, uint spellId, GameObject go)
|
||||
{
|
||||
foreach (var outdoor in m_OutdoorPvPSet)
|
||||
{
|
||||
if (outdoor.HandleCustomSpell(player, spellId, go))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ZoneScript GetZoneScript(uint zoneId)
|
||||
{
|
||||
var outdoor = GetOutdoorPvPToZoneId(zoneId);
|
||||
if (outdoor == null)
|
||||
return null;
|
||||
|
||||
return outdoor;
|
||||
}
|
||||
|
||||
public bool HandleOpenGo(Player player, GameObject go)
|
||||
{
|
||||
foreach (var outdoor in m_OutdoorPvPSet)
|
||||
{
|
||||
if (outdoor.HandleOpenGo(player, go))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void HandleGossipOption(Player player, Creature creature, uint gossipid)
|
||||
{
|
||||
foreach (var outdoor in m_OutdoorPvPSet)
|
||||
{
|
||||
if (outdoor.HandleGossipOption(player, creature, gossipid))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanTalkTo(Player player, Creature creature, GossipMenuItems gso)
|
||||
{
|
||||
foreach (var outdoor in m_OutdoorPvPSet)
|
||||
{
|
||||
if (outdoor.CanTalkTo(player, creature, gso))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void HandleDropFlag(Player player, uint spellId)
|
||||
{
|
||||
foreach (var outdoor in m_OutdoorPvPSet)
|
||||
{
|
||||
if (outdoor.HandleDropFlag(player, spellId))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void HandlePlayerResurrects(Player player, uint zoneid)
|
||||
{
|
||||
var outdoor = GetOutdoorPvPToZoneId(zoneid);
|
||||
if (outdoor == null)
|
||||
return;
|
||||
|
||||
if (outdoor.HasPlayer(player))
|
||||
outdoor.HandlePlayerResurrects(player, zoneid);
|
||||
}
|
||||
|
||||
public string GetDefenseMessage(uint zoneId, uint id, LocaleConstant locale)
|
||||
{
|
||||
BroadcastTextRecord bct = CliDB.BroadcastTextStorage.LookupByKey(id);
|
||||
if (bct != null)
|
||||
return Global.DB2Mgr.GetBroadcastTextValue(bct, locale);
|
||||
|
||||
Log.outError(LogFilter.Outdoorpvp, "Can not find DefenseMessage (Zone: {0}, Id: {1}). BroadcastText (Id: {2}) does not exist.", zoneId, id, id);
|
||||
return "";
|
||||
}
|
||||
|
||||
// contains all initiated outdoor pvp events
|
||||
// used when initing / cleaning up
|
||||
List<OutdoorPvP> m_OutdoorPvPSet = new List<OutdoorPvP>();
|
||||
|
||||
// maps the zone ids to an outdoor pvp event
|
||||
// used in player event handling
|
||||
Dictionary<uint, OutdoorPvP> m_OutdoorPvPMap = new Dictionary<uint, OutdoorPvP>();
|
||||
|
||||
// Holds the outdoor PvP templates
|
||||
Dictionary<OutdoorPvPTypes, OutdoorPvPData> m_OutdoorPvPDatas = new Dictionary<OutdoorPvPTypes, OutdoorPvPData>();
|
||||
|
||||
// update interval
|
||||
uint m_UpdateTimer;
|
||||
}
|
||||
|
||||
public class OutdoorPvPData
|
||||
{
|
||||
public OutdoorPvPTypes TypeId;
|
||||
public uint ScriptId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Framework.Constants;
|
||||
using Game.Entities;
|
||||
using Game.Maps;
|
||||
using Game.Network.Packets;
|
||||
using Game.Scripting;
|
||||
|
||||
namespace Game.PvP
|
||||
{
|
||||
struct HPConst
|
||||
{
|
||||
public static uint[] LangCapture_A = { DefenseMessages.BrokenHillTakenAlliance, DefenseMessages.OverlookTakenAlliance, DefenseMessages.StadiumTakenAlliance };
|
||||
|
||||
public static uint[] LangCapture_H = { DefenseMessages.BrokenHillTakenHorde, DefenseMessages.OverlookTakenHorde, DefenseMessages.StadiumTakenHorde };
|
||||
|
||||
public static uint[] Map_N = { 0x9b5, 0x9b2, 0x9a8 };
|
||||
|
||||
public static uint[] Map_A = { 0x9b3, 0x9b0, 0x9a7 };
|
||||
|
||||
public static uint[] Map_H = { 0x9b4, 0x9b1, 0x9a6 };
|
||||
|
||||
public static uint[] TowerArtKit_A = { 65, 62, 67 };
|
||||
|
||||
public static uint[] TowerArtKit_H = { 64, 61, 68 };
|
||||
|
||||
public static uint[] TowerArtKit_N = { 66, 63, 69 };
|
||||
|
||||
// HP, citadel, ramparts, blood furnace, shattered halls, mag's lair
|
||||
public static uint[] BuffZones = { 3483, 3563, 3562, 3713, 3714, 3836 };
|
||||
|
||||
public static uint[] CreditMarker = { 19032, 19028, 19029 };
|
||||
|
||||
public static uint[] CapturePointEventEnter = { 11404, 11396, 11388 };
|
||||
|
||||
public static uint[] CapturePointEventLeave = { 11403, 11395, 11387 };
|
||||
|
||||
public static go_type[] CapturePoints =
|
||||
{
|
||||
new go_type(182175, 530, -471.462f, 3451.09f, 34.6432f, 0.174533f, 0.0f, 0.0f, 0.087156f, 0.996195f), // 0 - Broken Hill
|
||||
new go_type(182174, 530, -184.889f, 3476.93f, 38.205f, -0.017453f, 0.0f, 0.0f, 0.008727f, -0.999962f), // 1 - Overlook
|
||||
new go_type(182173, 530, -290.016f, 3702.42f, 56.6729f, 0.034907f, 0.0f, 0.0f, 0.017452f, 0.999848f) // 2 - Stadium
|
||||
};
|
||||
|
||||
public static go_type[] TowerFlags =
|
||||
{
|
||||
new go_type(183514, 530, -467.078f, 3528.17f, 64.7121f, 3.14159f, 0.0f, 0.0f, 1.0f, 0.0f), // 0 broken hill
|
||||
new go_type(182525, 530, -187.887f, 3459.38f, 60.0403f, -3.12414f, 0.0f, 0.0f, 0.999962f, -0.008727f), // 1 overlook
|
||||
new go_type(183515, 530, -289.610f, 3696.83f, 75.9447f, 3.12414f, 0.0f, 0.0f, 0.999962f, 0.008727f) // 2 stadium
|
||||
};
|
||||
}
|
||||
|
||||
struct DefenseMessages
|
||||
{
|
||||
public const uint OverlookTakenAlliance = 14841; // '|cffffff00The Overlook has been taken by the Alliance!|r'
|
||||
public const uint OverlookTakenHorde = 14842; // '|cffffff00The Overlook has been taken by the Horde!|r'
|
||||
public const uint StadiumTakenAlliance = 14843; // '|cffffff00The Stadium has been taken by the Alliance!|r'
|
||||
public const uint StadiumTakenHorde = 14844; // '|cffffff00The Stadium has been taken by the Horde!|r'
|
||||
public const uint BrokenHillTakenAlliance = 14845; // '|cffffff00Broken Hill has been taken by the Alliance!|r'
|
||||
public const uint BrokenHillTakenHorde = 14846; // '|cffffff00Broken Hill has been taken by the Horde!|r'
|
||||
}
|
||||
|
||||
struct OutdoorPvPHPSpells
|
||||
{
|
||||
public const uint AlliancePlayerKillReward = 32155;
|
||||
public const uint HordePlayerKillReward = 32158;
|
||||
public const uint AllianceBuff = 32071;
|
||||
public const uint HordeBuff = 32049;
|
||||
}
|
||||
|
||||
enum OutdoorPvPHPTowerType
|
||||
{
|
||||
BrokenHill = 0,
|
||||
Overlook = 1,
|
||||
Stadium = 2,
|
||||
Num = 3
|
||||
}
|
||||
|
||||
struct OutdoorPvPHPWorldStates
|
||||
{
|
||||
public const uint Display_A = 0x9ba;
|
||||
public const uint Display_H = 0x9b9;
|
||||
|
||||
public const uint Count_H = 0x9ae;
|
||||
public const uint Count_A = 0x9ac;
|
||||
}
|
||||
|
||||
class HellfirePeninsulaPvP : OutdoorPvP
|
||||
{
|
||||
public HellfirePeninsulaPvP()
|
||||
{
|
||||
m_TypeId = OutdoorPvPTypes.HellfirePeninsula;
|
||||
m_AllianceTowersControlled = 0;
|
||||
m_HordeTowersControlled = 0;
|
||||
}
|
||||
|
||||
public override bool SetupOutdoorPvP()
|
||||
{
|
||||
m_AllianceTowersControlled = 0;
|
||||
m_HordeTowersControlled = 0;
|
||||
SetMapFromZone(HPConst.BuffZones[0]);
|
||||
|
||||
// add the zones affected by the pvp buff
|
||||
for (int i = 0; i < HPConst.BuffZones.Length; ++i)
|
||||
RegisterZone(HPConst.BuffZones[i]);
|
||||
|
||||
AddCapturePoint(new HellfirePeninsulaCapturePoint(this, OutdoorPvPHPTowerType.BrokenHill));
|
||||
|
||||
AddCapturePoint(new HellfirePeninsulaCapturePoint(this, OutdoorPvPHPTowerType.Overlook));
|
||||
|
||||
AddCapturePoint(new HellfirePeninsulaCapturePoint(this, OutdoorPvPHPTowerType.Stadium));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void HandlePlayerEnterZone(Player player, uint zone)
|
||||
{
|
||||
// add buffs
|
||||
if (player.GetTeam() == Team.Alliance)
|
||||
{
|
||||
if (m_AllianceTowersControlled >= 3)
|
||||
player.CastSpell(player, OutdoorPvPHPSpells.AllianceBuff, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_HordeTowersControlled >= 3)
|
||||
player.CastSpell(player, OutdoorPvPHPSpells.HordeBuff, true);
|
||||
}
|
||||
base.HandlePlayerEnterZone(player, zone);
|
||||
}
|
||||
|
||||
public override void HandlePlayerLeaveZone(Player player, uint zone)
|
||||
{
|
||||
// remove buffs
|
||||
if (player.GetTeam() == Team.Alliance)
|
||||
player.RemoveAurasDueToSpell(OutdoorPvPHPSpells.AllianceBuff);
|
||||
else
|
||||
player.RemoveAurasDueToSpell(OutdoorPvPHPSpells.HordeBuff);
|
||||
|
||||
base.HandlePlayerLeaveZone(player, zone);
|
||||
}
|
||||
|
||||
public override bool Update(uint diff)
|
||||
{
|
||||
bool changed = base.Update(diff);
|
||||
if (changed)
|
||||
{
|
||||
if (m_AllianceTowersControlled == 3)
|
||||
TeamApplyBuff(TeamId.Alliance, OutdoorPvPHPSpells.AllianceBuff, OutdoorPvPHPSpells.HordeBuff);
|
||||
else if (m_HordeTowersControlled == 3)
|
||||
TeamApplyBuff(TeamId.Horde, OutdoorPvPHPSpells.HordeBuff, OutdoorPvPHPSpells.AllianceBuff);
|
||||
else
|
||||
{
|
||||
TeamCastSpell(TeamId.Alliance, -(int)OutdoorPvPHPSpells.AllianceBuff);
|
||||
TeamCastSpell(TeamId.Horde, -(int)OutdoorPvPHPSpells.HordeBuff);
|
||||
}
|
||||
SendUpdateWorldState(OutdoorPvPHPWorldStates.Count_A, m_AllianceTowersControlled);
|
||||
SendUpdateWorldState(OutdoorPvPHPWorldStates.Count_H, m_HordeTowersControlled);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
public override void SendRemoveWorldStates(Player player)
|
||||
{
|
||||
player.SendUpdateWorldState(OutdoorPvPHPWorldStates.Display_A, 0);
|
||||
player.SendUpdateWorldState(OutdoorPvPHPWorldStates.Display_H, 0);
|
||||
player.SendUpdateWorldState(OutdoorPvPHPWorldStates.Count_H, 0);
|
||||
player.SendUpdateWorldState(OutdoorPvPHPWorldStates.Count_A, 0);
|
||||
|
||||
for (int i = 0; i < (int)OutdoorPvPHPTowerType.Num; ++i)
|
||||
{
|
||||
player.SendUpdateWorldState(HPConst.Map_N[i], 0);
|
||||
player.SendUpdateWorldState(HPConst.Map_A[i], 0);
|
||||
player.SendUpdateWorldState(HPConst.Map_H[i], 0);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FillInitialWorldStates(InitWorldStates packet)
|
||||
{
|
||||
packet.AddState(OutdoorPvPHPWorldStates.Display_A, 1);
|
||||
packet.AddState(OutdoorPvPHPWorldStates.Display_H, 1);
|
||||
packet.AddState(OutdoorPvPHPWorldStates.Count_A, (int)m_AllianceTowersControlled);
|
||||
packet.AddState(OutdoorPvPHPWorldStates.Count_H, (int)m_HordeTowersControlled);
|
||||
|
||||
foreach (var capture in m_capturePoints.Values)
|
||||
capture.FillInitialWorldStates(packet);
|
||||
}
|
||||
|
||||
public override void HandleKillImpl(Player killer, Unit killed)
|
||||
{
|
||||
if (!killed.IsTypeId(TypeId.Player))
|
||||
return;
|
||||
|
||||
if (killer.GetTeam() == Team.Alliance && killed.ToPlayer().GetTeam() != Team.Alliance)
|
||||
killer.CastSpell(killer, OutdoorPvPHPSpells.AlliancePlayerKillReward, true);
|
||||
else if (killer.GetTeam() == Team.Horde && killed.ToPlayer().GetTeam() != Team.Horde)
|
||||
killer.CastSpell(killer, OutdoorPvPHPSpells.HordePlayerKillReward, true);
|
||||
}
|
||||
|
||||
public uint GetAllianceTowersControlled()
|
||||
{
|
||||
return m_AllianceTowersControlled;
|
||||
}
|
||||
|
||||
public void SetAllianceTowersControlled(uint count)
|
||||
{
|
||||
m_AllianceTowersControlled = count;
|
||||
}
|
||||
|
||||
public uint GetHordeTowersControlled()
|
||||
{
|
||||
return m_HordeTowersControlled;
|
||||
}
|
||||
|
||||
public void SetHordeTowersControlled(uint count)
|
||||
{
|
||||
m_HordeTowersControlled = count;
|
||||
}
|
||||
|
||||
// how many towers are controlled
|
||||
uint m_AllianceTowersControlled;
|
||||
uint m_HordeTowersControlled;
|
||||
}
|
||||
|
||||
class HellfirePeninsulaCapturePoint : OPvPCapturePoint
|
||||
{
|
||||
public HellfirePeninsulaCapturePoint(OutdoorPvP pvp, OutdoorPvPHPTowerType type) : base(pvp)
|
||||
{
|
||||
m_TowerType = (uint)type;
|
||||
|
||||
var capturepoint = HPConst.CapturePoints[m_TowerType];
|
||||
var towerflag = HPConst.TowerFlags[m_TowerType];
|
||||
|
||||
SetCapturePointData(capturepoint.entry, capturepoint.map, capturepoint.x, capturepoint.y, capturepoint.z, capturepoint.o, capturepoint.rot0,
|
||||
capturepoint.rot1, capturepoint.rot2, capturepoint.rot3);
|
||||
|
||||
AddObject((uint)type, towerflag.entry, towerflag.map, towerflag.x, towerflag.y, towerflag.z, towerflag.o, towerflag.rot0, towerflag.rot1, towerflag.rot2, towerflag.rot3);
|
||||
}
|
||||
|
||||
public override void ChangeState()
|
||||
{
|
||||
uint field = 0;
|
||||
switch (m_OldState)
|
||||
{
|
||||
case ObjectiveStates.Neutral:
|
||||
field = HPConst.Map_N[m_TowerType];
|
||||
break;
|
||||
case ObjectiveStates.Alliance:
|
||||
field = HPConst.Map_A[m_TowerType];
|
||||
uint alliance_towers = ((HellfirePeninsulaPvP)m_PvP).GetAllianceTowersControlled();
|
||||
if (alliance_towers != 0)
|
||||
((HellfirePeninsulaPvP)m_PvP).SetAllianceTowersControlled(--alliance_towers);
|
||||
break;
|
||||
case ObjectiveStates.Horde:
|
||||
field = HPConst.Map_H[m_TowerType];
|
||||
uint horde_towers = ((HellfirePeninsulaPvP)m_PvP).GetHordeTowersControlled();
|
||||
if (horde_towers != 0)
|
||||
((HellfirePeninsulaPvP)m_PvP).SetHordeTowersControlled(--horde_towers);
|
||||
break;
|
||||
case ObjectiveStates.NeutralAllianceChallenge:
|
||||
field = HPConst.Map_N[m_TowerType];
|
||||
break;
|
||||
case ObjectiveStates.NeutralHordeChallenge:
|
||||
field = HPConst.Map_N[m_TowerType];
|
||||
break;
|
||||
case ObjectiveStates.AllianceHordeChallenge:
|
||||
field = HPConst.Map_A[m_TowerType];
|
||||
break;
|
||||
case ObjectiveStates.HordeAllianceChallenge:
|
||||
field = HPConst.Map_H[m_TowerType];
|
||||
break;
|
||||
}
|
||||
|
||||
// send world state update
|
||||
if (field != 0)
|
||||
{
|
||||
m_PvP.SendUpdateWorldState(field, 0);
|
||||
field = 0;
|
||||
}
|
||||
uint artkit = 21;
|
||||
uint artkit2 = HPConst.TowerArtKit_N[m_TowerType];
|
||||
switch (m_State)
|
||||
{
|
||||
case ObjectiveStates.Neutral:
|
||||
field = HPConst.Map_N[m_TowerType];
|
||||
break;
|
||||
case ObjectiveStates.Alliance:
|
||||
{
|
||||
field = HPConst.Map_A[m_TowerType];
|
||||
artkit = 2;
|
||||
artkit2 = HPConst.TowerArtKit_A[m_TowerType];
|
||||
uint alliance_towers = ((HellfirePeninsulaPvP)m_PvP).GetAllianceTowersControlled();
|
||||
if (alliance_towers < 3)
|
||||
((HellfirePeninsulaPvP)m_PvP).SetAllianceTowersControlled(++alliance_towers);
|
||||
m_PvP.SendDefenseMessage(HPConst.BuffZones[0], HPConst.LangCapture_A[m_TowerType]);
|
||||
break;
|
||||
}
|
||||
case ObjectiveStates.Horde:
|
||||
{
|
||||
field = HPConst.Map_H[m_TowerType];
|
||||
artkit = 1;
|
||||
artkit2 = HPConst.TowerArtKit_H[m_TowerType];
|
||||
uint horde_towers = ((HellfirePeninsulaPvP)m_PvP).GetHordeTowersControlled();
|
||||
if (horde_towers < 3)
|
||||
((HellfirePeninsulaPvP)m_PvP).SetHordeTowersControlled(++horde_towers);
|
||||
m_PvP.SendDefenseMessage(HPConst.BuffZones[0], HPConst.LangCapture_H[m_TowerType]);
|
||||
break;
|
||||
}
|
||||
case ObjectiveStates.NeutralAllianceChallenge:
|
||||
field = HPConst.Map_N[m_TowerType];
|
||||
break;
|
||||
case ObjectiveStates.NeutralHordeChallenge:
|
||||
field = HPConst.Map_N[m_TowerType];
|
||||
break;
|
||||
case ObjectiveStates.AllianceHordeChallenge:
|
||||
field = HPConst.Map_A[m_TowerType];
|
||||
artkit = 2;
|
||||
artkit2 = HPConst.TowerArtKit_A[m_TowerType];
|
||||
break;
|
||||
case ObjectiveStates.HordeAllianceChallenge:
|
||||
field = HPConst.Map_H[m_TowerType];
|
||||
artkit = 1;
|
||||
artkit2 = HPConst.TowerArtKit_H[m_TowerType];
|
||||
break;
|
||||
}
|
||||
|
||||
Map map = Global.MapMgr.FindMap(530, 0);
|
||||
var bounds = map.GetGameObjectBySpawnIdStore().LookupByKey(m_capturePointSpawnId);
|
||||
foreach (var go in bounds)
|
||||
go.SetGoArtKit((byte)artkit);
|
||||
|
||||
bounds = map.GetGameObjectBySpawnIdStore().LookupByKey(m_Objects[m_TowerType]);
|
||||
foreach (var go in bounds)
|
||||
go.SetGoArtKit((byte)artkit2);
|
||||
|
||||
// send world state update
|
||||
if (field != 0)
|
||||
m_PvP.SendUpdateWorldState(field, 1);
|
||||
|
||||
// complete quest objective
|
||||
if (m_State == ObjectiveStates.Alliance || m_State == ObjectiveStates.Horde)
|
||||
SendObjectiveComplete(HPConst.CreditMarker[m_TowerType], ObjectGuid.Empty);
|
||||
}
|
||||
|
||||
public override void FillInitialWorldStates(InitWorldStates packet)
|
||||
{
|
||||
switch (m_State)
|
||||
{
|
||||
case ObjectiveStates.Alliance:
|
||||
case ObjectiveStates.AllianceHordeChallenge:
|
||||
packet.AddState(HPConst.Map_N[m_TowerType], 0);
|
||||
packet.AddState(HPConst.Map_A[m_TowerType], 1);
|
||||
packet.AddState(HPConst.Map_H[m_TowerType], 0);
|
||||
break;
|
||||
case ObjectiveStates.Horde:
|
||||
case ObjectiveStates.HordeAllianceChallenge:
|
||||
packet.AddState(HPConst.Map_N[m_TowerType], 0);
|
||||
packet.AddState(HPConst.Map_A[m_TowerType], 0);
|
||||
packet.AddState(HPConst.Map_H[m_TowerType], 1);
|
||||
break;
|
||||
case ObjectiveStates.Neutral:
|
||||
case ObjectiveStates.NeutralAllianceChallenge:
|
||||
case ObjectiveStates.NeutralHordeChallenge:
|
||||
default:
|
||||
packet.AddState(HPConst.Map_N[m_TowerType], 1);
|
||||
packet.AddState(HPConst.Map_A[m_TowerType], 0);
|
||||
packet.AddState(HPConst.Map_H[m_TowerType], 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint m_TowerType;
|
||||
}
|
||||
|
||||
[Script]
|
||||
class HellfirePeninsulaPvPScript : OutdoorPvPScript
|
||||
{
|
||||
public HellfirePeninsulaPvPScript() : base("outdoorpvp_hp") { }
|
||||
|
||||
public override OutdoorPvP GetOutdoorPvP()
|
||||
{
|
||||
return new HellfirePeninsulaPvP();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,755 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Game.Network;
|
||||
using Game.Entities;
|
||||
using Framework.Constants;
|
||||
using Game.Scripting;
|
||||
using Game.Network.Packets;
|
||||
|
||||
namespace Game.PvP.Nagrand
|
||||
{
|
||||
struct Misc
|
||||
{
|
||||
// kill credit for pks
|
||||
public const uint CreditMarker = 24867;
|
||||
|
||||
public const uint MaxGuards = 15;
|
||||
|
||||
public const uint BuffZone = 3518;
|
||||
|
||||
public const uint HalaaGraveyard = 993;
|
||||
|
||||
public const uint HalaaGraveyardZone = 3518; // need to add zone id, not area id
|
||||
|
||||
public const uint RespawnTime = 3600000; // one hour to capture after defeating all guards
|
||||
|
||||
public const uint GuardCheckTime = 500; // every half second
|
||||
|
||||
public const uint FlightNodesNum = 4;
|
||||
|
||||
public static uint[] FlightPathStartNodes = { 103, 105, 107, 109 };
|
||||
public static uint[] FlightPathEndNodes = { 104, 106, 108, 110 };
|
||||
|
||||
// spawned when the alliance is attacking, horde is in control
|
||||
public static go_type[] HordeControlGOs =
|
||||
{
|
||||
new go_type(182267, 530, -1815.8f, 8036.51f, -26.2354f, -2.89725f, 0.0f, 0.0f, 0.992546f, -0.121869f), //ALLY_ROOST_SOUTH
|
||||
new go_type(182280, 530, -1507.95f, 8132.1f, -19.5585f, -1.3439f, 0.0f, 0.0f, 0.622515f, -0.782608f), //ALLY_ROOST_WEST
|
||||
new go_type(182281, 530, -1384.52f, 7779.33f, -11.1663f, -0.575959f, 0.0f, 0.0f, 0.284015f, -0.95882f), //ALLY_ROOST_NORTH
|
||||
new go_type(182282, 530, -1650.11f, 7732.56f, -15.4505f, -2.80998f, 0.0f, 0.0f, 0.986286f, -0.165048f), //ALLY_ROOST_EAST
|
||||
|
||||
new go_type(182222, 530, -1825.4022f, 8039.2602f, -26.08f, -2.89725f, 0.0f, 0.0f, 0.992546f, -0.121869f), //HORDE_BOMB_WAGON_SOUTH
|
||||
new go_type(182272, 530, -1515.37f, 8136.91f, -20.42f, -1.3439f, 0.0f, 0.0f, 0.622515f, -0.782608f), //HORDE_BOMB_WAGON_WEST
|
||||
new go_type(182273, 530, -1377.95f, 7773.44f, -10.31f, -0.575959f, 0.0f, 0.0f, 0.284015f, -0.95882f), //HORDE_BOMB_WAGON_NORTH
|
||||
new go_type(182274, 530, -1659.87f, 7733.15f, -15.75f, -2.80998f, 0.0f, 0.0f, 0.986286f, -0.165048f), //HORDE_BOMB_WAGON_EAST
|
||||
|
||||
new go_type(182266, 530, -1815.8f, 8036.51f, -26.2354f, -2.89725f, 0.0f, 0.0f, 0.992546f, -0.121869f), //DESTROYED_ALLY_ROOST_SOUTH
|
||||
new go_type(182275, 530, -1507.95f, 8132.1f, -19.5585f, -1.3439f, 0.0f, 0.0f, 0.622515f, -0.782608f), //DESTROYED_ALLY_ROOST_WEST
|
||||
new go_type(182276, 530, -1384.52f, 7779.33f, -11.1663f, -0.575959f, 0.0f, 0.0f, 0.284015f, -0.95882f), //DESTROYED_ALLY_ROOST_NORTH
|
||||
new go_type(182277, 530, -1650.11f, 7732.56f, -15.4505f, -2.80998f, 0.0f, 0.0f, 0.986286f, -0.165048f) //DESTROYED_ALLY_ROOST_EAST
|
||||
};
|
||||
|
||||
// spawned when the horde is attacking, alliance is in control
|
||||
public static go_type[] AllianceControlGOs =
|
||||
{
|
||||
new go_type(182301, 530, -1815.8f, 8036.51f, -26.2354f, -2.89725f, 0.0f, 0.0f, 0.992546f, -0.121869f), //HORDE_ROOST_SOUTH
|
||||
new go_type(182302, 530, -1507.95f, 8132.1f, -19.5585f, -1.3439f, 0.0f, 0.0f, 0.622515f, -0.782608f), //HORDE_ROOST_WEST
|
||||
new go_type(182303, 530, -1384.52f, 7779.33f, -11.1663f, -0.575959f, 0.0f, 0.0f, 0.284015f, -0.95882f), //HORDE_ROOST_NORTH
|
||||
new go_type(182304, 530, -1650.11f, 7732.56f, -15.4505f, -2.80998f, 0.0f, 0.0f, 0.986286f, -0.165048f), //HORDE_ROOST_EAST
|
||||
|
||||
new go_type(182305, 530, -1825.4022f, 8039.2602f, -26.08f, -2.89725f, 0.0f, 0.0f, 0.992546f, -0.121869f), //ALLY_BOMB_WAGON_SOUTH
|
||||
new go_type(182306, 530, -1515.37f, 8136.91f, -20.42f, -1.3439f, 0.0f, 0.0f, 0.622515f, -0.782608f), //ALLY_BOMB_WAGON_WEST
|
||||
new go_type(182307, 530, -1377.95f, 7773.44f, -10.31f, -0.575959f, 0.0f, 0.0f, 0.284015f, -0.95882f), //ALLY_BOMB_WAGON_NORTH
|
||||
new go_type(182308, 530, -1659.87f, 7733.15f, -15.75f, -2.80998f, 0.0f, 0.0f, 0.986286f, -0.165048f), //ALLY_BOMB_WAGON_EAST
|
||||
|
||||
new go_type(182297, 530, -1815.8f, 8036.51f, -26.2354f, -2.89725f, 0.0f, 0.0f, 0.992546f, -0.121869f), //DESTROYED_HORDE_ROOST_SOUTH
|
||||
new go_type(182298, 530, -1507.95f, 8132.1f, -19.5585f, -1.3439f, 0.0f, 0.0f, 0.622515f, -0.782608f), //DESTROYED_HORDE_ROOST_WEST
|
||||
new go_type(182299, 530, -1384.52f, 7779.33f, -11.1663f, -0.575959f, 0.0f, 0.0f, 0.284015f, -0.95882f), //DESTROYED_HORDE_ROOST_NORTH
|
||||
new go_type(182300, 530, -1650.11f, 7732.56f, -15.4505f, -2.80998f, 0.0f, 0.0f, 0.986286f, -0.165048f) //DESTROYED_HORDE_ROOST_EAST
|
||||
};
|
||||
|
||||
public static creature_type[] HordeControlNPCs =
|
||||
{
|
||||
new creature_type(18816, 530, -1523.92f, 7951.76f, -17.6942f, 3.51172f),
|
||||
new creature_type(18821, 530, -1527.75f, 7952.46f, -17.6948f, 3.99317f),
|
||||
new creature_type(21474, 530, -1520.14f, 7927.11f, -20.2527f, 3.39389f),
|
||||
new creature_type(21484, 530, -1524.84f, 7930.34f, -20.182f, 3.6405f),
|
||||
new creature_type(21483, 530, -1570.01f, 7993.8f, -22.4505f, 5.02655f),
|
||||
new creature_type(18192, 530, -1654.06f, 8000.46f, -26.59f, 3.37f),
|
||||
new creature_type(18192, 530, -1487.18f, 7899.1f, -19.53f, 0.954f),
|
||||
new creature_type(18192, 530, -1480.88f, 7908.79f, -19.19f, 4.485f),
|
||||
new creature_type(18192, 530, -1540.56f, 7995.44f, -20.45f, 0.947f),
|
||||
new creature_type(18192, 530, -1546.95f, 8000.85f, -20.72f, 6.035f),
|
||||
new creature_type(18192, 530, -1595.31f, 7860.53f, -21.51f, 3.747f),
|
||||
new creature_type(18192, 530, -1642.31f, 7995.59f, -25.8f, 3.317f),
|
||||
new creature_type(18192, 530, -1545.46f, 7995.35f, -20.63f, 1.094f),
|
||||
new creature_type(18192, 530, -1487.58f, 7907.99f, -19.27f, 5.567f),
|
||||
new creature_type(18192, 530, -1651.54f, 7988.56f, -26.5289f, 2.98451f),
|
||||
new creature_type(18192, 530, -1602.46f, 7866.43f, -22.1177f, 4.74729f),
|
||||
new creature_type(18192, 530, -1591.22f, 7875.29f, -22.3536f, 4.34587f),
|
||||
new creature_type(18192, 530, -1550.6f, 7944.45f, -21.63f, 3.559f),
|
||||
new creature_type(18192, 530, -1545.57f, 7935.83f, -21.13f, 3.448f),
|
||||
new creature_type(18192, 530, -1550.86f, 7937.56f, -21.7f, 3.801f)
|
||||
};
|
||||
|
||||
public static creature_type[] AllianceControlNPCs =
|
||||
{
|
||||
new creature_type(18817, 530, -1591.18f, 8020.39f, -22.2042f, 4.59022f),
|
||||
new creature_type(18822, 530, -1588.0f, 8019.0f, -22.2042f, 4.06662f),
|
||||
new creature_type(21485, 530, -1521.93f, 7927.37f, -20.2299f, 3.24631f),
|
||||
new creature_type(21487, 530, -1540.33f, 7971.95f, -20.7186f, 3.07178f),
|
||||
new creature_type(21488, 530, -1570.01f, 7993.8f, -22.4505f, 5.02655f),
|
||||
new creature_type(18256, 530, -1654.06f, 8000.46f, -26.59f, 3.37f),
|
||||
new creature_type(18256, 530, -1487.18f, 7899.1f, -19.53f, 0.954f),
|
||||
new creature_type(18256, 530, -1480.88f, 7908.79f, -19.19f, 4.485f),
|
||||
new creature_type(18256, 530, -1540.56f, 7995.44f, -20.45f, 0.947f),
|
||||
new creature_type(18256, 530, -1546.95f, 8000.85f, -20.72f, 6.035f),
|
||||
new creature_type(18256, 530, -1595.31f, 7860.53f, -21.51f, 3.747f),
|
||||
new creature_type(18256, 530, -1642.31f, 7995.59f, -25.8f, 3.317f),
|
||||
new creature_type(18256, 530, -1545.46f, 7995.35f, -20.63f, 1.094f),
|
||||
new creature_type(18256, 530, -1487.58f, 7907.99f, -19.27f, 5.567f),
|
||||
new creature_type(18256, 530, -1651.54f, 7988.56f, -26.5289f, 2.98451f),
|
||||
new creature_type(18256, 530, -1602.46f, 7866.43f, -22.1177f, 4.74729f),
|
||||
new creature_type(18256, 530, -1591.22f, 7875.29f, -22.3536f, 4.34587f),
|
||||
new creature_type(18256, 530, -1603.75f, 8000.36f, -24.18f, 4.516f),
|
||||
new creature_type(18256, 530, -1585.73f, 7994.68f, -23.29f, 4.439f),
|
||||
new creature_type(18256, 530, -1595.5f, 7991.27f, -23.53f, 4.738f)
|
||||
};
|
||||
}
|
||||
|
||||
class OutdoorPvPNA : OutdoorPvP
|
||||
{
|
||||
public OutdoorPvPNA()
|
||||
{
|
||||
m_TypeId = OutdoorPvPTypes.Nagrand;
|
||||
m_obj = null;
|
||||
}
|
||||
|
||||
public override void HandleKillImpl(Player player, Unit killed)
|
||||
{
|
||||
if (killed.GetTypeId() == TypeId.Player && player.GetTeam() != killed.ToPlayer().GetTeam())
|
||||
{
|
||||
player.KilledMonsterCredit(NA_CREDIT_MARKER); // 0 guid, btw it isn't even used in killedmonster function :S
|
||||
if (player.GetTeam() == Team.Alliance)
|
||||
player.CastSpell(player, NA_KILL_TOKEN_ALLIANCE, true);
|
||||
else
|
||||
player.CastSpell(player, NA_KILL_TOKEN_HORDE, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool SetupOutdoorPvP()
|
||||
{
|
||||
// m_TypeId = OUTDOOR_PVP_NA; _MUST_ be set in ctor, because of spawns cleanup
|
||||
// add the zones affected by the pvp buff
|
||||
SetMapFromZone(NA_BUFF_ZONE);
|
||||
RegisterZone(NA_BUFF_ZONE);
|
||||
|
||||
// halaa
|
||||
m_obj = new OPvPCapturePointNA(this);
|
||||
|
||||
AddCapturePoint(m_obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void HandlePlayerEnterZone(Player player, uint zone)
|
||||
{
|
||||
// add buffs
|
||||
if (player.GetTeam() == m_obj.GetControllingFaction())
|
||||
player.CastSpell(player, NA_CAPTURE_BUFF, true);
|
||||
base.HandlePlayerEnterZone(player, zone);
|
||||
}
|
||||
|
||||
public override void HandlePlayerLeaveZone(Player player, uint zone)
|
||||
{
|
||||
// remove buffs
|
||||
player.RemoveAurasDueToSpell(NA_CAPTURE_BUFF);
|
||||
base.HandlePlayerLeaveZone(player, zone);
|
||||
}
|
||||
|
||||
public override void FillInitialWorldStates(InitWorldStates packet)
|
||||
{
|
||||
m_obj.FillInitialWorldStates(packet);
|
||||
}
|
||||
|
||||
public override void SendRemoveWorldStates(Player player)
|
||||
{
|
||||
player.SendUpdateWorldState(NA_UI_HORDE_GUARDS_SHOW, 0);
|
||||
player.SendUpdateWorldState(NA_UI_ALLIANCE_GUARDS_SHOW, 0);
|
||||
player.SendUpdateWorldState(NA_UI_GUARDS_MAX, 0);
|
||||
player.SendUpdateWorldState(NA_UI_GUARDS_LEFT, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_NORTH_NEU_H, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_NORTH_NEU_A, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_NORTH_H, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_NORTH_A, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_SOUTH_NEU_H, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_SOUTH_NEU_A, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_SOUTH_H, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_SOUTH_A, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_WEST_NEU_H, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_WEST_NEU_A, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_WEST_H, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_WEST_A, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_EAST_NEU_H, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_EAST_NEU_A, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_EAST_H, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_WYVERN_EAST_A, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_HALAA_NEUTRAL, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_HALAA_NEU_A, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_HALAA_NEU_H, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_HALAA_HORDE, 0);
|
||||
player.SendUpdateWorldState(NA_MAP_HALAA_ALLIANCE, 0);
|
||||
}
|
||||
|
||||
public override bool Update(uint diff)
|
||||
{
|
||||
return m_obj.Update(diff);
|
||||
}
|
||||
|
||||
OPvPCapturePointNA m_obj;
|
||||
}
|
||||
|
||||
class OPvPCapturePointNA : OPvPCapturePoint
|
||||
{
|
||||
public OPvPCapturePointNA(OutdoorPvP pvp) : base(pvp)
|
||||
{
|
||||
m_capturable = true;
|
||||
m_HalaaState = HALAA_N;
|
||||
m_RespawnTimer = Misc.RespawnTime;
|
||||
m_GuardCheckTimer = Misc.GuardCheckTime;
|
||||
SetCapturePointData(182210, 530, -1572.57f, 7945.3f, -22.475f, 2.05949f, 0.0f, 0.0f, 0.857167f, 0.515038f);
|
||||
}
|
||||
|
||||
uint GetAliveGuardsCount()
|
||||
{
|
||||
uint cnt = 0;
|
||||
foreach (var pair in m_Creatures)
|
||||
{
|
||||
switch (pair.Key)
|
||||
{
|
||||
case NA_NPC_GUARD_01:
|
||||
case NA_NPC_GUARD_02:
|
||||
case NA_NPC_GUARD_03:
|
||||
case NA_NPC_GUARD_04:
|
||||
case NA_NPC_GUARD_05:
|
||||
case NA_NPC_GUARD_06:
|
||||
case NA_NPC_GUARD_07:
|
||||
case NA_NPC_GUARD_08:
|
||||
case NA_NPC_GUARD_09:
|
||||
case NA_NPC_GUARD_10:
|
||||
case NA_NPC_GUARD_11:
|
||||
case NA_NPC_GUARD_12:
|
||||
case NA_NPC_GUARD_13:
|
||||
case NA_NPC_GUARD_14:
|
||||
case NA_NPC_GUARD_15:
|
||||
{
|
||||
var bounds = m_PvP.GetMap().GetCreatureBySpawnIdStore().LookupByKey(pair.Value);
|
||||
foreach (var creature in bounds)
|
||||
if (creature.IsAlive())
|
||||
++cnt;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
public Team GetControllingFaction()
|
||||
{
|
||||
return m_ControllingFaction;
|
||||
}
|
||||
|
||||
void SpawnNPCsForTeam(Team team)
|
||||
{
|
||||
creature_type[] creatures = null;
|
||||
if (team == Team.Alliance)
|
||||
creatures = Misc.AllianceControlNPCs;
|
||||
else if (team == Team.Horde)
|
||||
creatures = Misc.HordeControlNPCs;
|
||||
else
|
||||
return;
|
||||
for (int i = 0; i < NA_CONTROL_NPC_NUM; ++i)
|
||||
AddCreature(i, creatures[i].entry, creatures[i].map, creatures[i].x, creatures[i].y, creatures[i].z, creatures[i].o, OutdoorPvP.GetTeamIdByTeam(team), 1000000);
|
||||
}
|
||||
|
||||
void DeSpawnNPCs()
|
||||
{
|
||||
for (uint i = 0; i < NA_CONTROL_NPC_NUM; ++i)
|
||||
DelCreature(i);
|
||||
}
|
||||
|
||||
void SpawnGOsForTeam(Team team)
|
||||
{
|
||||
go_type[] gos = null;
|
||||
if (team == Team.Alliance)
|
||||
gos = Misc.AllianceControlGOs;
|
||||
else if (team == Team.Horde)
|
||||
gos = Misc.HordeControlGOs;
|
||||
else
|
||||
return;
|
||||
for (uint i = 0; i < NA_CONTROL_GO_NUM; ++i)
|
||||
{
|
||||
if (i == NA_ROOST_S ||
|
||||
i == NA_ROOST_W ||
|
||||
i == NA_ROOST_N ||
|
||||
i == NA_ROOST_E ||
|
||||
i == NA_BOMB_WAGON_S ||
|
||||
i == NA_BOMB_WAGON_W ||
|
||||
i == NA_BOMB_WAGON_N ||
|
||||
i == NA_BOMB_WAGON_E)
|
||||
continue; // roosts and bomb wagons are spawned when someone uses the matching destroyed roost
|
||||
AddObject(i, gos[i].entry, gos[i].map, gos[i].x, gos[i].y, gos[i].z, gos[i].o, gos[i].rot0, gos[i].rot1, gos[i].rot2, gos[i].rot3);
|
||||
}
|
||||
}
|
||||
|
||||
void DeSpawnGOs()
|
||||
{
|
||||
for (uint i = 0; i < NA_CONTROL_GO_NUM; ++i)
|
||||
{
|
||||
DelObject(i);
|
||||
}
|
||||
}
|
||||
|
||||
void FactionTakeOver(Team team)
|
||||
{
|
||||
if (m_ControllingFaction != 0)
|
||||
Global.ObjectMgr.RemoveGraveYardLink(NA_HALAA_GRAVEYARD, NA_HALAA_GRAVEYARD_ZONE, m_ControllingFaction, false);
|
||||
|
||||
m_ControllingFaction = team;
|
||||
if (m_ControllingFaction != 0)
|
||||
Global.ObjectMgr.AddGraveYardLink(NA_HALAA_GRAVEYARD, NA_HALAA_GRAVEYARD_ZONE, m_ControllingFaction, false);
|
||||
DeSpawnGOs();
|
||||
DeSpawnNPCs();
|
||||
SpawnGOsForTeam(team);
|
||||
SpawnNPCsForTeam(team);
|
||||
m_GuardsAlive = Misc.MaxGuards;
|
||||
m_capturable = false;
|
||||
this.UpdateHalaaWorldState();
|
||||
if (team == Team.Alliance)
|
||||
{
|
||||
m_WyvernStateSouth = WYVERN_NEU_HORDE;
|
||||
m_WyvernStateNorth = WYVERN_NEU_HORDE;
|
||||
m_WyvernStateEast = WYVERN_NEU_HORDE;
|
||||
m_WyvernStateWest = WYVERN_NEU_HORDE;
|
||||
m_PvP.TeamApplyBuff(TeamId.Alliance, NA_CAPTURE_BUFF);
|
||||
m_PvP.SendUpdateWorldState(NA_UI_HORDE_GUARDS_SHOW, 0);
|
||||
m_PvP.SendUpdateWorldState(NA_UI_ALLIANCE_GUARDS_SHOW, 1);
|
||||
m_PvP.SendUpdateWorldState(NA_UI_GUARDS_LEFT, m_GuardsAlive);
|
||||
m_PvP.SendDefenseMessage(NA_HALAA_GRAVEYARD_ZONE, TEXT_HALAA_TAKEN_ALLIANCE);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_WyvernStateSouth = WYVERN_NEU_ALLIANCE;
|
||||
m_WyvernStateNorth = WYVERN_NEU_ALLIANCE;
|
||||
m_WyvernStateEast = WYVERN_NEU_ALLIANCE;
|
||||
m_WyvernStateWest = WYVERN_NEU_ALLIANCE;
|
||||
m_PvP.TeamApplyBuff(TeamId.Horde, NA_CAPTURE_BUFF);
|
||||
m_PvP.SendUpdateWorldState(NA_UI_HORDE_GUARDS_SHOW, 1);
|
||||
m_PvP.SendUpdateWorldState(NA_UI_ALLIANCE_GUARDS_SHOW, 0);
|
||||
m_PvP.SendUpdateWorldState(NA_UI_GUARDS_LEFT, m_GuardsAlive);
|
||||
m_PvP.SendDefenseMessage(NA_HALAA_GRAVEYARD_ZONE, TEXT_HALAA_TAKEN_HORDE);
|
||||
}
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_S);
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_N);
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_W);
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_E);
|
||||
}
|
||||
|
||||
public override void FillInitialWorldStates(InitWorldStates packet)
|
||||
{
|
||||
if (m_ControllingFaction == Team.Alliance)
|
||||
{
|
||||
packet.AddState(NA_UI_HORDE_GUARDS_SHOW, 0);
|
||||
packet.AddState(NA_UI_ALLIANCE_GUARDS_SHOW, 1);
|
||||
}
|
||||
else if (m_ControllingFaction == Team.Horde)
|
||||
{
|
||||
packet.AddState(NA_UI_HORDE_GUARDS_SHOW, 1);
|
||||
packet.AddState(NA_UI_ALLIANCE_GUARDS_SHOW, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.AddState(NA_UI_HORDE_GUARDS_SHOW, 0);
|
||||
packet.AddState(NA_UI_ALLIANCE_GUARDS_SHOW, 0);
|
||||
}
|
||||
|
||||
packet.AddState(NA_UI_GUARDS_MAX, Misc.MaxGuards);
|
||||
packet.AddState(NA_UI_GUARDS_LEFT, m_GuardsAlive);
|
||||
|
||||
packet.AddState(NA_MAP_WYVERN_NORTH_NEU_A, (m_WyvernStateNorth & WYVERN_NEU_HORDE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_NORTH_NEU_A, (m_WyvernStateNorth & WYVERN_NEU_ALLIANCE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_NORTH_H, (m_WyvernStateNorth & WYVERN_HORDE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_NORTH_A, (m_WyvernStateNorth & WYVERN_ALLIANCE) != 0);
|
||||
|
||||
packet.AddState(NA_MAP_WYVERN_SOUTH_NEU_H, (m_WyvernStateSouth & WYVERN_NEU_HORDE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_SOUTH_NEU_A, (m_WyvernStateSouth & WYVERN_NEU_ALLIANCE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_SOUTH_H, (m_WyvernStateSouth & WYVERN_HORDE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_SOUTH_A, (m_WyvernStateSouth & WYVERN_ALLIANCE) != 0);
|
||||
|
||||
packet.AddState(NA_MAP_WYVERN_WEST_NEU_H, (m_WyvernStateWest & WYVERN_NEU_HORDE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_WEST_NEU_A, (m_WyvernStateWest & WYVERN_NEU_ALLIANCE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_WEST_H, (m_WyvernStateWest & WYVERN_HORDE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_WEST_A, (m_WyvernStateWest & WYVERN_ALLIANCE) != 0);
|
||||
|
||||
packet.AddState(NA_MAP_WYVERN_EAST_NEU_H, (m_WyvernStateEast & WYVERN_NEU_HORDE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_EAST_NEU_A, (m_WyvernStateEast & WYVERN_NEU_ALLIANCE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_EAST_H, (m_WyvernStateEast & WYVERN_HORDE) != 0);
|
||||
packet.AddState(NA_MAP_WYVERN_EAST_A, (m_WyvernStateEast & WYVERN_ALLIANCE) != 0);
|
||||
|
||||
packet.AddState(NA_MAP_HALAA_NEUTRAL, (m_HalaaState & HALAA_N) != 0);
|
||||
packet.AddState(NA_MAP_HALAA_NEU_A, (m_HalaaState & HALAA_N_A) != 0);
|
||||
packet.AddState(NA_MAP_HALAA_NEU_H, (m_HalaaState & HALAA_N_H) != 0);
|
||||
packet.AddState(NA_MAP_HALAA_HORDE, (m_HalaaState & HALAA_H) != 0);
|
||||
packet.AddState(NA_MAP_HALAA_ALLIANCE, (m_HalaaState & HALAA_A) != 0);
|
||||
}
|
||||
|
||||
public override bool HandleCustomSpell(Player player, uint spellId, GameObject go)
|
||||
{
|
||||
List<uint> nodes = new List<uint>();
|
||||
|
||||
bool retval = false;
|
||||
switch (spellId)
|
||||
{
|
||||
case NA_SPELL_FLY_NORTH:
|
||||
nodes[0] = Misc.FlightPathStartNodes[NA_ROOST_N];
|
||||
nodes[1] = Misc.FlightPathEndNodes[NA_ROOST_N];
|
||||
player.ActivateTaxiPathTo(nodes);
|
||||
player.SetFlag(PlayerFields.Flags, PlayerFlags.InPVP);
|
||||
player.UpdatePvP(true, true);
|
||||
retval = true;
|
||||
break;
|
||||
case NA_SPELL_FLY_SOUTH:
|
||||
nodes[0] = Misc.FlightPathStartNodes[NA_ROOST_S];
|
||||
nodes[1] = Misc.FlightPathEndNodes[NA_ROOST_S];
|
||||
player.ActivateTaxiPathTo(nodes);
|
||||
player.SetFlag(PlayerFields.Flags, PlayerFlags.InPVP);
|
||||
player.UpdatePvP(true, true);
|
||||
retval = true;
|
||||
break;
|
||||
case NA_SPELL_FLY_WEST:
|
||||
nodes[0] = Misc.FlightPathStartNodes[NA_ROOST_W];
|
||||
nodes[1] = Misc.FlightPathEndNodes[NA_ROOST_W];
|
||||
player.ActivateTaxiPathTo(nodes);
|
||||
player.SetFlag(PlayerFields.Flags, PlayerFlags.InPVP);
|
||||
player.UpdatePvP(true, true);
|
||||
retval = true;
|
||||
break;
|
||||
case NA_SPELL_FLY_EAST:
|
||||
nodes[0] = Misc.FlightPathStartNodes[NA_ROOST_E];
|
||||
nodes[1] = Misc.FlightPathEndNodes[NA_ROOST_E];
|
||||
player.ActivateTaxiPathTo(nodes);
|
||||
player.SetFlag(PlayerFields.Flags, PlayerFlags.InPVP);
|
||||
player.UpdatePvP(true, true);
|
||||
retval = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (retval)
|
||||
{
|
||||
//Adding items
|
||||
uint noSpaceForCount = 0;
|
||||
|
||||
// check space and find places
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
|
||||
uint count = 10;
|
||||
uint itemid = 24538;
|
||||
// bomb id count
|
||||
InventoryResult msg = player.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, itemid, count, out noSpaceForCount);
|
||||
if (msg != InventoryResult.Ok) // convert to possible store amount
|
||||
count -= noSpaceForCount;
|
||||
|
||||
if (count == 0 || dest.Empty()) // can't add any
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Item item = player.StoreNewItem(dest, itemid, true);
|
||||
if (count > 0 && item)
|
||||
{
|
||||
player.SendNewItem(item, count, true, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int HandleOpenGo(Player player, GameObject go)
|
||||
{
|
||||
int retval = base.HandleOpenGo(player, go);
|
||||
if (retval >= 0)
|
||||
{
|
||||
go_type[] gos = null;
|
||||
if (m_ControllingFaction == Team.Alliance)
|
||||
gos = Misc.AllianceControlGOs;
|
||||
else if (m_ControllingFaction == Team.Horde)
|
||||
gos = Misc.HordeControlGOs;
|
||||
else
|
||||
return -1;
|
||||
|
||||
int del = -1;
|
||||
int del2 = -1;
|
||||
int add = -1;
|
||||
int add2 = -1;
|
||||
|
||||
switch (retval)
|
||||
{
|
||||
case NA_DESTROYED_ROOST_S:
|
||||
del = NA_DESTROYED_ROOST_S;
|
||||
add = NA_ROOST_S;
|
||||
add2 = NA_BOMB_WAGON_S;
|
||||
if (m_ControllingFaction == Team.Horde)
|
||||
m_WyvernStateSouth = WYVERN_ALLIANCE;
|
||||
else
|
||||
m_WyvernStateSouth = WYVERN_HORDE;
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_S);
|
||||
break;
|
||||
case NA_DESTROYED_ROOST_N:
|
||||
del = NA_DESTROYED_ROOST_N;
|
||||
add = NA_ROOST_N;
|
||||
add2 = NA_BOMB_WAGON_N;
|
||||
if (m_ControllingFaction == Team.Horde)
|
||||
m_WyvernStateNorth = WYVERN_ALLIANCE;
|
||||
else
|
||||
m_WyvernStateNorth = WYVERN_HORDE;
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_N);
|
||||
break;
|
||||
case NA_DESTROYED_ROOST_W:
|
||||
del = NA_DESTROYED_ROOST_W;
|
||||
add = NA_ROOST_W;
|
||||
add2 = NA_BOMB_WAGON_W;
|
||||
if (m_ControllingFaction == Team.Horde)
|
||||
m_WyvernStateWest = WYVERN_ALLIANCE;
|
||||
else
|
||||
m_WyvernStateWest = WYVERN_HORDE;
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_W);
|
||||
break;
|
||||
case NA_DESTROYED_ROOST_E:
|
||||
del = NA_DESTROYED_ROOST_E;
|
||||
add = NA_ROOST_E;
|
||||
add2 = NA_BOMB_WAGON_E;
|
||||
if (m_ControllingFaction == Team.Horde)
|
||||
m_WyvernStateEast = WYVERN_ALLIANCE;
|
||||
else
|
||||
m_WyvernStateEast = WYVERN_HORDE;
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_E);
|
||||
break;
|
||||
case NA_BOMB_WAGON_S:
|
||||
del = NA_BOMB_WAGON_S;
|
||||
del2 = NA_ROOST_S;
|
||||
add = NA_DESTROYED_ROOST_S;
|
||||
if (m_ControllingFaction == Team.Horde)
|
||||
m_WyvernStateSouth = WYVERN_NEU_ALLIANCE;
|
||||
else
|
||||
m_WyvernStateSouth = WYVERN_NEU_HORDE;
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_S);
|
||||
break;
|
||||
case NA_BOMB_WAGON_N:
|
||||
del = NA_BOMB_WAGON_N;
|
||||
del2 = NA_ROOST_N;
|
||||
add = NA_DESTROYED_ROOST_N;
|
||||
if (m_ControllingFaction == Team.Horde)
|
||||
m_WyvernStateNorth = WYVERN_NEU_ALLIANCE;
|
||||
else
|
||||
m_WyvernStateNorth = WYVERN_NEU_HORDE;
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_N);
|
||||
break;
|
||||
case NA_BOMB_WAGON_W:
|
||||
del = NA_BOMB_WAGON_W;
|
||||
del2 = NA_ROOST_W;
|
||||
add = NA_DESTROYED_ROOST_W;
|
||||
if (m_ControllingFaction == Team.Horde)
|
||||
m_WyvernStateWest = WYVERN_NEU_ALLIANCE;
|
||||
else
|
||||
m_WyvernStateWest = WYVERN_NEU_HORDE;
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_W);
|
||||
break;
|
||||
case NA_BOMB_WAGON_E:
|
||||
del = NA_BOMB_WAGON_E;
|
||||
del2 = NA_ROOST_E;
|
||||
add = NA_DESTROYED_ROOST_E;
|
||||
if (m_ControllingFaction == Team.Horde)
|
||||
m_WyvernStateEast = WYVERN_NEU_ALLIANCE;
|
||||
else
|
||||
m_WyvernStateEast = WYVERN_NEU_HORDE;
|
||||
UpdateWyvernRoostWorldState(NA_ROOST_E);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (del > -1)
|
||||
DelObject((uint)del);
|
||||
|
||||
if (del2 > -1)
|
||||
DelObject((uint)del2);
|
||||
|
||||
if (add > -1)
|
||||
AddObject((uint)add, gos[add].entry, gos[add].map, gos[add].x, gos[add].y, gos[add].z, gos[add].o, gos[add].rot0, gos[add].rot1, gos[add].rot2, gos[add].rot3);
|
||||
|
||||
if (add2 > -1)
|
||||
AddObject((uint)add2, gos[add2].entry, gos[add2].map, gos[add2].x, gos[add2].y, gos[add2].z, gos[add2].o, gos[add2].rot0, gos[add2].rot1, gos[add2].rot2, gos[add2].rot3);
|
||||
|
||||
return retval;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override bool Update(uint diff)
|
||||
{
|
||||
// let the controlling faction advance in phase
|
||||
bool capturable = false;
|
||||
if (m_ControllingFaction == Team.Alliance && m_activePlayers[0].Count > m_activePlayers[1].Count)
|
||||
capturable = true;
|
||||
else if (m_ControllingFaction == Team.Horde && m_activePlayers[0].Count < m_activePlayers[1].Count)
|
||||
capturable = true;
|
||||
|
||||
if (m_GuardCheckTimer < diff)
|
||||
{
|
||||
m_GuardCheckTimer = Misc.GuardCheckTime;
|
||||
uint cnt = GetAliveGuardsCount();
|
||||
if (cnt != m_GuardsAlive)
|
||||
{
|
||||
m_GuardsAlive = cnt;
|
||||
if (m_GuardsAlive == 0)
|
||||
m_capturable = true;
|
||||
// update the guard count for the players in zone
|
||||
m_PvP.SendUpdateWorldState(NA_UI_GUARDS_LEFT, m_GuardsAlive);
|
||||
}
|
||||
}
|
||||
else m_GuardCheckTimer -= diff;
|
||||
|
||||
if (m_capturable || capturable)
|
||||
{
|
||||
if (m_RespawnTimer < diff)
|
||||
{
|
||||
// if the guards have been killed, then the challenger has one hour to take over halaa.
|
||||
// in case they fail to do it, the guards are respawned, and they have to start again.
|
||||
if (m_ControllingFaction != 0)
|
||||
FactionTakeOver(m_ControllingFaction);
|
||||
m_RespawnTimer = NA_RESPAWN_TIME;
|
||||
}
|
||||
else m_RespawnTimer -= diff;
|
||||
|
||||
return base.Update(diff);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void ChangeState()
|
||||
{
|
||||
uint artkit = 21;
|
||||
switch (m_State)
|
||||
{
|
||||
case OBJECTIVESTATE_NEUTRAL:
|
||||
m_HalaaState = HALAA_N;
|
||||
break;
|
||||
case OBJECTIVESTATE_ALLIANCE:
|
||||
m_HalaaState = HALAA_A;
|
||||
FactionTakeOver(Team.Alliance);
|
||||
artkit = 2;
|
||||
break;
|
||||
case OBJECTIVESTATE_HORDE:
|
||||
m_HalaaState = HALAA_H;
|
||||
FactionTakeOver(Team.Horde);
|
||||
artkit = 1;
|
||||
break;
|
||||
case OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE:
|
||||
m_HalaaState = HALAA_N_A;
|
||||
break;
|
||||
case OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE:
|
||||
m_HalaaState = HALAA_N_H;
|
||||
break;
|
||||
case OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE:
|
||||
m_HalaaState = HALAA_N_A;
|
||||
artkit = 2;
|
||||
break;
|
||||
case OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE:
|
||||
m_HalaaState = HALAA_N_H;
|
||||
artkit = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
var bounds = Global.MapMgr.FindMap(530, 0).GetGameObjectBySpawnIdStore().LookupByKey(m_capturePointSpawnId);
|
||||
foreach (var itr in bounds)
|
||||
itr.SetGoArtKit((byte)artkit);
|
||||
|
||||
UpdateHalaaWorldState();
|
||||
}
|
||||
|
||||
void UpdateHalaaWorldState()
|
||||
{
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_HALAA_NEUTRAL, (m_HalaaState & HALAA_N) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_HALAA_NEU_A, (m_HalaaState & HALAA_N_A) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_HALAA_NEU_H, (m_HalaaState & HALAA_N_H) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_HALAA_HORDE, (m_HalaaState & HALAA_H) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_HALAA_ALLIANCE, (m_HalaaState & HALAA_A) != 0);
|
||||
}
|
||||
|
||||
void UpdateWyvernRoostWorldState(uint roost)
|
||||
{
|
||||
switch (roost)
|
||||
{
|
||||
case NA_ROOST_S:
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_SOUTH_NEU_H, (m_WyvernStateSouth & WYVERN_NEU_HORDE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_SOUTH_NEU_A, (m_WyvernStateSouth & WYVERN_NEU_ALLIANCE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_SOUTH_H, (m_WyvernStateSouth & WYVERN_HORDE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_SOUTH_A, (m_WyvernStateSouth & WYVERN_ALLIANCE) != 0);
|
||||
break;
|
||||
case NA_ROOST_N:
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_NORTH_NEU_H, (m_WyvernStateNorth & WYVERN_NEU_HORDE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_NORTH_NEU_A, (m_WyvernStateNorth & WYVERN_NEU_ALLIANCE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_NORTH_H, (m_WyvernStateNorth & WYVERN_HORDE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_NORTH_A, (m_WyvernStateNorth & WYVERN_ALLIANCE) != 0);
|
||||
break;
|
||||
case NA_ROOST_W:
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_WEST_NEU_H, (m_WyvernStateWest & WYVERN_NEU_HORDE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_WEST_NEU_A, (m_WyvernStateWest & WYVERN_NEU_ALLIANCE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_WEST_H, (m_WyvernStateWest & WYVERN_HORDE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_WEST_A, (m_WyvernStateWest & WYVERN_ALLIANCE) != 0);
|
||||
break;
|
||||
case NA_ROOST_E:
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_EAST_NEU_H, (m_WyvernStateEast & WYVERN_NEU_HORDE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_EAST_NEU_A, (m_WyvernStateEast & WYVERN_NEU_ALLIANCE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_EAST_H, (m_WyvernStateEast & WYVERN_HORDE) != 0);
|
||||
m_PvP.SendUpdateWorldState(NA_MAP_WYVERN_EAST_A, (m_WyvernStateEast & WYVERN_ALLIANCE) != 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool m_capturable;
|
||||
|
||||
uint m_GuardsAlive;
|
||||
|
||||
Team m_ControllingFaction;
|
||||
|
||||
uint m_WyvernStateNorth;
|
||||
uint m_WyvernStateSouth;
|
||||
uint m_WyvernStateEast;
|
||||
uint m_WyvernStateWest;
|
||||
|
||||
uint m_HalaaState;
|
||||
|
||||
uint m_RespawnTimer;
|
||||
|
||||
uint m_GuardCheckTimer;
|
||||
}
|
||||
|
||||
class OutdoorPvP_nagrand : OutdoorPvPScript
|
||||
{
|
||||
public OutdoorPvP_nagrand() : base("outdoorpvp_na") { }
|
||||
|
||||
public override OutdoorPvP GetOutdoorPvP()
|
||||
{
|
||||
return new OutdoorPvPNA();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user