public static void HandlePort(IRealmClient client, RealmPacketIn packet) { int num1 = packet.ReadInt16(); BattlegroundId id = (BattlegroundId)packet.ReadUInt32(); int num2 = packet.ReadInt16(); bool flag = packet.ReadBoolean(); Character activeCharacter = client.ActiveCharacter; if (flag) { BattlegroundInvitation invitation = activeCharacter.Battlegrounds.Invitation; if (invitation == null || invitation.Team.Battleground == null) { return; } Battleground battleground = invitation.Team.Battleground; if (battleground.Template.Id != id) { return; } battleground.TeleportInside(activeCharacter); } else { activeCharacter.Battlegrounds.CancelRelation(id); } }
public static void SendStatusActive(Character chr, Battleground bg, int queueIndex) { BattlegroundStatus battlegroundStatus = BattlegroundStatus.Active; BattlegroundSide battlegroundSide = chr.FactionGroup.GetBattlegroundSide(); using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_BATTLEFIELD_STATUS)) { packet.Write(queueIndex); BattlegroundId id = bg.Template.Id; packet.Write((byte)0); packet.Write((byte)1); packet.Write((uint)id); packet.Write((ushort)8080); packet.Write((byte)0); packet.Write((byte)0); packet.Write(bg.InstanceId); packet.Write((byte)0); packet.Write((int)battlegroundStatus); packet.Write((int)bg.Id); packet.Write(bg.RemainingShutdownDelay); packet.Write(bg.RuntimeMillis); packet.Write((byte)battlegroundSide); chr.Send(packet, false); } }
public static void SetCreator(BattlegroundId id, string typeName) { Type type = ServerApp <WCell.RealmServer.RealmServer> .GetType(typeName); BattlegroundTemplate template = BattlegroundMgr.GetTemplate(id); if (type == (Type)null || template == null) { object obj1; object obj2; if (type == (Type)null) { obj1 = (object)"type"; obj2 = (object)string.Format("({0}) - Please correct it in the Battleground-config file: {1}", (object)typeName, (object)InstanceConfigBase <BattlegroundConfig, BattlegroundId> .Filename); } else { obj1 = (object)"Template"; obj2 = (object)"<not in DB>"; } BattlegroundMgr.log.Warn("Battleground {0} has invalid {1} {2}", (object)id, obj1, obj2); } else { IProducer producer = AccessorMgr.GetOrCreateDefaultProducer(type); template.Creator = (BattlegroundCreator)(() => (Battleground)producer.Produce()); } }
public static void SetCreator(BattlegroundId id, string typeName) { var type = RealmServer.GetType(typeName); var template = GetTemplate(id); if (type == null || template == null) { //throw new ArgumentException("Invalid Creator for type \"" + id + "\": " + typeName); object cause, causer; if (type == null) { cause = "type"; causer = string.Format("({0}) - Please correct it in the Battleground-config file: {1}", typeName, BattlegroundConfig.Filename); } else { cause = "Template"; causer = "******"; } log.Warn("Battleground {0} has invalid {1} {2}", id, cause, causer); } else { var producer = AccessorMgr.GetOrCreateDefaultProducer(type); template.Creator = () => (Battleground)producer.Produce(); } }
public static uint GetHolidayIdByBGId(BattlegroundId bgId) { switch (bgId) { case BattlegroundId.AlteracValley: return((uint)BattlegroundHolidays.CallToArmsAV); case BattlegroundId.WarsongGulch: return((uint)BattlegroundHolidays.CallToArmsWS); case BattlegroundId.ArathiBasin: return((uint)BattlegroundHolidays.CallToArmsAB); case BattlegroundId.EyeOfTheStorm: return((uint)BattlegroundHolidays.CallToArmsEY); case BattlegroundId.StrandOfTheAncients: return((uint)BattlegroundHolidays.CallToArmsSA); case BattlegroundId.IsleOfConquest: return((uint)BattlegroundHolidays.CallToArmsIsleOfConquest); default: return((uint)BattlegroundHolidays.None); } }
public static uint GetHolidayIdByBGId(BattlegroundId bgId) { switch (bgId) { case BattlegroundId.AlteracValley: return(283); case BattlegroundId.WarsongGulch: return(284); case BattlegroundId.ArathiBasin: return(285); case BattlegroundId.EyeOfTheStorm: return(353); case BattlegroundId.StrandOfTheAncients: return(400); case BattlegroundId.IsleOfConquest: return(420); default: return(0); } }
public bool IsParticipating(BattlegroundId bgId) { if (Team != null) { return(Team.Battleground.Template.Id == bgId); } return(false); }
/// <summary> /// "Your group joined Name" /// </summary> /// <param name="battleground"></param> public static void SendGroupJoinedBattleground(IPacketReceiver rcv, BattlegroundId battleground) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GROUP_JOINED_BATTLEGROUND, 4)) { packet.Write((int)battleground); rcv.Send(packet); } }
public bool IsEnqueuedFor(BattlegroundId bgId) { BattlegroundRelation relation = this.GetRelation(bgId); if (relation != null) { return(relation.IsEnqueued); } return(false); }
public static void JoinBattlefield(BattlegroundId type, bool asGroup = false) { if (type == BattlegroundId.None) { return; } Lua.LuaDoString( "for i = 1, GetNumBattlegroundTypes() do local _,_,_,_,id = GetBattlegroundInfo(i); if id == {0} then RequestBattlegroundInstanceInfo(i); end end"); Lua.LuaDoString(string.Format("JoinBattlefield(1, {0})", asGroup ? "true" : "false")); Thread.Sleep(500); }
/// <summary> /// Gets the <see cref="BattlegroundQueue"/> for a specific instance of the given Battleground for /// the given Character. /// </summary> /// <param name="bgid"></param> /// <param name="level">The level determines the bracket id of the queue.</param> /// <returns></returns> public static BattlegroundQueue GetInstanceQueue(BattlegroundId bgid, uint instanceId, int level) { Battleground bg = Templates.Get((uint)bgid).GetQueue(level).GetBattleground(instanceId); if (bg != null) { return(bg.InstanceQueue); //.GetTeamQueue(chr); } return(null); }
/// <summary> /// Gets the <see cref="T:WCell.RealmServer.Battlegrounds.BattlegroundQueue" /> for a specific instance of the given Battleground for /// the given Character. /// </summary> /// <param name="bgid"></param> /// <param name="level">The level determines the bracket id of the queue.</param> /// <returns></returns> public static BattlegroundQueue GetInstanceQueue(BattlegroundId bgid, uint instanceId, int level) { Battleground battleground = BattlegroundMgr.Templates.Get <BattlegroundTemplate>((uint)bgid).GetQueue(level) .GetBattleground(instanceId); if (battleground != null) { return((BattlegroundQueue)battleground.InstanceQueue); } return((BattlegroundQueue)null); }
public static void HandleBattlefieldLeave(IRealmClient client, RealmPacketIn packet) { int num1 = packet.ReadInt16(); BattlegroundId bgId = (BattlegroundId)packet.ReadUInt32(); int num2 = packet.ReadInt16(); BattlegroundInfo battlegrounds = client.ActiveCharacter.Battlegrounds; if (!battlegrounds.IsParticipating(bgId)) { return; } battlegrounds.TeleportBack(); }
public static void HandleBattlemasterJoin(IRealmClient client, RealmPacketIn packet) { packet.ReadEntityId(); BattlegroundId bgId = (BattlegroundId)packet.ReadUInt32(); uint instanceId = packet.ReadUInt32(); bool asGroup = packet.ReadBoolean(); if (bgId <= BattlegroundId.None || bgId >= BattlegroundId.End) { return; } BattlegroundMgr.EnqueuePlayers(client.ActiveCharacter, bgId, instanceId, asGroup); }
/// <summary> /// Gets the <see cref="T:WCell.RealmServer.Battlegrounds.BattlegroundRelation" /> for the given Battleground for /// the Character. /// </summary> /// <param name="bgId"></param> /// <returns></returns> public BattlegroundRelation GetRelation(BattlegroundId bgId) { for (int index = 0; index < this._relations.Length; ++index) { BattlegroundRelation relation = this._relations[index]; if (relation != null && relation.Queue.ParentQueue.Template.Id == bgId) { return(relation); } } return((BattlegroundRelation)null); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> /// <remarks>Requires Context</remarks> public int GetIndex(BattlegroundId id) { this._chr.ContextHandler.EnsureContext(); for (int index = 0; index < this._relations.Length; ++index) { BattlegroundRelation relation = this._relations[index]; if (relation != null && relation.Queue.ParentQueue.Template.Id == id) { return(index); } } return(-1); }
/// <summary> /// Gets the <see cref="BattlegroundRelation"/> for the given Battleground for /// the Character. /// </summary> /// <param name="bgId"></param> /// <returns></returns> public BattlegroundRelation GetRelation(BattlegroundId bgId) { for (var i = 0; i < _relations.Length; i++) { var request = _relations[i]; if (request != null && request.Queue.ParentQueue.Template.Id == bgId) { return(request); } } return(null); }
/// <summary> /// Removes the corresponding relation and removes it from the queue /// if it is enqueued. /// </summary> /// <param name="id"></param> /// <returns></returns> public int CancelRelation(BattlegroundId id) { _chr.EnsureContext(); for (var i = 0; i < _relations.Length; i++) { var relation = _relations[i]; if (relation != null && relation.Queue.ParentQueue.Template.Id == id) { CancelRelation(i, relation, true); return(i); } } return(-1); }
/// <summary> /// Removes the corresponding relation and removes it from the queue /// if it is enqueued. /// </summary> /// <param name="id"></param> /// <returns></returns> public int CancelRelation(BattlegroundId id) { this._chr.EnsureContext(); for (int index = 0; index < this._relations.Length; ++index) { BattlegroundRelation relation = this._relations[index]; if (relation != null && relation.Queue.ParentQueue.Template.Id == id) { this.CancelRelation(index, relation, true); return(index); } } return(-1); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> /// <remarks>Requires Context</remarks> public int GetIndex(BattlegroundId id) { _chr.ContextHandler.EnsureContext(); for (var i = 0; i < _relations.Length; i++) { var request = _relations[i]; if (request != null && request.Queue.ParentQueue.Template.Id == id) { return(i); } } return(-1); }
public bool CancelIfEnqueued(BattlegroundId bgId) { this._chr.ContextHandler.EnsureContext(); for (int index = 0; index < this._relations.Length; ++index) { BattlegroundRelation relation = this._relations[index]; if (relation != null && relation.Queue.ParentQueue.Template.Id == bgId) { if (!relation.IsEnqueued) { return(false); } relation.Cancel(); return(true); } } return(false); }
internal void RemoveRelation(int index, BattlegroundRelation relation, bool isCharActive) { this._chr.EnsureContext(); this._relations[index] = (BattlegroundRelation)null; BattlegroundInvitation invitation = this.Invitation; if (invitation != null) { --invitation.Team.ReservedSlots; this.Invitation = (BattlegroundInvitation)null; } BattlegroundId bgId = relation.BattlegroundId; Battleground map = this._chr.Map as Battleground; if (map != null && map.Template.Id == bgId && (!relation.IsEnqueued && !this._chr.IsTeleporting) && isCharActive) { map.TeleportOutside(this._chr); } if (isCharActive) { BattlegroundHandler.ClearStatus((IPacketReceiver)this._chr, index); } if (!relation.IsEnqueued || relation.Characters.CharacterCount <= 1) { return; } Group group = this._chr.Group; if (group == null || !group.IsLeader(this._chr)) { return; } relation.Characters.ForeachCharacter((Action <Character>)(chr => { if (chr == this._chr) { return; } chr.ExecuteInContext((Action)(() => chr.Battlegrounds.RemoveRelation(bgId))); })); }
public void Initialize(bool configOnly, bool resetSettings = false) { try { if (!Loop) { Loop = true; } InternalIgnoreFight = false; InternalDontStartFights = false; Logging.Write("Loading TheNoobBot ProfileType C# Profile system."); CurrentBattlegroundId = Battleground.GetCurrentBattleground(); if (CurrentBattlegroundId != BattlegroundId.None) { if (CurrentBattlegroundId == BattlegroundId.WarsongGulch || CurrentBattlegroundId == BattlegroundId.TwinPeaks) { if (configOnly) { string currentSettingsFile = Application.StartupPath + "\\Profiles\\Battlegrounder\\ProfileType\\CSharpProfile\\Settings\\CaptureTheFlag.xml"; var currentSetting = new CaptureTheFlag.CaptureTheFlagSettings(); if (File.Exists(currentSettingsFile) && !resetSettings) { currentSetting = Settings.Load <CaptureTheFlag.CaptureTheFlagSettings>(currentSettingsFile); } currentSetting.ToForm(); currentSetting.Save(currentSettingsFile); } else { Logging.Write("Loading Capture The Flag module."); new CaptureTheFlag(); } Logging.WriteFight("CaptureTheFlag stopped, broken ?"); } } } catch (Exception exception) { Logging.WriteError("Initialize(): " + exception); } Logging.WriteFight("TheNoobBot example Custom Profile stopped. Loop shutdown."); }
/// <summary>Enqueues players in a battleground queue.</summary> /// <param name="chr">the character who enqueued</param> /// <param name="bgId">the type of battleground</param> /// <param name="instanceId">the instance id of the battleground</param> /// <param name="asGroup">whether or not to enqueue the character or his/her group</param> internal static void EnqueuePlayers(Character chr, BattlegroundId bgId, uint instanceId, bool asGroup) { if (!chr.Battlegrounds.HasAvailableQueueSlots) { BattlegroundHandler.SendBattlegroundError((IPacketReceiver)chr, BattlegroundJoinError.Max3Battles); } else { if (chr.Battlegrounds.IsEnqueuedFor(bgId)) { return; } BattlegroundTemplate template = BattlegroundMgr.GetTemplate(bgId); if (template == null) { return; } template.TryEnqueue(chr, asGroup, instanceId); } }
public bool CancelIfEnqueued(BattlegroundId bgId) { _chr.ContextHandler.EnsureContext(); for (var i = 0; i < _relations.Length; i++) { var request = _relations[i]; if (request != null && request.Queue.ParentQueue.Template.Id == bgId) { if (request.IsEnqueued) { request.Cancel(); return(true); } return(false); } } return(false); }
public static void HandleBattlefieldList(IRealmClient client, RealmPacketIn packet) { BattlegroundId bgid = (BattlegroundId)packet.ReadUInt32(); packet.ReadBoolean(); int num = packet.ReadByte(); BattlegroundTemplate template = BattlegroundMgr.GetTemplate(bgid); Character activeCharacter = client.ActiveCharacter; if (template == null) { return; } GlobalBattlegroundQueue queue = template.GetQueue(activeCharacter.Level); if (queue == null) { return; } SendBattlefieldList(activeCharacter, queue); }
/// <summary> /// Enqueues players in a battleground queue. /// </summary> /// <param name="chr">the character who enqueued</param> /// <param name="bgId">the type of battleground</param> /// <param name="instanceId">the instance id of the battleground</param> /// <param name="asGroup">whether or not to enqueue the character or his/her group</param> internal static void EnqueuePlayers(Character chr, BattlegroundId bgId, uint instanceId, bool asGroup) { if (!chr.Battlegrounds.HasAvailableQueueSlots) { BattlegroundHandler.SendBattlegroundError(chr, BattlegroundJoinError.Max3Battles); return; } // cannot enqueue twice for the same bg if (chr.Battlegrounds.IsEnqueuedFor(bgId)) { return; } var template = GetTemplate(bgId); // TODO: Is Character just updating an existing queue slot? if (template != null) { template.TryEnqueue(chr, asGroup, instanceId); } }
public static void SendStatusEnqueued(Character chr, int index, BattlegroundRelation relation, BattlegroundQueue queue) { BattlegroundStatus battlegroundStatus = BattlegroundStatus.Enqueued; using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_BATTLEFIELD_STATUS)) { packet.Write(index); BattlegroundId id = queue.Template.Id; packet.Write((byte)0); packet.Write((byte)1); packet.Write((uint)id); packet.Write((ushort)8080); packet.Write((byte)0); packet.Write((byte)0); packet.Write(queue.InstanceId); packet.Write(false); packet.Write((int)battlegroundStatus); packet.Write(queue.AverageWaitTime); packet.Write((int)relation.QueueTime.TotalMilliseconds); chr.Send(packet, false); } }
public static void SendStatusInvited(Character chr, int inviteTimeout) { BattlegroundStatus battlegroundStatus = BattlegroundStatus.Preparing; BattlegroundInvitation invitation = chr.Battlegrounds.Invitation; using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_BATTLEFIELD_STATUS)) { packet.Write(invitation.QueueIndex); Battleground battleground = invitation.Team.Battleground; BattlegroundId id = battleground.Template.Id; packet.Write((byte)0); packet.Write((byte)1); packet.Write((uint)id); packet.Write((ushort)8080); packet.Write((byte)0); packet.Write((byte)0); packet.Write(battleground.InstanceId); packet.Write((byte)chr.FactionGroup.GetBattlegroundSide()); packet.Write((int)battlegroundStatus); packet.Write((int)battleground.Id); packet.Write(inviteTimeout); chr.Send(packet, false); } }
public static BattlegroundTemplate GetTemplate(BattlegroundId bgid) { return Templates.Get((uint)bgid); }
public static uint GetHolidayIdByBGId(BattlegroundId bgId) { switch (bgId) { case BattlegroundId.AlteracValley: return (uint)BattlegroundHolidays.CallToArmsAV; case BattlegroundId.WarsongGulch: return (uint)BattlegroundHolidays.CallToArmsWS; case BattlegroundId.ArathiBasin: return (uint)BattlegroundHolidays.CallToArmsAB; case BattlegroundId.EyeOfTheStorm: return (uint)BattlegroundHolidays.CallToArmsEY; case BattlegroundId.StrandOfTheAncients: return (uint)BattlegroundHolidays.CallToArmsSA; case BattlegroundId.IsleOfConquest: return (uint)BattlegroundHolidays.CallToArmsIsleOfConquest; default: return (uint)BattlegroundHolidays.None; } }
/// <summary> /// Gets the <see cref="BattlegroundQueue"/> for a specific instance of the given Battleground for /// the given Character. /// </summary> /// <param name="bgid"></param> /// <returns></returns> public static BattlegroundQueue GetInstanceQueue(BattlegroundId bgid, uint instanceId, Unit unit) { return(GetInstanceQueue(bgid, instanceId, unit.Level)); }
/// <summary> /// Enqueues players in a battleground queue. /// </summary> /// <param name="chr">the character who enqueued</param> /// <param name="bgId">the type of battleground</param> /// <param name="instanceId">the instance id of the battleground</param> /// <param name="asGroup">whether or not to enqueue the character or his/her group</param> internal static void EnqueuePlayers(Character chr, BattlegroundId bgId, uint instanceId, bool asGroup) { if (!chr.Battlegrounds.HasAvailableQueueSlots) { BattlegroundHandler.SendBattlegroundError(chr, BattlegroundJoinError.Max3Battles); return; } // cannot enqueue twice for the same bg if (chr.Battlegrounds.IsEnqueuedFor(bgId)) return; var template = GetTemplate(bgId); // TODO: Is Character just updating an existing queue slot? if (template != null) { template.TryEnqueue(chr, asGroup, instanceId); } }
/// <summary> /// Gets the <see cref="BattlegroundQueue"/> for a specific instance of the given Battleground for /// the given Character. /// </summary> /// <param name="bgid"></param> /// <param name="level">The level determines the bracket id of the queue.</param> /// <returns></returns> public static BattlegroundQueue GetInstanceQueue(BattlegroundId bgid, uint instanceId, int level) { Battleground bg = Templates.Get((uint)bgid).GetQueue(level).GetBattleground(instanceId); if (bg != null) { return bg.InstanceQueue; //.GetTeamQueue(chr); } return null; }
/// <summary> /// Gets the <see cref="BattlegroundQueue"/> for a specific instance of the given Battleground for /// the given Character. /// </summary> /// <param name="bgid"></param> /// <returns></returns> public static BattlegroundQueue GetInstanceQueue(BattlegroundId bgid, uint instanceId, Unit unit) { return GetInstanceQueue(bgid, instanceId, unit.Level); }
/// <summary> /// Gets the global <see cref="BattlegroundQueue"/> for the given Battleground for /// the given Character. /// </summary> /// <param name="bgid"></param> /// <returns></returns> public static GlobalBattlegroundQueue GetGlobalQueue(BattlegroundId bgid, int level) { return Templates.Get((uint)bgid).GetQueue(level); //.GetTeamQueue(chr); }
/// <summary> /// Gets the global <see cref="BattlegroundQueue"/> for the given Battleground for /// the given Character. /// </summary> /// <param name="bgid"></param> /// <returns></returns> public static GlobalBattlegroundQueue GetGlobalQueue(BattlegroundId bgid, Unit unit) { return GetGlobalQueue(bgid, unit.Level); }
public bool IsParticipating(BattlegroundId bgId) { if (Team != null) { return Team.Battleground.Template.Id == bgId; } return false; }
/// <summary> /// Removes the corresponding relation and removes it from the queue /// if it is enqueued. /// </summary> /// <param name="id"></param> /// <returns></returns> public int CancelRelation(BattlegroundId id) { _chr.EnsureContext(); for (var i = 0; i < _relations.Length; i++) { var relation = _relations[i]; if (relation != null && relation.Queue.ParentQueue.Template.Id == id) { CancelRelation(i, relation, true); return i; } } return -1; }
public bool IsEnqueuedFor(BattlegroundId bgId) { var relation = GetRelation(bgId); return relation != null && relation.IsEnqueued; }
/// <summary> /// Gets the <see cref="BattlegroundRelation"/> for the given Battleground for /// the Character. /// </summary> /// <param name="bgId"></param> /// <returns></returns> public BattlegroundRelation GetRelation(BattlegroundId bgId) { for (var i = 0; i < _relations.Length; i++) { var request = _relations[i]; if (request != null && request.Queue.ParentQueue.Template.Id == bgId) { return request; } } return null; }
public bool CancelIfEnqueued(BattlegroundId bgId) { _chr.ContextHandler.EnsureContext(); for (var i = 0; i < _relations.Length; i++) { var request = _relations[i]; if (request != null && request.Queue.ParentQueue.Template.Id == bgId) { if (request.IsEnqueued) { request.Cancel(); return true; } return false; } } return false; }
public static void SetCreator(BattlegroundId id, BattlegroundCreator creator) { GetTemplate(id).Creator = creator; }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> /// <remarks>Requires Context</remarks> public int GetIndex(BattlegroundId id) { _chr.ContextHandler.EnsureContext(); for (var i = 0; i < _relations.Length; i++) { var request = _relations[i]; if (request != null && request.Queue.ParentQueue.Template.Id == id) { return i; } } return -1; }
/// <summary> /// Gets all instances of the given battleground type. /// </summary> /// <param name="bgId">the type of battleground</param> public static IDictionary<uint, Battleground> GetInstances(BattlegroundId bgId) { return Instances[(int)bgId]; }
/// <summary> /// Gets the battleground instance of the given battleground type and instance id. /// </summary> /// <param name="bgId">the type of battleground</param> /// <param name="instanceId">the instance id</param> /// <returns>the given instance, if it exists</returns> public static Battleground GetInstance(BattlegroundId bgId, uint instanceId) { Battleground bg; Instances[(int)bgId].TryGetValue(instanceId, out bg); return bg; }