Ensoul system implementation.

Contributed by Mathael.
This commit is contained in:
MobiusDev
2016-03-05 16:25:48 +00:00
parent 7a9de77047
commit 240332641f
23 changed files with 1680 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ import com.l2jmobius.gameserver.model.buylist.Product;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
import com.l2jmobius.gameserver.model.items.L2WarehouseItem;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.clientpackets.ensoul.SoulCrystalOption;
/**
* @author UnAfraid
@@ -116,6 +117,10 @@ public abstract class AbstractItemPacket extends AbstractMaskPacket<ItemListType
{
writeD(item.getVisualId()); // Item remodel visual ID
}
if (containsMask(mask, ItemListType.SOUL_CRYSTAL))
{
writeItemSoulCrystalOptions(item);
}
}
protected static final int calculateMask(ItemInfo item)
@@ -158,6 +163,24 @@ public abstract class AbstractItemPacket extends AbstractMaskPacket<ItemListType
{
mask |= ItemListType.VISUAL_ID.getMask();
}
if ((item.getCommonSoulCrystalOptions().length != 0) || (item.getSpecialSoulCrystalOption() != null))
{
for (SoulCrystalOption sco : item.getCommonSoulCrystalOptions())
{
if (sco != null)
{
mask |= ItemListType.SOUL_CRYSTAL.getMask();
break;
}
}
if (item.getSpecialSoulCrystalOption() != null)
{
mask |= ItemListType.SOUL_CRYSTAL.getMask();
}
}
return mask;
}
@@ -217,4 +240,31 @@ public abstract class AbstractItemPacket extends AbstractMaskPacket<ItemListType
writeC(0);
writeC(0);
}
protected void writeItemSoulCrystalOptions(ItemInfo item)
{
int count = 0;
for (SoulCrystalOption sc : item.getCommonSoulCrystalOptions())
{
if (sc != null)
{
count++;
}
}
writeC(count);
for (SoulCrystalOption sco : item.getCommonSoulCrystalOptions())
{
if (sco != null)
{
writeD(sco.getEffect());
}
}
writeC(item.getSpecialSoulCrystalOption() != null);
if (item.getSpecialSoulCrystalOption() != null)
{
writeD(item.getSpecialSoulCrystalOption().getEffect());
}
}
}

View File

@@ -0,0 +1,82 @@
/*
* 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 com.l2jmobius.gameserver.network.serverpackets.ensoul;
import com.l2jmobius.gameserver.network.clientpackets.ensoul.SoulCrystalOption;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
/**
* @author Mathael
*/
public class ExEnsoulResult extends L2GameServerPacket
{
public static final ExEnsoulResult FAILED = new ExEnsoulResult();
private final int _result;
private final SoulCrystalOption[] _commons;
private final SoulCrystalOption _special;
public ExEnsoulResult()
{
_result = 0;
_commons = null;
_special = null;
}
public ExEnsoulResult(int result, SoulCrystalOption[] commons, SoulCrystalOption special)
{
_result = result;
_commons = commons;
_special = special;
}
@Override
protected void writeImpl()
{
writeC(0xFE);
writeH(0x17F);
// Success (Yes or No)
writeC(_result);
// Primary special abilities
int count = 0;
for (SoulCrystalOption sc : _commons)
{
if (sc != null)
{
count++;
}
}
writeC(count);
for (SoulCrystalOption sc : _commons)
{
if (sc != null)
{
writeD(sc.getEffect());
}
}
// Secondary special abilities
writeC(_special != null);
if (_special != null)
{
writeD(_special.getEffect());
}
}
}

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 com.l2jmobius.gameserver.network.serverpackets.ensoul;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
public class ExShowEnsoulWindow extends L2GameServerPacket
{
public static final ExShowEnsoulWindow STATIC_PACKET = new ExShowEnsoulWindow();
public ExShowEnsoulWindow()
{
}
@Override
protected void writeImpl()
{
writeC(0xFE);
writeD(0x17E);
}
}