public override void write() { this.writeH((short)3338); this.writeD(this.slot._id); this.writeD(this.room.spawnsCount++); this.writeD(++this.slot.spawnsCount); this.writeD(this.slot._equip._primary); this.writeD(this.slot._equip._secondary); this.writeD(this.slot._equip._melee); this.writeD(this.slot._equip._grenade); this.writeD(this.slot._equip._special); this.writeD(0); this.writeB(new byte[6] { (byte)100, (byte)100, (byte)100, (byte)100, (byte)100, (byte)1 }); this.writeD(this.slot._equip._red); this.writeD(this.slot._equip._blue); this.writeD(this.slot._equip._helmet); this.writeD(this.slot._equip._beret); this.writeD(this.slot._equip._dino); if (this.room.room_type != (byte)7 && this.room.room_type != (byte)12) { return; } List <int> dinossaurs = AllUtils.getDinossaurs(this.room,false,this.slot._id); int num1 = dinossaurs.Count == 1 || this.room.room_type == (byte)12 ? (int)byte.MaxValue : this.room.TRex; this.writeC((byte)num1); foreach (int num2 in dinossaurs) { if (num2 != this.room.TRex && this.room.room_type == (byte)7 || this.room.room_type == (byte)12) { this.writeC((byte)num2); } } int num3 = 8 - dinossaurs.Count - (num1 == (int)byte.MaxValue ? 1 : 0); for (int index = 0; index < num3; ++index) { this.writeC(byte.MaxValue); } this.writeC(byte.MaxValue); this.writeC(byte.MaxValue); }
public override void write() { writeH(3338); writeD(slot._id); writeD(room.spawnsCount++); //total number of all players' respawns writeD(++slot.spawnsCount); //total number of current player's respawns writeD(slot._equip._primary); writeD(slot._equip._secondary); writeD(slot._equip._melee); writeD(slot._equip._grenade); writeD(slot._equip._special); writeD(0); writeB(new byte[6] { 100,100,100,100,100,1 }); //Durabilidade das armas writeD(slot._equip._red); writeD(slot._equip._blue); writeD(slot._equip._helmet); writeD(slot._equip._beret); writeD(slot._equip._dino); if (room.room_type == 7 || room.room_type == 12) { List <int> pL = AllUtils.getDinossaurs(room,false,slot._id); int TRex = pL.Count == 1 || room.room_type == 12 ? 255 : room.TRex; writeC((byte)TRex); foreach (int slotId in pL) { if (slotId != room.TRex && room.room_type == 7 || room.room_type == 12) { writeC((byte)slotId); } } int falta = 8 - pL.Count - (TRex == 255 ? 1 : 0); for (int i = 0; i < falta; i++) { writeC(255); } writeC(255); writeC(255); } }
public BATTLE_ROUND_RESTART_PAK(Room r) { _r = r; _dinos = AllUtils.getDinossaurs(r, false, -1); isBotMode = _r.isBotMode(); }
private void EndRound(Room room,bool isBotMode) { try { room.swapRound = true; if (room.room_type == (byte)7 || room.room_type == (byte)12) { if (room.rodada == 1) { room.rodada = 2; for (int index = 0; index < 16; ++index) { SLOT slot = room._slots[index]; if (slot.state == SLOT_STATE.BATTLE) { slot.killsOnLife = 0; slot.lastKillState = 0; slot.repeatLastState = false; } } List <int> dinossaurs = AllUtils.getDinossaurs(room,true,-2); using (BATTLE_ROUND_WINNER_PAK battleRoundWinnerPak = new BATTLE_ROUND_WINNER_PAK(room,2,RoundEndType.TimeOut)) { using (BATTLE_ROUND_RESTART_PAK battleRoundRestartPak = new BATTLE_ROUND_RESTART_PAK(room,dinossaurs,isBotMode)) room.SendPacketToPlayers((SendPacket)battleRoundWinnerPak,(SendPacket)battleRoundRestartPak,SLOT_STATE.BATTLE,0); } room.round.StartJob(5250,(TimerCallback)(callbackState => { if (room._state == RoomState.Battle) { room.BattleStart = DateTime.Now.AddSeconds(5.0); using (BATTLE_TIMERSYNC_PAK battleTimersyncPak = new BATTLE_TIMERSYNC_PAK(room)) room.SendPacketToPlayers((SendPacket)battleTimersyncPak,SLOT_STATE.BATTLE,0); } room.swapRound = false; lock (callbackState) room.round.Timer = (Timer)null; })); } else { if (room.rodada != 2) { return; } AllUtils.EndBattle(room,isBotMode); } } else if (room.thisModeHaveRounds()) { int winner = 1; if (room.room_type != (byte)3) { ++room.blue_rounds; } else if (room.Bar1 > room.Bar2) { ++room.red_rounds; winner = 0; } else if (room.Bar1 < room.Bar2) { ++room.blue_rounds; } else { winner = 2; } AllUtils.BattleEndRound(room,winner,RoundEndType.TimeOut); } else { List <Account> allPlayers = room.getAllPlayers(SLOT_STATE.READY,1); if (allPlayers.Count != 0) { TeamResultType winnerTeam = AllUtils.GetWinnerTeam(room); room.CalculateResult(winnerTeam,isBotMode); using (BATTLE_ROUND_WINNER_PAK battleRoundWinnerPak = new BATTLE_ROUND_WINNER_PAK(room,winnerTeam,RoundEndType.TimeOut)) { ushort result1; ushort result2; byte[] data; AllUtils.getBattleResult(room,out result1,out result2,out data); byte[] completeBytes = battleRoundWinnerPak.GetCompleteBytes("BATTLE_TIMERSYNC_REC"); foreach (Account p in allPlayers) { if (room._slots[p._slotId].state == SLOT_STATE.BATTLE) { p.SendCompletePacket(completeBytes); } p.SendPacket((SendPacket) new BATTLE_ENDBATTLE_PAK(p,winnerTeam,result2,result1,isBotMode,data)); } } } AllUtils.resetBattleInfo(room); } } catch (Exception ex) { if (room != null) { Logger.error("[!] Crash no BATTLE_TIMERSYNC_REC, Sala: " + (object)room._roomId + ";" + (object)room._channelId + ";" + (object)room.room_type); } Logger.error("[BATTLE_TIMERSYNC_REC2] " + ex.ToString()); } }
private void EndRound(Room room,bool isBotMode) { try { room.swapRound = true; if (room.room_type == 7 || room.room_type == 12) { if (room.rodada == 1) { room.rodada = 2; for (int i = 0; i < 16; i++) { SLOT slot = room._slots[i]; if (slot.state == SLOT_STATE.BATTLE) { slot.killsOnLife = 0; slot.lastKillState = 0; slot.repeatLastState = false; } } List <int> dinos = AllUtils.getDinossaurs(room,true,-2); using (BATTLE_ROUND_WINNER_PAK packet = new BATTLE_ROUND_WINNER_PAK(room,2,RoundEndType.TimeOut)) using (BATTLE_ROUND_RESTART_PAK packet2 = new BATTLE_ROUND_RESTART_PAK(room,dinos,isBotMode)) room.SendPacketToPlayers(packet,packet2,SLOT_STATE.BATTLE,0); room.round.StartJob(5250,(callbackState) => { if (room._state == RoomState.Battle) { room.BattleStart = DateTime.Now.AddSeconds(5); using (BATTLE_TIMERSYNC_PAK packet = new BATTLE_TIMERSYNC_PAK(room)) room.SendPacketToPlayers(packet,SLOT_STATE.BATTLE,0); } room.swapRound = false; lock (callbackState) { room.round.Timer = null; } }); } else if (room.rodada == 2) { AllUtils.EndBattle(room,isBotMode); } } else if (room.thisModeHaveRounds()) { int winner = 1; if (room.room_type != 3) { room.blue_rounds++; } else { if (room.Bar1 > room.Bar2) { room.red_rounds++; winner = 0; } else if (room.Bar1 < room.Bar2) { room.blue_rounds++; } else { winner = 2; } } AllUtils.BattleEndRound(room,winner,RoundEndType.TimeOut); } else { List <Account> players = room.getAllPlayers(SLOT_STATE.READY,1); if (players.Count == 0) { goto EndLabel; } TeamResultType winnerTeam = AllUtils.GetWinnerTeam(room); room.CalculateResult(winnerTeam,isBotMode); using (BATTLE_ROUND_WINNER_PAK packet = new BATTLE_ROUND_WINNER_PAK(room,winnerTeam,RoundEndType.TimeOut)) { ushort inBattle,missionCompletes; byte[] a1; AllUtils.getBattleResult(room,out missionCompletes,out inBattle,out a1); byte[] data = packet.GetCompleteBytes(); foreach (Account pR in players) { if (room._slots[pR._slotId].state == SLOT_STATE.BATTLE) { pR.SendCompletePacket(data); } pR.SendPacket(new BATTLE_ENDBATTLE_PAK(pR,winnerTeam,inBattle,missionCompletes,isBotMode,a1)); } } EndLabel: AllUtils.resetBattleInfo(room); } } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[BATTLE_TIMERSYNC_REC2.EndRound] Erro fatal!"); if (room != null) { SaveLog.fatal("[!] Crash no BATTLE_TIMERSYNC_REC, Sala: " + room._roomId + ";" + room._channelId + ";" + room.room_type); } } }