Addition of Player isInTimedHuntingZone method.

This commit is contained in:
MobiusDevelopment
2022-08-30 23:32:54 +00:00
parent 98166d7d78
commit 54578fc855
32 changed files with 90 additions and 52 deletions

View File

@@ -572,7 +572,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{
if (isPlayer())
{
if (isInsideZone(ZoneId.TIMED_HUNTING))
if (getActingPlayer().isInTimedHuntingZone())
{
getActingPlayer().stopTimedHuntingZoneTask();
abortCast();

View File

@@ -5090,7 +5090,7 @@ public class Player extends Playable
setReputation(newRep < -20 ? newRep : 0);
}
if (isInsideZone(ZoneId.TIMED_HUNTING))
if (isInTimedHuntingZone())
{
DecayTaskManager.getInstance().add(this);
sendPacket(new TimeRestrictFieldDieLimitTime());
@@ -10836,7 +10836,7 @@ public class Player extends Playable
}
// Close time limited zone window.
if (!isInsideZone(ZoneId.TIMED_HUNTING))
if (!isInTimedHuntingZone())
{
stopTimedHuntingZoneTask();
}
@@ -11303,7 +11303,7 @@ public class Player extends Playable
}
// Exit timed hunting zone.
if (isInTimedHuntingZone(getX(), getY()))
if (isInTimedHuntingZone())
{
teleToLocation(TeleportWhereType.TOWN);
storeCharBase();
@@ -14836,6 +14836,11 @@ public class Player extends Playable
return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
}
public boolean isInTimedHuntingZone()
{
return isInTimedHuntingZone(getX(), getY());
}
public boolean isInTimedHuntingZone(int x, int y)
{
for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())

View File

@@ -90,7 +90,7 @@ public class TimedHuntingZone extends ZoneType
ThreadPool.schedule(() ->
{
if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
if (!player.isInTimedHuntingZone())
{
player.sendPacket(new TimedHuntingZoneExit(player.getVariables().getInt(PlayerVariables.LAST_HUNTING_ZONE_ID, 0)));
}

View File

@@ -89,7 +89,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.sendMessage("Cannot use time-limited hunting zones while registered on an event.");
return;
}
if (player.isInInstance() || player.isInTimedHuntingZone(player.getX(), player.getY()))
if (player.isInInstance() || player.isInTimedHuntingZone())
{
player.sendMessage("Cannot use time-limited hunting zones while in an instance.");
return;

View File

@@ -25,7 +25,6 @@ import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.zone.ZoneId;
/**
* @author Mobius
@@ -92,14 +91,14 @@ public class DecayTaskManager implements Runnable
if (creature.isPlayer())
{
if (Config.DISCONNECT_AFTER_DEATH)
{
delay = 3600; // 1 hour
}
if (creature.isInsideZone(ZoneId.TIMED_HUNTING))
if (creature.getActingPlayer().isInTimedHuntingZone())
{
delay = 60; // 10 minutes
}
else if (Config.DISCONNECT_AFTER_DEATH)
{
delay = 3600; // 1 hour
}
}
// Add to decay schedules.