Removed not used files
This commit is contained in:
@@ -1,273 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
|
||||
class Metric
|
||||
{
|
||||
void Initialize(string realmName, Action overallStatusLogger)
|
||||
{
|
||||
_realmName = realmName;
|
||||
_batchTimer = new Timer();
|
||||
_overallStatusTimer = new Timer();
|
||||
_overallStatusLogger = overallStatusLogger;
|
||||
LoadFromConfigs();
|
||||
}
|
||||
|
||||
bool Connect()
|
||||
{
|
||||
_dataStream.Connect(_hostname, _port);
|
||||
auto error = _dataStream.Client.error();
|
||||
if (error)
|
||||
{
|
||||
TC_LOG_ERROR("metric", "Error connecting to '%s:%s', disabling Metric. Error message : %s",
|
||||
_hostname.c_str(), _port.c_str(), error.message().c_str());
|
||||
_enabled = false;
|
||||
return false;
|
||||
}
|
||||
_dataStream.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void LoadFromConfigs()
|
||||
{
|
||||
bool previousValue = _enabled;
|
||||
_enabled = sConfigMgr.GetBoolDefault("Metric.Enable", false);
|
||||
_updateInterval = sConfigMgr.GetIntDefault("Metric.Interval", 10);
|
||||
if (_updateInterval < 1)
|
||||
{
|
||||
TC_LOG_ERROR("metric", "'Metric.Interval' config set to %d, overriding to 1.", _updateInterval);
|
||||
_updateInterval = 1;
|
||||
}
|
||||
|
||||
_overallStatusTimerInterval = sConfigMgr.GetIntDefault("Metric.OverallStatusInterval", 1);
|
||||
if (_overallStatusTimerInterval < 1)
|
||||
{
|
||||
TC_LOG_ERROR("metric", "'Metric.OverallStatusInterval' config set to %d, overriding to 1.", _overallStatusTimerInterval);
|
||||
_overallStatusTimerInterval = 1;
|
||||
}
|
||||
|
||||
// Schedule a send at this point only if the config changed from Disabled to Enabled.
|
||||
// Cancel any scheduled operation if the config changed from Enabled to Disabled.
|
||||
if (_enabled && !previousValue)
|
||||
{
|
||||
std::string connectionInfo = sConfigMgr.GetStringDefault("Metric.ConnectionInfo", "");
|
||||
if (connectionInfo.empty())
|
||||
{
|
||||
TC_LOG_ERROR("metric", "'Metric.ConnectionInfo' not specified in configuration file.");
|
||||
return;
|
||||
}
|
||||
|
||||
Tokenizer tokens(connectionInfo, ';');
|
||||
if (tokens.size() != 3)
|
||||
{
|
||||
TC_LOG_ERROR("metric", "'Metric.ConnectionInfo' specified with wrong format in configuration file.");
|
||||
return;
|
||||
}
|
||||
|
||||
_hostname.assign(tokens[0]);
|
||||
_port.assign(tokens[1]);
|
||||
_databaseName.assign(tokens[2]);
|
||||
Connect();
|
||||
|
||||
ScheduleSend();
|
||||
ScheduleOverallStatusLog();
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_overallStatusTimerTriggered)
|
||||
{
|
||||
_overallStatusTimerTriggered = false;
|
||||
_overallStatusLogger();
|
||||
}
|
||||
}
|
||||
|
||||
void LogEvent(string category, string title, string description)
|
||||
{
|
||||
MetricData data = new MetricData();
|
||||
data.Category = category;
|
||||
data.Timestamp = system_clock::now();
|
||||
data.Type = METRIC_DATA_EVENT;
|
||||
data.Title = title;
|
||||
data.Text = description;
|
||||
|
||||
_queuedData.Enqueue(data);
|
||||
}
|
||||
|
||||
void SendBatch()
|
||||
{
|
||||
std::stringstream batchedData;
|
||||
MetricData data;
|
||||
bool firstLoop = true;
|
||||
while (_queuedData.Dequeue(data))
|
||||
{
|
||||
if (!firstLoop)
|
||||
batchedData << "\n";
|
||||
|
||||
batchedData << data.Category;
|
||||
if (!_realmName.empty())
|
||||
batchedData << ",realm=" << _realmName;
|
||||
|
||||
batchedData << " ";
|
||||
|
||||
switch (data.Type)
|
||||
{
|
||||
case METRIC_DATA_VALUE:
|
||||
batchedData << "value=" << data.Value;
|
||||
break;
|
||||
case METRIC_DATA_EVENT:
|
||||
batchedData << "title=\"" << data.Title << "\",text=\"" << data.Text << "\"";
|
||||
break;
|
||||
}
|
||||
|
||||
batchedData << " ";
|
||||
|
||||
batchedData << std::to_string(duration_cast<nanoseconds>(data.Timestamp.time_since_epoch()).count());
|
||||
|
||||
firstLoop = false;
|
||||
delete data;
|
||||
}
|
||||
|
||||
// Check if there's any data to send
|
||||
if (batchedData.tellp() == std::streampos(0))
|
||||
{
|
||||
ScheduleSend();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_dataStream.good() && !Connect())
|
||||
return;
|
||||
|
||||
var blah = new InfluxDB.Net.InfluxDb(_hostname, "root", "root", InfluxDB.Net.Enums.InfluxVersion.v010x);
|
||||
InfluxDB.Net.Models.Serie b = new InfluxDB.Net.Models.Serie();
|
||||
b.Columns
|
||||
_dataStream.UploadString( << "POST " << "/write?db=" << _databaseName << " HTTP/1.1\r\n";
|
||||
_dataStream << "Host: " << _hostname << ":" << _port << "\r\n";
|
||||
_dataStream << "Accept: */*\r\n";
|
||||
_dataStream << "Content-Type: application/octet-stream\r\n";
|
||||
_dataStream << "Content-Transfer-Encoding: binary\r\n";
|
||||
|
||||
_dataStream << "Content-Length: " << std::to_string(batchedData.tellp()) << "\r\n\r\n";
|
||||
_dataStream << batchedData.rdbuf();
|
||||
|
||||
std::string http_version;
|
||||
_dataStream >> http_version;
|
||||
unsigned int status_code = 0;
|
||||
_dataStream >> status_code;
|
||||
if (status_code != 204)
|
||||
{
|
||||
TC_LOG_ERROR("metric", "Error sending data, returned HTTP code: %u", status_code);
|
||||
}
|
||||
|
||||
// Read and ignore the status description
|
||||
std::string status_description;
|
||||
std::getline(_dataStream, status_description);
|
||||
// Read headers
|
||||
std::string header;
|
||||
while (std::getline(_dataStream, header) && header != "\r")
|
||||
{
|
||||
if (header == "Connection: close\r")
|
||||
_dataStream.close();
|
||||
}
|
||||
|
||||
ScheduleSend();
|
||||
}
|
||||
|
||||
void ScheduleSend()
|
||||
{
|
||||
if (_enabled)
|
||||
{
|
||||
_batchTimer.expires_from_now(boost::posix_time::seconds(_updateInterval));
|
||||
_batchTimer.async_wait(std::bind(&SendBatch, this));
|
||||
}
|
||||
else
|
||||
{
|
||||
_dataStream.close();
|
||||
MetricData* data;
|
||||
// Clear the queue
|
||||
while (_queuedData.Dequeue(data))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void ForceSend()
|
||||
{
|
||||
// Send what's queued only if io_service is stopped (so only on shutdown)
|
||||
if (_enabled && _batchTimer.get_io_service().stopped())
|
||||
SendBatch();
|
||||
}
|
||||
|
||||
void ScheduleOverallStatusLog()
|
||||
{
|
||||
if (_enabled)
|
||||
{
|
||||
_overallStatusTimer.expires_from_now(boost::posix_time::seconds(_overallStatusTimerInterval));
|
||||
_overallStatusTimer.async_wait([this](const boost::system::error_code&)
|
||||
{
|
||||
_overallStatusTimerTriggered = true;
|
||||
ScheduleOverallStatusLog();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static string FormatInfluxDBValue<T>(T value) { return Convert.ToString(value) + 'i'; }
|
||||
|
||||
static string FormatInfluxDBValue(string value)
|
||||
{
|
||||
return '"' + boost::replace_all_copy(value, "\"", "\\\"") + '"';
|
||||
}
|
||||
static string FormatInfluxDBValue(bool value) { return value ? "t" : "f"; }
|
||||
static string FormatInfluxDBValue(char[] value) { return FormatInfluxDBValue(new string(value)); }
|
||||
static string FormatInfluxDBValue(double value) { return Convert.ToString(value); }
|
||||
static string FormatInfluxDBValue(float value) { return FormatInfluxDBValue((double)value); }
|
||||
|
||||
void LogValue<T>(string category, T value)
|
||||
{
|
||||
MetricData data = new MetricData();
|
||||
data.Category = category;
|
||||
data.Timestamp = DateTime.Now;
|
||||
data.Type = MetricDataType.Value;
|
||||
data.Value = FormatInfluxDBValue(value);
|
||||
|
||||
_queuedData.Enqueue(data);
|
||||
}
|
||||
|
||||
System.Net.WebClient _dataStream;
|
||||
MPSCQueue<MetricData> _queuedData;
|
||||
Timer _batchTimer;
|
||||
Timer _overallStatusTimer;
|
||||
int _updateInterval = 0;
|
||||
int _overallStatusTimerInterval = 0;
|
||||
bool _enabled = false;
|
||||
bool _overallStatusTimerTriggered = false;
|
||||
string _hostname;
|
||||
string _port;
|
||||
string _databaseName;
|
||||
Action _overallStatusLogger;
|
||||
string _realmName;
|
||||
}
|
||||
|
||||
struct MetricData
|
||||
{
|
||||
public string Category;
|
||||
public DateTime Timestamp;
|
||||
public MetricDataType Type;
|
||||
|
||||
// LogValue-specific fields
|
||||
public string Value;
|
||||
|
||||
// LogEvent-specific fields
|
||||
public string Title;
|
||||
public string Text;
|
||||
}
|
||||
|
||||
enum MetricDataType
|
||||
{
|
||||
Value,
|
||||
Event
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,755 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,756 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Game.Scripting;
|
||||
using Game.Maps;
|
||||
using Game.WorldEntities;
|
||||
using Framework.Util;
|
||||
using Framework.Constants;
|
||||
using Game.Spells;
|
||||
using Game;
|
||||
|
||||
namespace Scripts.Northrend.VioletHold
|
||||
{
|
||||
class instance_violet_hold : InstanceMapScript
|
||||
{
|
||||
public instance_violet_hold() : base("instance_violet_hold", 608) { }
|
||||
|
||||
public override InstanceScript GetInstanceScript(InstanceMap map)
|
||||
{
|
||||
return new instance_violet_hold_InstanceMapScript(map);
|
||||
}
|
||||
|
||||
class instance_violet_hold_InstanceMapScript : InstanceScript
|
||||
{
|
||||
public instance_violet_hold_InstanceMapScript(Map map) : base(map) { }
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
uiMoragg = 0;
|
||||
uiErekem = 0;
|
||||
uiIchoron = 0;
|
||||
uiLavanthor = 0;
|
||||
uiXevozz = 0;
|
||||
uiZuramat = 0;
|
||||
uiCyanigosa = 0;
|
||||
uiSinclari = 0;
|
||||
|
||||
uiMoraggCell = 0;
|
||||
uiErekemCell = 0;
|
||||
uiErekemGuard[0] = 0;
|
||||
uiErekemGuard[1] = 0;
|
||||
uiIchoronCell = 0;
|
||||
uiLavanthorCell = 0;
|
||||
uiXevozzCell = 0;
|
||||
uiZuramatCell = 0;
|
||||
uiMainDoor = 0;
|
||||
uiTeleportationPortal = 0;
|
||||
uiSaboteurPortal = 0;
|
||||
|
||||
trashMobs.Clear();
|
||||
|
||||
uiRemoveNpc = 0;
|
||||
|
||||
uiDoorIntegrity = 100;
|
||||
|
||||
uiWaveCount = 0;
|
||||
uiLocation = (byte)RandomHelper.URand(0, 5);
|
||||
uiFirstBoss = 0;
|
||||
uiSecondBoss = 0;
|
||||
uiCountErekemGuards = 0;
|
||||
uiCountActivationCrystals = 0;
|
||||
uiCyanigosaEventPhase = 1;
|
||||
|
||||
uiActivationTimer = 5000;
|
||||
uiDoorSpellTimer = 2000;
|
||||
uiCyanigosaEventTimer = 3 * Time.InMilliseconds;
|
||||
|
||||
bActive = false;
|
||||
bIsDoorSpellCast = false;
|
||||
bCrystalActivated = false;
|
||||
defenseless = true;
|
||||
uiMainEventPhase = EncounterState.NotStarted;
|
||||
}
|
||||
|
||||
public override bool IsEncounterInProgress()
|
||||
{
|
||||
for (byte i = 0; i < MAX_ENCOUNTER; ++i)
|
||||
if ((EncounterState)m_auiEncounter[i] == EncounterState.InProgress)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnCreatureCreate(Creature creature)
|
||||
{
|
||||
switch (creature.GetEntry())
|
||||
{
|
||||
case CREATURE_XEVOZZ:
|
||||
uiXevozz = creature.GetGUID();
|
||||
break;
|
||||
case CREATURE_LAVANTHOR:
|
||||
uiLavanthor = creature.GetGUID();
|
||||
break;
|
||||
case CREATURE_ICHORON:
|
||||
uiIchoron = creature.GetGUID();
|
||||
break;
|
||||
case CREATURE_ZURAMAT:
|
||||
uiZuramat = creature.GetGUID();
|
||||
break;
|
||||
case CREATURE_EREKEM:
|
||||
uiErekem = creature.GetGUID();
|
||||
break;
|
||||
case CREATURE_EREKEM_GUARD:
|
||||
if (uiCountErekemGuards < 2)
|
||||
{
|
||||
uiErekemGuard[uiCountErekemGuards++] = creature.GetGUID();
|
||||
creature.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.NonAttackable);
|
||||
}
|
||||
break;
|
||||
case CREATURE_MORAGG:
|
||||
uiMoragg = creature.GetGUID();
|
||||
break;
|
||||
case CREATURE_CYANIGOSA:
|
||||
uiCyanigosa = creature.GetGUID();
|
||||
creature.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.NonAttackable);
|
||||
break;
|
||||
case CREATURE_SINCLARI:
|
||||
uiSinclari = creature.GetGUID();
|
||||
break;
|
||||
}
|
||||
|
||||
if (creature.GetGUID() == uiFirstBoss || creature.GetGUID() == uiSecondBoss)
|
||||
{
|
||||
creature.AllLootRemovedFromCorpse();
|
||||
creature.RemoveLootMode(1);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGameObjectCreate(GameObject go)
|
||||
{
|
||||
switch (go.GetEntry())
|
||||
{
|
||||
case GO_EREKEM_GUARD_1_DOOR:
|
||||
uiErekemLeftGuardCell = go.GetGUID();
|
||||
break;
|
||||
case GO_EREKEM_GUARD_2_DOOR:
|
||||
uiErekemRightGuardCell = go.GetGUID();
|
||||
break;
|
||||
case GO_EREKEM_DOOR:
|
||||
uiErekemCell = go.GetGUID();
|
||||
break;
|
||||
case GO_ZURAMAT_DOOR:
|
||||
uiZuramatCell = go.GetGUID();
|
||||
break;
|
||||
case GO_LAVANTHOR_DOOR:
|
||||
uiLavanthorCell = go.GetGUID();
|
||||
break;
|
||||
case GO_MORAGG_DOOR:
|
||||
uiMoraggCell = go.GetGUID();
|
||||
break;
|
||||
case GO_ICHORON_DOOR:
|
||||
uiIchoronCell = go.GetGUID();
|
||||
break;
|
||||
case GO_XEVOZZ_DOOR:
|
||||
uiXevozzCell = go.GetGUID();
|
||||
break;
|
||||
case GO_MAIN_DOOR:
|
||||
uiMainDoor = go.GetGUID();
|
||||
break;
|
||||
case GO_ACTIVATION_CRYSTAL:
|
||||
if (uiCountActivationCrystals < 4)
|
||||
uiActivationCrystal[uiCountActivationCrystals++] = go.GetGUID();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetData(uint type, uint data)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DATA_1ST_BOSS_EVENT:
|
||||
UpdateEncounterState(EncounterCreditType.KillCreature, CREATURE_EREKEM, null);
|
||||
m_auiEncounter[0] = (byte)data;
|
||||
if ((EncounterState)data == EncounterState.Done)
|
||||
SaveToDB();
|
||||
break;
|
||||
case DATA_2ND_BOSS_EVENT:
|
||||
UpdateEncounterState(EncounterCreditType.KillCreature, CREATURE_MORAGG, null);
|
||||
m_auiEncounter[1] = (byte)data;
|
||||
if ((EncounterState)data == EncounterState.Done)
|
||||
SaveToDB();
|
||||
break;
|
||||
case DATA_CYANIGOSA_EVENT:
|
||||
m_auiEncounter[2] = (byte)data;
|
||||
if ((EncounterState)data == EncounterState.Done)
|
||||
{
|
||||
SaveToDB();
|
||||
uiMainEventPhase = EncounterState.EncounterState.Done;
|
||||
if (GameObject pMainDoor = instance.GetGameObject(uiMainDoor))
|
||||
pMainDoor.SetGoState(GameObjectState.Active);
|
||||
}
|
||||
break;
|
||||
case DATA_WAVE_COUNT:
|
||||
uiWaveCount = (byte)data;
|
||||
bActive = true;
|
||||
break;
|
||||
case DATA_REMOVE_NPC:
|
||||
uiRemoveNpc = (byte)data;
|
||||
break;
|
||||
case DATA_PORTAL_LOCATION:
|
||||
uiLocation = (byte)data;
|
||||
break;
|
||||
case DATA_DOOR_INTEGRITY:
|
||||
uiDoorIntegrity = (byte)data;
|
||||
defenseless = false;
|
||||
DoUpdateWorldState(WORLD_STATE_VH_PRISON_STATE, uiDoorIntegrity);
|
||||
break;
|
||||
case DATA_NPC_PRESENCE_AT_DOOR_ADD:
|
||||
NpcAtDoorCastingList.Add((byte)data);
|
||||
break;
|
||||
case DATA_NPC_PRESENCE_AT_DOOR_REMOVE:
|
||||
if (!NpcAtDoorCastingList.Empty())
|
||||
NpcAtDoorCastingList.RemoveAt(0);//.pop_back();
|
||||
break;
|
||||
case DATA_MAIN_DOOR:
|
||||
if (GameObject pMainDoor = instance.GetGameObject(uiMainDoor))
|
||||
{
|
||||
switch ((GameObjectState)data)
|
||||
{
|
||||
case GameObjectState.Active:
|
||||
case GameObjectState.Ready:
|
||||
case GameObjectState.ActiveAlternative:
|
||||
pMainDoor.SetGoState((GameObjectState)data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DATA_START_BOSS_ENCOUNTER:
|
||||
switch (uiWaveCount)
|
||||
{
|
||||
case 6:
|
||||
StartBossEncounter(uiFirstBoss);
|
||||
break;
|
||||
case 12:
|
||||
StartBossEncounter(uiSecondBoss);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DATA_ACTIVATE_CRYSTAL:
|
||||
ActivateCrystal();
|
||||
break;
|
||||
case DATA_MAIN_EVENT_PHASE:
|
||||
uiMainEventPhase = (EncounterState)data;
|
||||
if ((EncounterState)data == EncounterState.InProgress) // Start event
|
||||
{
|
||||
if (GameObject mainDoor = instance.GetGameObject(uiMainDoor))
|
||||
mainDoor.SetGoState(GameObjectState.Ready);
|
||||
uiWaveCount = 1;
|
||||
bActive = true;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (GameObject crystal = instance.GetGameObject(uiActivationCrystal[i]))
|
||||
crystal.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.NotSelectable);
|
||||
}
|
||||
uiRemoveNpc = 0; // might not have been reset after a wipe on a boss.
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetData64(uint type, ulong data)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DATA_ADD_TRASH_MOB:
|
||||
trashMobs.Add(data);
|
||||
break;
|
||||
case DATA_DEL_TRASH_MOB:
|
||||
trashMobs.Remove(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override uint GetData(uint type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DATA_1ST_BOSS_EVENT:
|
||||
return m_auiEncounter[0];
|
||||
case DATA_2ND_BOSS_EVENT:
|
||||
return m_auiEncounter[1];
|
||||
case DATA_CYANIGOSA_EVENT:
|
||||
return m_auiEncounter[2];
|
||||
case DATA_WAVE_COUNT:
|
||||
return uiWaveCount;
|
||||
case DATA_REMOVE_NPC:
|
||||
return uiRemoveNpc;
|
||||
case DATA_PORTAL_LOCATION:
|
||||
return uiLocation;
|
||||
case DATA_DOOR_INTEGRITY:
|
||||
return uiDoorIntegrity;
|
||||
case DATA_NPC_PRESENCE_AT_DOOR:
|
||||
return (uint)NpcAtDoorCastingList.Count;
|
||||
case DATA_FIRST_BOSS:
|
||||
return uiFirstBoss;
|
||||
case DATA_SECOND_BOSS:
|
||||
return uiSecondBoss;
|
||||
case DATA_MAIN_EVENT_PHASE:
|
||||
return (uint)uiMainEventPhase;
|
||||
case DATA_DEFENSELESS:
|
||||
return (uint)(defenseless ? 1 : 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override ulong GetData64(uint identifier)
|
||||
{
|
||||
switch (identifier)
|
||||
{
|
||||
case DATA_MORAGG: return uiMoragg;
|
||||
case DATA_EREKEM: return uiErekem;
|
||||
case DATA_EREKEM_GUARD_1: return uiErekemGuard[0];
|
||||
case DATA_EREKEM_GUARD_2: return uiErekemGuard[1];
|
||||
case DATA_ICHORON: return uiIchoron;
|
||||
case DATA_LAVANTHOR: return uiLavanthor;
|
||||
case DATA_XEVOZZ: return uiXevozz;
|
||||
case DATA_ZURAMAT: return uiZuramat;
|
||||
case DATA_CYANIGOSA: return uiCyanigosa;
|
||||
case DATA_MORAGG_CELL: return uiMoraggCell;
|
||||
case DATA_EREKEM_CELL: return uiErekemCell;
|
||||
case DATA_EREKEM_RIGHT_GUARD_CELL: return uiErekemRightGuardCell;
|
||||
case DATA_EREKEM_LEFT_GUARD_CELL: return uiErekemLeftGuardCell;
|
||||
case DATA_ICHORON_CELL: return uiIchoronCell;
|
||||
case DATA_LAVANTHOR_CELL: return uiLavanthorCell;
|
||||
case DATA_XEVOZZ_CELL: return uiXevozzCell;
|
||||
case DATA_ZURAMAT_CELL: return uiZuramatCell;
|
||||
case DATA_MAIN_DOOR: return uiMainDoor;
|
||||
case DATA_SINCLARI: return uiSinclari;
|
||||
case DATA_TELEPORTATION_PORTAL: return uiTeleportationPortal;
|
||||
case DATA_SABOTEUR_PORTAL: return uiSaboteurPortal;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SpawnPortal()
|
||||
{
|
||||
SetData(DATA_PORTAL_LOCATION, (GetData(DATA_PORTAL_LOCATION) + RandomHelper.URand(1, 5)) % 6);
|
||||
if (Creature pSinclari = instance.GetCreature(uiSinclari))
|
||||
if (Creature portal = pSinclari.SummonCreature(CREATURE_TELEPORTATION_PORTAL, PortalLocation[GetData(DATA_PORTAL_LOCATION)], TempSummonType.CorpseDespawn))
|
||||
uiTeleportationPortal = portal.GetGUID();
|
||||
}
|
||||
|
||||
void StartBossEncounter(byte uiBoss, bool bForceRespawn = true)
|
||||
{
|
||||
Creature pBoss = null;
|
||||
|
||||
switch (uiBoss)
|
||||
{
|
||||
case BOSS_MORAGG:
|
||||
HandleGameObject(uiMoraggCell, bForceRespawn);
|
||||
pBoss = instance.GetCreature(uiMoragg);
|
||||
if (pBoss)
|
||||
pBoss.GetMotionMaster().MovePoint(0, BossStartMove1);
|
||||
break;
|
||||
case BOSS_EREKEM:
|
||||
HandleGameObject(uiErekemCell, bForceRespawn);
|
||||
HandleGameObject(uiErekemRightGuardCell, bForceRespawn);
|
||||
HandleGameObject(uiErekemLeftGuardCell, bForceRespawn);
|
||||
|
||||
pBoss = instance.GetCreature(uiErekem);
|
||||
|
||||
if (pBoss)
|
||||
pBoss.GetMotionMaster().MovePoint(0, BossStartMove2);
|
||||
|
||||
if (Creature pGuard1 = instance.GetCreature(uiErekemGuard[0]))
|
||||
{
|
||||
if (bForceRespawn)
|
||||
pGuard1.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.NonAttackable);
|
||||
else
|
||||
pGuard1.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.NonAttackable);
|
||||
pGuard1.GetMotionMaster().MovePoint(0, BossStartMove21);
|
||||
}
|
||||
|
||||
if (Creature pGuard2 = instance.GetCreature(uiErekemGuard[1]))
|
||||
{
|
||||
if (bForceRespawn)
|
||||
pGuard2.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.NonAttackable);
|
||||
else
|
||||
pGuard2.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.NonAttackable);
|
||||
pGuard2.GetMotionMaster().MovePoint(0, BossStartMove22);
|
||||
}
|
||||
break;
|
||||
case BOSS_ICHORON:
|
||||
HandleGameObject(uiIchoronCell, bForceRespawn);
|
||||
pBoss = instance.GetCreature(uiIchoron);
|
||||
if (pBoss)
|
||||
pBoss.GetMotionMaster().MovePoint(0, BossStartMove3);
|
||||
break;
|
||||
case BOSS_LAVANTHOR:
|
||||
HandleGameObject(uiLavanthorCell, bForceRespawn);
|
||||
pBoss = instance.GetCreature(uiLavanthor);
|
||||
if (pBoss)
|
||||
pBoss.GetMotionMaster().MovePoint(0, BossStartMove4);
|
||||
break;
|
||||
case BOSS_XEVOZZ:
|
||||
HandleGameObject(uiXevozzCell, bForceRespawn);
|
||||
pBoss = instance.GetCreature(uiXevozz);
|
||||
if (pBoss)
|
||||
pBoss.GetMotionMaster().MovePoint(0, BossStartMove5);
|
||||
break;
|
||||
case BOSS_ZURAMAT:
|
||||
HandleGameObject(uiZuramatCell, bForceRespawn);
|
||||
pBoss = instance.GetCreature(uiZuramat);
|
||||
if (pBoss)
|
||||
pBoss.GetMotionMaster().MovePoint(0, BossStartMove6);
|
||||
break;
|
||||
}
|
||||
|
||||
// generic boss state changes
|
||||
if (pBoss)
|
||||
{
|
||||
pBoss.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.NonAttackable);
|
||||
pBoss.SetReactState(ReactStates.Aggressive);
|
||||
|
||||
if (!bForceRespawn)
|
||||
{
|
||||
if (pBoss.IsDead())
|
||||
{
|
||||
// respawn but avoid to be looted again
|
||||
pBoss.Respawn();
|
||||
pBoss.RemoveLootMode(1);
|
||||
}
|
||||
pBoss.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.NonAttackable);
|
||||
uiWaveCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddWave()
|
||||
{
|
||||
DoUpdateWorldState(WORLD_STATE_VH, 1);
|
||||
DoUpdateWorldState(WORLD_STATE_VH_WAVE_COUNT, uiWaveCount);
|
||||
|
||||
switch (uiWaveCount)
|
||||
{
|
||||
case 6:
|
||||
if (uiFirstBoss == 0)
|
||||
uiFirstBoss = (byte)RandomHelper.URand(1, 6);
|
||||
if (Creature pSinclari = instance.GetCreature(uiSinclari))
|
||||
{
|
||||
if (Creature pPortal = pSinclari.SummonCreature(CREATURE_TELEPORTATION_PORTAL, MiddleRoomPortalSaboLocation, TempSummonType.CorpseDespawn))
|
||||
uiSaboteurPortal = pPortal.GetGUID();
|
||||
if (Creature pAzureSaboteur = pSinclari.SummonCreature(CREATURE_SABOTEOUR, MiddleRoomLocation, TempSummonType.DeadDespawn))
|
||||
pAzureSaboteur.CastSpell(pAzureSaboteur, SABOTEUR_SHIELD_EFFECT, false);
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
if (uiSecondBoss == 0)
|
||||
do
|
||||
{
|
||||
uiSecondBoss = (byte)RandomHelper.URand(1, 6);
|
||||
} while (uiSecondBoss == uiFirstBoss);
|
||||
if (Creature pSinclari = instance.GetCreature(uiSinclari))
|
||||
{
|
||||
if (Creature pPortal = pSinclari.SummonCreature(CREATURE_TELEPORTATION_PORTAL, MiddleRoomPortalSaboLocation, TempSummonType.CorpseDespawn))
|
||||
uiSaboteurPortal = pPortal.GetGUID();
|
||||
if (Creature pAzureSaboteur = pSinclari.SummonCreature(CREATURE_SABOTEOUR, MiddleRoomLocation, TempSummonType.DeadDespawn))
|
||||
pAzureSaboteur.CastSpell(pAzureSaboteur, SABOTEUR_SHIELD_EFFECT, false);
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
{
|
||||
Creature pSinclari = instance.GetCreature(uiSinclari);
|
||||
if (pSinclari)
|
||||
pSinclari.SummonCreature(CREATURE_CYANIGOSA, CyanigosasSpawnLocation, TempSummonType.DeadDespawn);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (GameObject pMainDoor = instance.GetGameObject(uiMainDoor))
|
||||
pMainDoor.SetGoState(GameObjectState.Ready);
|
||||
DoUpdateWorldState(WORLD_STATE_VH_PRISON_STATE, 100);
|
||||
// no break
|
||||
}
|
||||
goto default;
|
||||
default:
|
||||
SpawnPortal();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetSaveData()
|
||||
{
|
||||
OUT_SAVE_INST_DATA();
|
||||
|
||||
str_data = string.Format("V H {0} {1} {2} {3} {4}", m_auiEncounter[0], m_auiEncounter[1], m_auiEncounter[2], uiFirstBoss, uiSecondBoss);
|
||||
|
||||
OUT_SAVE_INST_DATA_COMPLETE();
|
||||
return str_data;
|
||||
}
|
||||
|
||||
public override void Load(string str)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
{
|
||||
OUT_LOAD_INST_DATA_FAIL();
|
||||
return;
|
||||
}
|
||||
|
||||
OUT_LOAD_INST_DATA(str);
|
||||
|
||||
StringArguments args = new StringArguments(str);
|
||||
char dataHead1 = args.NextChar();
|
||||
char dataHead2 = args.NextChar();
|
||||
ushort data0 = args.NextUInt16();
|
||||
ushort data1 = args.NextUInt16();
|
||||
ushort data2 = args.NextUInt16();
|
||||
ushort data3 = args.NextUInt16();
|
||||
ushort data4 = args.NextUInt16();
|
||||
|
||||
if (dataHead1 == 'V' && dataHead2 == 'H')
|
||||
{
|
||||
m_auiEncounter[0] = data0;
|
||||
m_auiEncounter[1] = data1;
|
||||
m_auiEncounter[2] = data2;
|
||||
|
||||
for (byte i = 0; i < MAX_ENCOUNTER; ++i)
|
||||
if ((EncounterState)m_auiEncounter[i] == EncounterState.InProgress)
|
||||
m_auiEncounter[i] = (ushort)EncounterState.NotStarted;
|
||||
|
||||
uiFirstBoss = (byte)data3;
|
||||
uiSecondBoss = (byte)data4;
|
||||
}
|
||||
else
|
||||
OUT_LOAD_INST_DATA_FAIL();
|
||||
|
||||
OUT_LOAD_INST_DATA_COMPLETE();
|
||||
}
|
||||
|
||||
bool CheckWipe()
|
||||
{
|
||||
var players = instance.GetPlayers();
|
||||
foreach (var player in players)
|
||||
{
|
||||
if (player.IsGameMaster())
|
||||
continue;
|
||||
|
||||
if (player.IsAlive())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Update(uint diff)
|
||||
{
|
||||
if (!instance.HavePlayers())
|
||||
return;
|
||||
|
||||
// portals should spawn if other portal is dead and doors are closed
|
||||
if (bActive && uiMainEventPhase == EncounterState.InProgress)
|
||||
{
|
||||
if (uiActivationTimer < diff)
|
||||
{
|
||||
AddWave();
|
||||
bActive = false;
|
||||
// 1 minute waiting time after each boss fight
|
||||
uiActivationTimer = (uint)((uiWaveCount == 6 || uiWaveCount == 12) ? 60000 : 5000);
|
||||
} else uiActivationTimer -= diff;
|
||||
}
|
||||
|
||||
// if main event is in progress and players have wiped then reset instance
|
||||
if (uiMainEventPhase == EncounterState.InProgress && CheckWipe())
|
||||
{
|
||||
SetData(DATA_REMOVE_NPC, 1);
|
||||
StartBossEncounter(uiFirstBoss, false);
|
||||
StartBossEncounter(uiSecondBoss, false);
|
||||
|
||||
SetData(DATA_MAIN_DOOR, GameObjectState.Active);
|
||||
SetData(DATA_WAVE_COUNT, 0);
|
||||
uiMainEventPhase = EncounterState.NotStarted;
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (GameObject crystal = instance.GetGameObject(uiActivationCrystal[i]))
|
||||
crystal.SetFlag(GameObjectFields.Flags, GameObjectFlags.NotSelectable);
|
||||
}
|
||||
|
||||
if (Creature pSinclari = instance.GetCreature(uiSinclari))
|
||||
{
|
||||
pSinclari.SetVisible(true);
|
||||
|
||||
List<Creature> GuardList = new List<Creature>();
|
||||
pSinclari.GetCreatureListWithEntryInGrid(GuardList, NPC_VIOLET_HOLD_GUARD, 40.0f);
|
||||
if (!GuardList.Empty())
|
||||
{
|
||||
foreach (var pGuard in GuardList)
|
||||
{
|
||||
pGuard.SetVisible(true);
|
||||
pGuard.SetReactState(ReactStates.Aggressive);
|
||||
pGuard.GetMotionMaster().MovePoint(1, pGuard.GetHomePosition());
|
||||
}
|
||||
}
|
||||
pSinclari.GetMotionMaster().MovePoint(1, pSinclari.GetHomePosition());
|
||||
pSinclari.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable);
|
||||
}
|
||||
}
|
||||
|
||||
// Cyanigosa is spawned but not tranformed, prefight event
|
||||
Creature pCyanigosa = instance.GetCreature(uiCyanigosa);
|
||||
if (pCyanigosa && !pCyanigosa.HasAura(CYANIGOSA_SPELL_TRANSFORM))
|
||||
{
|
||||
if (uiCyanigosaEventTimer <= diff)
|
||||
{
|
||||
switch (uiCyanigosaEventPhase)
|
||||
{
|
||||
case 1:
|
||||
pCyanigosa.CastSpell(pCyanigosa, CYANIGOSA_BLUE_AURA, false);
|
||||
pCyanigosa.GetAI().Talk(CYANIGOSA_SAY_SPAWN);
|
||||
uiCyanigosaEventTimer = 7 * Time.InMilliseconds;
|
||||
++uiCyanigosaEventPhase;
|
||||
break;
|
||||
case 2:
|
||||
pCyanigosa.GetMotionMaster().MoveJump(MiddleRoomLocation.GetPositionX(), MiddleRoomLocation.GetPositionY(), MiddleRoomLocation.GetPositionZ(), 10.0f, 20.0f);
|
||||
pCyanigosa.CastSpell(pCyanigosa, CYANIGOSA_BLUE_AURA, false);
|
||||
uiCyanigosaEventTimer = 7 * Time.InMilliseconds;
|
||||
++uiCyanigosaEventPhase;
|
||||
break;
|
||||
case 3:
|
||||
pCyanigosa.RemoveAurasDueToSpell(CYANIGOSA_BLUE_AURA);
|
||||
pCyanigosa.CastSpell(pCyanigosa, CYANIGOSA_SPELL_TRANSFORM, 0);
|
||||
pCyanigosa.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.NonAttackable);
|
||||
pCyanigosa.SetReactState(ReactStates.Aggressive);
|
||||
uiCyanigosaEventTimer = 2 * Time.InMilliseconds;
|
||||
++uiCyanigosaEventPhase;
|
||||
break;
|
||||
case 4:
|
||||
uiCyanigosaEventPhase = 0;
|
||||
break;
|
||||
}
|
||||
} else uiCyanigosaEventTimer -= diff;
|
||||
}
|
||||
|
||||
// if there are NPCs in front of the prison door, which are casting the door seal spell and doors are active
|
||||
if (GetData(DATA_NPC_PRESENCE_AT_DOOR) && uiMainEventPhase == EncounterState.InProgress)
|
||||
{
|
||||
// if door integrity is > 0 then decrase it's integrity state
|
||||
if (GetData(DATA_DOOR_INTEGRITY))
|
||||
{
|
||||
if (uiDoorSpellTimer < diff)
|
||||
{
|
||||
SetData(DATA_DOOR_INTEGRITY, GetData(DATA_DOOR_INTEGRITY) - 1);
|
||||
uiDoorSpellTimer = 2000;
|
||||
} else uiDoorSpellTimer -= diff;
|
||||
}
|
||||
// else set door state to active (means door will open and group have failed to sustain mob invasion on the door)
|
||||
else
|
||||
{
|
||||
SetData(DATA_MAIN_DOOR, GameObjectState.Active);
|
||||
uiMainEventPhase = EncounterState.Fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActivateCrystal()
|
||||
{
|
||||
// just to make things easier we'll get the gameobject from the map
|
||||
GameObject invoker = instance.GetGameObject(uiActivationCrystal[0]);
|
||||
if (!invoker)
|
||||
return;
|
||||
|
||||
SpellInfo spellInfoLightning = Global.SpellMgr.GetSpellInfo(SPELL_ARCANE_LIGHTNING);
|
||||
if (spellInfoLightning == null)
|
||||
return;
|
||||
|
||||
// the orb
|
||||
TempSummon trigger = invoker.SummonCreature(NPC_DEFENSE_SYSTEM, ArcaneSphere, TempSummonType.ManualDespawn, 0);
|
||||
if (!trigger)
|
||||
return;
|
||||
|
||||
// visuals
|
||||
trigger.CastSpell(trigger, spellInfoLightning, true, 0, 0, trigger.GetGUID());
|
||||
|
||||
// Kill all mobs registered with SetData64(ADD_TRASH_MOB)
|
||||
foreach (var guid in trashMobs)
|
||||
{
|
||||
Creature creature = instance.GetCreature(guid);
|
||||
if (creature && creature.IsAlive())
|
||||
trigger.Kill(creature);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ProcessEvent(WorldObject go, uint uiEventId)
|
||||
{
|
||||
switch (uiEventId)
|
||||
{
|
||||
case EVENT_ACTIVATE_CRYSTAL:
|
||||
bCrystalActivated = true; // Activation by player's will throw event signal
|
||||
ActivateCrystal();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#region Fields
|
||||
|
||||
ulong uiMoragg;
|
||||
ulong uiErekem;
|
||||
ulong[] uiErekemGuard = new ulong[2];
|
||||
ulong uiIchoron;
|
||||
ulong uiLavanthor;
|
||||
ulong uiXevozz;
|
||||
ulong uiZuramat;
|
||||
ulong uiCyanigosa;
|
||||
ulong uiSinclari;
|
||||
|
||||
ulong uiMoraggCell;
|
||||
ulong uiErekemCell;
|
||||
ulong uiErekemLeftGuardCell;
|
||||
ulong uiErekemRightGuardCell;
|
||||
ulong uiIchoronCell;
|
||||
ulong uiLavanthorCell;
|
||||
ulong uiXevozzCell;
|
||||
ulong uiZuramatCell;
|
||||
ulong uiMainDoor;
|
||||
ulong uiTeleportationPortal;
|
||||
ulong uiSaboteurPortal;
|
||||
|
||||
ulong[] uiActivationCrystal = new ulong[4];
|
||||
|
||||
uint uiActivationTimer;
|
||||
uint uiCyanigosaEventTimer;
|
||||
uint uiDoorSpellTimer;
|
||||
|
||||
List<ulong> trashMobs = new List<ulong>(); // to kill with crystal
|
||||
|
||||
byte uiWaveCount;
|
||||
byte uiLocation;
|
||||
byte uiFirstBoss;
|
||||
byte uiSecondBoss;
|
||||
byte uiRemoveNpc;
|
||||
|
||||
byte uiDoorIntegrity;
|
||||
|
||||
ushort[] m_auiEncounter = new ushort[MAX_ENCOUNTER];
|
||||
byte uiCountErekemGuards;
|
||||
byte uiCountActivationCrystals;
|
||||
byte uiCyanigosaEventPhase;
|
||||
EncounterState uiMainEventPhase; // SPECIAL: pre event animations, InProgress: event itself
|
||||
|
||||
bool bActive;
|
||||
bool bWiped;
|
||||
bool bIsDoorSpellCast;
|
||||
bool bCrystalActivated;
|
||||
bool defenseless;
|
||||
|
||||
List<byte> NpcAtDoorCastingList = new List<byte>();
|
||||
|
||||
string str_data;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user