Рейтинг темы:
  • 0 Голос(ов) - 0 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
Косяк в раундах
#1
в настройках комнаты 5 а играть может хоть 20 раундов
помогите конец боя сделать
Ответ
#2
А проверка на раунды есть?
Ответ
#3
В каком пакете она должна быть?
Timer.sync все прописал
Ответ
#4
Где вызываете PROTOCOL_BATTLE_MISSION_ROUND_END_ACK, там нужно инкрементировать раунды и проверять не последний ли раунд только что закончился.
Ответ
#5
В фраг инфо и таймер сунк

Добавлено через 25 минут
Код:
public class CM_BATTLE_FRAG_INFO extends ClientPacket {

    private FragInfos fragInfos = new FragInfos();
    private int TeamWin = -1;

    public CM_BATTLE_FRAG_INFO(int opcode) {
        super(opcode);
    }

    @Override
    public void readImpl() {
        fragInfos.setVicTimIdx(readC()); // WTF? killsCount - 1, если РЅРµ убиваеш себя... если Рё себя то 0 будет если пострадал 1 Р±РѕС‚ Рё сам РёРіСЂРѕРє.
        fragInfos.setKillsCount(readC()); // Всего померло.
        fragInfos.setKiller(readC()); // Слот убившего.
        fragInfos.setKillWeapon(readD()); // РћСЂСѓРґРёРµ убийства.
        fragInfos.setUnkBytes(readB(13)); // РҐР· что там

        for (int i = 1; i <= fragInfos.getKillsCount(); i++) {
            Frag frag = new Frag();
            frag.setUnkC1(readC()); //
            frag.setDeathMask(readC()); //
            frag.setUnkC3(readC()); //
            frag.setUnkC4(readC()); //
            frag.setUnk13bytes(readB(13));

            fragInfos.addFrag(i, frag);
        }
    }

    @Override
    public void runImpl() {
        Room room = getConnection().getRoom();
        Player player = getConnection().getPlayer();
        if (room != null && player != null) {
            RoomSlot killer = room.getRoomSlot(fragInfos.getKiller());
            for (int i = 1; i <= fragInfos.getKillsCount(); i++) {
                Frag frag = fragInfos.getFrag(i);
                if (frag != null) {
                    boolean suicide = frag.getDeatSlot() == fragInfos.getKiller();
                    RoomSlot death = room.getRoomSlot(frag.getDeatSlot());
                    if (!suicide) {
                        killer.setAllKills(killer.getAllKills() + 1);
                        killer.setOneTimeKills(killer.getOneTimeKills() + 1);

                        int weaponHeadNum = fragInfos.getWeaponHeadNum();
                        killer.setKillMessage(0);
                        if (fragInfos.getKillsCount() > 1) {
                            if ((weaponHeadNum == 8030) || (weaponHeadNum == 9030)) {
                                killer.setKillMessage(2);
                            } else {
                                killer.setKillMessage(1);
                            }
                        } else {
                            int killMessage = 0;
                            if (frag.getDeathMask() >> 4 == 3) { //TODO:: понять что это Рё всунуть РІ Frag!
                                killMessage = 4;
                            } else if ((frag.getDeathMask() >> 4 == 1) && (frag.getDeathMask() >> 2 == 1) && (weaponHeadNum == 7020)) {
                                killMessage = 6;
                            }

                            if (killMessage > 0) {
                                int lastMessage = killer.lastKillState >> 12;

                                if (killMessage == 4) {
                                    if (lastMessage != 4) {
                                        killer.repeatLastState = false;
                                        killer.setOneTimeKills(0);
                                    }

                                    killer.setOneTimeKills(killer.getOneTimeKills() + 1);
                                    killer.lastKillState = killMessage << 12 | killer.getOneTimeKills();

                                    int countedKill = killer.lastKillState & 0xF;

                                    if (killer.repeatLastState) {
                                        if (countedKill > 1)
                                            killer.setKillMessage(5);
                                        else
                                            killer.setKillMessage(4);
                                    } else {
                                        killer.setKillMessage(4);
                                        killer.repeatLastState = true;
                                    }
                                } else if (killMessage == 6) {
                                    if (lastMessage != 6) {
                                        killer.repeatLastState = false;
                                        killer.setOneTimeKills(0);
                                    }

                                    killer.setOneTimeKills(killer.getOneTimeKills() + 1);
                                    killer.lastKillState = killMessage << 12 | killer.getOneTimeKills();

                                    int countedKill = killer.lastKillState & 0xF;

                                    if (killer.repeatLastState) {
                                        if (countedKill > 1)
                                            killer.setKillMessage(6);
                                    } else
                                        killer.repeatLastState = true;
                                } else if (killMessage == 0) {
                                    //TODO: Што это ваще ? Накой?
                                    //if (killer.getOneTimeKills() == 1)
                                    //killer.setKillMessage(3);
                                    //else if (killer.getOneTimeKills() == 2)
                                    //killer.setKillMessage(3);
                                }
                            } else {
                                killer.lastKillState = 0;
                                killer.repeatLastState = false;
                            }
                        }

                        //Добавляем общий счет команде
                        if (frag.getDeatSlot() % 2 == 0) {    // Если помер красный
                            room.setRedDeaths(room.getRedDeaths() + 1);
                            room.setBlueKills(room.getBlueKills() + 1);
                        } else {
                            room.setBlueDeaths(room.getBlueDeaths() + 1);
                            room.setRedKills(room.getRedKills() + 1);
                        }
                        death.setOneTimeKills(0);
                        death.setKillMessage(0);
                        death.setLastKillMessage(0);
                        death.lastKillState = 0;
                    }
                    death.setAllDeahts(death.getAllDeath() + 1);
                    //Добавляем очки РІ Р±РѕСЋ СЃ ботами
                    if (room.getSpecial() == 6) {
                        RoomSlot slot = room.getRoomSlot(fragInfos.getKiller());
                        int AILevel = room.getRoomSlotByPlayer(room.getLeader()).getId() % 2 == 0 ? room.getAiLevel() + room.getBlueDeaths() / 20 : room.getAiLevel() + room.getRedDeaths() / 20;
                        int AIScore = 10 + room.getRoomSlot(fragInfos.getKiller()).getOneTimeKills() * AILevel;
                        slot.setBotScore(slot.getBotScore() + AIScore);
                    }
                }
            }
            

             if (room.getType() == 2)
             {
                 if (room.getBlueKills() == room.redTeamCount)
                 {
                     TeamWin = 0;
                 }
                 else if (room.getRedKills() == room.blueTeamCount)
                 {
                     TeamWin = 1;
                 }
             }
          
             if (room.getType() == 4)
             {
                 if (room.getBlueKills()  == room.redTeamCount)
                 {
                     TeamWin = 0;
                 }
                 else if (room.getRedKills() == room.blueTeamCount)
                 {
                     TeamWin = 1;
                 }
             }
         }
    
    

    for (Player member : room.getPlayers().values()) {
        if (SlotState.SLOT_STATE_BATTLE == room.getRoomSlotByPlayer(member).getState()) {
            member.getConnection().sendPacket(new SM_BATTLE_FRAG_INFO(room, fragInfos));
        }
    }

    
      
               if (TeamWin >= 0)
     {
         //TeamWin = -1;
         if (!(TeamWin == 1 && room.getBombState() == 1))
         {
             room.setRedKills(0);
             room.setBlueKills(0);
             if (TeamWin == 1)
             {
                 room.setBlueWinRounds(room.getBlueWinRounds() + 1);
             }
             else
             {
                 room.setRedWinRounds(room.getRedWinRounds() + 1);
             }
             if ((TeamWin == 0 ? room.getBlueWinRounds() : room.getRedWinRounds()) == room.getKillsByMask())
//                  if ((((((room.killtime == 2) && (room.getRedWinRounds() >= 3)) || ((room.killtime == 2) && (room.getBlueWinRounds() >= 3))) || (((room.killtime == 3) && (room.getRedWinRounds() >= 5)) || ((room.killtime == 3) && (room.getBlueWinRounds() >= 5)))) || ((((room.killtime == 4) && (room.getRedWinRounds() >= 7)) || ((room.killtime == 4) && (room.getBlueWinRounds() >= 7))) || ((room.killtime == 5) && (room.getRedWinRounds() >= 9)))) || ((room.killtime == 5) && (room.getBlueWinRounds() >= 9)))
             {
                  for (Player member : getConnection().getRoom().getPlayers().values())
                 {
                     RoomSlot slot = room.getRoomSlotByPlayer(member);
                      member.getConnection().sendPacket(new SM_BATTLE_END(player, room));
                     slot.setKillMessage(0);
                     slot.setLastKillMessage(0);
                     slot.setOneTimeKills(0);
                     slot.setAllKills(0);
                     slot.setAllDeahts(0);
                 }
                 room.setRedKills(0);
                 room.setRedDeaths(0);
                 room.setBlueKills(0);
                 room.setBlueDeaths(0);
                 room.setFigth(false);
                 room.setBlueWinRounds(0);
                 room.setRedWinRounds(0);
                 room.setBombState(0);
             }
             else
             {
                  for (Player member : getConnection().getRoom().getPlayers().values())
                 {
                     RoomSlot slot = room.getRoomSlotByPlayer(member);
                     slot.setKillMessage(0);
                     slot.setLastKillMessage(0);
                     slot.setOneTimeKills(0);
                     slot.lastKillState = 0;
                     room.setRedKills(0);
                     room.setRedDeaths(0);
                     room.setBlueKills(0);
                     room.setBlueDeaths(0);
                     room.setBombState(0);
                     member.getConnection().sendPacket(new SM_BATTLE_ROUND_END(TeamWin, 4, room));
                 }
                 try {
                     Thread.sleep(8000);
                 } catch (InterruptedException ex) {
                   //  Logger.getLogger(CM_BATTLE_FRAG_INFO.class.getName()).log(Level.SEVERE, null, ex);
                 }
                 for (Player member : getConnection().getRoom().getPlayers().values())
                 {
                     member.getConnection().sendPacket(new SM_UNK_3865());
                     member.getConnection().sendPacket(new SM_BATTLE_ROUND_START(room));
                 }
             }
            // TeamWin = -1;
         }
         TeamWin = -1;
                 }
             }
             //TeamWin = -1;
                    
         }
Ответ
#6
Код:
if (TeamWin == 1)
             {
                 room.setBlueWinRounds(room.getBlueWinRounds() + 1);
             }

Код:
if ((TeamWin == 0 ? room.getBlueWinRounds() : room.getRedWinRounds()) == room.getKillsByMask())

Так всё же, BlueWin это когда TeamWin == 1 или 0, и что есть getKillsByMask? Так как я вижу, там что-то с убийствами связано, но сравнивается это всё с раундами.
Ответ
#7
PROGRAMMATOR Написал:
Код:
if (TeamWin == 1)
             {
                 room.setBlueWinRounds(room.getBlueWinRounds() + 1);
             }

Код:
if ((TeamWin == 0 ? room.getBlueWinRounds() : room.getRedWinRounds()) == room.getKillsByMask())

Так всё же, BlueWin это когда TeamWin == 1 или 0, и что есть getKillsByMask? Так как я вижу, там что-то с убийствами связано, но сравнивается это всё с раундами.

Проверка, убиты ли все члены команды и стоит ли бомба( правда я ее не заметил там..) (но как вариант, раунды без плента)
Ответ
#8
public int getKillsByMask()
{
if (killMask >> 4 < 3)
return ROUNDS[killMask-1 & 15]; // Если бой по раундам.
else
return KILLS[killMask & 15]; // Если бой по кол-ву убийств.
}
Ответ
#9
slawa560, у вас ошибка скорее всего во втором куске кода, что я процитировал.

Пробуйте сделать типа:

[SRC="java"]if (Math.max(redTeamWonRounds, blueTeamWonRounds) >= roundsQty) {
// ...
// PROTOCOL_BATTLE_ENDBATTLE_ACK
// ...
}
[/SRC]
Ответ
#10
https://www.youtube.com/watch?v=nPn9Mtr6MxU
ПРОГРАММАТОР СПАСИБО БОЛЬШОЕ Я ВСЕ ИСПРАВИЛ ВОТ ТОЛЬКО БОМБА НЕ ДЕФУЗИТЬСЯ НЕ МОГУ ПОНЯТЬ КАК СДЕЛАТЬ ВЕДЬ НА АРАБ КЛИЕНТЕ ДАЖЕ С УПД 2 ВСЕ РАБОТАЛО)))
Ответ


Перейти к форуму:


Пользователи, просматривающие эту тему: 5 Гость(ей)