Support for exiting instance at nearest town.

This commit is contained in:
MobiusDevelopment 2021-05-23 16:38:37 +00:00
parent 35553698f1
commit f4f7c98c29
20 changed files with 198 additions and 86 deletions

View File

@ -89,6 +89,7 @@
<xs:enumeration value="FIXED" />
<xs:enumeration value="RANDOM" />
<xs:enumeration value="ORIGIN" />
<xs:enumeration value="TOWN" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>

View File

@ -24,5 +24,6 @@ public enum InstanceTeleportType
NONE,
FIXED,
RANDOM,
ORIGIN
ORIGIN,
TOWN
}

View File

@ -209,6 +209,10 @@ public class InstanceManager implements IXmlReader
{
template.setExitLocation(type, null);
}
else if (type.equals(InstanceTeleportType.TOWN))
{
template.setExitLocation(type, null);
}
else
{
final List<Location> locations = new ArrayList<>();

View File

@ -325,23 +325,7 @@ public class MapRegionManager implements IXmlReader
// Karma player land out of city
if (player.getReputation() < 0)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(player, RespawnZone.class);
if (zone != null)
{
return getRestartRegion(creature, zone.getRespawnPoint((PlayerInstance) creature)).getChaoticSpawnLoc();
}
return getMapRegion(creature).getChaoticSpawnLoc();
}
catch (Exception e)
{
if (player.isFlyingMounted())
{
return REGIONS.get("union_base_of_kserth").getChaoticSpawnLoc();
}
return REGIONS.get(DEFAULT_RESPAWN).getChaoticSpawnLoc();
}
return getNearestKarmaRespawn(player);
}
// Checking if needed to be respawned in "far" town from the castle;
@ -377,6 +361,32 @@ public class MapRegionManager implements IXmlReader
}
// Get the nearest town
return getNearestTownRespawn(creature);
}
public Location getNearestKarmaRespawn(PlayerInstance player)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(player, RespawnZone.class);
if (zone != null)
{
return getRestartRegion(player, zone.getRespawnPoint(player)).getChaoticSpawnLoc();
}
return getMapRegion(player).getChaoticSpawnLoc();
}
catch (Exception e)
{
if (player.isFlyingMounted())
{
return REGIONS.get("union_base_of_kserth").getChaoticSpawnLoc();
}
return REGIONS.get(DEFAULT_RESPAWN).getChaoticSpawnLoc();
}
}
public Location getNearestTownRespawn(Creature creature)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(creature, RespawnZone.class);

View File

@ -33,6 +33,7 @@ import org.l2jmobius.gameserver.enums.InstanceReenterType;
import org.l2jmobius.gameserver.enums.InstanceRemoveBuffType;
import org.l2jmobius.gameserver.enums.InstanceTeleportType;
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.AbstractPlayerGroup;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
@ -367,7 +368,6 @@ public class InstanceTemplate extends ListenersContainer implements IIdentifiabl
public Location getExitLocation(PlayerInstance player)
{
Location location = null;
switch (_exitLocationType)
{
case RANDOM:
@ -391,6 +391,18 @@ public class InstanceTemplate extends ListenersContainer implements IIdentifiabl
}
break;
}
case TOWN:
{
if (player.getReputation() < 0)
{
location = MapRegionManager.getInstance().getNearestKarmaRespawn(player);
}
else
{
location = MapRegionManager.getInstance().getNearestTownRespawn(player);
}
break;
}
}
return location;
}

View File

@ -89,6 +89,7 @@
<xs:enumeration value="FIXED" />
<xs:enumeration value="RANDOM" />
<xs:enumeration value="ORIGIN" />
<xs:enumeration value="TOWN" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>

View File

@ -24,5 +24,6 @@ public enum InstanceTeleportType
NONE,
FIXED,
RANDOM,
ORIGIN
ORIGIN,
TOWN
}

View File

@ -209,6 +209,10 @@ public class InstanceManager implements IXmlReader
{
template.setExitLocation(type, null);
}
else if (type.equals(InstanceTeleportType.TOWN))
{
template.setExitLocation(type, null);
}
else
{
final List<Location> locations = new ArrayList<>();

View File

@ -325,23 +325,7 @@ public class MapRegionManager implements IXmlReader
// Karma player land out of city
if (player.getReputation() < 0)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(player, RespawnZone.class);
if (zone != null)
{
return getRestartRegion(creature, zone.getRespawnPoint((PlayerInstance) creature)).getChaoticSpawnLoc();
}
return getMapRegion(creature).getChaoticSpawnLoc();
}
catch (Exception e)
{
if (player.isFlyingMounted())
{
return REGIONS.get("union_base_of_kserth").getChaoticSpawnLoc();
}
return REGIONS.get(DEFAULT_RESPAWN).getChaoticSpawnLoc();
}
return getNearestKarmaRespawn(player);
}
// Checking if needed to be respawned in "far" town from the castle;
@ -377,6 +361,32 @@ public class MapRegionManager implements IXmlReader
}
// Get the nearest town
return getNearestTownRespawn(creature);
}
public Location getNearestKarmaRespawn(PlayerInstance player)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(player, RespawnZone.class);
if (zone != null)
{
return getRestartRegion(player, zone.getRespawnPoint(player)).getChaoticSpawnLoc();
}
return getMapRegion(player).getChaoticSpawnLoc();
}
catch (Exception e)
{
if (player.isFlyingMounted())
{
return REGIONS.get("union_base_of_kserth").getChaoticSpawnLoc();
}
return REGIONS.get(DEFAULT_RESPAWN).getChaoticSpawnLoc();
}
}
public Location getNearestTownRespawn(Creature creature)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(creature, RespawnZone.class);

View File

@ -33,6 +33,7 @@ import org.l2jmobius.gameserver.enums.InstanceReenterType;
import org.l2jmobius.gameserver.enums.InstanceRemoveBuffType;
import org.l2jmobius.gameserver.enums.InstanceTeleportType;
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.AbstractPlayerGroup;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
@ -367,7 +368,6 @@ public class InstanceTemplate extends ListenersContainer implements IIdentifiabl
public Location getExitLocation(PlayerInstance player)
{
Location location = null;
switch (_exitLocationType)
{
case RANDOM:
@ -391,6 +391,18 @@ public class InstanceTemplate extends ListenersContainer implements IIdentifiabl
}
break;
}
case TOWN:
{
if (player.getReputation() < 0)
{
location = MapRegionManager.getInstance().getNearestKarmaRespawn(player);
}
else
{
location = MapRegionManager.getInstance().getNearestTownRespawn(player);
}
break;
}
}
return location;
}

View File

@ -89,6 +89,7 @@
<xs:enumeration value="FIXED" />
<xs:enumeration value="RANDOM" />
<xs:enumeration value="ORIGIN" />
<xs:enumeration value="TOWN" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>

View File

@ -24,5 +24,6 @@ public enum InstanceTeleportType
NONE,
FIXED,
RANDOM,
ORIGIN
ORIGIN,
TOWN
}

View File

@ -209,6 +209,10 @@ public class InstanceManager implements IXmlReader
{
template.setExitLocation(type, null);
}
else if (type.equals(InstanceTeleportType.TOWN))
{
template.setExitLocation(type, null);
}
else
{
final List<Location> locations = new ArrayList<>();

View File

@ -325,28 +325,7 @@ public class MapRegionManager implements IXmlReader
// Karma player land out of city
if (player.getReputation() < 0)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(player, RespawnZone.class);
if (zone != null)
{
return getRestartRegion(creature, zone.getRespawnPoint((PlayerInstance) creature)).getChaoticSpawnLoc();
}
// Opposing race check.
if (getMapRegion(creature).getBannedRace().containsKey(creature.getRace()))
{
return REGIONS.get(getMapRegion(creature).getBannedRace().get(creature.getRace())).getChaoticSpawnLoc();
}
return getMapRegion(creature).getChaoticSpawnLoc();
}
catch (Exception e)
{
if (player.isFlyingMounted())
{
return REGIONS.get("union_base_of_kserth").getChaoticSpawnLoc();
}
return REGIONS.get(DEFAULT_RESPAWN).getChaoticSpawnLoc();
}
return getNearestKarmaRespawn(player);
}
// Checking if needed to be respawned in "far" town from the castle;
@ -382,6 +361,37 @@ public class MapRegionManager implements IXmlReader
}
// Get the nearest town
return getNearestTownRespawn(creature);
}
public Location getNearestKarmaRespawn(PlayerInstance player)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(player, RespawnZone.class);
if (zone != null)
{
return getRestartRegion(player, zone.getRespawnPoint(player)).getChaoticSpawnLoc();
}
// Opposing race check.
if (getMapRegion(player).getBannedRace().containsKey(player.getRace()))
{
return REGIONS.get(getMapRegion(player).getBannedRace().get(player.getRace())).getChaoticSpawnLoc();
}
return getMapRegion(player).getChaoticSpawnLoc();
}
catch (Exception e)
{
if (player.isFlyingMounted())
{
return REGIONS.get("union_base_of_kserth").getChaoticSpawnLoc();
}
return REGIONS.get(DEFAULT_RESPAWN).getChaoticSpawnLoc();
}
}
public Location getNearestTownRespawn(Creature creature)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(creature, RespawnZone.class);

View File

@ -33,6 +33,7 @@ import org.l2jmobius.gameserver.enums.InstanceReenterType;
import org.l2jmobius.gameserver.enums.InstanceRemoveBuffType;
import org.l2jmobius.gameserver.enums.InstanceTeleportType;
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.AbstractPlayerGroup;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
@ -367,7 +368,6 @@ public class InstanceTemplate extends ListenersContainer implements IIdentifiabl
public Location getExitLocation(PlayerInstance player)
{
Location location = null;
switch (_exitLocationType)
{
case RANDOM:
@ -391,6 +391,18 @@ public class InstanceTemplate extends ListenersContainer implements IIdentifiabl
}
break;
}
case TOWN:
{
if (player.getReputation() < 0)
{
location = MapRegionManager.getInstance().getNearestKarmaRespawn(player);
}
else
{
location = MapRegionManager.getInstance().getNearestTownRespawn(player);
}
break;
}
}
return location;
}

View File

@ -89,6 +89,7 @@
<xs:enumeration value="FIXED" />
<xs:enumeration value="RANDOM" />
<xs:enumeration value="ORIGIN" />
<xs:enumeration value="TOWN" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>

View File

@ -24,5 +24,6 @@ public enum InstanceTeleportType
NONE,
FIXED,
RANDOM,
ORIGIN
ORIGIN,
TOWN
}

View File

@ -209,6 +209,10 @@ public class InstanceManager implements IXmlReader
{
template.setExitLocation(type, null);
}
else if (type.equals(InstanceTeleportType.TOWN))
{
template.setExitLocation(type, null);
}
else
{
final List<Location> locations = new ArrayList<>();

View File

@ -325,28 +325,7 @@ public class MapRegionManager implements IXmlReader
// Karma player land out of city
if (player.getReputation() < 0)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(player, RespawnZone.class);
if (zone != null)
{
return getRestartRegion(creature, zone.getRespawnPoint((PlayerInstance) creature)).getChaoticSpawnLoc();
}
// Opposing race check.
if (getMapRegion(creature).getBannedRace().containsKey(creature.getRace()))
{
return REGIONS.get(getMapRegion(creature).getBannedRace().get(creature.getRace())).getChaoticSpawnLoc();
}
return getMapRegion(creature).getChaoticSpawnLoc();
}
catch (Exception e)
{
if (player.isFlyingMounted())
{
return REGIONS.get("union_base_of_kserth").getChaoticSpawnLoc();
}
return REGIONS.get(DEFAULT_RESPAWN).getChaoticSpawnLoc();
}
return getNearestKarmaRespawn(player);
}
// Checking if needed to be respawned in "far" town from the castle;
@ -382,6 +361,37 @@ public class MapRegionManager implements IXmlReader
}
// Get the nearest town
return getNearestTownRespawn(creature);
}
public Location getNearestKarmaRespawn(PlayerInstance player)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(player, RespawnZone.class);
if (zone != null)
{
return getRestartRegion(player, zone.getRespawnPoint(player)).getChaoticSpawnLoc();
}
// Opposing race check.
if (getMapRegion(player).getBannedRace().containsKey(player.getRace()))
{
return REGIONS.get(getMapRegion(player).getBannedRace().get(player.getRace())).getChaoticSpawnLoc();
}
return getMapRegion(player).getChaoticSpawnLoc();
}
catch (Exception e)
{
if (player.isFlyingMounted())
{
return REGIONS.get("union_base_of_kserth").getChaoticSpawnLoc();
}
return REGIONS.get(DEFAULT_RESPAWN).getChaoticSpawnLoc();
}
}
public Location getNearestTownRespawn(Creature creature)
{
try
{
final RespawnZone zone = ZoneManager.getInstance().getZone(creature, RespawnZone.class);

View File

@ -33,6 +33,7 @@ import org.l2jmobius.gameserver.enums.InstanceReenterType;
import org.l2jmobius.gameserver.enums.InstanceRemoveBuffType;
import org.l2jmobius.gameserver.enums.InstanceTeleportType;
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.AbstractPlayerGroup;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
@ -367,7 +368,6 @@ public class InstanceTemplate extends ListenersContainer implements IIdentifiabl
public Location getExitLocation(PlayerInstance player)
{
Location location = null;
switch (_exitLocationType)
{
case RANDOM:
@ -391,6 +391,18 @@ public class InstanceTemplate extends ListenersContainer implements IIdentifiabl
}
break;
}
case TOWN:
{
if (player.getReputation() < 0)
{
location = MapRegionManager.getInstance().getNearestKarmaRespawn(player);
}
else
{
location = MapRegionManager.getInstance().getNearestTownRespawn(player);
}
break;
}
}
return location;
}