diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/EffectMasterHandler.java index 7f83965f1a..97238978de 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -369,6 +369,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_1.0_Ertheia/dist/game/data/stats/skills/documentation.txt index ed046dcaf7..3d80b12087 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/stats/skills/documentation.txt @@ -337,6 +337,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/EffectMasterHandler.java index 7f83965f1a..97238978de 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -369,6 +369,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_2.5_Underground/dist/game/data/stats/skills/documentation.txt index ed046dcaf7..3d80b12087 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_2.5_Underground/dist/game/data/stats/skills/documentation.txt @@ -337,6 +337,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/EffectMasterHandler.java index 7f83965f1a..97238978de 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -369,6 +369,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_3.0_Helios/dist/game/data/stats/skills/documentation.txt index ed046dcaf7..3d80b12087 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_3.0_Helios/dist/game/data/stats/skills/documentation.txt @@ -337,6 +337,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/EffectMasterHandler.java index 327de4e647..bf24b391b8 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -374,6 +374,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/stats/skills/documentation.txt index c47e59a8c4..2d7db86519 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/stats/skills/documentation.txt @@ -342,6 +342,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/EffectMasterHandler.java index 3ea0fadb77..29c6a8f851 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -379,6 +379,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_5.0_Salvation/dist/game/data/stats/skills/documentation.txt index 47b1f61bb5..3700ae3089 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/stats/skills/documentation.txt @@ -347,6 +347,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/EffectMasterHandler.java index 73d6d960a3..e3fe71bb1e 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -380,6 +380,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_5.5_EtinasFate/dist/game/data/stats/skills/documentation.txt index 84641d7d6f..21a78c25a6 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/stats/skills/documentation.txt @@ -348,6 +348,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/EffectMasterHandler.java index 73d6d960a3..e3fe71bb1e 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -380,6 +380,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_6.0_Fafurion/dist/game/data/stats/skills/documentation.txt index 84641d7d6f..21a78c25a6 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/stats/skills/documentation.txt @@ -348,6 +348,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/EffectMasterHandler.java index a59d55b96d..1b57b7250f 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -380,6 +380,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/stats/skills/documentation.txt index c5295a3a6e..aa38fbe909 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/stats/skills/documentation.txt @@ -347,6 +347,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/EffectMasterHandler.java index 8531b684f8..f45c7985af 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -381,6 +381,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_8.0_Homunculus/dist/game/data/stats/skills/documentation.txt index e3c907937e..ba8e77bb39 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_8.0_Homunculus/dist/game/data/stats/skills/documentation.txt @@ -348,6 +348,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/EffectMasterHandler.java index 36cd12a9fc..44b82973e2 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -382,6 +382,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDualRange", TriggerSkillByDualRange::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/stats/skills/documentation.txt index 83ec0450a5..b6beaaed26 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/stats/skills/documentation.txt @@ -349,6 +349,7 @@ TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). TriggerSkillByDualRange: Triggers a specified skill based on close or ranged distance. (l2jmobius) +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/EffectMasterHandler.java index 770b0ba3f3..26fc48c913 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -365,6 +365,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/stats/skills/documentation.txt index 60df008dc2..b00a68dfa3 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/stats/skills/documentation.txt @@ -333,6 +333,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/EffectMasterHandler.java index 770b0ba3f3..26fc48c913 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -365,6 +365,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/stats/skills/documentation.txt index 60df008dc2..b00a68dfa3 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/stats/skills/documentation.txt @@ -333,6 +333,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/EffectMasterHandler.java index 9e292c0bb9..d05857031f 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -366,6 +366,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/stats/skills/documentation.txt index 6d8a292bda..f802180616 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/stats/skills/documentation.txt @@ -334,6 +334,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/EffectMasterHandler.java index 03b1447e4f..8a7611b956 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -370,6 +370,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/stats/skills/documentation.txt index 98e7d5a4e5..9d46ec24e0 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/stats/skills/documentation.txt @@ -338,6 +338,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/EffectMasterHandler.java index 03b1447e4f..8a7611b956 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -370,6 +370,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/stats/skills/documentation.txt index 98e7d5a4e5..9d46ec24e0 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/stats/skills/documentation.txt @@ -338,6 +338,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/EffectMasterHandler.java index b32ecec476..b70bdeddb4 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -372,6 +372,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/stats/skills/documentation.txt index 4efd1a55ce..e487805be9 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/stats/skills/documentation.txt @@ -340,6 +340,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/EffectMasterHandler.java index 88e06d4622..833c3dd255 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -368,6 +368,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Classic_Interlude/dist/game/data/stats/skills/documentation.txt index 35c8e6201e..9eb4376efe 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/stats/skills/documentation.txt @@ -335,6 +335,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/EffectMasterHandler.java index 349a12aa17..f8fc447bd3 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -378,6 +378,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/stats/skills/documentation.txt index 1f32c75fea..660e2e0028 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/stats/skills/documentation.txt @@ -346,6 +346,7 @@ TriggerSkillByAttack: Triggers a specified skill when you deal damage. TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage. TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage. diff --git a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/scripts/handlers/EffectMasterHandler.java index 6db860ab74..3e8b088abd 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -380,6 +380,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new); EffectHandler.getInstance().registerHandler("TriggerSkillByDualRange", TriggerSkillByDualRange::new); + EffectHandler.getInstance().registerHandler("TriggerSkillByHpPercent", TriggerSkillByHpPercent::new); EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new); EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new); EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new); diff --git a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java new file mode 100644 index 0000000000..c6bcec6fed --- /dev/null +++ b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/scripts/handlers/effecthandlers/TriggerSkillByHpPercent.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.data.xml.SkillData; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.events.EventType; +import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureHpChange; +import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.skills.SkillCaster; + +/** + * @author Mobius + */ +public class TriggerSkillByHpPercent extends AbstractEffect +{ + private final int _skillId; + private final int _skillLevel; + private final int _percentFrom; + private final int _percentTo; + + public TriggerSkillByHpPercent(StatSet params) + { + _skillId = params.getInt("skillId", 0); + _skillLevel = params.getInt("skillLevel", 1); + _percentFrom = params.getInt("percentFrom", 0); + _percentTo = params.getInt("percentTo", 100); + } + + @Override + public void onStart(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + effected.addListener(new ConsumerEventListener(effected, EventType.ON_CREATURE_HP_CHANGE, (OnCreatureHpChange event) -> onHpChange(event), this)); + } + + @Override + public void onExit(Creature effector, Creature effected, Skill skill) + { + effected.removeListenerIf(EventType.ON_CREATURE_HP_CHANGE, listener -> listener.getOwner() == this); + } + + private void onHpChange(OnCreatureHpChange event) + { + final Creature creature = event.getCreature(); + final int hpPercent = creature.getCurrentHpPercent(); + if ((hpPercent >= _percentFrom) && (hpPercent <= _percentTo)) + { + SkillCaster.triggerCast(creature, creature, SkillData.getInstance().getSkill(_skillId, _skillLevel)); + } + } +} diff --git a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/stats/skills/documentation.txt index 17ae344e3d..e7af4d34c7 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/stats/skills/documentation.txt @@ -348,6 +348,7 @@ TriggerSkillByAvoid: Triggers a specified skill when you avoid autoattack damage TriggerSkillByDamage: Triggers a specified skill when you receive damage. TriggerSkillByDeathBlow: Triggers a specified skill when you land a death blow (killing a creature). TriggerSkillByDualRange: Triggers a specified skill based on close or ranged distance. (l2jmobius) +TriggerSkillByHpPercent: Triggers a specified skill based on effected HP percent. (l2jmobius) TriggerSkillByKill: Triggers a specified skill when you kill a creature. TriggerSkillByMagicType: Triggers skill when you finish casting a skill with a specified magic type. TriggerSkillBySkillAttack: Triggers skill when you finish casting a skill that does damage.