Timed zones separation.
This commit is contained in:
parent
12456c3e91
commit
e3421df4c4
@ -14221,18 +14221,40 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
public boolean isInTimedHuntingZone()
|
||||
{
|
||||
return isInTimedHuntingZone(1) // Storm Isle
|
||||
|| isInTimedHuntingZone(6); // Primeval Isle
|
||||
}
|
||||
|
||||
public boolean isInTimedHuntingZone(int zoneId)
|
||||
{
|
||||
final int x = ((getX() - World.MAP_MIN_X) >> 15) + World.TILE_X_MIN;
|
||||
final int y = ((getY() - World.MAP_MIN_Y) >> 15) + World.TILE_Y_MIN;
|
||||
if (((x == 25) && (y == 23)) // Storm Isle.
|
||||
|| ((x == 20) && (y == 17))) // Primeval Isle.
|
||||
|
||||
switch (zoneId)
|
||||
{
|
||||
return true;
|
||||
case 1: // Storm Isle
|
||||
{
|
||||
if ((x == 25) && (y == 23))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: // Primeval Isle
|
||||
{
|
||||
if ((x == 20) && (y == 17))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void startTimedHuntingZone(long delay)
|
||||
public void startTimedHuntingZone(int zoneId, long delay)
|
||||
{
|
||||
// TODO: Delay window.
|
||||
// sendPacket(new TimedHuntingZoneEnter((int) (delay / 60 / 1000)));
|
||||
@ -14241,7 +14263,7 @@ public class PlayerInstance extends Playable
|
||||
|
||||
_timedHuntingZoneFinishTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
if ((isOnlineInt() > 0) && isInTimedHuntingZone())
|
||||
if ((isOnlineInt() > 0) && isInTimedHuntingZone(zoneId))
|
||||
{
|
||||
sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
|
||||
abortCast();
|
||||
|
@ -63,7 +63,7 @@ public class PlayerVariables extends AbstractVariables
|
||||
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
||||
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
||||
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
||||
public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME";
|
||||
public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME_";
|
||||
|
||||
private final int _objectId;
|
||||
|
||||
|
@ -648,10 +648,15 @@ public class EnterWorld implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
// Check if in time limited hunting zone.
|
||||
final long exitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME, 0);
|
||||
if (exitTime > System.currentTimeMillis())
|
||||
final long stormIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0);
|
||||
final long primevalIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 6, 0);
|
||||
if (stormIsleExitTime > System.currentTimeMillis())
|
||||
{
|
||||
player.startTimedHuntingZone(exitTime - System.currentTimeMillis());
|
||||
player.startTimedHuntingZone(1, stormIsleExitTime - System.currentTimeMillis());
|
||||
}
|
||||
else if (primevalIsleExitTime > System.currentTimeMillis())
|
||||
{
|
||||
player.startTimedHuntingZone(6, primevalIsleExitTime - System.currentTimeMillis());
|
||||
}
|
||||
else if (player.isInTimedHuntingZone())
|
||||
{
|
||||
|
@ -29,12 +29,12 @@ import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
*/
|
||||
public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
|
||||
{
|
||||
private int _fieldId;
|
||||
private int _zoneId;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_fieldId = packet.readD();
|
||||
_zoneId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME, 0) > System.currentTimeMillis())
|
||||
if (player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0) > System.currentTimeMillis())
|
||||
{
|
||||
if (player.isInTimedHuntingZone())
|
||||
{
|
||||
@ -86,18 +86,18 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
if (((_fieldId == 1) && (player.getLevel() < 100)) //
|
||||
|| ((_fieldId == 6) && (player.getLevel() < 105)) //
|
||||
if (((_zoneId == 1) && (player.getLevel() < 100)) //
|
||||
|| ((_zoneId == 6) && (player.getLevel() < 105)) //
|
||||
)
|
||||
{
|
||||
player.sendMessage("Your level is too low.");
|
||||
player.sendMessage("Your level does not corespont the zone equivalent.");
|
||||
}
|
||||
|
||||
if (player.getAdena() > 150000)
|
||||
{
|
||||
player.reduceAdena("TimedHuntingZone", 150000, player, true);
|
||||
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME, System.currentTimeMillis() + 18000000); // 300 minutes
|
||||
switch (_fieldId)
|
||||
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, System.currentTimeMillis() + 18000000); // 300 minutes
|
||||
switch (_zoneId)
|
||||
{
|
||||
case 1: // Storm Isle
|
||||
{
|
||||
@ -110,7 +110,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
|
||||
break;
|
||||
}
|
||||
}
|
||||
player.startTimedHuntingZone(18000000); // 300 minutes
|
||||
player.startTimedHuntingZone(_zoneId, 18000000); // 300 minutes
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -14167,17 +14167,31 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
public boolean isInTimedHuntingZone()
|
||||
{
|
||||
return isInTimedHuntingZone(2); // Storm Isle
|
||||
}
|
||||
|
||||
public boolean isInTimedHuntingZone(int zoneId)
|
||||
{
|
||||
final int x = ((getX() - World.MAP_MIN_X) >> 15) + World.TILE_X_MIN;
|
||||
final int y = ((getY() - World.MAP_MIN_Y) >> 15) + World.TILE_Y_MIN;
|
||||
if ((x == 20) && (y == 15)) // Ancient Pirates' Tomb.
|
||||
|
||||
switch (zoneId)
|
||||
{
|
||||
return true;
|
||||
case 2: // Ancient Pirates' Tomb.
|
||||
{
|
||||
if ((x == 20) && (y == 15))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void startTimedHuntingZone(long delay)
|
||||
public void startTimedHuntingZone(int zoneId, long delay)
|
||||
{
|
||||
// TODO: Delay window.
|
||||
// sendPacket(new TimedHuntingZoneEnter((int) (delay / 60 / 1000)));
|
||||
@ -14186,7 +14200,7 @@ public class PlayerInstance extends Playable
|
||||
|
||||
_timedHuntingZoneFinishTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
if ((isOnlineInt() > 0) && isInTimedHuntingZone())
|
||||
if ((isOnlineInt() > 0) && isInTimedHuntingZone(zoneId))
|
||||
{
|
||||
sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
|
||||
abortCast();
|
||||
|
@ -63,7 +63,7 @@ public class PlayerVariables extends AbstractVariables
|
||||
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
||||
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
||||
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
||||
public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME";
|
||||
public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME_";
|
||||
|
||||
private final int _objectId;
|
||||
|
||||
|
@ -633,10 +633,10 @@ public class EnterWorld implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
// Check if in time limited hunting zone.
|
||||
final long exitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME, 0);
|
||||
if (exitTime > System.currentTimeMillis())
|
||||
final long pirateTombExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 2, 0);
|
||||
if (pirateTombExitTime > System.currentTimeMillis())
|
||||
{
|
||||
player.startTimedHuntingZone(exitTime - System.currentTimeMillis());
|
||||
player.startTimedHuntingZone(2, pirateTombExitTime - System.currentTimeMillis());
|
||||
}
|
||||
else if (player.isInTimedHuntingZone())
|
||||
{
|
||||
|
@ -28,12 +28,12 @@ import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
*/
|
||||
public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
|
||||
{
|
||||
private int _fieldId;
|
||||
private int _zoneId;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_fieldId = packet.readD();
|
||||
_zoneId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME, 0) > System.currentTimeMillis())
|
||||
if (player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0) > System.currentTimeMillis())
|
||||
{
|
||||
if (player.isInTimedHuntingZone())
|
||||
{
|
||||
@ -85,7 +85,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_fieldId == 2) && (player.getLevel() < 78))
|
||||
if ((_zoneId == 2) && (player.getLevel() < 78))
|
||||
{
|
||||
player.sendMessage("Your level is too low.");
|
||||
}
|
||||
@ -93,8 +93,8 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
|
||||
if (player.getAdena() > 10000)
|
||||
{
|
||||
player.reduceAdena("TimedHuntingZone", 10000, player, true);
|
||||
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME, System.currentTimeMillis() + 18000000); // 300 minutes
|
||||
switch (_fieldId)
|
||||
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, System.currentTimeMillis() + 18000000); // 300 minutes
|
||||
switch (_zoneId)
|
||||
{
|
||||
case 2: // Ancient Pirates' Tomb
|
||||
{
|
||||
@ -102,7 +102,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
|
||||
break;
|
||||
}
|
||||
}
|
||||
player.startTimedHuntingZone(18000000); // 300 minutes
|
||||
player.startTimedHuntingZone(_zoneId, 18000000); // 300 minutes
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user