diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } } diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java index 6aa21de45d..363d1209bc 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/skillconditionhandlers/OpTargetArmorTypeSkillCondition.java @@ -16,21 +16,97 @@ */ package handlers.skillconditionhandlers; +import java.util.ArrayList; +import java.util.List; + import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.items.Item; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.items.type.ArmorType; +import org.l2jmobius.gameserver.model.items.type.ItemType; import org.l2jmobius.gameserver.model.skills.ISkillCondition; import org.l2jmobius.gameserver.model.skills.Skill; +/** + * @author Mobius + */ public class OpTargetArmorTypeSkillCondition implements ISkillCondition { + private final List _armorTypes = new ArrayList<>(); + public OpTargetArmorTypeSkillCondition(StatSet params) { + final List armorTypes = params.getList("armorType", String.class); + if (armorTypes != null) + { + armorTypes.stream().map(ArmorType::valueOf).forEach(_armorTypes::add); + } } @Override public boolean canUse(Creature caster, Skill skill, WorldObject target) { - return false; // TODO: + if ((target == null) || !target.isCreature()) + { + return false; + } + + final Creature targetCreature = (Creature) target; + final Inventory inv = targetCreature.getInventory(); + + // Get the chest armor. + final ItemInstance chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST); + if (chest == null) + { + return false; + } + + // Get the chest item type. + final ItemType chestType = chest.getItem().getItemType(); + + // Get the chest body part. + final long chestBodyPart = chest.getItem().getBodyPart(); + + // Get the legs armor. + final ItemInstance legs = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS); + + // Get the legs item type. + ItemType legsType = null; + if (legs != null) + { + legsType = legs.getItem().getItemType(); + } + + for (ArmorType armorType : _armorTypes) + { + // If chest armor is different from the condition one continue. + if (chestType != armorType) + { + continue; + } + + // Return true if chest armor is a full armor. + if (chestBodyPart == Item.SLOT_FULL_ARMOR) + { + return true; + } + + // Check legs armor. + if (legs == null) + { + continue; + } + + // Return true if legs armor matches too. + if (legsType == armorType) + { + return true; + } + } + + return false; } }