From c597a45fca39525e65e5e7b599440e7a08847476 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 6 Jun 2021 21:44:04 +0000 Subject: [PATCH] Various homunculus packet related adjustments. --- .../RequestExActivateHomunculus.java | 63 +++++++++---------- .../homunculus/RequestExHomunculusSummon.java | 30 ++++----- .../homunculus/ExShowHomunculusList.java | 12 +++- .../RequestExActivateHomunculus.java | 63 +++++++++---------- .../homunculus/ExShowHomunculusList.java | 12 +++- 5 files changed, 89 insertions(+), 91 deletions(-) diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExActivateHomunculus.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExActivateHomunculus.java index 10334de859..104976d8a2 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExActivateHomunculus.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExActivateHomunculus.java @@ -43,52 +43,45 @@ public class RequestExActivateHomunculus implements IClientIncomingPacket @Override public void run(GameClient client) { - PlayerInstance activeChar = client.getPlayer(); + final PlayerInstance activeChar = client.getPlayer(); if (activeChar == null) { return; } - final Homunculus homunculus = activeChar.getHomunculusList().get(_slot); - boolean anotherActive = false; - int size = activeChar.getHomunculusList().size(); - if (size > 1) - { - if (_slot == 0) - { - if (activeChar.getHomunculusList().get(1).isActive()) - { - anotherActive = true; - } - } - else - { - if (activeChar.getHomunculusList().get(0).isActive()) - { - anotherActive = true; - } - } - } - - if (anotherActive) + if (activeChar.getHomunculusList().size() == 0) { return; } - if (!homunculus.isActive() && _activate) + + final Homunculus homunculus = activeChar.getHomunculusList().get(_slot); + if (homunculus == null) { - homunculus.setActive(true); - activeChar.getHomunculusList().update(homunculus); - activeChar.getHomunculusList().refreshStats(true); - activeChar.sendPacket(new ExShowHomunculusList(activeChar)); - activeChar.sendPacket(new ExActivateHomunculusResult(true)); + return; } - else if (homunculus.isActive() && !_activate) + + if (_activate) { - homunculus.setActive(false); - activeChar.getHomunculusList().update(homunculus); - activeChar.getHomunculusList().refreshStats(true); - activeChar.sendPacket(new ExShowHomunculusList(activeChar)); - activeChar.sendPacket(new ExActivateHomunculusResult(false)); + if (!homunculus.isActive()) + { + + homunculus.setActive(true); + activeChar.getHomunculusList().update(homunculus); + activeChar.getHomunculusList().refreshStats(true); + activeChar.sendPacket(new ExShowHomunculusList(activeChar)); + activeChar.sendPacket(new ExActivateHomunculusResult(true)); + } + } + else + { + if (homunculus.isActive()) + { + homunculus.setActive(false); + activeChar.getHomunculusList().update(homunculus); + activeChar.getHomunculusList().refreshStats(true); + activeChar.sendPacket(new ExShowHomunculusList(activeChar)); + activeChar.sendPacket(new ExActivateHomunculusResult(false)); + } } } } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExHomunculusSummon.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExHomunculusSummon.java index d07760eefd..9c44d02e07 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExHomunculusSummon.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExHomunculusSummon.java @@ -68,20 +68,20 @@ public class RequestExHomunculusSummon implements IClientIncomingPacket final int chance = Rnd.get(100); if (chance >= 60) // Basic Homunculus { - int chance2 = Rnd.get(100); - if (chance2 >= 80) + final int random = Rnd.get(100); + if (random >= 80) { homunculusId = 1; } - else if (chance2 >= 60) + else if (random >= 60) { homunculusId = 4; } - else if (chance2 >= 40) + else if (random >= 40) { homunculusId = 7; } - else if (chance2 >= 20) + else if (random >= 20) { homunculusId = 10; } @@ -92,20 +92,20 @@ public class RequestExHomunculusSummon implements IClientIncomingPacket } else if (chance >= 10) // Water Homunculus { - int chance2 = Rnd.get(100); - if (chance2 >= 80) + final int random = Rnd.get(100); + if (random >= 80) { homunculusId = 2; } - else if (chance2 >= 60) + else if (random >= 60) { homunculusId = 5; } - else if (chance2 >= 40) + else if (random >= 40) { homunculusId = 8; } - else if (chance2 >= 20) + else if (random >= 20) { homunculusId = 11; } @@ -116,20 +116,20 @@ public class RequestExHomunculusSummon implements IClientIncomingPacket } else // Luminous Homunculus { - int chance2 = Rnd.get(100); - if (chance2 >= 80) + final int random = Rnd.get(100); + if (random >= 80) { homunculusId = 3; } - else if (chance2 >= 60) + else if (random >= 60) { homunculusId = 6; } - else if (chance2 >= 40) + else if (random >= 40) { homunculusId = 9; } - else if (chance2 >= 20) + else if (random >= 20) { homunculusId = 12; } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/homunculus/ExShowHomunculusList.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/homunculus/ExShowHomunculusList.java index 602e3185a8..8eb2384ba0 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/homunculus/ExShowHomunculusList.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/homunculus/ExShowHomunculusList.java @@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.network.serverpackets.homunculus; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.homunculus.Homunculus; +import org.l2jmobius.gameserver.model.homunculus.HomunculusList; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; @@ -42,12 +43,16 @@ public class ExShowHomunculusList implements IClientOutgoingPacket if (_player.getHomunculusList().size() > 0) { packet.writeD(_player.getHomunculusList().size()); // homunculus count - for (int i = 0; i < _player.getHomunculusList().size(); i++) + int counter = 0; + for (int i = 0; i < HomunculusList.MAX_SIZE; i++) { - packet.writeD(i); // slot - final Homunculus homunculus = _player.getHomunculusList().get(i); + if (homunculus == null) + { + continue; + } + packet.writeD(counter); // slot packet.writeD(homunculus.getId()); // homunculus id packet.writeD(homunculus.getType()); packet.writeC(homunculus.isActive() ? 1 : 0); @@ -69,6 +74,7 @@ public class ExShowHomunculusList implements IClientOutgoingPacket packet.writeD(homunculus.getAtk()); packet.writeD(homunculus.getDef()); packet.writeD(homunculus.getCritRate()); + counter++; } } else diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExActivateHomunculus.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExActivateHomunculus.java index 10334de859..104976d8a2 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExActivateHomunculus.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/homunculus/RequestExActivateHomunculus.java @@ -43,52 +43,45 @@ public class RequestExActivateHomunculus implements IClientIncomingPacket @Override public void run(GameClient client) { - PlayerInstance activeChar = client.getPlayer(); + final PlayerInstance activeChar = client.getPlayer(); if (activeChar == null) { return; } - final Homunculus homunculus = activeChar.getHomunculusList().get(_slot); - boolean anotherActive = false; - int size = activeChar.getHomunculusList().size(); - if (size > 1) - { - if (_slot == 0) - { - if (activeChar.getHomunculusList().get(1).isActive()) - { - anotherActive = true; - } - } - else - { - if (activeChar.getHomunculusList().get(0).isActive()) - { - anotherActive = true; - } - } - } - - if (anotherActive) + if (activeChar.getHomunculusList().size() == 0) { return; } - if (!homunculus.isActive() && _activate) + + final Homunculus homunculus = activeChar.getHomunculusList().get(_slot); + if (homunculus == null) { - homunculus.setActive(true); - activeChar.getHomunculusList().update(homunculus); - activeChar.getHomunculusList().refreshStats(true); - activeChar.sendPacket(new ExShowHomunculusList(activeChar)); - activeChar.sendPacket(new ExActivateHomunculusResult(true)); + return; } - else if (homunculus.isActive() && !_activate) + + if (_activate) { - homunculus.setActive(false); - activeChar.getHomunculusList().update(homunculus); - activeChar.getHomunculusList().refreshStats(true); - activeChar.sendPacket(new ExShowHomunculusList(activeChar)); - activeChar.sendPacket(new ExActivateHomunculusResult(false)); + if (!homunculus.isActive()) + { + + homunculus.setActive(true); + activeChar.getHomunculusList().update(homunculus); + activeChar.getHomunculusList().refreshStats(true); + activeChar.sendPacket(new ExShowHomunculusList(activeChar)); + activeChar.sendPacket(new ExActivateHomunculusResult(true)); + } + } + else + { + if (homunculus.isActive()) + { + homunculus.setActive(false); + activeChar.getHomunculusList().update(homunculus); + activeChar.getHomunculusList().refreshStats(true); + activeChar.sendPacket(new ExShowHomunculusList(activeChar)); + activeChar.sendPacket(new ExActivateHomunculusResult(false)); + } } } } diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/homunculus/ExShowHomunculusList.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/homunculus/ExShowHomunculusList.java index 602e3185a8..8eb2384ba0 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/homunculus/ExShowHomunculusList.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/homunculus/ExShowHomunculusList.java @@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.network.serverpackets.homunculus; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.homunculus.Homunculus; +import org.l2jmobius.gameserver.model.homunculus.HomunculusList; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; @@ -42,12 +43,16 @@ public class ExShowHomunculusList implements IClientOutgoingPacket if (_player.getHomunculusList().size() > 0) { packet.writeD(_player.getHomunculusList().size()); // homunculus count - for (int i = 0; i < _player.getHomunculusList().size(); i++) + int counter = 0; + for (int i = 0; i < HomunculusList.MAX_SIZE; i++) { - packet.writeD(i); // slot - final Homunculus homunculus = _player.getHomunculusList().get(i); + if (homunculus == null) + { + continue; + } + packet.writeD(counter); // slot packet.writeD(homunculus.getId()); // homunculus id packet.writeD(homunculus.getType()); packet.writeC(homunculus.isActive() ? 1 : 0); @@ -69,6 +74,7 @@ public class ExShowHomunculusList implements IClientOutgoingPacket packet.writeD(homunculus.getAtk()); packet.writeD(homunculus.getDef()); packet.writeD(homunculus.getCritRate()); + counter++; } } else