Verify owning existing homunculus at RequestExHomunculusSummon.

This commit is contained in:
MobiusDevelopment 2021-08-01 00:59:44 +00:00
parent ec9cdcced0
commit 0297e45f3e
6 changed files with 219 additions and 162 deletions

View File

@ -78,6 +78,18 @@ public class HomunculusList
return null;
}
public boolean hasHomunculus(int templateId)
{
for (Homunculus homunculus : _homunculusList)
{
if (homunculus.getId() == templateId)
{
return true;
}
}
return false;
}
public int size()
{
return _homunculusList.size();

View File

@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.HomunculusData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@ -60,84 +61,91 @@ public class RequestExHomunculusSummon implements IClientIncomingPacket
_vpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP_POINTS, 0);
_homunculusCreateTime = (int) (player.getVariables().getLong(PlayerVariables.HOMUNCULUS_CREATION_TIME, 0) / 1000);
if (_homunculusCreateTime > 0)
{
if (((System.currentTimeMillis() / 1000) >= _homunculusCreateTime) && (_hpPoints == 100) && (_spPoints == 10) && (_vpPoints == 5))
if ((_homunculusCreateTime > 0) && ((Chronos.currentTimeMillis() / 1000) >= _homunculusCreateTime) && (_hpPoints == 100) && (_spPoints == 10) && (_vpPoints == 5))
{
int chance;
int random;
int homunculusId = 0;
final int chance = Rnd.get(100);
if (chance >= 60) // Basic Homunculus
while (homunculusId == 0)
{
final int random = Rnd.get(100);
if (random >= 80)
chance = Rnd.get(100);
random = Rnd.get(100);
// Basic Homunculus
if (chance >= 60)
{
if ((random >= 80) && !player.getHomunculusList().hasHomunculus(1))
{
homunculusId = 1;
}
else if (random >= 60)
else if ((random >= 60) && !player.getHomunculusList().hasHomunculus(4))
{
homunculusId = 4;
}
else if (random >= 40)
else if ((random >= 40) && !player.getHomunculusList().hasHomunculus(7))
{
homunculusId = 7;
}
else if (random >= 20)
else if ((random >= 20) && !player.getHomunculusList().hasHomunculus(10))
{
homunculusId = 10;
}
else
else if (!player.getHomunculusList().hasHomunculus(13))
{
homunculusId = 13;
}
}
else if (chance >= 10) // Water Homunculus
// Water Homunculus
if ((homunculusId == 0) && (chance >= 10))
{
final int random = Rnd.get(100);
if (random >= 80)
if ((random >= 80) && !player.getHomunculusList().hasHomunculus(2))
{
homunculusId = 2;
}
else if (random >= 60)
else if ((random >= 60) && !player.getHomunculusList().hasHomunculus(5))
{
homunculusId = 5;
}
else if (random >= 40)
else if ((random >= 40) && !player.getHomunculusList().hasHomunculus(8))
{
homunculusId = 8;
}
else if (random >= 20)
else if ((random >= 20) && !player.getHomunculusList().hasHomunculus(11))
{
homunculusId = 11;
}
else
else if (!player.getHomunculusList().hasHomunculus(14))
{
homunculusId = 14;
}
}
else // Luminous Homunculus
// Luminous Homunculus
if (homunculusId == 0)
{
final int random = Rnd.get(100);
if (random >= 80)
if ((random >= 80) && !player.getHomunculusList().hasHomunculus(3))
{
homunculusId = 3;
}
else if (random >= 60)
else if ((random >= 60) && !player.getHomunculusList().hasHomunculus(6))
{
homunculusId = 6;
}
else if (random >= 40)
else if ((random >= 40) && !player.getHomunculusList().hasHomunculus(9))
{
homunculusId = 9;
}
else if (random >= 20)
else if ((random >= 20) && !player.getHomunculusList().hasHomunculus(12))
{
homunculusId = 12;
}
else
else if (!player.getHomunculusList().hasHomunculus(15))
{
homunculusId = 15;
}
}
}
final HomunculusTemplate template = HomunculusData.getInstance().getTemplate(homunculusId);
if (template == null)
@ -160,4 +168,3 @@ public class RequestExHomunculusSummon implements IClientIncomingPacket
}
}
}
}

View File

@ -78,6 +78,18 @@ public class HomunculusList
return null;
}
public boolean hasHomunculus(int templateId)
{
for (Homunculus homunculus : _homunculusList)
{
if (homunculus.getId() == templateId)
{
return true;
}
}
return false;
}
public int size()
{
return _homunculusList.size();

View File

@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.HomunculusData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@ -60,144 +61,151 @@ public class RequestExHomunculusSummon implements IClientIncomingPacket
_vpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP_POINTS, 0);
_homunculusCreateTime = (int) (player.getVariables().getLong(PlayerVariables.HOMUNCULUS_CREATION_TIME, 0) / 1000);
if (_homunculusCreateTime > 0)
{
if (((System.currentTimeMillis() / 1000) >= _homunculusCreateTime) && (_hpPoints == 100) && (_spPoints == 10) && (_vpPoints == 5))
if ((_homunculusCreateTime > 0) && ((Chronos.currentTimeMillis() / 1000) >= _homunculusCreateTime) && (_hpPoints == 100) && (_spPoints == 10) && (_vpPoints == 5))
{
int chance;
int random;
int homunculusId = 0;
final int chance = Rnd.get(100);
if (chance >= 60) // Basic Homunculus
while (homunculusId == 0)
{
final int random = Rnd.get(100);
if (random >= 90)
chance = Rnd.get(100);
random = Rnd.get(100);
// Basic Homunculus
if (chance >= 60)
{
if ((random >= 90) && !player.getHomunculusList().hasHomunculus(1))
{
homunculusId = 1;
}
else if (random >= 80)
else if ((random >= 80) && !player.getHomunculusList().hasHomunculus(4))
{
homunculusId = 4;
}
else if (random >= 70)
else if ((random >= 70) && !player.getHomunculusList().hasHomunculus(7))
{
homunculusId = 7;
}
else if (random >= 60)
else if ((random >= 60) && !player.getHomunculusList().hasHomunculus(10))
{
homunculusId = 10;
}
else if (random >= 50)
else if ((random >= 50) && !player.getHomunculusList().hasHomunculus(13))
{
homunculusId = 13;
}
else if (random >= 40)
else if ((random >= 40) && !player.getHomunculusList().hasHomunculus(16))
{
homunculusId = 16;
}
else if (random >= 30)
else if ((random >= 30) && !player.getHomunculusList().hasHomunculus(19))
{
homunculusId = 19;
}
else if (random >= 20)
else if ((random >= 20) && !player.getHomunculusList().hasHomunculus(22))
{
homunculusId = 22;
}
else if (random >= 10)
else if ((random >= 10) && !player.getHomunculusList().hasHomunculus(25))
{
homunculusId = 25;
}
else
else if (!player.getHomunculusList().hasHomunculus(28))
{
homunculusId = 28;
}
}
else if (chance >= 10) // Water Homunculus
// Water Homunculus
if ((homunculusId == 0) && (chance >= 10))
{
final int random = Rnd.get(100);
if (random >= 90)
if ((random >= 90) && !player.getHomunculusList().hasHomunculus(2))
{
homunculusId = 2;
}
else if (random >= 80)
else if ((random >= 80) && !player.getHomunculusList().hasHomunculus(5))
{
homunculusId = 5;
}
else if (random >= 70)
else if ((random >= 70) && !player.getHomunculusList().hasHomunculus(8))
{
homunculusId = 8;
}
else if (random >= 60)
else if ((random >= 60) && !player.getHomunculusList().hasHomunculus(11))
{
homunculusId = 11;
}
else if (random >= 50)
else if ((random >= 50) && !player.getHomunculusList().hasHomunculus(14))
{
homunculusId = 14;
}
else if (random >= 40)
else if ((random >= 40) && !player.getHomunculusList().hasHomunculus(17))
{
homunculusId = 17;
}
else if (random >= 30)
else if ((random >= 30) && !player.getHomunculusList().hasHomunculus(20))
{
homunculusId = 20;
}
else if (random >= 20)
else if ((random >= 20) && !player.getHomunculusList().hasHomunculus(23))
{
homunculusId = 23;
}
else if (random >= 10)
else if ((random >= 10) && !player.getHomunculusList().hasHomunculus(26))
{
homunculusId = 26;
}
else
else if (!player.getHomunculusList().hasHomunculus(29))
{
homunculusId = 29;
}
}
else // Luminous Homunculus
// Luminous Homunculus
if (homunculusId == 0)
{
final int random = Rnd.get(100);
if (random >= 90)
if ((random >= 90) && !player.getHomunculusList().hasHomunculus(3))
{
homunculusId = 3;
}
else if (random >= 80)
else if ((random >= 80) && !player.getHomunculusList().hasHomunculus(6))
{
homunculusId = 6;
}
else if (random >= 70)
else if ((random >= 70) && !player.getHomunculusList().hasHomunculus(9))
{
homunculusId = 9;
}
else if (random >= 60)
else if ((random >= 60) && !player.getHomunculusList().hasHomunculus(12))
{
homunculusId = 12;
}
else if (random >= 50)
else if ((random >= 50) && !player.getHomunculusList().hasHomunculus(15))
{
homunculusId = 15;
}
else if (random >= 40)
else if ((random >= 40) && !player.getHomunculusList().hasHomunculus(18))
{
homunculusId = 18;
}
else if (random >= 30)
else if ((random >= 30) && !player.getHomunculusList().hasHomunculus(21))
{
homunculusId = 21;
}
else if (random >= 20)
else if ((random >= 20) && !player.getHomunculusList().hasHomunculus(24))
{
homunculusId = 24;
}
else if (random >= 10)
else if ((random >= 10) && !player.getHomunculusList().hasHomunculus(27))
{
homunculusId = 27;
}
else
else if (!player.getHomunculusList().hasHomunculus(30))
{
homunculusId = 30;
}
}
}
final HomunculusTemplate template = HomunculusData.getInstance().getTemplate(homunculusId);
if (template == null)
@ -220,4 +228,3 @@ public class RequestExHomunculusSummon implements IClientIncomingPacket
}
}
}
}

View File

@ -78,6 +78,18 @@ public class HomunculusList
return null;
}
public boolean hasHomunculus(int templateId)
{
for (Homunculus homunculus : _homunculusList)
{
if (homunculus.getId() == templateId)
{
return true;
}
}
return false;
}
public int size()
{
return _homunculusList.size();

View File

@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.HomunculusData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@ -60,144 +61,151 @@ public class RequestExHomunculusSummon implements IClientIncomingPacket
_vpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP_POINTS, 0);
_homunculusCreateTime = (int) (player.getVariables().getLong(PlayerVariables.HOMUNCULUS_CREATION_TIME, 0) / 1000);
if (_homunculusCreateTime > 0)
{
if (((System.currentTimeMillis() / 1000) >= _homunculusCreateTime) && (_hpPoints == 100) && (_spPoints == 10) && (_vpPoints == 5))
if ((_homunculusCreateTime > 0) && ((Chronos.currentTimeMillis() / 1000) >= _homunculusCreateTime) && (_hpPoints == 100) && (_spPoints == 10) && (_vpPoints == 5))
{
int chance;
int random;
int homunculusId = 0;
final int chance = Rnd.get(100);
if (chance >= 60) // Basic Homunculus
while (homunculusId == 0)
{
final int random = Rnd.get(100);
if (random >= 90)
chance = Rnd.get(100);
random = Rnd.get(100);
// Basic Homunculus
if (chance >= 60)
{
if ((random >= 90) && !player.getHomunculusList().hasHomunculus(1))
{
homunculusId = 1;
}
else if (random >= 80)
else if ((random >= 80) && !player.getHomunculusList().hasHomunculus(4))
{
homunculusId = 4;
}
else if (random >= 70)
else if ((random >= 70) && !player.getHomunculusList().hasHomunculus(7))
{
homunculusId = 7;
}
else if (random >= 60)
else if ((random >= 60) && !player.getHomunculusList().hasHomunculus(10))
{
homunculusId = 10;
}
else if (random >= 50)
else if ((random >= 50) && !player.getHomunculusList().hasHomunculus(13))
{
homunculusId = 13;
}
else if (random >= 40)
else if ((random >= 40) && !player.getHomunculusList().hasHomunculus(16))
{
homunculusId = 16;
}
else if (random >= 30)
else if ((random >= 30) && !player.getHomunculusList().hasHomunculus(19))
{
homunculusId = 19;
}
else if (random >= 20)
else if ((random >= 20) && !player.getHomunculusList().hasHomunculus(22))
{
homunculusId = 22;
}
else if (random >= 10)
else if ((random >= 10) && !player.getHomunculusList().hasHomunculus(25))
{
homunculusId = 25;
}
else
else if (!player.getHomunculusList().hasHomunculus(28))
{
homunculusId = 28;
}
}
else if (chance >= 10) // Water Homunculus
// Water Homunculus
if ((homunculusId == 0) && (chance >= 10))
{
final int random = Rnd.get(100);
if (random >= 90)
if ((random >= 90) && !player.getHomunculusList().hasHomunculus(2))
{
homunculusId = 2;
}
else if (random >= 80)
else if ((random >= 80) && !player.getHomunculusList().hasHomunculus(5))
{
homunculusId = 5;
}
else if (random >= 70)
else if ((random >= 70) && !player.getHomunculusList().hasHomunculus(8))
{
homunculusId = 8;
}
else if (random >= 60)
else if ((random >= 60) && !player.getHomunculusList().hasHomunculus(11))
{
homunculusId = 11;
}
else if (random >= 50)
else if ((random >= 50) && !player.getHomunculusList().hasHomunculus(14))
{
homunculusId = 14;
}
else if (random >= 40)
else if ((random >= 40) && !player.getHomunculusList().hasHomunculus(17))
{
homunculusId = 17;
}
else if (random >= 30)
else if ((random >= 30) && !player.getHomunculusList().hasHomunculus(20))
{
homunculusId = 20;
}
else if (random >= 20)
else if ((random >= 20) && !player.getHomunculusList().hasHomunculus(23))
{
homunculusId = 23;
}
else if (random >= 10)
else if ((random >= 10) && !player.getHomunculusList().hasHomunculus(26))
{
homunculusId = 26;
}
else
else if (!player.getHomunculusList().hasHomunculus(29))
{
homunculusId = 29;
}
}
else // Luminous Homunculus
// Luminous Homunculus
if (homunculusId == 0)
{
final int random = Rnd.get(100);
if (random >= 90)
if ((random >= 90) && !player.getHomunculusList().hasHomunculus(3))
{
homunculusId = 3;
}
else if (random >= 80)
else if ((random >= 80) && !player.getHomunculusList().hasHomunculus(6))
{
homunculusId = 6;
}
else if (random >= 70)
else if ((random >= 70) && !player.getHomunculusList().hasHomunculus(9))
{
homunculusId = 9;
}
else if (random >= 60)
else if ((random >= 60) && !player.getHomunculusList().hasHomunculus(12))
{
homunculusId = 12;
}
else if (random >= 50)
else if ((random >= 50) && !player.getHomunculusList().hasHomunculus(15))
{
homunculusId = 15;
}
else if (random >= 40)
else if ((random >= 40) && !player.getHomunculusList().hasHomunculus(18))
{
homunculusId = 18;
}
else if (random >= 30)
else if ((random >= 30) && !player.getHomunculusList().hasHomunculus(21))
{
homunculusId = 21;
}
else if (random >= 20)
else if ((random >= 20) && !player.getHomunculusList().hasHomunculus(24))
{
homunculusId = 24;
}
else if (random >= 10)
else if ((random >= 10) && !player.getHomunculusList().hasHomunculus(27))
{
homunculusId = 27;
}
else
else if (!player.getHomunculusList().hasHomunculus(30))
{
homunculusId = 30;
}
}
}
final HomunculusTemplate template = HomunculusData.getInstance().getTemplate(homunculusId);
if (template == null)
@ -220,4 +228,3 @@ public class RequestExHomunculusSummon implements IClientIncomingPacket
}
}
}
}