Addition of AddHuntingTime effect handler.

This commit is contained in:
MobiusDevelopment
2020-01-23 14:54:23 +00:00
parent 86b672924c
commit 3d0bdd0a46
18 changed files with 536 additions and 541 deletions

View File

@@ -37,6 +37,7 @@ public class EffectMasterHandler
EffectHandler.getInstance().registerHandler("AbsorbDamage", AbsorbDamage::new);
EffectHandler.getInstance().registerHandler("Accuracy", Accuracy::new);
EffectHandler.getInstance().registerHandler("AddHate", AddHate::new);
EffectHandler.getInstance().registerHandler("AddHuntingTime", AddHuntingTime::new);
EffectHandler.getInstance().registerHandler("AdditionalPotionCp", AdditionalPotionCp::new);
EffectHandler.getInstance().registerHandler("AdditionalPotionHp", AdditionalPotionHp::new);
EffectHandler.getInstance().registerHandler("AdditionalPotionMp", AdditionalPotionMp::new);

View File

@@ -0,0 +1,80 @@
/*
* 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.gameserver.model.StatsSet;
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.sessionzones.TimedHuntingZoneList;
/**
* @author Mobius
*/
public class AddHuntingTime extends AbstractEffect
{
private final int _zoneId;
private final long _time;
public AddHuntingTime(StatsSet params)
{
_zoneId = params.getInt("zoneId", 0);
_time = params.getLong("time", 3600000);
}
@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 = System.currentTimeMillis();
if (player.isInTimedHuntingZone(_zoneId))
{
final long increasedTime = _time + player.getTimedHuntingZoneRemainingTime();
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, currentTime + increasedTime);
player.startTimedHuntingZone(_zoneId, increasedTime);
}
else
{
long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0);
if ((endTime + 18000000) < currentTime)
{
endTime = currentTime + 18000000;
}
else if (endTime < currentTime)
{
endTime = currentTime;
}
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime + _time);
}
player.sendPacket(new TimedHuntingZoneList(player));
}
}