public bool TryStartDissmisProgress(Character initer, Character dissmiser) { lock (this) { if (IsDismissInProgress) { if (DissmissTimeouted < DateTime.Now) { Asda2BattlegroundHandler.SendDissmissResultResponse(this, DismissPlayerResult.Fail, DissmissingCharacter.SessionId, (int)DissmissingCharacter.AccId); } else { return(false); } } IsDismissInProgress = true; Asda2BattlegroundHandler.SendQuestionDismissPlayerOrNotResponse(this, initer, dissmiser); DissmissingCharacter = dissmiser; DissmissYes.Clear(); DissmissNo.Clear(); DissmissTimeouted = DateTime.Now.AddMinutes(1); DissmisFaction = initer.Asda2FactionId; return(true); } }
public void Update(int dt) { if (Status == Asda2WarPointStatus.Owned) { //gain scores each one minute to team _timeToNextGainPoints -= dt; if (_timeToNextGainPoints <= 0) { BattleGround.GainScores(OwnedFaction, CharacterFormulas.FactionWarPointsPerTicForCapturedPoints); _timeToNextGainPoints += CharacterFormulas.DefaultTimeGainExpReward; } } if (_isCapturing) { _tomeToCaprute -= dt; if (_tomeToCaprute <= 0) { //point captured Status = Asda2WarPointStatus.Owned; Asda2BattlegroundHandler.SendUpdatePointInfoResponse(null, this); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(BattleGround, BattleGroundInfoMessageType.SuccessToCompletelyOccuptyTheNumOccupationPoints, Id, null, OwnedFaction); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(BattleGround, BattleGroundInfoMessageType.TheOtherSideHasTemporarilyOccupiedTheNumOccupationPoint, Id, null, (short?)(OwnedFaction == 0 ? 1 : 0)); BattleGround.GainScores(OwnedFaction, CharacterFormulas.FactionWarPointsPerTicForCapturedPoints); _isCapturing = false; } } else { if (CapturingCharacter == null || !BattleGround.IsStarted) { return; } _timeToStartCapturing -= dt; if (_timeToStartCapturing <= 0) { _tomeToCaprute = CharacterFormulas.DefaultCaptureTime; _isCapturing = true; OwnedFaction = CapturingCharacter.Asda2FactionId; CapturingCharacter.GainActPoints(1); BattleGround.GainScores(CapturingCharacter, 1); Status = Asda2WarPointStatus.Capturing; Asda2BattlegroundHandler.SendUpdatePointInfoResponse(null, this); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(BattleGround, BattleGroundInfoMessageType.SuccessToTemporarilyOccuptyTheNumOccupationPoints, Id, null, CapturingCharacter.Asda2FactionId); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(BattleGround, BattleGroundInfoMessageType.TheOtherSideHasTemporarilyOccupiedTheNumOccupationPoint, Id, null, (short?)(CapturingCharacter.Asda2FactionId == 1 ? 0 : 1)); Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(CapturingCharacter.Client, Id, OcupationPointStartedStatus.Fail); CapturingCharacter.CurrentCapturingPoint = null; CapturingCharacter = null; _timeToNextGainPoints = CharacterFormulas.DefaultTimeGainExpReward; } } }
public static void RequestUpdateWarScreenManagerDataRequest(IRealmClient client, RealmPacketIn packet) { int num; if (client.ActiveCharacter.MapId == MapId.Alpia) { num = 0; } else if (client.ActiveCharacter.MapId == MapId.Silaris) { num = 1; } else if (client.ActiveCharacter.MapId == MapId.Flamio) { num = 2; } else { if (client.ActiveCharacter.MapId != MapId.Aquaton) { return; } num = 3; } Asda2BattlegroundHandler.SendUpdateWarManagerScreenDataResponse(client, Asda2BattlegroundMgr.AllBattleGrounds[(Asda2BattlegroundTown)num][0]); }
public void Stop() { if (!this.IsRunning) { return; } this._notificationsAboutStart = 3; this.IsStarted = false; WCell.RealmServer.Global.World.Broadcast(string.Format( "War in {0} has ended. Light scores {1} vs {2} dark scores.", (object)this.Town, (object)this.LightScores, (object)this.DarkScores)); this.IsRunning = false; this.SetNextWarParametrs(); lock (this.JoinLock) { foreach (Character character in this.LightScores > this.DarkScores ? this.LightTeam.Values : this.DarkTeam.Values) { if (this.MvpCharacter == null) { this.MvpCharacter = character; } else if ((int)this.MvpCharacter.BattlegroundActPoints < (int)character.BattlegroundActPoints) { this.MvpCharacter = character; } } Asda2BattlegroundHandler.SendWiningFactionInfoResponse(this.Town, this.WiningFactionId, this.MvpCharacter == null ? "[No character]" : this.MvpCharacter.Name); if (this.MvpCharacter != null) { ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => { BattlegroundResultRecord battlegroundResultRecord = new BattlegroundResultRecord(this.Town, this.MvpCharacter.Name, this.MvpCharacter.EntityId.Low, this.LightScores, this.DarkScores); battlegroundResultRecord.CreateLater(); this.CurrentWarResultRecordGuid = battlegroundResultRecord.Guid; Asda2BattlegroundMgr.ProcessBattlegroundResultRecord(battlegroundResultRecord); })); } foreach (Character character in this.LightTeam.Values) { this.ProcessEndWar(character); } foreach (Character character in this.DarkTeam.Values) { this.ProcessEndWar(character); } foreach (Asda2WarPoint point in this.Points) { point.Status = Asda2WarPointStatus.NotOwned; point.OwnedFaction = (short)-1; Asda2BattlegroundHandler.SendUpdatePointInfoResponse((IRealmClient)null, point); } WCell.RealmServer.Global.World.TaskQueue.CallDelayed(60000, new Action(this.KickAll)); } }
private void SendWarTimeMotofocation() { if (!this.IsRunning) { return; } switch (this.WarNotofocationStep) { case 0: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarStartsInNumMins, (short)1, (Character)null, new short?()); WCell.RealmServer.Global.World.TaskQueue.CallDelayed(60000, new Action(this.SendWarTimeMotofocation)); break; case 1: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarStarted, (short)0, (Character)null, new short?()); WCell.RealmServer.Global.World.TaskQueue.CallDelayed(1380000, new Action(this.SendWarTimeMotofocation)); this.IsStarted = true; break; case 2: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarEndsInNumMins, (short)5, (Character)null, new short?()); WCell.RealmServer.Global.World.TaskQueue.CallDelayed(60000, new Action(this.SendWarTimeMotofocation)); break; case 3: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarEndsInNumMins, (short)4, (Character)null, new short?()); WCell.RealmServer.Global.World.TaskQueue.CallDelayed(60000, new Action(this.SendWarTimeMotofocation)); break; case 4: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarEndsInNumMins, (short)3, (Character)null, new short?()); WCell.RealmServer.Global.World.TaskQueue.CallDelayed(60000, new Action(this.SendWarTimeMotofocation)); break; case 5: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarEndsInNumMins, (short)2, (Character)null, new short?()); WCell.RealmServer.Global.World.TaskQueue.CallDelayed(60000, new Action(this.SendWarTimeMotofocation)); break; case 6: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarEndsInNumMins, (short)1, (Character)null, new short?()); break; } ++this.WarNotofocationStep; }
public static void ShowWarUnitRequest(IRealmClient client, RealmPacketIn packet) { if (!client.ActiveCharacter.IsAsda2BattlegroundInProgress) { return; } Asda2BattlegroundHandler.SendWarTeamListResponse(client.ActiveCharacter); }
public void Update(int dt) { switch (this._notificationsAboutStart) { case 1: if (DateTime.Now > this.StartTime.Subtract(new TimeSpan(0, 5, 0))) { --this._notificationsAboutStart; WCell.RealmServer.Global.World.BroadcastMsg("War Manager", string.Format("{1} in {0} starts in 5 mins.", (object)this.Town, (object)this.WarType), Color.Firebrick); Asda2BattlegroundHandler.SendMessageServerAboutWarStartsResponse((byte)5); break; } break; case 2: if (DateTime.Now > this.StartTime.Subtract(new TimeSpan(0, 15, 0))) { --this._notificationsAboutStart; WCell.RealmServer.Global.World.BroadcastMsg("War Manager", string.Format("{1} in {0} starts in 15 mins.", (object)this.Town, (object)this.WarType), Color.Firebrick); Asda2BattlegroundHandler.SendMessageServerAboutWarStartsResponse((byte)15); break; } break; case 3: if (DateTime.Now > this.StartTime.Subtract(new TimeSpan(0, 30, 0))) { --this._notificationsAboutStart; WCell.RealmServer.Global.World.BroadcastMsg("War Manager", string.Format("{1} in {0} starts in 30 mins.", (object)this.Town, (object)this.WarType), Color.Firebrick); Asda2BattlegroundHandler.SendMessageServerAboutWarStartsResponse((byte)30); break; } break; } if (DateTime.Now > this.EndTime && this.IsRunning) { this.Stop(); } else { if (!(DateTime.Now > this.StartTime) || !(DateTime.Now < this.EndTime)) { return; } this.Start(); } }
public static void CancleWarPatipicationRequest(IRealmClient client, RealmPacketIn packet) { Asda2BattlegroundHandler.SendWarPartipicationCanceledResponse(client); if (client.ActiveCharacter.CurrentBattleGround == null) { return; } client.ActiveCharacter.CurrentBattleGround.Leave(client.ActiveCharacter); }
public void StopCapture() { Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this.BattleGround, BattleGroundInfoMessageType.FailedToTemporarilyOccuptyTheNumOccupationPoints, this.Id, (Character)null, new short?(this.CapturingCharacter.Asda2FactionId)); Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(this.CapturingCharacter.Client, this.Id, OcupationPointStartedStatus.Fail); this.CapturingCharacter.CurrentCapturingPoint = (Asda2WarPoint)null; this.CapturingCharacter = (Character)null; this._isCapturing = false; }
public void StopCapture() { Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(BattleGround, BattleGroundInfoMessageType.FailedToTemporarilyOccuptyTheNumOccupationPoints, Id, null, CapturingCharacter.Asda2FactionId); Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(CapturingCharacter.Client, Id, OcupationPointStartedStatus.Fail); CapturingCharacter.CurrentCapturingPoint = null; CapturingCharacter = null; _isCapturing = false; }
public bool Leave(Character chr) { lock (this.JoinLock) { if (chr.Asda2FactionId == (short)0) { if (!this.LightTeam.ContainsValue(chr)) { return(false); } this.LightTeam.Remove(chr.CurrentBattleGroundId); this.FreeLightIds.Add(chr.CurrentBattleGroundId); chr.CurrentBattleGround = (Asda2Battleground)null; chr.Map.CallDelayed(1, (Action)(() => { Asda2BattlegroundHandler.SendHowManyPeopleInWarTeamsResponse(this, (Character)null); Asda2BattlegroundHandler.SendCharacterHasLeftWarResponse(this, (int)chr.AccId, chr.CurrentBattleGroundId, chr.Name, (int)chr.Asda2FactionId); })); if (chr.MapId == MapId.BatleField) { chr.TeleportTo((IWorldLocation)chr.LocatonBeforeOnEnterWar); } if (chr.IsStunned) { --chr.Stunned; } return(true); } if (chr.Asda2FactionId != (short)1 || !this.DarkTeam.ContainsValue(chr)) { return(false); } this.DarkTeam.Remove(chr.CurrentBattleGroundId); this.FreeDarkIds.Add(chr.CurrentBattleGroundId); chr.CurrentBattleGround = (Asda2Battleground)null; chr.Map.CallDelayed(1, (Action)(() => { Asda2BattlegroundHandler.SendHowManyPeopleInWarTeamsResponse(this, (Character)null); Asda2BattlegroundHandler.SendCharacterHasLeftWarResponse(this, (int)chr.AccId, chr.CurrentBattleGroundId, chr.Name, (int)chr.Asda2FactionId); })); if (chr.MapId == MapId.BatleField) { chr.TeleportTo((IWorldLocation)chr.LocatonBeforeOnEnterWar); } if (chr.IsStunned) { --chr.Stunned; } return(true); } }
public void GainScores(short factionId, short points) { if (factionId == (short)0) { this.LightScores += (int)points; } else { this.DarkScores += (int)points; } Asda2BattlegroundHandler.SendTeamPointsResponse(this, (Character)null); }
public void GainScores(short factionId, short points) { if (factionId == 0) { LightScores += points; } else { DarkScores += points; } Asda2BattlegroundHandler.SendTeamPointsResponse(this); }
public bool Join(Character chr) { lock (JoinLock) { chr.BattlegroundActPoints = 0; chr.BattlegroundKills = 0; chr.BattlegroundDeathes = 0; if (chr.Asda2FactionId == 0) //light { if (FreeLightIds.Count == 0) { return(false); } var id = FreeLightIds[0]; LightTeam.Add(id, chr); FreeLightIds.RemoveAt(0); chr.CurrentBattleGround = this; chr.CurrentBattleGroundId = id; chr.LocatonBeforeOnEnterWar = new WorldLocation(chr.Map, chr.Position); if (IsRunning) { //TeleportToWar(chr); Asda2BattlegroundHandler.SendYouCanEnterWarResponse(chr.Client); //Asda2BattlegroundHandler.SendYouCanEnterWarAfterResponse(chr.Client); } //chr.Map.CallDelayed(1,()=> Asda2BattlegroundHandler.SendHowManyPeopleInWarTeamsResponse(this)); return(true); } if (chr.Asda2FactionId == 1) //Dark { if (FreeDarkIds.Count == 0) { return(false); } var id = FreeDarkIds[0]; DarkTeam.Add(id, chr); FreeDarkIds.RemoveAt(0); chr.CurrentBattleGround = this; chr.CurrentBattleGroundId = id; chr.LocatonBeforeOnEnterWar = new WorldLocation(chr.Map, chr.Position); if (IsRunning) { //TeleportToWar(chr); Asda2BattlegroundHandler.SendYouCanEnterWarResponse(chr.Client); //Asda2BattlegroundHandler.SendYouCanEnterWarAfterResponse(chr.Client); } //chr.Map.CallDelayed(1, () => Asda2BattlegroundHandler.SendHowManyPeopleInWarTeamsResponse(this)); return(true); } return(false); } }
public void SendCurrentProgress(Character character) { if (DateTime.Now < StartTime.AddMinutes(2)) { Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarStartsInNumMins, (short)(StartTime.AddMinutes(2) - DateTime.Now).TotalMinutes, character); } else { Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarStarted, 0, character); } }
private void SendWarTimeMotofocation() { if (!IsRunning) { return; } switch (WarNotofocationStep) { case 0: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarStartsInNumMins, 1); World.TaskQueue.CallDelayed(60000, SendWarTimeMotofocation); break; case 1: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarStarted, 0); World.TaskQueue.CallDelayed(23 * 60000, SendWarTimeMotofocation); IsStarted = true; break; case 2: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarEndsInNumMins, 5); World.TaskQueue.CallDelayed(60000, SendWarTimeMotofocation); break; case 3: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarEndsInNumMins, 4); World.TaskQueue.CallDelayed(60000, SendWarTimeMotofocation); break; case 4: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarEndsInNumMins, 3); World.TaskQueue.CallDelayed(60000, SendWarTimeMotofocation); break; case 5: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarEndsInNumMins, 2); World.TaskQueue.CallDelayed(60000, SendWarTimeMotofocation); break; case 6: Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this, BattleGroundInfoMessageType.WarEndsInNumMins, 1); break; } WarNotofocationStep++; }
public void AnswerDismiss(bool kick, Character answerer) { lock (this) { if (!this.IsDismissInProgress || (int)answerer.Asda2FactionId != (int)this.DissmisFaction || answerer == this.DissmissingCharacter) { return; } if (kick) { if (this.DissmissYes.Contains(answerer)) { return; } this.DissmissYes.Add(answerer); if ((double)this.DissmissYes.Count <= (this.DissmisFaction == (short)0 ? (double)this.LightTeam.Count * 0.65 : (double)this.DarkTeam.Count * 0.65)) { return; } Asda2BattlegroundHandler.SendDissmissResultResponse(this, DismissPlayerResult.Ok, this.DissmissingCharacter.SessionId, (int)this.DissmissingCharacter.AccId); this.Leave(this.DissmissingCharacter); this.IsDismissInProgress = false; this.DissmissingCharacter = (Character)null; } else { if (this.DissmissNo.Contains(answerer)) { return; } this.DissmissNo.Add(answerer); if ((double)this.DissmissNo.Count <= (this.DissmisFaction == (short)0 ? (double)this.LightTeam.Count * 0.3 : (double)this.DarkTeam.Count * 0.3)) { return; } Asda2BattlegroundHandler.SendDissmissResultResponse(this, DismissPlayerResult.Fail, this.DissmissingCharacter.SessionId, (int)this.DissmissingCharacter.AccId); this.IsDismissInProgress = false; this.DissmissingCharacter = (Character)null; } } }
public void Start() { if (this.IsRunning) { return; } this.StartTime = DateTime.Now; this.EndTime = DateTime.Now.AddMinutes(this.WarType == Asda2BattlegroundType.Occupation ? (double)Asda2BattlegroundMgr.EveryDayDeathMatchHour : (double)Asda2BattlegroundMgr.DeathMatchDurationMins); if (this.LightTeam.Count < Asda2BattlegroundMgr.MinimumPlayersToStartWar || this.DarkTeam.Count < Asda2BattlegroundMgr.MinimumPlayersToStartWar) { WCell.RealmServer.Global.World.Broadcast(string.Format("War terminated due not enough players in {0}.", (object)this.Town)); this.SetNextWarParametrs(); } else { WCell.RealmServer.Global.World.Broadcast(string.Format("War started in {0}. Availible lvls {1}-{2}.", (object)this.Town, (object)this.MinEntryLevel, (object)this.MaxEntryLevel)); foreach (Asda2WarPoint point in this.Points) { point.Status = Asda2WarPointStatus.NotOwned; point.OwnedFaction = (short)-1; } this.DissmisedCharacterNames.Clear(); this.IsRunning = true; this.LightScores = 0; this.DarkScores = 0; this.MvpCharacter = (Character)null; this.WarNotofocationStep = (byte)0; lock (this.JoinLock) { foreach (Character character in this.LightTeam.Values) { Asda2BattlegroundHandler.SendYouCanEnterWarResponse(character.Client); } foreach (Character character in this.DarkTeam.Values) { Asda2BattlegroundHandler.SendYouCanEnterWarResponse(character.Client); } } WCell.RealmServer.Global.World.TaskQueue.CallDelayed(60000, new Action(this.SendWarTimeMotofocation)); } }
public void Update(int dt) { switch (_notificationsAboutStart) { case 3: if (DateTime.Now > StartTime.Subtract(new TimeSpan(0, 30, 0))) { _notificationsAboutStart--; World.BroadcastMsg("ÍÑÈ ÇáÝÑÞ", string.Format("{1} in {0} íÈÏà ÈÚÏ 30 ÏÞíÞÉ", Town, WarType), Color.Firebrick); Asda2BattlegroundHandler.SendMessageServerAboutWarStartsResponse(30); } break; case 2: if (DateTime.Now > StartTime.Subtract(new TimeSpan(0, 15, 0))) { _notificationsAboutStart--; World.BroadcastMsg("ÍÑÈ ÇáÝÑÞ", string.Format("{1} in {0} íÈÏà ÈÚÏ 15 ÏÞíÞÉ", Town, WarType), Color.Firebrick); Asda2BattlegroundHandler.SendMessageServerAboutWarStartsResponse(15); } break; case 1: if (DateTime.Now > StartTime.Subtract(new TimeSpan(0, 5, 0))) { _notificationsAboutStart--; World.BroadcastMsg("ÍÑÈ ÇáÝÑÞ", string.Format("{1} in {0} íÈÏà ÈÚÏ 5 ÏÞÇÆÞ", Town, WarType), Color.Firebrick); Asda2BattlegroundHandler.SendMessageServerAboutWarStartsResponse(5); } break; default: break; } if (DateTime.Now > EndTime && IsRunning) { Stop(); } else if (DateTime.Now > StartTime && DateTime.Now < EndTime) { Start(); } }
public void AnswerDismiss(bool kick, Character answerer) { lock (this) { if (!IsDismissInProgress || answerer.Asda2FactionId != DissmisFaction || answerer == DissmissingCharacter) { return; } if (kick) { if (DissmissYes.Contains(answerer)) { return; } DissmissYes.Add(answerer); if (DissmissYes.Count > (DissmisFaction == 0 ? LightTeam.Count * 0.65 : DarkTeam.Count * 0.65)) { //kick him Asda2BattlegroundHandler.SendDissmissResultResponse(this, DismissPlayerResult.Ok, DissmissingCharacter.SessionId, (int)DissmissingCharacter.AccId); Leave(DissmissingCharacter); IsDismissInProgress = false; DissmissingCharacter = null; } } else { if (DissmissNo.Contains(answerer)) { return; } DissmissNo.Add(answerer); if (DissmissNo.Count > (DissmisFaction == 0 ? LightTeam.Count * 0.3 : DarkTeam.Count * 0.3)) { //CANcel dissmis Asda2BattlegroundHandler.SendDissmissResultResponse(this, DismissPlayerResult.Fail, DissmissingCharacter.SessionId, (int)DissmissingCharacter.AccId); IsDismissInProgress = false; DissmissingCharacter = null; } } } }
public void Start() { if (IsRunning) { return; } StartTime = DateTime.Now; EndTime = DateTime.Now.AddMinutes(Asda2BattlegroundMgr.WarLengthMinutes); if (LightTeam.Count < Asda2BattlegroundMgr.MinimumPlayersToStartWar || DarkTeam.Count < Asda2BattlegroundMgr.MinimumPlayersToStartWar) { World.Broadcast(string.Format("Êã ÅáÛÇÁ ÇáÍÑÈ ÈÓÈÈ ÚÏã ßÝÇíÉ ÇááÇÚÈíä Ýí ÈáÇÏ {0}.", Town)); SetNextWarParametrs(); return; } World.Broadcast(string.Format("áÞÏ ÈÏÃÊ ÇáÍÑÈ Ýí ÈáÇÏ {0}. ÇáãÓÊæíÇÊ ÇáãÊÇÍÉ : {1}-{2}.", Town, MinEntryLevel, MaxEntryLevel)); foreach (var asda2WarPoint in Points) { asda2WarPoint.Status = Asda2WarPointStatus.NotOwned; asda2WarPoint.OwnedFaction = -1; } DissmisedCharacterNames.Clear(); IsRunning = true; LightScores = 0; DarkScores = 0; MvpCharacter = null; WarNotofocationStep = 0; //Notify character that they can login lock (JoinLock) { foreach (var character in LightTeam.Values) { //TeleportToWar(character); Asda2BattlegroundHandler.SendYouCanEnterWarResponse(character.Client); //Asda2BattlegroundHandler.SendYouCanEnterWarAfterResponse(character.Client); } foreach (var character in DarkTeam.Values) { //TeleportToWar(character); Asda2BattlegroundHandler.SendYouCanEnterWarResponse(character.Client); // Asda2BattlegroundHandler.SendYouCanEnterWarAfterResponse(character.Client); } } World.TaskQueue.CallDelayed(60000, SendWarTimeMotofocation); }
public bool Join(Character chr) { lock (this.JoinLock) { chr.BattlegroundActPoints = (short)0; chr.BattlegroundKills = 0; chr.BattlegroundDeathes = 0; if (chr.Asda2FactionId == (short)0) { if (this.FreeLightIds.Count == 0) { return(false); } byte freeLightId = this.FreeLightIds[0]; this.LightTeam.Add(freeLightId, chr); this.FreeLightIds.RemoveAt(0); chr.CurrentBattleGround = this; chr.CurrentBattleGroundId = freeLightId; chr.LocatonBeforeOnEnterWar = new WorldLocation(chr.Map, chr.Position, 1U); if (this.IsRunning) { Asda2BattlegroundHandler.SendYouCanEnterWarResponse(chr.Client); } return(true); } if (chr.Asda2FactionId != (short)1 || this.FreeDarkIds.Count == 0) { return(false); } byte freeDarkId = this.FreeDarkIds[0]; this.DarkTeam.Add(freeDarkId, chr); this.FreeDarkIds.RemoveAt(0); chr.CurrentBattleGround = this; chr.CurrentBattleGroundId = freeDarkId; chr.LocatonBeforeOnEnterWar = new WorldLocation(chr.Map, chr.Position, 1U); if (this.IsRunning) { Asda2BattlegroundHandler.SendYouCanEnterWarResponse(chr.Client); } return(true); } }
public static void RegisterToWarRequest(IRealmClient client, RealmPacketIn packet) { Asda2Battleground asda2Battleground = Asda2BattlegroundMgr.AllBattleGrounds[ client.ActiveCharacter.MapId == MapId.Alpia ? Asda2BattlegroundTown.Alpia : (client.ActiveCharacter.MapId == MapId.Silaris ? Asda2BattlegroundTown.Silaris : (client.ActiveCharacter.MapId == MapId.Aquaton ? Asda2BattlegroundTown.Aquaton : Asda2BattlegroundTown.Flamio))][0]; if (client.ActiveCharacter.Level < (int)asda2Battleground.MinEntryLevel || client.ActiveCharacter.Level > (int)asda2Battleground.MaxEntryLevel) { Asda2BattlegroundHandler.SendRegisteredToWarResponse(client, RegisterToBattlegroundStatus.WrongLevel); } else if (client.ActiveCharacter.CurrentBattleGround != null) { Asda2BattlegroundHandler.SendRegisteredToWarResponse(client, RegisterToBattlegroundStatus.YouHaveAlreadyRegistered); } else if (asda2Battleground.DissmisedCharacterNames.Contains(client.ActiveCharacter.Name)) { Asda2BattlegroundHandler.SendRegisteredToWarResponse(client, RegisterToBattlegroundStatus.YouCantEnterCauseYouHaveBeenDissmised); } else if (client.ActiveCharacter.Asda2FactionId < (short)0 || client.ActiveCharacter.Asda2FactionId > (short)1) { Asda2BattlegroundHandler.SendRegisteredToWarResponse(client, RegisterToBattlegroundStatus.BattleGroupInfoIsInvalid); } else if (asda2Battleground.Join(client.ActiveCharacter)) { Asda2BattlegroundHandler.SendRegisteredToWarResponse(client, RegisterToBattlegroundStatus.Ok); } else { Asda2BattlegroundHandler.SendRegisteredToWarResponse(client, RegisterToBattlegroundStatus.Fail); client.ActiveCharacter.SendInfoMsg("Sry no more free war places. Try again later."); } }
public static void WarChatRequestRequest(IRealmClient client, RealmPacketIn packet) { int num1 = (int)packet.ReadInt16(); int num2 = (int)packet.ReadInt16(); packet.Position += 20; string str = packet.ReadAsdaString(200, client.Locale); if (str.Length < 1 || RealmCommandHandler.HandleCommand((IUser)client.ActiveCharacter, str, (IGenericChatTarget)(client.ActiveCharacter.Target as Character)) || !client.ActiveCharacter.IsAsda2BattlegroundInProgress) { return; } Locale locale = Asda2EncodingHelper.MinimumAvailableLocale(client.Locale, str); Asda2BattlegroundHandler.SendWarChatResponseResponse(client.ActiveCharacter.CurrentBattleGround, client.ActiveCharacter.Name, str, (int)client.ActiveCharacter.Asda2FactionId, locale); }
public void TryCapture(Character activeCharacter) { lock (this) { if (this.CapturingCharacter != null) { activeCharacter.SendWarMsg(string.Format("Point {0} already capturing by {1}.", (object)((int)this.Id + 1), (object)this.CapturingCharacter.Name)); Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(activeCharacter.Client, this.Id, OcupationPointStartedStatus.Fail); } else if ((double)activeCharacter.Asda2Position.GetDistance(new Vector3((float)this.X, (float)this.Y)) > 7.0) { activeCharacter.SendWarMsg(string.Format("Distance to {0} is too big.", (object)((int)this.Id + 1))); Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(activeCharacter.Client, this.Id, OcupationPointStartedStatus.Fail); } else if (this.Status != Asda2WarPointStatus.NotOwned && (int)this.OwnedFaction == (int)activeCharacter.Asda2FactionId) { Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(activeCharacter.Client, this.Id, OcupationPointStartedStatus.YouAreOcupaingTheSameSide); } else { this.CapturingCharacter = activeCharacter; activeCharacter.CurrentCapturingPoint = this; this.CapturingCharacter.IsMoving = false; this.CapturingCharacter.IsFighting = false; Asda2MovmentHandler.SendEndMoveByFastInstantRegularMoveResponse(this.CapturingCharacter); this._isCapturing = false; this._timeToStartCapturing = CharacterFormulas.DefaultTimeToStartCapture; Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(activeCharacter.Client, this.Id, OcupationPointStartedStatus.Ok); } } }
//todo disable on move\take dmg\stun public void TryCapture(Character activeCharacter) { lock (this) { if (CapturingCharacter != null) { activeCharacter.SendWarMsg(string.Format("Point {0} already capturing by {1}.", Id + 1, CapturingCharacter.Name)); Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(activeCharacter.Client, Id, OcupationPointStartedStatus.Fail); return; } if (activeCharacter.Asda2Position.GetDistance(new Vector3(X, Y)) > 7) { activeCharacter.SendWarMsg(string.Format("Distance to {0} is too big.", Id + 1)); Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(activeCharacter.Client, Id, OcupationPointStartedStatus.Fail); return; } if (Status != Asda2WarPointStatus.NotOwned && OwnedFaction == activeCharacter.Asda2FactionId) { Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(activeCharacter.Client, Id, OcupationPointStartedStatus.YouAreOcupaingTheSameSide); return; } CapturingCharacter = activeCharacter; activeCharacter.CurrentCapturingPoint = this; CapturingCharacter.IsMoving = false; CapturingCharacter.IsFighting = false; Asda2MovmentHandler.SendEndMoveByFastInstantRegularMoveResponse(CapturingCharacter); _isCapturing = false; _timeToStartCapturing = CharacterFormulas.DefaultTimeToStartCapture; Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(activeCharacter.Client, Id, OcupationPointStartedStatus.Ok); } }
private void ProcessEndWar(Character character) { ++character.Stunned; GlobalHandler.SendFightingModeChangedResponse(character.Client, character.SessionId, (int)character.AccId, (short)-1); if (this.MvpCharacter != null) { ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => new BattlegroundCharacterResultRecord(this.CurrentWarResultRecordGuid, character.Name, character.EntityId.Low, (int)character.BattlegroundActPoints, character.BattlegroundKills, character.BattlegroundDeathes).CreateLater())); } int honorPoints = this.WiningFactionId == 2 ? 0 : CharacterFormulas.CalcHonorPoints(character.Level, character.BattlegroundActPoints, this.LightScores > this.DarkScores, character.BattlegroundDeathes, character.BattlegroundKills, this.MvpCharacter == character, this.Town); short honorCoins = this.WiningFactionId == 2 ? (short)0 : (short)((double)honorPoints / (double)CharacterFormulas.HonorCoinsDivider); if (character.BattlegroundActPoints < (short)5) { character.BattlegroundActPoints = (short)5; } if (honorPoints <= 0) { honorPoints = 1; } if (honorCoins <= (short)0) { honorCoins = (short)1; } Asda2Item asda2Item = (Asda2Item)null; if (honorCoins > (short)0) { int num = (int)character.Asda2Inventory.TryAdd(20614, (int)honorCoins, true, ref asda2Item, new Asda2InventoryType?(), (Asda2Item)null); Log.Create(Log.Types.ItemOperations, LogSourceType.Character, character.EntryId) .AddAttribute("source", 0.0, "honor_coins_for_bg").AddItemAttributes(asda2Item, "") .AddAttribute("amount", (double)honorCoins, "").Write(); } int bonusExp = this.WiningFactionId == 2 ? 0 : (int)((double)XpGenerator.GetBaseExpForLevel(character.Level) * (double)character.BattlegroundActPoints / 2.5); character.GainXp(bonusExp, "battle_ground", false); character.Asda2HonorPoints += honorPoints; AchievementProgressRecord progressRecord = character.Achievements.GetOrCreateProgressRecord(20U); if (character.FactionId == (FactionId)this.WiningFactionId) { switch (++progressRecord.Counter) { case 5: character.DiscoverTitle(Asda2TitleId.Challenger125); break; case 10: character.GetTitle(Asda2TitleId.Challenger125); break; case 25: character.DiscoverTitle(Asda2TitleId.Winner126); break; case 50: character.GetTitle(Asda2TitleId.Winner126); break; case 75: character.DiscoverTitle(Asda2TitleId.Champion127); break; case 100: character.GetTitle(Asda2TitleId.Champion127); break; case 250: character.DiscoverTitle(Asda2TitleId.Conqueror128); break; case 500: character.GetTitle(Asda2TitleId.Conqueror128); break; } progressRecord.SaveAndFlush(); } character.Resurrect(); character.Map.CallDelayed(500, (Action)(() => Asda2BattlegroundHandler.SendWarEndedResponse(character.Client, (byte)this.WiningFactionId, this.LightScores > this.DarkScores ? this.LightScores : this.DarkScores, this.LightScores > this.DarkScores ? this.DarkScores : this.LightScores, honorPoints, honorCoins, (long)bonusExp, this.MvpCharacter == null ? "" : this.MvpCharacter.Name))); Asda2BattlegroundHandler.SendWarEndedOneResponse(character.Client, (IEnumerable <Asda2Item>) new List <Asda2Item>() { asda2Item }); character.SendWarMsg("You will automaticly teleported to town in 1 minute."); }
public void Stop() { if (!IsRunning) { return; } _notificationsAboutStart = 3; IsStarted = false; World.Broadcast(string.Format("ÇáÍÑÈ Ýí {0} ÇäÊåÊ.. äÞÇØ ÇáäæÑ {1} ÖÏ {2} äÞÇØ ÇáÙáÇã", Town, LightScores, DarkScores)); IsRunning = false; SetNextWarParametrs(); //Notify players war ended. lock (JoinLock) { //find mvp foreach (var character in LightScores > DarkScores ? LightTeam.Values : DarkTeam.Values) { if (MvpCharacter == null) { MvpCharacter = character; continue; } if (MvpCharacter.BattlegroundActPoints < character.BattlegroundActPoints) { MvpCharacter = character; } } Asda2BattlegroundHandler.SendWiningFactionInfoResponse(Town, WiningFactionId, MvpCharacter == null ? "[áÇ ÃÍÏ]" : MvpCharacter.Name); if (MvpCharacter != null) { //create db records about war RealmServer.IOQueue.AddMessage(() => { var warResRec = new BattlegroundResultRecord(Town, MvpCharacter.Name, MvpCharacter.EntityId.Low, LightScores, DarkScores); warResRec.CreateLater(); CurrentWarResultRecordGuid = warResRec.Guid; Asda2BattlegroundMgr.ProcessBattlegroundResultRecord(warResRec); }); } foreach (var character in LightTeam.Values) { ProcessEndWar(character); if (WiningFactionId == 0) { Asda2TitleChecker.OnWinWar(character); } else { Asda2TitleChecker.OnLoseWar(character); } } foreach (var character in DarkTeam.Values) { ProcessEndWar(character); if (WiningFactionId == 1) { Asda2TitleChecker.OnWinWar(character); } else { Asda2TitleChecker.OnLoseWar(character); } } foreach (var asda2WarPoint in Points) { asda2WarPoint.Status = Asda2WarPointStatus.NotOwned; asda2WarPoint.OwnedFaction = -1; Asda2BattlegroundHandler.SendUpdatePointInfoResponse(null, asda2WarPoint); } World.TaskQueue.CallDelayed(60000, KickAll); } }
private void ProcessEndWar(Character character) { character.Stunned++; GlobalHandler.SendFightingModeChangedResponse(character.Client, character.SessionId, (int)character.AccId, -1); //create db record if (MvpCharacter != null) { RealmServer.IOQueue.AddMessage(() => { var rec = new BattlegroundCharacterResultRecord(CurrentWarResultRecordGuid, character.Name, character.EntityId.Low, character.BattlegroundActPoints, character.BattlegroundKills, character.BattlegroundDeathes); rec.CreateLater(); }); } var honorPoints = WiningFactionId == 2 ? 0 : CharacterFormulas.CalcHonorPoints(character.Level, character.BattlegroundActPoints, LightScores > DarkScores, character.BattlegroundDeathes, character.BattlegroundKills, MvpCharacter == character, Town); var honorCoins = (short)(WiningFactionId == 2 ? 0 : (honorPoints / CharacterFormulas.HonorCoinsDivider)); if (character.BattlegroundActPoints < 5) { character.BattlegroundActPoints = 5; } if (honorPoints <= 0) { honorPoints = 1; } if (honorCoins <= 0) { honorCoins = 1; } Asda2Item itemCoins = null; if (honorCoins > 0) { character.Asda2Inventory.TryAdd( 20614, honorCoins, true, ref itemCoins); Log.Create(Log.Types.ItemOperations, LogSourceType.Character, character.EntryId) .AddAttribute("source", 0, "honor_coins_for_bg") .AddItemAttributes(itemCoins) .AddAttribute("amount", honorCoins) .Write(); } var bonusExp = WiningFactionId == 2 ? 0 : (int)((float)XpGenerator.GetBaseExpForLevel(character.Level) * character.BattlegroundActPoints / 2.5); character.GainXp(bonusExp, "battle_ground"); character.Asda2HonorPoints += honorPoints; Asda2BattlegroundHandler.SendWarEndedResponse(character.Client, (byte)WiningFactionId, LightScores > DarkScores ? LightScores : DarkScores, LightScores > DarkScores ? DarkScores : LightScores, honorPoints, honorCoins, bonusExp, MvpCharacter == null ? "" : MvpCharacter.Name); Asda2BattlegroundHandler.SendWarEndedOneResponse(character.Client, new List <Asda2Item> { itemCoins }); character.SendWarMsg("ÓæÝ íÊã ÅÑÓÇáß Åáì ÇáãÏíäÉ ÈÚÏ 1 ÏÞíÞÉ ãä ÇáÇä."); }
public static void SendWarTeamListResponse(Character chr) { Asda2Battleground currentBattleGround = chr.CurrentBattleGround; List <List <Character> > characterListList = new List <List <Character> >(); lock (currentBattleGround.JoinLock) { if (chr.Asda2FactionId == (short)0) { int num = currentBattleGround.LightTeam.Count / 6; if (num == 0) { num = 1; } for (int index = 0; index < num; ++index) { characterListList.Add(currentBattleGround.LightTeam.Values.Skip <Character>(index * 6) .Take <Character>(6).ToList <Character>()); } } else { int num = currentBattleGround.DarkTeam.Count / 6; if (num == 0) { num = 1; } for (int index = 0; index < num; ++index) { characterListList.Add(currentBattleGround.DarkTeam.Values.Skip <Character>(index * 6) .Take <Character>(6).ToList <Character>()); } } foreach (List <Character> characterList in characterListList) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.WarTeamList)) { foreach (Character character in characterList) { packet.WriteByte(character.CurrentBattleGroundId); packet.WriteByte(character.Asda2FactionId); packet.WriteInt16(character.SessionId); packet.WriteInt32(character.AccId); packet.WriteByte(character.CharNum); packet.WriteByte(3); packet.WriteByte(character.Asda2FactionRank); packet.WriteInt16(character.Level); packet.WriteByte(character.ProfessionLevel); packet.WriteByte((byte)character.Archetype.ClassId); packet.WriteByte(character.Guild == null ? 0 : (character.Guild.ClanCrest == null ? 0 : 1)); packet.WriteSkip(character.Guild == null ? Asda2BattlegroundHandler.guildCrest : character.Guild.ClanCrest ?? Asda2BattlegroundHandler.guildCrest); packet.WriteInt16(character.IsInGroup ? 1 : -1); packet.WriteInt16(character.BattlegroundDeathes); packet.WriteInt16(character.BattlegroundKills); packet.WriteInt16(character.BattlegroundActPoints); packet.WriteFixedAsciiString(character.Name, 20, Locale.Start); packet.WriteFixedAsciiString(character.Guild == null ? "" : character.Guild.Name, 17, Locale.Start); packet.WriteInt16((short)character.Asda2Position.X); packet.WriteInt16((short)character.Asda2Position.Y); } chr.Send(packet, false); } } Asda2BattlegroundHandler.SendWarTeamListEndedResponse(chr.Client); } }