From 1f501863511a8b38cd347ae706b9610baef0f32e Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sat, 29 Oct 2022 21:43:43 +0000 Subject: [PATCH] Support for multiple AttackAttribute and DefenceAttribute element values. --- .../effecthandlers/AttackAttribute.java | 72 +++++++++++-------- .../effecthandlers/DefenceAttribute.java | 72 +++++++++++-------- .../effecthandlers/AttackAttribute.java | 72 +++++++++++-------- .../effecthandlers/DefenceAttribute.java | 72 +++++++++++-------- 4 files changed, 172 insertions(+), 116 deletions(-) diff --git a/L2J_Mobius_10.3_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AttackAttribute.java b/L2J_Mobius_10.3_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AttackAttribute.java index e3c9d87ead..25185f33c3 100644 --- a/L2J_Mobius_10.3_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AttackAttribute.java +++ b/L2J_Mobius_10.3_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AttackAttribute.java @@ -16,6 +16,9 @@ */ package handlers.effecthandlers; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.enums.AttributeType; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Creature; @@ -28,48 +31,59 @@ import org.l2jmobius.gameserver.model.stats.Stat; */ public class AttackAttribute extends AbstractEffect { - private final AttributeType _attribute; + private final Set _attributes = new HashSet<>(); private final double _amount; public AttackAttribute(StatSet params) { _amount = params.getDouble("amount", 0); - _attribute = params.getEnum("attribute", AttributeType.class, AttributeType.FIRE); + final String attributes = params.getString("attribute", "FIRE"); + if (attributes.contains(",")) + { + for (String attribute : attributes.split(",")) + { + _attributes.add(AttributeType.findByName(attribute.trim())); + } + } + else + { + _attributes.add(AttributeType.findByName(attributes)); + } } @Override public void pump(Creature effected, Skill skill) { - Stat stat = Stat.FIRE_POWER; - - switch (_attribute) + for (AttributeType attribute : _attributes) { - case WATER: + switch (attribute) { - stat = Stat.WATER_POWER; - break; - } - case WIND: - { - stat = Stat.WIND_POWER; - break; - } - case EARTH: - { - stat = Stat.EARTH_POWER; - break; - } - case HOLY: - { - stat = Stat.HOLY_POWER; - break; - } - case DARK: - { - stat = Stat.DARK_POWER; - break; + case WATER: + { + effected.getStat().mergeAdd(Stat.WATER_POWER, _amount); + break; + } + case WIND: + { + effected.getStat().mergeAdd(Stat.WIND_POWER, _amount); + break; + } + case EARTH: + { + effected.getStat().mergeAdd(Stat.EARTH_POWER, _amount); + break; + } + case HOLY: + { + effected.getStat().mergeAdd(Stat.HOLY_POWER, _amount); + break; + } + case DARK: + { + effected.getStat().mergeAdd(Stat.DARK_POWER, _amount); + break; + } } } - effected.getStat().mergeAdd(stat, _amount); } } diff --git a/L2J_Mobius_10.3_MasterClass/dist/game/data/scripts/handlers/effecthandlers/DefenceAttribute.java b/L2J_Mobius_10.3_MasterClass/dist/game/data/scripts/handlers/effecthandlers/DefenceAttribute.java index 6e56b12f99..adc36a85eb 100644 --- a/L2J_Mobius_10.3_MasterClass/dist/game/data/scripts/handlers/effecthandlers/DefenceAttribute.java +++ b/L2J_Mobius_10.3_MasterClass/dist/game/data/scripts/handlers/effecthandlers/DefenceAttribute.java @@ -16,6 +16,9 @@ */ package handlers.effecthandlers; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.enums.AttributeType; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Creature; @@ -28,48 +31,59 @@ import org.l2jmobius.gameserver.model.stats.Stat; */ public class DefenceAttribute extends AbstractEffect { - private final AttributeType _attribute; + private final Set _attributes = new HashSet<>(); private final double _amount; public DefenceAttribute(StatSet params) { _amount = params.getDouble("amount", 0); - _attribute = params.getEnum("attribute", AttributeType.class, AttributeType.FIRE); + final String attributes = params.getString("attribute", "FIRE"); + if (attributes.contains(",")) + { + for (String attribute : attributes.split(",")) + { + _attributes.add(AttributeType.findByName(attribute.trim())); + } + } + else + { + _attributes.add(AttributeType.findByName(attributes)); + } } @Override public void pump(Creature effected, Skill skill) { - Stat stat = Stat.FIRE_RES; - - switch (_attribute) + for (AttributeType attribute : _attributes) { - case WATER: + switch (attribute) { - stat = Stat.WATER_RES; - break; - } - case WIND: - { - stat = Stat.WIND_RES; - break; - } - case EARTH: - { - stat = Stat.EARTH_RES; - break; - } - case HOLY: - { - stat = Stat.HOLY_RES; - break; - } - case DARK: - { - stat = Stat.DARK_RES; - break; + case WATER: + { + effected.getStat().mergeAdd(Stat.WATER_RES, _amount); + break; + } + case WIND: + { + effected.getStat().mergeAdd(Stat.WIND_RES, _amount); + break; + } + case EARTH: + { + effected.getStat().mergeAdd(Stat.EARTH_RES, _amount); + break; + } + case HOLY: + { + effected.getStat().mergeAdd(Stat.HOLY_RES, _amount); + break; + } + case DARK: + { + effected.getStat().mergeAdd(Stat.DARK_RES, _amount); + break; + } } } - effected.getStat().mergeAdd(stat, _amount); } } diff --git a/L2J_Mobius_Essence_6.3_Crusader/dist/game/data/scripts/handlers/effecthandlers/AttackAttribute.java b/L2J_Mobius_Essence_6.3_Crusader/dist/game/data/scripts/handlers/effecthandlers/AttackAttribute.java index e3c9d87ead..25185f33c3 100644 --- a/L2J_Mobius_Essence_6.3_Crusader/dist/game/data/scripts/handlers/effecthandlers/AttackAttribute.java +++ b/L2J_Mobius_Essence_6.3_Crusader/dist/game/data/scripts/handlers/effecthandlers/AttackAttribute.java @@ -16,6 +16,9 @@ */ package handlers.effecthandlers; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.enums.AttributeType; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Creature; @@ -28,48 +31,59 @@ import org.l2jmobius.gameserver.model.stats.Stat; */ public class AttackAttribute extends AbstractEffect { - private final AttributeType _attribute; + private final Set _attributes = new HashSet<>(); private final double _amount; public AttackAttribute(StatSet params) { _amount = params.getDouble("amount", 0); - _attribute = params.getEnum("attribute", AttributeType.class, AttributeType.FIRE); + final String attributes = params.getString("attribute", "FIRE"); + if (attributes.contains(",")) + { + for (String attribute : attributes.split(",")) + { + _attributes.add(AttributeType.findByName(attribute.trim())); + } + } + else + { + _attributes.add(AttributeType.findByName(attributes)); + } } @Override public void pump(Creature effected, Skill skill) { - Stat stat = Stat.FIRE_POWER; - - switch (_attribute) + for (AttributeType attribute : _attributes) { - case WATER: + switch (attribute) { - stat = Stat.WATER_POWER; - break; - } - case WIND: - { - stat = Stat.WIND_POWER; - break; - } - case EARTH: - { - stat = Stat.EARTH_POWER; - break; - } - case HOLY: - { - stat = Stat.HOLY_POWER; - break; - } - case DARK: - { - stat = Stat.DARK_POWER; - break; + case WATER: + { + effected.getStat().mergeAdd(Stat.WATER_POWER, _amount); + break; + } + case WIND: + { + effected.getStat().mergeAdd(Stat.WIND_POWER, _amount); + break; + } + case EARTH: + { + effected.getStat().mergeAdd(Stat.EARTH_POWER, _amount); + break; + } + case HOLY: + { + effected.getStat().mergeAdd(Stat.HOLY_POWER, _amount); + break; + } + case DARK: + { + effected.getStat().mergeAdd(Stat.DARK_POWER, _amount); + break; + } } } - effected.getStat().mergeAdd(stat, _amount); } } diff --git a/L2J_Mobius_Essence_6.3_Crusader/dist/game/data/scripts/handlers/effecthandlers/DefenceAttribute.java b/L2J_Mobius_Essence_6.3_Crusader/dist/game/data/scripts/handlers/effecthandlers/DefenceAttribute.java index 6e56b12f99..adc36a85eb 100644 --- a/L2J_Mobius_Essence_6.3_Crusader/dist/game/data/scripts/handlers/effecthandlers/DefenceAttribute.java +++ b/L2J_Mobius_Essence_6.3_Crusader/dist/game/data/scripts/handlers/effecthandlers/DefenceAttribute.java @@ -16,6 +16,9 @@ */ package handlers.effecthandlers; +import java.util.HashSet; +import java.util.Set; + import org.l2jmobius.gameserver.enums.AttributeType; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Creature; @@ -28,48 +31,59 @@ import org.l2jmobius.gameserver.model.stats.Stat; */ public class DefenceAttribute extends AbstractEffect { - private final AttributeType _attribute; + private final Set _attributes = new HashSet<>(); private final double _amount; public DefenceAttribute(StatSet params) { _amount = params.getDouble("amount", 0); - _attribute = params.getEnum("attribute", AttributeType.class, AttributeType.FIRE); + final String attributes = params.getString("attribute", "FIRE"); + if (attributes.contains(",")) + { + for (String attribute : attributes.split(",")) + { + _attributes.add(AttributeType.findByName(attribute.trim())); + } + } + else + { + _attributes.add(AttributeType.findByName(attributes)); + } } @Override public void pump(Creature effected, Skill skill) { - Stat stat = Stat.FIRE_RES; - - switch (_attribute) + for (AttributeType attribute : _attributes) { - case WATER: + switch (attribute) { - stat = Stat.WATER_RES; - break; - } - case WIND: - { - stat = Stat.WIND_RES; - break; - } - case EARTH: - { - stat = Stat.EARTH_RES; - break; - } - case HOLY: - { - stat = Stat.HOLY_RES; - break; - } - case DARK: - { - stat = Stat.DARK_RES; - break; + case WATER: + { + effected.getStat().mergeAdd(Stat.WATER_RES, _amount); + break; + } + case WIND: + { + effected.getStat().mergeAdd(Stat.WIND_RES, _amount); + break; + } + case EARTH: + { + effected.getStat().mergeAdd(Stat.EARTH_RES, _amount); + break; + } + case HOLY: + { + effected.getStat().mergeAdd(Stat.HOLY_RES, _amount); + break; + } + case DARK: + { + effected.getStat().mergeAdd(Stat.DARK_RES, _amount); + break; + } } } - effected.getStat().mergeAdd(stat, _amount); } }