From b3374a719ab0613eaef85db1e7903c721c76b7b6 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Wed, 28 Dec 2022 09:12:12 +0000 Subject: [PATCH] Unhardcoded Flip Block skills. --- .../scripts/handlers/EffectMasterHandler.java | 1 + .../handlers/effecthandlers/FlipBlock.java | 79 +++++++++++++++++++ .../game/data/stats/skills/05800-05899.xml | 10 ++- .../gameserver/model/skill/Skill.java | 70 +++------------- .../scripts/handlers/EffectMasterHandler.java | 1 + .../handlers/effecthandlers/FlipBlock.java | 79 +++++++++++++++++++ .../game/data/stats/skills/05800-05899.xml | 10 ++- .../dist/game/data/xsd/skills.xsd | 1 + .../gameserver/model/skill/Skill.java | 70 +++------------- 9 files changed, 203 insertions(+), 118 deletions(-) create mode 100644 L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/effecthandlers/FlipBlock.java create mode 100644 L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/effecthandlers/FlipBlock.java diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/EffectMasterHandler.java index 3f192309ba..ad1210720d 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -88,6 +88,7 @@ public class EffectMasterHandler Fear.class, Fishing.class, Flag.class, + FlipBlock.class, FocusEnergy.class, FocusMaxEnergy.class, FocusSouls.class, diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/effecthandlers/FlipBlock.java b/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/effecthandlers/FlipBlock.java new file mode 100644 index 0000000000..c2560e73c2 --- /dev/null +++ b/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/scripts/handlers/effecthandlers/FlipBlock.java @@ -0,0 +1,79 @@ +/* + * 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.instancemanager.HandysBlockCheckerManager; +import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.actor.instance.Block; +import org.l2jmobius.gameserver.model.conditions.Condition; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.skill.BuffInfo; + +/** + * Flip Block effect implementation. + * @author Mobius + */ +public class FlipBlock extends AbstractEffect +{ + public FlipBlock(Condition attachCond, Condition applyCond, StatSet set, StatSet params) + { + super(attachCond, applyCond, set, params); + } + + @Override + public boolean isInstant() + { + return true; + } + + @Override + public void onStart(BuffInfo info) + { + final Creature effector = info.getEffector(); + final Creature effected = info.getEffected(); + final Block block = effected instanceof Block ? (Block) effected : null; + final Player player = effector.isPlayer() ? (Player) effector : null; + if ((block == null) || (player == null)) + { + return; + } + + final int arena = player.getBlockCheckerArena(); + if (arena != -1) + { + final ArenaParticipantsHolder holder = HandysBlockCheckerManager.getInstance().getHolder(arena); + if (holder == null) + { + return; + } + + final int team = holder.getPlayerTeam(player); + final int color = block.getColorEffect(); + if ((team == 0) && (color == 0x00)) + { + block.changeColor(player, holder, team); + } + else if ((team == 1) && (color == 0x53)) + { + block.changeColor(player, holder, team); + } + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/stats/skills/05800-05899.xml b/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/stats/skills/05800-05899.xml index 5546d1cac5..58b887f9cc 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/stats/skills/05800-05899.xml +++ b/L2J_Mobius_CT_2.4_Epilogue/dist/game/data/stats/skills/05800-05899.xml @@ -753,25 +753,31 @@ + - + + + + - + + + diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/skill/Skill.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/skill/Skill.java index 7c7d95a301..0253395ad3 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/skill/Skill.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/skill/Skill.java @@ -38,15 +38,12 @@ import org.l2jmobius.gameserver.enums.SkillFinishType; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.handler.ITargetTypeHandler; import org.l2jmobius.gameserver.handler.TargetHandler; -import org.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager; -import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.ExtractableProductItem; import org.l2jmobius.gameserver.model.ExtractableSkill; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; -import org.l2jmobius.gameserver.model.actor.instance.Block; import org.l2jmobius.gameserver.model.actor.instance.Cubic; import org.l2jmobius.gameserver.model.conditions.Condition; import org.l2jmobius.gameserver.model.effects.AbstractEffect; @@ -1387,65 +1384,24 @@ public class Skill implements IIdentifiable */ private void activateSkill(Creature caster, Cubic cubic, WorldObject... targets) { - switch (_id) + for (WorldObject obj : targets) { - // TODO: replace with AI - case 5852: - case 5853: + final Creature target = (Creature) obj; + if (Formulas.calcBuffDebuffReflection(target, this)) { - final Block block = targets[0] instanceof Block ? (Block) targets[0] : null; - final Player player = caster.isPlayer() ? (Player) caster : null; - if ((block == null) || (player == null)) - { - return; - } + // If skill is reflected instant effects should be casted on target and continuous effects on caster. + applyEffects(target, caster, false, 0); - final int arena = player.getBlockCheckerArena(); - if (arena != -1) - { - final ArenaParticipantsHolder holder = HandysBlockCheckerManager.getInstance().getHolder(arena); - if (holder == null) - { - return; - } - - final int team = holder.getPlayerTeam(player); - final int color = block.getColorEffect(); - if ((team == 0) && (color == 0x00)) - { - block.changeColor(player, holder, team); - } - else if ((team == 1) && (color == 0x53)) - { - block.changeColor(player, holder, team); - } - } - break; + final BuffInfo info = new BuffInfo(caster, target, this); + applyEffectScope(EffectScope.GENERAL, info, true, false); + + final EffectScope pvpOrPveEffectScope = caster.isPlayable() && target.isAttackable() ? EffectScope.PVE : caster.isPlayable() && target.isPlayable() ? EffectScope.PVP : null; + applyEffectScope(pvpOrPveEffectScope, info, true, false); + applyEffectScope(EffectScope.CHANNELING, info, true, false); } - default: + else { - for (WorldObject obj : targets) - { - final Creature target = (Creature) obj; - if (Formulas.calcBuffDebuffReflection(target, this)) - { - // if skill is reflected instant effects should be casted on target - // and continuous effects on caster - applyEffects(target, caster, false, 0); - - final BuffInfo info = new BuffInfo(caster, target, this); - applyEffectScope(EffectScope.GENERAL, info, true, false); - - final EffectScope pvpOrPveEffectScope = caster.isPlayable() && target.isAttackable() ? EffectScope.PVE : caster.isPlayable() && target.isPlayable() ? EffectScope.PVP : null; - applyEffectScope(pvpOrPveEffectScope, info, true, false); - applyEffectScope(EffectScope.CHANNELING, info, true, false); - } - else - { - applyEffects(caster, target); - } - } - break; + applyEffects(caster, target); } } diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/EffectMasterHandler.java index e4d75c761b..491ab7e106 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -88,6 +88,7 @@ public class EffectMasterHandler Fear.class, Fishing.class, Flag.class, + FlipBlock.class, FocusEnergy.class, FocusMaxEnergy.class, FocusSouls.class, diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/effecthandlers/FlipBlock.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/effecthandlers/FlipBlock.java new file mode 100644 index 0000000000..c2560e73c2 --- /dev/null +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/effecthandlers/FlipBlock.java @@ -0,0 +1,79 @@ +/* + * 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.instancemanager.HandysBlockCheckerManager; +import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.actor.instance.Block; +import org.l2jmobius.gameserver.model.conditions.Condition; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.skill.BuffInfo; + +/** + * Flip Block effect implementation. + * @author Mobius + */ +public class FlipBlock extends AbstractEffect +{ + public FlipBlock(Condition attachCond, Condition applyCond, StatSet set, StatSet params) + { + super(attachCond, applyCond, set, params); + } + + @Override + public boolean isInstant() + { + return true; + } + + @Override + public void onStart(BuffInfo info) + { + final Creature effector = info.getEffector(); + final Creature effected = info.getEffected(); + final Block block = effected instanceof Block ? (Block) effected : null; + final Player player = effector.isPlayer() ? (Player) effector : null; + if ((block == null) || (player == null)) + { + return; + } + + final int arena = player.getBlockCheckerArena(); + if (arena != -1) + { + final ArenaParticipantsHolder holder = HandysBlockCheckerManager.getInstance().getHolder(arena); + if (holder == null) + { + return; + } + + final int team = holder.getPlayerTeam(player); + final int color = block.getColorEffect(); + if ((team == 0) && (color == 0x00)) + { + block.changeColor(player, holder, team); + } + else if ((team == 1) && (color == 0x53)) + { + block.changeColor(player, holder, team); + } + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/stats/skills/05800-05899.xml b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/stats/skills/05800-05899.xml index e932398411..de920e6513 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/stats/skills/05800-05899.xml +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/stats/skills/05800-05899.xml @@ -753,25 +753,31 @@ + - + + + + - + + + diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/skills.xsd b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/skills.xsd index b9f61b3452..c47bad9458 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/skills.xsd +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/skills.xsd @@ -553,6 +553,7 @@ + diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java index 0305acaf23..e26c81f193 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java @@ -38,15 +38,12 @@ import org.l2jmobius.gameserver.enums.SkillFinishType; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.handler.ITargetTypeHandler; import org.l2jmobius.gameserver.handler.TargetHandler; -import org.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager; -import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.ExtractableProductItem; import org.l2jmobius.gameserver.model.ExtractableSkill; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; -import org.l2jmobius.gameserver.model.actor.instance.Block; import org.l2jmobius.gameserver.model.actor.instance.Cubic; import org.l2jmobius.gameserver.model.conditions.Condition; import org.l2jmobius.gameserver.model.effects.AbstractEffect; @@ -1407,65 +1404,24 @@ public class Skill implements IIdentifiable */ private void activateSkill(Creature caster, Cubic cubic, WorldObject... targets) { - switch (_id) + for (WorldObject obj : targets) { - // TODO: replace with AI - case 5852: - case 5853: + final Creature target = (Creature) obj; + if (Formulas.calcBuffDebuffReflection(target, this)) { - final Block block = targets[0] instanceof Block ? (Block) targets[0] : null; - final Player player = caster.isPlayer() ? (Player) caster : null; - if ((block == null) || (player == null)) - { - return; - } + // If skill is reflected instant effects should be casted on target and continuous effects on caster. + applyEffects(target, caster, false, 0); - final int arena = player.getBlockCheckerArena(); - if (arena != -1) - { - final ArenaParticipantsHolder holder = HandysBlockCheckerManager.getInstance().getHolder(arena); - if (holder == null) - { - return; - } - - final int team = holder.getPlayerTeam(player); - final int color = block.getColorEffect(); - if ((team == 0) && (color == 0x00)) - { - block.changeColor(player, holder, team); - } - else if ((team == 1) && (color == 0x53)) - { - block.changeColor(player, holder, team); - } - } - break; + final BuffInfo info = new BuffInfo(caster, target, this); + applyEffectScope(EffectScope.GENERAL, info, true, false); + + final EffectScope pvpOrPveEffectScope = caster.isPlayable() && target.isAttackable() ? EffectScope.PVE : caster.isPlayable() && target.isPlayable() ? EffectScope.PVP : null; + applyEffectScope(pvpOrPveEffectScope, info, true, false); + applyEffectScope(EffectScope.CHANNELING, info, true, false); } - default: + else { - for (WorldObject obj : targets) - { - final Creature target = (Creature) obj; - if (Formulas.calcBuffDebuffReflection(target, this)) - { - // if skill is reflected instant effects should be casted on target - // and continuous effects on caster - applyEffects(target, caster, false, 0); - - final BuffInfo info = new BuffInfo(caster, target, this); - applyEffectScope(EffectScope.GENERAL, info, true, false); - - final EffectScope pvpOrPveEffectScope = caster.isPlayable() && target.isAttackable() ? EffectScope.PVE : caster.isPlayable() && target.isPlayable() ? EffectScope.PVP : null; - applyEffectScope(pvpOrPveEffectScope, info, true, false); - applyEffectScope(EffectScope.CHANNELING, info, true, false); - } - else - { - applyEffects(caster, target); - } - } - break; + applyEffects(caster, target); } }