From 8a64ca5fcb93e36252511a652acb84d587f427d1 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sat, 5 Jun 2021 22:37:10 +0000 Subject: [PATCH] Addition of DecreaseWaitingTime effect handler. Contributed by CostyKiller. --- .../scripts/handlers/EffectMasterHandler.java | 1 + .../effecthandlers/DecreaseWaitingTime.java | 79 +++++++++++++++++++ .../game/data/stats/skills/39600-39699.xml | 28 ++++++- .../scripts/handlers/EffectMasterHandler.java | 1 + .../effecthandlers/DecreaseWaitingTime.java | 79 +++++++++++++++++++ .../game/data/stats/skills/39600-39699.xml | 28 ++++++- 6 files changed, 212 insertions(+), 4 deletions(-) create mode 100644 L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/DecreaseWaitingTime.java create mode 100644 L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/DecreaseWaitingTime.java 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 f45c7985af..cdf24a3595 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 @@ -116,6 +116,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("DamOverTimePercent", DamOverTimePercent::new); EffectHandler.getInstance().registerHandler("DeathLink", DeathLink::new); EffectHandler.getInstance().registerHandler("DebuffBlock", DebuffBlock::new); + EffectHandler.getInstance().registerHandler("DecreaseWaitingTime", DecreaseWaitingTime::new); EffectHandler.getInstance().registerHandler("DefenceAttribute", DefenceAttribute::new); EffectHandler.getInstance().registerHandler("DefenceCriticalDamage", DefenceCriticalDamage::new); EffectHandler.getInstance().registerHandler("DefenceCriticalRate", DefenceCriticalRate::new); diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/DecreaseWaitingTime.java b/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/DecreaseWaitingTime.java new file mode 100644 index 0000000000..54a92d2b96 --- /dev/null +++ b/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/DecreaseWaitingTime.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.commons.util.Chronos; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.variables.PlayerVariables; +import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo; + +/** + * @author CostyKiller + */ +public class DecreaseWaitingTime extends AbstractEffect +{ + private final long _time; + + public DecreaseWaitingTime(StatSet params) + { + _time = params.getLong("time", 0); + } + + @Override + public boolean isInstant() + { + return true; + } + + @Override + public void instant(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + final PlayerInstance player = effected.getActingPlayer(); + if (player == null) + { + return; + } + + final long currentTime = Chronos.currentTimeMillis(); + long creationTime = player.getVariables().getLong(PlayerVariables.HOMUNCULUS_CREATION_TIME, 0); + final long waitTime = 86400; // 86400 = 24 Hours + if (creationTime == 0) + { + player.getInventory().addItem("DecreaseWaitingTime effect refund", item.getId(), 1, player, player); + player.sendMessage("You don't have any Homunculus in progress."); + } + else if (((currentTime / 1000) - (creationTime / 1000)) > waitTime) + { + player.getInventory().addItem("DecreaseWaitingTime effect refund", item.getId(), 1, player, player); + player.sendMessage("You cannot decrease the waiting time anymore."); + } + else if (((currentTime / 1000) - (creationTime / 1000)) < waitTime) + { + player.getVariables().set(PlayerVariables.HOMUNCULUS_CREATION_TIME, creationTime - (_time)); + player.sendPacket(new ExShowHomunculusBirthInfo(player)); + } + else + { + player.sendMessage("You cannot use this item yet."); + } + } +} diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/data/stats/skills/39600-39699.xml b/L2J_Mobius_8.0_Homunculus/dist/game/data/stats/skills/39600-39699.xml index d5e4e6f356..2584de6da7 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/game/data/stats/skills/39600-39699.xml +++ b/L2J_Mobius_8.0_Homunculus/dist/game/data/stats/skills/39600-39699.xml @@ -725,13 +725,37 @@ - icon.skill0000 + 1 A1 + 4 + 5 + 0 + SELF + SINGLE + 1 + 81673 + + + + + - icon.skill0000 + 1 A1 + 4 + 5 + 0 + SELF + SINGLE + 1 + 81674 + + + + + icon.skill0000 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 44b82973e2..d56bf8fa99 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 @@ -116,6 +116,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("DamOverTimePercent", DamOverTimePercent::new); EffectHandler.getInstance().registerHandler("DeathLink", DeathLink::new); EffectHandler.getInstance().registerHandler("DebuffBlock", DebuffBlock::new); + EffectHandler.getInstance().registerHandler("DecreaseWaitingTime", DecreaseWaitingTime::new); EffectHandler.getInstance().registerHandler("DefenceAttribute", DefenceAttribute::new); EffectHandler.getInstance().registerHandler("DefenceCriticalDamage", DefenceCriticalDamage::new); EffectHandler.getInstance().registerHandler("DefenceCriticalRate", DefenceCriticalRate::new); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/DecreaseWaitingTime.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/DecreaseWaitingTime.java new file mode 100644 index 0000000000..54a92d2b96 --- /dev/null +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/DecreaseWaitingTime.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.commons.util.Chronos; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.Skill; +import org.l2jmobius.gameserver.model.variables.PlayerVariables; +import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo; + +/** + * @author CostyKiller + */ +public class DecreaseWaitingTime extends AbstractEffect +{ + private final long _time; + + public DecreaseWaitingTime(StatSet params) + { + _time = params.getLong("time", 0); + } + + @Override + public boolean isInstant() + { + return true; + } + + @Override + public void instant(Creature effector, Creature effected, Skill skill, ItemInstance item) + { + final PlayerInstance player = effected.getActingPlayer(); + if (player == null) + { + return; + } + + final long currentTime = Chronos.currentTimeMillis(); + long creationTime = player.getVariables().getLong(PlayerVariables.HOMUNCULUS_CREATION_TIME, 0); + final long waitTime = 86400; // 86400 = 24 Hours + if (creationTime == 0) + { + player.getInventory().addItem("DecreaseWaitingTime effect refund", item.getId(), 1, player, player); + player.sendMessage("You don't have any Homunculus in progress."); + } + else if (((currentTime / 1000) - (creationTime / 1000)) > waitTime) + { + player.getInventory().addItem("DecreaseWaitingTime effect refund", item.getId(), 1, player, player); + player.sendMessage("You cannot decrease the waiting time anymore."); + } + else if (((currentTime / 1000) - (creationTime / 1000)) < waitTime) + { + player.getVariables().set(PlayerVariables.HOMUNCULUS_CREATION_TIME, creationTime - (_time)); + player.sendPacket(new ExShowHomunculusBirthInfo(player)); + } + else + { + player.sendMessage("You cannot use this item yet."); + } + } +} diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/stats/skills/39600-39699.xml b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/stats/skills/39600-39699.xml index eb69919686..a41a077da2 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/stats/skills/39600-39699.xml +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/stats/skills/39600-39699.xml @@ -725,13 +725,37 @@ - icon.skill0000 + 1 A1 + 4 + 5 + 0 + SELF + SINGLE + 1 + 81673 + + + + + - icon.skill0000 + 1 A1 + 4 + 5 + 0 + SELF + SINGLE + 1 + 81674 + + + + + icon.skill0000