Various homunculus packet related adjustments.

This commit is contained in:
MobiusDevelopment 2021-06-06 21:44:04 +00:00
parent 60fbaeac5f
commit c597a45fca
5 changed files with 89 additions and 91 deletions

View File

@ -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));
}
}
}
}

View File

@ -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;
}

View File

@ -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

View File

@ -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));
}
}
}
}

View File

@ -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