Addition of new homunculus packets.

Contributed by manax182.
This commit is contained in:
MobiusDevelopment 2021-06-19 21:16:43 +00:00
parent b6885b2aa8
commit 7412c8899b
5 changed files with 516 additions and 2 deletions

View File

@ -86,6 +86,7 @@ import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEvo
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExActivateHomunculus; import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExActivateHomunculus;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExDeleteHomunculusData; import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExDeleteHomunculusData;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExEnchantHomunculusSkill; import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExEnchantHomunculusSkill;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusActivateSlot;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusCreateStart; import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusCreateStart;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusEnchantExp; import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusEnchantExp;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusGetEnchantPoint; import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusGetEnchantPoint;
@ -93,6 +94,7 @@ import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunc
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusInsert; import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusInsert;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusSummon; import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusSummon;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExShowHomunculusInfo; import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExShowHomunculusInfo;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExSummonHomunculusCouponResult;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneEnter; import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneEnter;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneList; import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneList;
import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay; import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay;
@ -642,8 +644,8 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_USER_WATCHER_TARGET_LIST(0x1E9, null, ConnectionState.IN_GAME), EX_USER_WATCHER_TARGET_LIST(0x1E9, null, ConnectionState.IN_GAME),
EX_USER_WATCHER_ADD(0x1EA, null, ConnectionState.IN_GAME), EX_USER_WATCHER_ADD(0x1EA, null, ConnectionState.IN_GAME),
EX_USER_WATCHER_DELETE(0x1EB, null, ConnectionState.IN_GAME), EX_USER_WATCHER_DELETE(0x1EB, null, ConnectionState.IN_GAME),
EX_HOMUNCULUS_ACTIVATE_SLOT(0x1EC, null, ConnectionState.IN_GAME), EX_HOMUNCULUS_ACTIVATE_SLOT(0x1EC, RequestExHomunculusActivateSlot::new, ConnectionState.IN_GAME),
EX_SUMMON_HOMUNCULUS_COUPON(0x1ED, null, ConnectionState.IN_GAME), EX_SUMMON_HOMUNCULUS_COUPON(0x1ED, RequestExSummonHomunculusCouponResult::new, ConnectionState.IN_GAME),
EX_SUBJUGATION_LIST(0x1EE, null, ConnectionState.IN_GAME), EX_SUBJUGATION_LIST(0x1EE, null, ConnectionState.IN_GAME),
EX_SUBJUGATION_RANKING(0x1EF, null, ConnectionState.IN_GAME), EX_SUBJUGATION_RANKING(0x1EF, null, ConnectionState.IN_GAME),
EX_SUBJUGATION_GACHA_UI(0x1F0, null, ConnectionState.IN_GAME), EX_SUBJUGATION_GACHA_UI(0x1F0, null, ConnectionState.IN_GAME),

View File

@ -0,0 +1,112 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExActivateHomunculusResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Manax
*/
public class RequestExHomunculusActivateSlot implements IClientIncomingPacket
{
private int _slot;
private boolean _activate;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_slot = packet.readD();
_activate = packet.readC() == 1; // enabled?
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance activeChar = client.getPlayer();
if (activeChar == null)
{
return;
}
final int size = activeChar.getHomunculusList().size();
if (size == 0)
{
return;
}
final Homunculus homunculus = activeChar.getHomunculusList().get(_slot);
if (homunculus == null)
{
return;
}
for (int i = 0; i < Config.MAX_HOMUNCULUS_COUNT; i++)
{
if (size <= i)
{
break;
}
final Homunculus homu = activeChar.getHomunculusList().get(i);
if (homu == null)
{
continue;
}
if (homu.isActive())
{
homu.setActive(false);
activeChar.getHomunculusList().update(homu);
activeChar.getHomunculusList().refreshStats(true);
activeChar.sendPacket(new ExShowHomunculusList(activeChar));
activeChar.sendPacket(new ExActivateHomunculusResult(false));
}
}
if (_activate)
{
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

@ -0,0 +1,322 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.HomunculusData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.model.homunculus.HomunculusTemplate;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusSummonResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExSummonHomunculusCouponResult;
/**
* @author NasSeKa, Manax
*/
public class RequestExSummonHomunculusCouponResult implements IClientIncomingPacket
{
private static final int HOURGLASS = 81815;
private static final int HOURGLASS_SHINY = 81879;
private static final int ADENA = 57;
private static final int ADENA_COUNT = 2000000;
@Override
public boolean read(GameClient client, PacketReader packet)
{
// packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
int homunculusId = 0;
if ((homunculusId == 0) && (player.getInventory().getItemByItemId(HOURGLASS) != null) && (player.getInventory().getItemByItemId(ADENA).getCount() > ADENA_COUNT))
{
player.destroyItemByItemId("Homunculus Hourglass", HOURGLASS, 1, player, true);
player.destroyItemByItemId("Adena", ADENA, 2000000, player, true);
final int chance = Rnd.get(100);
if (chance >= 60) // Basic Homunculus
{
final int random = Rnd.get(100);
if (random >= 90)
{
homunculusId = 1;
}
else if (random >= 80)
{
homunculusId = 4;
}
else if (random >= 70)
{
homunculusId = 7;
}
else if (random >= 60)
{
homunculusId = 10;
}
else if (random >= 50)
{
homunculusId = 13;
}
else if (random >= 40)
{
homunculusId = 16;
}
else if (random >= 30)
{
homunculusId = 19;
}
else if (random >= 20)
{
homunculusId = 22;
}
else if (random >= 10)
{
homunculusId = 25;
}
else
{
homunculusId = 28;
}
}
else if (chance >= 10) // Water Homunculus
{
final int random = Rnd.get(100);
if (random >= 90)
{
homunculusId = 2;
}
else if (random >= 80)
{
homunculusId = 5;
}
else if (random >= 70)
{
homunculusId = 8;
}
else if (random >= 60)
{
homunculusId = 11;
}
else if (random >= 50)
{
homunculusId = 14;
}
else if (random >= 40)
{
homunculusId = 17;
}
else if (random >= 30)
{
homunculusId = 20;
}
else if (random >= 20)
{
homunculusId = 23;
}
else if (random >= 10)
{
homunculusId = 26;
}
else
{
homunculusId = 29;
}
}
else // Luminous Homunculus
{
final int random = Rnd.get(100);
if (random >= 90)
{
homunculusId = 3;
}
else if (random >= 80)
{
homunculusId = 6;
}
else if (random >= 70)
{
homunculusId = 9;
}
else if (random >= 60)
{
homunculusId = 12;
}
else if (random >= 50)
{
homunculusId = 15;
}
else if (random >= 40)
{
homunculusId = 18;
}
else if (random >= 30)
{
homunculusId = 21;
}
else if (random >= 20)
{
homunculusId = 24;
}
else if (random >= 10)
{
homunculusId = 27;
}
else
{
homunculusId = 30;
}
}
final HomunculusTemplate template = HomunculusData.getInstance().getTemplate(homunculusId);
if (template == null)
{
LOGGER.warning("Could not find Homunculus template " + homunculusId + ".");
return;
}
final Homunculus homunculus = new Homunculus(template, player.getHomunculusList().size(), 1, 0, 0, 0, 0, 0, 0, false);
if (player.getHomunculusList().add(homunculus))
{
player.sendPacket(new ExShowHomunculusBirthInfo(player));
player.sendPacket(new ExShowHomunculusList(player));
player.sendPacket(new ExHomunculusSummonResult());
}
}
else if ((homunculusId == 1) && (player.getInventory().getItemByItemId(HOURGLASS_SHINY) != null) && (player.getInventory().getItemByItemId(ADENA).getCount() >= ADENA_COUNT))
{
final int chance = Rnd.get(100);
if (chance >= 70) // Water Homunculus
{
player.destroyItemByItemId("Shiny Homunculus Hourglass", HOURGLASS_SHINY, 1, player, true);
player.destroyItemByItemId("Adena", ADENA, 2000000, player, true);
final int random = Rnd.get(100);
if (random >= 90)
{
homunculusId = 2;
}
else if (random >= 80)
{
homunculusId = 5;
}
else if (random >= 70)
{
homunculusId = 8;
}
else if (random >= 60)
{
homunculusId = 11;
}
else if (random >= 50)
{
homunculusId = 14;
}
else if (random >= 40)
{
homunculusId = 17;
}
else if (random >= 30)
{
homunculusId = 20;
}
else if (random >= 20)
{
homunculusId = 23;
}
else if (random >= 10)
{
homunculusId = 26;
}
else
{
homunculusId = 29;
}
}
else // Luminous Homunculus
{
final int random = Rnd.get(100);
if (random >= 90)
{
homunculusId = 3;
}
else if (random >= 80)
{
homunculusId = 6;
}
else if (random >= 70)
{
homunculusId = 9;
}
else if (random >= 60)
{
homunculusId = 12;
}
else if (random >= 50)
{
homunculusId = 15;
}
else if (random >= 40)
{
homunculusId = 18;
}
else if (random >= 30)
{
homunculusId = 21;
}
else if (random >= 20)
{
homunculusId = 24;
}
else if (random >= 10)
{
homunculusId = 27;
}
else
{
homunculusId = 30;
}
}
final HomunculusTemplate template = HomunculusData.getInstance().getTemplate(homunculusId);
if (template == null)
{
LOGGER.warning("Could not find Homunculus template " + homunculusId + ".");
return;
}
final Homunculus homunculus = new Homunculus(template, player.getHomunculusList().size(), 1, 0, 0, 0, 0, 0, 0, false);
if (player.getHomunculusList().add(homunculus))
{
player.sendPacket(new ExShowHomunculusBirthInfo(player));
player.sendPacket(new ExShowHomunculusList(player));
player.sendPacket(new ExSummonHomunculusCouponResult());
}
}
}
}

View File

@ -0,0 +1,35 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Manax
*/
public class ExShowHomunculusCouponUi implements IClientOutgoingPacket
{
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_HOMUNCULUS_COUPON_UI.writeId(packet);
packet.writeD(0x00);
return true;
}
}

View File

@ -0,0 +1,43 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author `NasSeKa`
*/
public class ExSummonHomunculusCouponResult implements IClientOutgoingPacket
{
public ExSummonHomunculusCouponResult()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SUMMON_HOMUNCULUS_COUPON_RESULT.writeId(packet);
packet.writeD(1); // 1 - success
packet.writeD(SystemMessageId.A_NEW_HOMUNCULUS_IS_CREATED.getId());
return true;
}
}