Addition of DecreaseWaitingTime effect handler.
Contributed by CostyKiller.
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
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.");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -725,13 +725,37 @@
 | 
			
		||||
	</skill>
 | 
			
		||||
	<skill id="39671" toLevel="1" name="Essence of Time">
 | 
			
		||||
		<!-- When used, decreases time of homunculus creation for 1 h. -->
 | 
			
		||||
		<icon>icon.skill0000</icon>
 | 
			
		||||
		<magicLevel>1</magicLevel>
 | 
			
		||||
		<operateType>A1</operateType>
 | 
			
		||||
		<isMagic>4</isMagic>
 | 
			
		||||
		<magicCriticalRate>5</magicCriticalRate>
 | 
			
		||||
		<hitCancelTime>0</hitCancelTime>
 | 
			
		||||
		<targetType>SELF</targetType>
 | 
			
		||||
		<affectScope>SINGLE</affectScope>
 | 
			
		||||
		<itemConsumeCount>1</itemConsumeCount>
 | 
			
		||||
		<itemConsumeId>81673</itemConsumeId> <!-- Essence of Time -->
 | 
			
		||||
		<effects>
 | 
			
		||||
			<effect name="DecreaseWaitingTime">
 | 
			
		||||
				<time>3600000</time>
 | 
			
		||||
			</effect>
 | 
			
		||||
		</effects>
 | 
			
		||||
	</skill>
 | 
			
		||||
	<skill id="39672" toLevel="1" name="Essence of Time (test)">
 | 
			
		||||
		<!-- A test item for homunculus system. When used, decreases time of homunculus creation for 24 h. -->
 | 
			
		||||
		<icon>icon.skill0000</icon>
 | 
			
		||||
		<magicLevel>1</magicLevel>
 | 
			
		||||
		<operateType>A1</operateType>
 | 
			
		||||
		<isMagic>4</isMagic>
 | 
			
		||||
		<magicCriticalRate>5</magicCriticalRate>
 | 
			
		||||
		<hitCancelTime>0</hitCancelTime>
 | 
			
		||||
		<targetType>SELF</targetType>
 | 
			
		||||
		<affectScope>SINGLE</affectScope>
 | 
			
		||||
		<itemConsumeCount>1</itemConsumeCount>
 | 
			
		||||
		<itemConsumeId>81674</itemConsumeId> <!-- Essence of Time (test) -->
 | 
			
		||||
		<effects>
 | 
			
		||||
			<effect name="DecreaseWaitingTime">
 | 
			
		||||
				<time>86400000</time>
 | 
			
		||||
			</effect>
 | 
			
		||||
		</effects>
 | 
			
		||||
	</skill>
 | 
			
		||||
	<skill id="39673" toLevel="1" name="Milk of Vitality">
 | 
			
		||||
		<icon>icon.skill0000</icon>
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
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.");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -725,13 +725,37 @@
 | 
			
		||||
	</skill>
 | 
			
		||||
	<skill id="39671" toLevel="1" name="Essence of Time">
 | 
			
		||||
		<!-- When used, decreases time of homunculus creation for 1 h. -->
 | 
			
		||||
		<icon>icon.skill0000</icon>
 | 
			
		||||
		<magicLevel>1</magicLevel>
 | 
			
		||||
		<operateType>A1</operateType>
 | 
			
		||||
		<isMagic>4</isMagic>
 | 
			
		||||
		<magicCriticalRate>5</magicCriticalRate>
 | 
			
		||||
		<hitCancelTime>0</hitCancelTime>
 | 
			
		||||
		<targetType>SELF</targetType>
 | 
			
		||||
		<affectScope>SINGLE</affectScope>
 | 
			
		||||
		<itemConsumeCount>1</itemConsumeCount>
 | 
			
		||||
		<itemConsumeId>81673</itemConsumeId> <!-- Essence of Time -->
 | 
			
		||||
		<effects>
 | 
			
		||||
			<effect name="DecreaseWaitingTime">
 | 
			
		||||
				<time>3600000</time>
 | 
			
		||||
			</effect>
 | 
			
		||||
		</effects>
 | 
			
		||||
	</skill>
 | 
			
		||||
	<skill id="39672" toLevel="1" name="Essence of Time (test)">
 | 
			
		||||
		<!-- A test item for homunculus system. When used, decreases time of homunculus creation for 24 h. -->
 | 
			
		||||
		<icon>icon.skill0000</icon>
 | 
			
		||||
		<magicLevel>1</magicLevel>
 | 
			
		||||
		<operateType>A1</operateType>
 | 
			
		||||
		<isMagic>4</isMagic>
 | 
			
		||||
		<magicCriticalRate>5</magicCriticalRate>
 | 
			
		||||
		<hitCancelTime>0</hitCancelTime>
 | 
			
		||||
		<targetType>SELF</targetType>
 | 
			
		||||
		<affectScope>SINGLE</affectScope>
 | 
			
		||||
		<itemConsumeCount>1</itemConsumeCount>
 | 
			
		||||
		<itemConsumeId>81674</itemConsumeId> <!-- Essence of Time (test) -->
 | 
			
		||||
		<effects>
 | 
			
		||||
			<effect name="DecreaseWaitingTime">
 | 
			
		||||
				<time>86400000</time>
 | 
			
		||||
			</effect>
 | 
			
		||||
		</effects>
 | 
			
		||||
	</skill>
 | 
			
		||||
	<skill id="39673" toLevel="1" name="Milk of Vitality">
 | 
			
		||||
		<icon>icon.skill0000</icon>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user