Addition of SchedulingPattern support for DBSpawnManager.
Contributed by kamikadzz.
This commit is contained in:
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
@@ -24,6 +24,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||||
@@ -69,6 +70,8 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
private int _respawnMinDelay;
|
private int _respawnMinDelay;
|
||||||
/** Maximum respawn delay */
|
/** Maximum respawn delay */
|
||||||
private int _respawnMaxDelay;
|
private int _respawnMaxDelay;
|
||||||
|
/** Respawn Pattern **/
|
||||||
|
private SchedulingPattern _respawnPattern;
|
||||||
/** The generic constructor of Npc managed by this Spawn */
|
/** The generic constructor of Npc managed by this Spawn */
|
||||||
private Constructor<? extends Npc> _constructor;
|
private Constructor<? extends Npc> _constructor;
|
||||||
/** If True an Npc is respawned each time that another is killed */
|
/** If True an Npc is respawned each time that another is killed */
|
||||||
@@ -194,6 +197,14 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
return _respawnMaxDelay;
|
return _respawnMaxDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return respawn pattern
|
||||||
|
*/
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the maximum number of Npc that this Spawn can manage.
|
* Set the maximum number of Npc that this Spawn can manage.
|
||||||
* @param amount
|
* @param amount
|
||||||
@@ -503,6 +514,11 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRespawnPattern(SchedulingPattern respawnPattern)
|
||||||
|
{
|
||||||
|
_respawnPattern = respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRespawnDelay(int delay)
|
public void setRespawnDelay(int delay)
|
||||||
{
|
{
|
||||||
setRespawnDelay(delay, 0);
|
setRespawnDelay(delay, 0);
|
||||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -54,6 +55,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
private final int _count;
|
private final int _count;
|
||||||
private final Duration _respawnTime;
|
private final Duration _respawnTime;
|
||||||
private final Duration _respawnTimeRandom;
|
private final Duration _respawnTimeRandom;
|
||||||
|
private final SchedulingPattern _respawnPattern;
|
||||||
private final int _chaseRange;
|
private final int _chaseRange;
|
||||||
private List<ChanceLocation> _locations;
|
private List<ChanceLocation> _locations;
|
||||||
private SpawnTerritory _zone;
|
private SpawnTerritory _zone;
|
||||||
@@ -74,6 +76,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = template._count;
|
_count = template._count;
|
||||||
_respawnTime = template._respawnTime;
|
_respawnTime = template._respawnTime;
|
||||||
_respawnTimeRandom = template._respawnTimeRandom;
|
_respawnTimeRandom = template._respawnTimeRandom;
|
||||||
|
_respawnPattern = template._respawnPattern;
|
||||||
_chaseRange = template._chaseRange;
|
_chaseRange = template._chaseRange;
|
||||||
_spawnAnimation = template._spawnAnimation;
|
_spawnAnimation = template._spawnAnimation;
|
||||||
_saveInDB = template._saveInDB;
|
_saveInDB = template._saveInDB;
|
||||||
@@ -92,6 +95,7 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
_count = set.getInt("count", 1);
|
_count = set.getInt("count", 1);
|
||||||
_respawnTime = set.getDuration("respawnTime", null);
|
_respawnTime = set.getDuration("respawnTime", null);
|
||||||
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
_respawnTimeRandom = set.getDuration("respawnRandom", null);
|
||||||
|
_respawnPattern = (set.getString("respawnPattern", null) == null) || set.getString("respawnPattern", null).isEmpty() ? null : new SchedulingPattern(set.getString("respawnPattern", null));
|
||||||
_chaseRange = set.getInt("chaseRange", 0);
|
_chaseRange = set.getInt("chaseRange", 0);
|
||||||
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
_spawnAnimation = set.getBoolean("spawnAnimation", false);
|
||||||
_saveInDB = set.getBoolean("dbSave", false);
|
_saveInDB = set.getBoolean("dbSave", false);
|
||||||
@@ -198,6 +202,11 @@ public class NpcSpawnTemplate implements Cloneable, IParameterized<StatSet>
|
|||||||
return _respawnTimeRandom;
|
return _respawnTimeRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SchedulingPattern getRespawnPattern()
|
||||||
|
{
|
||||||
|
return _respawnPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChaseRange()
|
public int getChaseRange()
|
||||||
{
|
{
|
||||||
return _chaseRange;
|
return _chaseRange;
|
||||||
|
@@ -113,6 +113,7 @@
|
|||||||
<xs:attribute type="xs:positiveInteger" name="count" />
|
<xs:attribute type="xs:positiveInteger" name="count" />
|
||||||
<xs:attribute type="xs:string" name="respawnTime" />
|
<xs:attribute type="xs:string" name="respawnTime" />
|
||||||
<xs:attribute type="xs:string" name="respawnRandom" />
|
<xs:attribute type="xs:string" name="respawnRandom" />
|
||||||
|
<xs:attribute type="xs:string" name="respawnPattern" />
|
||||||
<xs:attribute type="xs:integer" name="chaseRange" />
|
<xs:attribute type="xs:integer" name="chaseRange" />
|
||||||
<xs:attribute type="xs:integer" name="x" />
|
<xs:attribute type="xs:integer" name="x" />
|
||||||
<xs:attribute type="xs:integer" name="y" />
|
<xs:attribute type="xs:integer" name="y" />
|
||||||
|
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.threads.ThreadPool;
|
import org.l2jmobius.commons.threads.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.time.SchedulingPattern;
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||||
@@ -121,6 +122,7 @@ public class DBSpawnManager
|
|||||||
|
|
||||||
int respawn = 0;
|
int respawn = 0;
|
||||||
int respawnRandom = 0;
|
int respawnRandom = 0;
|
||||||
|
SchedulingPattern respawnPattern = null;
|
||||||
if (spawnTemplate.getRespawnTime() != null)
|
if (spawnTemplate.getRespawnTime() != null)
|
||||||
{
|
{
|
||||||
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
respawn = (int) spawnTemplate.getRespawnTime().getSeconds();
|
||||||
@@ -129,10 +131,15 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
respawnRandom = (int) spawnTemplate.getRespawnTimeRandom().getSeconds();
|
||||||
}
|
}
|
||||||
|
if (spawnTemplate.getRespawnPattern() != null)
|
||||||
|
{
|
||||||
|
respawnPattern = spawnTemplate.getRespawnPattern();
|
||||||
|
}
|
||||||
|
|
||||||
if (respawn > 0)
|
if ((respawn > 0) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
spawn.setRespawnDelay(respawn, respawnRandom);
|
spawn.setRespawnDelay(respawn, respawnRandom);
|
||||||
|
spawn.setRespawnPattern(respawnPattern);
|
||||||
spawn.startRespawn();
|
spawn.startRespawn();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,14 +218,27 @@ public class DBSpawnManager
|
|||||||
{
|
{
|
||||||
npc.setDBStatus(RaidBossStatus.DEAD);
|
npc.setDBStatus(RaidBossStatus.DEAD);
|
||||||
|
|
||||||
final int respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
final SchedulingPattern respawnPattern = npc.getSpawn().getRespawnPattern();
|
||||||
final int respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
int respawnMinDelay, respawnMaxDelay, respawnDelay;
|
||||||
final int respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
long respawnTime;
|
||||||
final long respawnTime = System.currentTimeMillis() + respawnDelay;
|
|
||||||
|
if (respawnPattern != null)
|
||||||
|
{
|
||||||
|
respawnTime = respawnPattern.next(System.currentTimeMillis());
|
||||||
|
respawnMinDelay = respawnMaxDelay = respawnDelay = (int) (respawnTime - System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
respawnMinDelay = (int) (npc.getSpawn().getRespawnMinDelay() * Config.RAID_MIN_RESPAWN_MULTIPLIER);
|
||||||
|
respawnMaxDelay = (int) (npc.getSpawn().getRespawnMaxDelay() * Config.RAID_MAX_RESPAWN_MULTIPLIER);
|
||||||
|
respawnDelay = Rnd.get(respawnMinDelay, respawnMaxDelay);
|
||||||
|
respawnTime = System.currentTimeMillis() + respawnDelay;
|
||||||
|
}
|
||||||
|
|
||||||
info.set("currentHP", npc.getMaxHp());
|
info.set("currentHP", npc.getMaxHp());
|
||||||
info.set("currentMP", npc.getMaxMp());
|
info.set("currentMP", npc.getMaxMp());
|
||||||
info.set("respawnTime", respawnTime);
|
info.set("respawnTime", respawnTime);
|
||||||
if (!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0)))
|
if ((!_schedules.containsKey(npc.getId()) && ((respawnMinDelay > 0) || (respawnMaxDelay > 0))) || (respawnPattern != null))
|
||||||
{
|
{
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
|
||||||
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
_schedules.put(npc.getId(), ThreadPool.schedule(() -> scheduleSpawn(npc.getId()), respawnDelay));
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user