From 38c6078f5c63ac4e60728acbbda31bd910592cd9 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Thu, 6 Aug 2020 07:36:12 +0000 Subject: [PATCH] Addition of cancel Skill restore buffs configuration. Contributed by G-hamsteR. --- .../config/custom/CancelSkillRestoreBuffs.ini | 8 +++ .../java/org/l2jmobius/Config.java | 10 ++++ .../handler/skillhandlers/Disablers.java | 19 +++++++ .../tasks/player/CancelSkillRestoreTask.java | 52 +++++++++++++++++++ .../config/custom/CancelSkillRestoreBuffs.ini | 8 +++ .../java/org/l2jmobius/Config.java | 10 ++++ .../handler/skillhandlers/Disablers.java | 19 +++++++ .../tasks/player/CancelSkillRestoreTask.java | 52 +++++++++++++++++++ 8 files changed, 178 insertions(+) create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/custom/CancelSkillRestoreBuffs.ini create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/tasks/player/CancelSkillRestoreTask.java create mode 100644 L2J_Mobius_C6_Interlude/dist/game/config/custom/CancelSkillRestoreBuffs.ini create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/player/CancelSkillRestoreTask.java diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/custom/CancelSkillRestoreBuffs.ini b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/custom/CancelSkillRestoreBuffs.ini new file mode 100644 index 0000000000..d77db36486 --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/custom/CancelSkillRestoreBuffs.ini @@ -0,0 +1,8 @@ +# --------------------------------------------------------------------------- +# Cancel Skill Restore Buffs +# --------------------------------------------------------------------------- + +# Restore lost buffs on Cancellation skill after a few seconds. +# Input the value in seconds (0 to disable). +# Default : 0 +SecondsToReturnCancelledBuffs = 0 diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java index aa2fa2f4d2..bad87eb073 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java @@ -86,6 +86,7 @@ public class Config private static final String EVENT_TW_CONFIG_FILE = "./config/events/TW.ini"; // custom private static final String BANK_CONFIG_FILE = "./config/custom/Bank.ini"; + private static final String CANCEL_SKILL_RESTORE_BUFFS_CONFIG_FILE = "./config/custom/CancelSkillRestoreBuffs.ini"; private static final String CHAMPION_CONFIG_FILE = "./config/custom/Champion.ini"; private static final String MERCHANT_ZERO_SELL_PRICE_CONFIG_FILE = "./config/custom/MerchantZeroSellPrice.ini"; private static final String OFFLINE_CONFIG_FILE = "./config/custom/Offline.ini"; @@ -538,6 +539,8 @@ public class Config public static int BANKING_SYSTEM_GOLDBARS; public static int BANKING_SYSTEM_ADENA; + public static int RESTORE_CANCELLED_BUFFS_SECONDS; + public static int BUFFER_MAX_SCHEMES; public static int BUFFER_STATIC_BUFF_COST; @@ -1715,6 +1718,12 @@ public class Config BANKING_SYSTEM_ADENA = bankConfig.getInt("BankingAdenaCount", 500000000); } + public static void loadCancelSkillRestoreBuffsConfig() + { + final PropertiesParser cancelSkillRestoreBuffsConfig = new PropertiesParser(CANCEL_SKILL_RESTORE_BUFFS_CONFIG_FILE); + RESTORE_CANCELLED_BUFFS_SECONDS = cancelSkillRestoreBuffsConfig.getInt("SecondsToReturnCancelledBuffs", 0); + } + public static void loadBufferConfig() { final PropertiesParser shemeBufferConfig = new PropertiesParser(SCHEME_BUFFER_CONFIG_FILE); @@ -3025,6 +3034,7 @@ public class Config loadgeodataConfig(); // Custom + loadCancelSkillRestoreBuffsConfig(); loadChampionConfig(); loadMerchantZeroPriceConfig(); loadWeddingConfig(); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java index b20d27a8e6..050224cedc 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java @@ -17,9 +17,12 @@ package org.l2jmobius.gameserver.handler.skillhandlers; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.logging.Logger; import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.ai.AttackableAI; import org.l2jmobius.gameserver.ai.CtrlEvent; @@ -38,6 +41,7 @@ import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.PetInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.SiegeSummonInstance; +import org.l2jmobius.gameserver.model.actor.tasks.player.CancelSkillRestoreTask; import org.l2jmobius.gameserver.model.skills.Formulas; import org.l2jmobius.gameserver.model.skills.Stat; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -427,6 +431,8 @@ public class Disablers implements ISkillHandler } break; } + + final List cancelledBuffs = new ArrayList<>(); int lvlmodifier = 52 + (skill.getLevel() * 2); if (skill.getLevel() == 12) { @@ -480,6 +486,15 @@ public class Disablers implements ISkillHandler if (Rnd.get(100) < rate) { + if (Config.RESTORE_CANCELLED_BUFFS_SECONDS > 0) + { + // store them + if (!cancelledBuffs.contains(e.getSkill())) + { + cancelledBuffs.add(e.getSkill()); + } + } + // cancel them e.exit(true); maxfive--; if (maxfive == 0) @@ -490,6 +505,10 @@ public class Disablers implements ISkillHandler } } } + if ((Config.RESTORE_CANCELLED_BUFFS_SECONDS > 0) && (cancelledBuffs.size() > 0)) + { + ThreadPool.schedule(new CancelSkillRestoreTask((PlayerInstance) target, cancelledBuffs), Config.RESTORE_CANCELLED_BUFFS_SECONDS * 1000); + } } else if (creature instanceof PlayerInstance) { diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/tasks/player/CancelSkillRestoreTask.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/tasks/player/CancelSkillRestoreTask.java new file mode 100644 index 0000000000..b1aaf789f2 --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/tasks/player/CancelSkillRestoreTask.java @@ -0,0 +1,52 @@ +/* + * 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 org.l2jmobius.gameserver.model.actor.tasks.player; + +import java.util.List; + +import org.l2jmobius.gameserver.model.Skill; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; + +public class CancelSkillRestoreTask implements Runnable +{ + private PlayerInstance _player = null; + private List _buffs = null; + + public CancelSkillRestoreTask(PlayerInstance player, List buffs) + { + _player = player; + _buffs = buffs; + } + + @Override + public void run() + { + if ((_player == null) || !_player.isOnline()) + { + return; + } + + for (Skill skill : _buffs) + { + if (skill == null) + { + continue; + } + skill.getEffects(_player, _player); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_C6_Interlude/dist/game/config/custom/CancelSkillRestoreBuffs.ini b/L2J_Mobius_C6_Interlude/dist/game/config/custom/CancelSkillRestoreBuffs.ini new file mode 100644 index 0000000000..d77db36486 --- /dev/null +++ b/L2J_Mobius_C6_Interlude/dist/game/config/custom/CancelSkillRestoreBuffs.ini @@ -0,0 +1,8 @@ +# --------------------------------------------------------------------------- +# Cancel Skill Restore Buffs +# --------------------------------------------------------------------------- + +# Restore lost buffs on Cancellation skill after a few seconds. +# Input the value in seconds (0 to disable). +# Default : 0 +SecondsToReturnCancelledBuffs = 0 diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java index 4e12f30388..904357542b 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java @@ -87,6 +87,7 @@ public class Config private static final String EVENT_TW_CONFIG_FILE = "./config/events/TW.ini"; // custom private static final String BANK_CONFIG_FILE = "./config/custom/Bank.ini"; + private static final String CANCEL_SKILL_RESTORE_BUFFS_CONFIG_FILE = "./config/custom/CancelSkillRestoreBuffs.ini"; private static final String CHAMPION_CONFIG_FILE = "./config/custom/Champion.ini"; private static final String MERCHANT_ZERO_SELL_PRICE_CONFIG_FILE = "./config/custom/MerchantZeroSellPrice.ini"; private static final String OFFLINE_CONFIG_FILE = "./config/custom/Offline.ini"; @@ -558,6 +559,8 @@ public class Config public static int BANKING_SYSTEM_GOLDBARS; public static int BANKING_SYSTEM_ADENA; + public static int RESTORE_CANCELLED_BUFFS_SECONDS; + public static int BUFFER_MAX_SCHEMES; public static int BUFFER_STATIC_BUFF_COST; @@ -1766,6 +1769,12 @@ public class Config BANKING_SYSTEM_ADENA = bankConfig.getInt("BankingAdenaCount", 500000000); } + public static void loadCancelSkillRestoreBuffsConfig() + { + final PropertiesParser cancelSkillRestoreBuffsConfig = new PropertiesParser(CANCEL_SKILL_RESTORE_BUFFS_CONFIG_FILE); + RESTORE_CANCELLED_BUFFS_SECONDS = cancelSkillRestoreBuffsConfig.getInt("SecondsToReturnCancelledBuffs", 0); + } + public static void loadBufferConfig() { final PropertiesParser shemeBufferConfig = new PropertiesParser(SCHEME_BUFFER_CONFIG_FILE); @@ -3094,6 +3103,7 @@ public class Config loadgeodataConfig(); // Custom + loadCancelSkillRestoreBuffsConfig(); loadChampionConfig(); loadMerchantZeroPriceConfig(); loadWeddingConfig(); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java index b20d27a8e6..050224cedc 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java @@ -17,9 +17,12 @@ package org.l2jmobius.gameserver.handler.skillhandlers; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.logging.Logger; import org.l2jmobius.Config; +import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.ai.AttackableAI; import org.l2jmobius.gameserver.ai.CtrlEvent; @@ -38,6 +41,7 @@ import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.PetInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.SiegeSummonInstance; +import org.l2jmobius.gameserver.model.actor.tasks.player.CancelSkillRestoreTask; import org.l2jmobius.gameserver.model.skills.Formulas; import org.l2jmobius.gameserver.model.skills.Stat; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -427,6 +431,8 @@ public class Disablers implements ISkillHandler } break; } + + final List cancelledBuffs = new ArrayList<>(); int lvlmodifier = 52 + (skill.getLevel() * 2); if (skill.getLevel() == 12) { @@ -480,6 +486,15 @@ public class Disablers implements ISkillHandler if (Rnd.get(100) < rate) { + if (Config.RESTORE_CANCELLED_BUFFS_SECONDS > 0) + { + // store them + if (!cancelledBuffs.contains(e.getSkill())) + { + cancelledBuffs.add(e.getSkill()); + } + } + // cancel them e.exit(true); maxfive--; if (maxfive == 0) @@ -490,6 +505,10 @@ public class Disablers implements ISkillHandler } } } + if ((Config.RESTORE_CANCELLED_BUFFS_SECONDS > 0) && (cancelledBuffs.size() > 0)) + { + ThreadPool.schedule(new CancelSkillRestoreTask((PlayerInstance) target, cancelledBuffs), Config.RESTORE_CANCELLED_BUFFS_SECONDS * 1000); + } } else if (creature instanceof PlayerInstance) { diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/player/CancelSkillRestoreTask.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/player/CancelSkillRestoreTask.java new file mode 100644 index 0000000000..b1aaf789f2 --- /dev/null +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/player/CancelSkillRestoreTask.java @@ -0,0 +1,52 @@ +/* + * 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 org.l2jmobius.gameserver.model.actor.tasks.player; + +import java.util.List; + +import org.l2jmobius.gameserver.model.Skill; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; + +public class CancelSkillRestoreTask implements Runnable +{ + private PlayerInstance _player = null; + private List _buffs = null; + + public CancelSkillRestoreTask(PlayerInstance player, List buffs) + { + _player = player; + _buffs = buffs; + } + + @Override + public void run() + { + if ((_player == null) || !_player.isOnline()) + { + return; + } + + for (Skill skill : _buffs) + { + if (skill == null) + { + continue; + } + skill.getEffects(_player, _player); + } + } +} \ No newline at end of file