Support for single slot augments.
This commit is contained in:
@@ -231,7 +231,7 @@ public class VariationData implements IXmlReader
|
|||||||
{
|
{
|
||||||
final Options option1 = variation.getRandomEffect(0, targetItemId);
|
final Options option1 = variation.getRandomEffect(0, targetItemId);
|
||||||
final Options option2 = variation.getRandomEffect(1, targetItemId);
|
final Options option2 = variation.getRandomEffect(1, targetItemId);
|
||||||
return ((option1 != null) && (option2 != null)) ? new VariationInstance(variation.getMineralId(), option1, option2) : null;
|
return new VariationInstance(variation.getMineralId(), option1, option2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Variation getVariation(int mineralId)
|
public Variation getVariation(int mineralId)
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.l2jmobius.gameserver.data.xml.OptionData;
|
import org.l2jmobius.gameserver.data.xml.OptionData;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.options.Options;
|
import org.l2jmobius.gameserver.model.options.Options;
|
||||||
@@ -37,17 +35,10 @@ public class VariationInstance
|
|||||||
_mineralId = mineralId;
|
_mineralId = mineralId;
|
||||||
_option1 = OptionData.getInstance().getOptions(option1Id);
|
_option1 = OptionData.getInstance().getOptions(option1Id);
|
||||||
_option2 = OptionData.getInstance().getOptions(option2Id);
|
_option2 = OptionData.getInstance().getOptions(option2Id);
|
||||||
if ((_option1 == null) || (_option2 == null))
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Couldn't find option for id: " + option1Id + " or id: " + option1Id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VariationInstance(int mineralId, Options op1, Options op2)
|
public VariationInstance(int mineralId, Options op1, Options op2)
|
||||||
{
|
{
|
||||||
Objects.requireNonNull(op1);
|
|
||||||
Objects.requireNonNull(op2);
|
|
||||||
|
|
||||||
_mineralId = mineralId;
|
_mineralId = mineralId;
|
||||||
_option1 = op1;
|
_option1 = op1;
|
||||||
_option2 = op2;
|
_option2 = op2;
|
||||||
@@ -60,23 +51,35 @@ public class VariationInstance
|
|||||||
|
|
||||||
public int getOption1Id()
|
public int getOption1Id()
|
||||||
{
|
{
|
||||||
return _option1.getId();
|
return _option1 == null ? -1 : _option1.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOption2Id()
|
public int getOption2Id()
|
||||||
{
|
{
|
||||||
return _option2.getId();
|
return _option2 == null ? -1 : _option2.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyBonus(PlayerInstance player)
|
public void applyBonus(PlayerInstance player)
|
||||||
{
|
{
|
||||||
_option1.apply(player);
|
if (_option1 != null)
|
||||||
_option2.apply(player);
|
{
|
||||||
|
_option1.apply(player);
|
||||||
|
}
|
||||||
|
if (_option2 != null)
|
||||||
|
{
|
||||||
|
_option2.apply(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBonus(PlayerInstance player)
|
public void removeBonus(PlayerInstance player)
|
||||||
{
|
{
|
||||||
_option1.remove(player);
|
if (_option1 != null)
|
||||||
_option2.remove(player);
|
{
|
||||||
|
_option1.remove(player);
|
||||||
|
}
|
||||||
|
if (_option2 != null)
|
||||||
|
{
|
||||||
|
_option2.remove(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,11 +45,15 @@ public class Variation
|
|||||||
|
|
||||||
public Options getRandomEffect(int order, int targetItemId)
|
public Options getRandomEffect(int order, int targetItemId)
|
||||||
{
|
{
|
||||||
if ((_effects == null) || (_effects[order] == null))
|
if (_effects == null)
|
||||||
{
|
{
|
||||||
LOGGER.warning("Null effect: for mineral " + _mineralId + ", order " + order);
|
LOGGER.warning("Null effect: for mineral " + _mineralId + ", order " + order);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (_effects[order] == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return _effects[order].getRandomEffect(targetItemId);
|
return _effects[order].getRandomEffect(targetItemId);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -104,14 +104,33 @@ public class RequestRefine extends AbstractRefinePacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final VariationInstance augment = VariationData.getInstance().generateRandomVariation(variation, targetItem);
|
VariationInstance augment = VariationData.getInstance().generateRandomVariation(variation, targetItem);
|
||||||
if (augment == null)
|
if (augment == null)
|
||||||
{
|
{
|
||||||
player.sendPacket(new ExVariationResult(0, 0, false));
|
player.sendPacket(new ExVariationResult(0, 0, false));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unequip item
|
// Support for single slot augments.
|
||||||
|
final int option1 = augment.getOption1Id();
|
||||||
|
final int option2 = augment.getOption2Id();
|
||||||
|
if ((option1 == -1) || (option2 == -1))
|
||||||
|
{
|
||||||
|
final VariationInstance oldAugment = targetItem.getAugmentation();
|
||||||
|
if (oldAugment != null)
|
||||||
|
{
|
||||||
|
if (option1 == -1)
|
||||||
|
{
|
||||||
|
augment = new VariationInstance(augment.getMineralId(), oldAugment.getOption1Id(), option2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
augment = new VariationInstance(augment.getMineralId(), option1, oldAugment.getOption2Id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unequip item.
|
||||||
final InventoryUpdate iu = new InventoryUpdate();
|
final InventoryUpdate iu = new InventoryUpdate();
|
||||||
if (targetItem.isEquipped())
|
if (targetItem.isEquipped())
|
||||||
{
|
{
|
||||||
@@ -122,13 +141,13 @@ public class RequestRefine extends AbstractRefinePacket
|
|||||||
player.broadcastUserInfo();
|
player.broadcastUserInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// consume the life stone
|
// Consume the life stone.
|
||||||
if (!player.destroyItem("RequestRefine", mineralItem, 1, null, false))
|
if (!player.destroyItem("RequestRefine", mineralItem, 1, null, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// consume the gemstones
|
// Consume the gemstones.
|
||||||
if (!player.destroyItem("RequestRefine", feeItem, _feeCount, null, false))
|
if (!player.destroyItem("RequestRefine", feeItem, _feeCount, null, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@@ -231,7 +231,7 @@ public class VariationData implements IXmlReader
|
|||||||
{
|
{
|
||||||
final Options option1 = variation.getRandomEffect(0, targetItemId);
|
final Options option1 = variation.getRandomEffect(0, targetItemId);
|
||||||
final Options option2 = variation.getRandomEffect(1, targetItemId);
|
final Options option2 = variation.getRandomEffect(1, targetItemId);
|
||||||
return ((option1 != null) && (option2 != null)) ? new VariationInstance(variation.getMineralId(), option1, option2) : null;
|
return new VariationInstance(variation.getMineralId(), option1, option2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Variation getVariation(int mineralId)
|
public Variation getVariation(int mineralId)
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.l2jmobius.gameserver.data.xml.OptionData;
|
import org.l2jmobius.gameserver.data.xml.OptionData;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.options.Options;
|
import org.l2jmobius.gameserver.model.options.Options;
|
||||||
@@ -37,17 +35,10 @@ public class VariationInstance
|
|||||||
_mineralId = mineralId;
|
_mineralId = mineralId;
|
||||||
_option1 = OptionData.getInstance().getOptions(option1Id);
|
_option1 = OptionData.getInstance().getOptions(option1Id);
|
||||||
_option2 = OptionData.getInstance().getOptions(option2Id);
|
_option2 = OptionData.getInstance().getOptions(option2Id);
|
||||||
if ((_option1 == null) || (_option2 == null))
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Couldn't find option for id: " + option1Id + " or id: " + option1Id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VariationInstance(int mineralId, Options op1, Options op2)
|
public VariationInstance(int mineralId, Options op1, Options op2)
|
||||||
{
|
{
|
||||||
Objects.requireNonNull(op1);
|
|
||||||
Objects.requireNonNull(op2);
|
|
||||||
|
|
||||||
_mineralId = mineralId;
|
_mineralId = mineralId;
|
||||||
_option1 = op1;
|
_option1 = op1;
|
||||||
_option2 = op2;
|
_option2 = op2;
|
||||||
@@ -60,23 +51,35 @@ public class VariationInstance
|
|||||||
|
|
||||||
public int getOption1Id()
|
public int getOption1Id()
|
||||||
{
|
{
|
||||||
return _option1.getId();
|
return _option1 == null ? -1 : _option1.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOption2Id()
|
public int getOption2Id()
|
||||||
{
|
{
|
||||||
return _option2.getId();
|
return _option2 == null ? -1 : _option2.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyBonus(PlayerInstance player)
|
public void applyBonus(PlayerInstance player)
|
||||||
{
|
{
|
||||||
_option1.apply(player);
|
if (_option1 != null)
|
||||||
_option2.apply(player);
|
{
|
||||||
|
_option1.apply(player);
|
||||||
|
}
|
||||||
|
if (_option2 != null)
|
||||||
|
{
|
||||||
|
_option2.apply(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBonus(PlayerInstance player)
|
public void removeBonus(PlayerInstance player)
|
||||||
{
|
{
|
||||||
_option1.remove(player);
|
if (_option1 != null)
|
||||||
_option2.remove(player);
|
{
|
||||||
|
_option1.remove(player);
|
||||||
|
}
|
||||||
|
if (_option2 != null)
|
||||||
|
{
|
||||||
|
_option2.remove(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,11 +45,15 @@ public class Variation
|
|||||||
|
|
||||||
public Options getRandomEffect(int order, int targetItemId)
|
public Options getRandomEffect(int order, int targetItemId)
|
||||||
{
|
{
|
||||||
if ((_effects == null) || (_effects[order] == null))
|
if (_effects == null)
|
||||||
{
|
{
|
||||||
LOGGER.warning("Null effect: for mineral " + _mineralId + ", order " + order);
|
LOGGER.warning("Null effect: for mineral " + _mineralId + ", order " + order);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (_effects[order] == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return _effects[order].getRandomEffect(targetItemId);
|
return _effects[order].getRandomEffect(targetItemId);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -104,14 +104,33 @@ public class RequestRefine extends AbstractRefinePacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final VariationInstance augment = VariationData.getInstance().generateRandomVariation(variation, targetItem);
|
VariationInstance augment = VariationData.getInstance().generateRandomVariation(variation, targetItem);
|
||||||
if (augment == null)
|
if (augment == null)
|
||||||
{
|
{
|
||||||
player.sendPacket(new ExVariationResult(0, 0, false));
|
player.sendPacket(new ExVariationResult(0, 0, false));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unequip item
|
// Support for single slot augments.
|
||||||
|
final int option1 = augment.getOption1Id();
|
||||||
|
final int option2 = augment.getOption2Id();
|
||||||
|
if ((option1 == -1) || (option2 == -1))
|
||||||
|
{
|
||||||
|
final VariationInstance oldAugment = targetItem.getAugmentation();
|
||||||
|
if (oldAugment != null)
|
||||||
|
{
|
||||||
|
if (option1 == -1)
|
||||||
|
{
|
||||||
|
augment = new VariationInstance(augment.getMineralId(), oldAugment.getOption1Id(), option2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
augment = new VariationInstance(augment.getMineralId(), option1, oldAugment.getOption2Id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unequip item.
|
||||||
final InventoryUpdate iu = new InventoryUpdate();
|
final InventoryUpdate iu = new InventoryUpdate();
|
||||||
if (targetItem.isEquipped())
|
if (targetItem.isEquipped())
|
||||||
{
|
{
|
||||||
@@ -122,13 +141,13 @@ public class RequestRefine extends AbstractRefinePacket
|
|||||||
player.broadcastUserInfo();
|
player.broadcastUserInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// consume the life stone
|
// Consume the life stone.
|
||||||
if (!player.destroyItem("RequestRefine", mineralItem, 1, null, false))
|
if (!player.destroyItem("RequestRefine", mineralItem, 1, null, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// consume the gemstones
|
// Consume the gemstones.
|
||||||
if (!player.destroyItem("RequestRefine", feeItem, _feeCount, null, false))
|
if (!player.destroyItem("RequestRefine", feeItem, _feeCount, null, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@@ -231,7 +231,7 @@ public class VariationData implements IXmlReader
|
|||||||
{
|
{
|
||||||
final Options option1 = variation.getRandomEffect(0, targetItemId);
|
final Options option1 = variation.getRandomEffect(0, targetItemId);
|
||||||
final Options option2 = variation.getRandomEffect(1, targetItemId);
|
final Options option2 = variation.getRandomEffect(1, targetItemId);
|
||||||
return ((option1 != null) && (option2 != null)) ? new VariationInstance(variation.getMineralId(), option1, option2) : null;
|
return new VariationInstance(variation.getMineralId(), option1, option2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Variation getVariation(int mineralId)
|
public Variation getVariation(int mineralId)
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.l2jmobius.gameserver.data.xml.OptionData;
|
import org.l2jmobius.gameserver.data.xml.OptionData;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.options.Options;
|
import org.l2jmobius.gameserver.model.options.Options;
|
||||||
@@ -37,17 +35,10 @@ public class VariationInstance
|
|||||||
_mineralId = mineralId;
|
_mineralId = mineralId;
|
||||||
_option1 = OptionData.getInstance().getOptions(option1Id);
|
_option1 = OptionData.getInstance().getOptions(option1Id);
|
||||||
_option2 = OptionData.getInstance().getOptions(option2Id);
|
_option2 = OptionData.getInstance().getOptions(option2Id);
|
||||||
if ((_option1 == null) || (_option2 == null))
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Couldn't find option for id: " + option1Id + " or id: " + option1Id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VariationInstance(int mineralId, Options op1, Options op2)
|
public VariationInstance(int mineralId, Options op1, Options op2)
|
||||||
{
|
{
|
||||||
Objects.requireNonNull(op1);
|
|
||||||
Objects.requireNonNull(op2);
|
|
||||||
|
|
||||||
_mineralId = mineralId;
|
_mineralId = mineralId;
|
||||||
_option1 = op1;
|
_option1 = op1;
|
||||||
_option2 = op2;
|
_option2 = op2;
|
||||||
@@ -60,23 +51,35 @@ public class VariationInstance
|
|||||||
|
|
||||||
public int getOption1Id()
|
public int getOption1Id()
|
||||||
{
|
{
|
||||||
return _option1.getId();
|
return _option1 == null ? -1 : _option1.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOption2Id()
|
public int getOption2Id()
|
||||||
{
|
{
|
||||||
return _option2.getId();
|
return _option2 == null ? -1 : _option2.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyBonus(PlayerInstance player)
|
public void applyBonus(PlayerInstance player)
|
||||||
{
|
{
|
||||||
_option1.apply(player);
|
if (_option1 != null)
|
||||||
_option2.apply(player);
|
{
|
||||||
|
_option1.apply(player);
|
||||||
|
}
|
||||||
|
if (_option2 != null)
|
||||||
|
{
|
||||||
|
_option2.apply(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBonus(PlayerInstance player)
|
public void removeBonus(PlayerInstance player)
|
||||||
{
|
{
|
||||||
_option1.remove(player);
|
if (_option1 != null)
|
||||||
_option2.remove(player);
|
{
|
||||||
|
_option1.remove(player);
|
||||||
|
}
|
||||||
|
if (_option2 != null)
|
||||||
|
{
|
||||||
|
_option2.remove(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,11 +45,15 @@ public class Variation
|
|||||||
|
|
||||||
public Options getRandomEffect(int order, int targetItemId)
|
public Options getRandomEffect(int order, int targetItemId)
|
||||||
{
|
{
|
||||||
if ((_effects == null) || (_effects[order] == null))
|
if (_effects == null)
|
||||||
{
|
{
|
||||||
LOGGER.warning("Null effect: for mineral " + _mineralId + ", order " + order);
|
LOGGER.warning("Null effect: for mineral " + _mineralId + ", order " + order);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (_effects[order] == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return _effects[order].getRandomEffect(targetItemId);
|
return _effects[order].getRandomEffect(targetItemId);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -104,14 +104,33 @@ public class RequestRefine extends AbstractRefinePacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final VariationInstance augment = VariationData.getInstance().generateRandomVariation(variation, targetItem);
|
VariationInstance augment = VariationData.getInstance().generateRandomVariation(variation, targetItem);
|
||||||
if (augment == null)
|
if (augment == null)
|
||||||
{
|
{
|
||||||
player.sendPacket(new ExVariationResult(0, 0, false));
|
player.sendPacket(new ExVariationResult(0, 0, false));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unequip item
|
// Support for single slot augments.
|
||||||
|
final int option1 = augment.getOption1Id();
|
||||||
|
final int option2 = augment.getOption2Id();
|
||||||
|
if ((option1 == -1) || (option2 == -1))
|
||||||
|
{
|
||||||
|
final VariationInstance oldAugment = targetItem.getAugmentation();
|
||||||
|
if (oldAugment != null)
|
||||||
|
{
|
||||||
|
if (option1 == -1)
|
||||||
|
{
|
||||||
|
augment = new VariationInstance(augment.getMineralId(), oldAugment.getOption1Id(), option2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
augment = new VariationInstance(augment.getMineralId(), option1, oldAugment.getOption2Id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unequip item.
|
||||||
final InventoryUpdate iu = new InventoryUpdate();
|
final InventoryUpdate iu = new InventoryUpdate();
|
||||||
if (targetItem.isEquipped())
|
if (targetItem.isEquipped())
|
||||||
{
|
{
|
||||||
@@ -122,13 +141,13 @@ public class RequestRefine extends AbstractRefinePacket
|
|||||||
player.broadcastUserInfo();
|
player.broadcastUserInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// consume the life stone
|
// Consume the life stone.
|
||||||
if (!player.destroyItem("RequestRefine", mineralItem, 1, null, false))
|
if (!player.destroyItem("RequestRefine", mineralItem, 1, null, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// consume the gemstones
|
// Consume the gemstones.
|
||||||
if (!player.destroyItem("RequestRefine", feeItem, _feeCount, null, false))
|
if (!player.destroyItem("RequestRefine", feeItem, _feeCount, null, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@@ -231,7 +231,7 @@ public class VariationData implements IXmlReader
|
|||||||
{
|
{
|
||||||
final Options option1 = variation.getRandomEffect(0, targetItemId);
|
final Options option1 = variation.getRandomEffect(0, targetItemId);
|
||||||
final Options option2 = variation.getRandomEffect(1, targetItemId);
|
final Options option2 = variation.getRandomEffect(1, targetItemId);
|
||||||
return ((option1 != null) && (option2 != null)) ? new VariationInstance(variation.getMineralId(), option1, option2) : null;
|
return new VariationInstance(variation.getMineralId(), option1, option2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Variation getVariation(int mineralId)
|
public Variation getVariation(int mineralId)
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.l2jmobius.gameserver.data.xml.OptionData;
|
import org.l2jmobius.gameserver.data.xml.OptionData;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.options.Options;
|
import org.l2jmobius.gameserver.model.options.Options;
|
||||||
@@ -37,17 +35,10 @@ public class VariationInstance
|
|||||||
_mineralId = mineralId;
|
_mineralId = mineralId;
|
||||||
_option1 = OptionData.getInstance().getOptions(option1Id);
|
_option1 = OptionData.getInstance().getOptions(option1Id);
|
||||||
_option2 = OptionData.getInstance().getOptions(option2Id);
|
_option2 = OptionData.getInstance().getOptions(option2Id);
|
||||||
if ((_option1 == null) || (_option2 == null))
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Couldn't find option for id: " + option1Id + " or id: " + option1Id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VariationInstance(int mineralId, Options op1, Options op2)
|
public VariationInstance(int mineralId, Options op1, Options op2)
|
||||||
{
|
{
|
||||||
Objects.requireNonNull(op1);
|
|
||||||
Objects.requireNonNull(op2);
|
|
||||||
|
|
||||||
_mineralId = mineralId;
|
_mineralId = mineralId;
|
||||||
_option1 = op1;
|
_option1 = op1;
|
||||||
_option2 = op2;
|
_option2 = op2;
|
||||||
@@ -60,23 +51,35 @@ public class VariationInstance
|
|||||||
|
|
||||||
public int getOption1Id()
|
public int getOption1Id()
|
||||||
{
|
{
|
||||||
return _option1.getId();
|
return _option1 == null ? -1 : _option1.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOption2Id()
|
public int getOption2Id()
|
||||||
{
|
{
|
||||||
return _option2.getId();
|
return _option2 == null ? -1 : _option2.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyBonus(PlayerInstance player)
|
public void applyBonus(PlayerInstance player)
|
||||||
{
|
{
|
||||||
_option1.apply(player);
|
if (_option1 != null)
|
||||||
_option2.apply(player);
|
{
|
||||||
|
_option1.apply(player);
|
||||||
|
}
|
||||||
|
if (_option2 != null)
|
||||||
|
{
|
||||||
|
_option2.apply(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBonus(PlayerInstance player)
|
public void removeBonus(PlayerInstance player)
|
||||||
{
|
{
|
||||||
_option1.remove(player);
|
if (_option1 != null)
|
||||||
_option2.remove(player);
|
{
|
||||||
|
_option1.remove(player);
|
||||||
|
}
|
||||||
|
if (_option2 != null)
|
||||||
|
{
|
||||||
|
_option2.remove(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,11 +45,15 @@ public class Variation
|
|||||||
|
|
||||||
public Options getRandomEffect(int order, int targetItemId)
|
public Options getRandomEffect(int order, int targetItemId)
|
||||||
{
|
{
|
||||||
if ((_effects == null) || (_effects[order] == null))
|
if (_effects == null)
|
||||||
{
|
{
|
||||||
LOGGER.warning("Null effect: for mineral " + _mineralId + ", order " + order);
|
LOGGER.warning("Null effect: for mineral " + _mineralId + ", order " + order);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (_effects[order] == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return _effects[order].getRandomEffect(targetItemId);
|
return _effects[order].getRandomEffect(targetItemId);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -104,14 +104,33 @@ public class RequestRefine extends AbstractRefinePacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final VariationInstance augment = VariationData.getInstance().generateRandomVariation(variation, targetItem);
|
VariationInstance augment = VariationData.getInstance().generateRandomVariation(variation, targetItem);
|
||||||
if (augment == null)
|
if (augment == null)
|
||||||
{
|
{
|
||||||
player.sendPacket(new ExVariationResult(0, 0, false));
|
player.sendPacket(new ExVariationResult(0, 0, false));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unequip item
|
// Support for single slot augments.
|
||||||
|
final int option1 = augment.getOption1Id();
|
||||||
|
final int option2 = augment.getOption2Id();
|
||||||
|
if ((option1 == -1) || (option2 == -1))
|
||||||
|
{
|
||||||
|
final VariationInstance oldAugment = targetItem.getAugmentation();
|
||||||
|
if (oldAugment != null)
|
||||||
|
{
|
||||||
|
if (option1 == -1)
|
||||||
|
{
|
||||||
|
augment = new VariationInstance(augment.getMineralId(), oldAugment.getOption1Id(), option2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
augment = new VariationInstance(augment.getMineralId(), option1, oldAugment.getOption2Id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unequip item.
|
||||||
final InventoryUpdate iu = new InventoryUpdate();
|
final InventoryUpdate iu = new InventoryUpdate();
|
||||||
if (targetItem.isEquipped())
|
if (targetItem.isEquipped())
|
||||||
{
|
{
|
||||||
@@ -122,13 +141,13 @@ public class RequestRefine extends AbstractRefinePacket
|
|||||||
player.broadcastUserInfo();
|
player.broadcastUserInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// consume the life stone
|
// Consume the life stone.
|
||||||
if (!player.destroyItem("RequestRefine", mineralItem, 1, null, false))
|
if (!player.destroyItem("RequestRefine", mineralItem, 1, null, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// consume the gemstones
|
// Consume the gemstones.
|
||||||
if (!player.destroyItem("RequestRefine", feeItem, _feeCount, null, false))
|
if (!player.destroyItem("RequestRefine", feeItem, _feeCount, null, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user