Prevent thinking in non active regions.

This commit is contained in:
MobiusDevelopment 2019-03-21 12:49:10 +00:00
parent 8b0e0c53f3
commit ad9a9006cf
52 changed files with 81 additions and 1022 deletions

View File

@ -1174,6 +1174,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -40,12 +39,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -43,10 +41,6 @@ public class L2MonsterInstance extends L2Attackable
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
/** /**
* Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br> * Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B>
@ -115,8 +109,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -134,15 +126,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -150,25 +133,12 @@ public class L2MonsterInstance extends L2Attackable
{ {
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -30,8 +27,6 @@ import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -60,47 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0)); broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0));
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ);
}
}
}
@Override @Override
public int getVitalityPoints(int level, double exp, boolean isBoss) public int getVitalityPoints(int level, double exp, boolean isBoss)
{ {

View File

@ -1174,6 +1174,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -40,12 +39,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -43,10 +41,6 @@ public class L2MonsterInstance extends L2Attackable
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
/** /**
* Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br> * Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B>
@ -115,8 +109,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -134,15 +126,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -150,25 +133,12 @@ public class L2MonsterInstance extends L2Attackable
{ {
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -30,8 +27,6 @@ import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -60,47 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0)); broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0));
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ);
}
}
}
@Override @Override
public int getVitalityPoints(int level, double exp, boolean isBoss) public int getVitalityPoints(int level, double exp, boolean isBoss)
{ {

View File

@ -1174,6 +1174,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -40,12 +39,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -43,10 +41,6 @@ public class L2MonsterInstance extends L2Attackable
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
/** /**
* Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br> * Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B>
@ -115,8 +109,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -134,15 +126,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -150,25 +133,12 @@ public class L2MonsterInstance extends L2Attackable
{ {
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -30,8 +27,6 @@ import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -60,47 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0)); broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0));
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ);
}
}
}
@Override @Override
public int getVitalityPoints(int level, double exp, boolean isBoss) public int getVitalityPoints(int level, double exp, boolean isBoss)
{ {

View File

@ -1174,6 +1174,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -40,12 +39,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -43,10 +41,6 @@ public class L2MonsterInstance extends L2Attackable
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
/** /**
* Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br> * Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B>
@ -115,8 +109,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -134,15 +126,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -150,25 +133,12 @@ public class L2MonsterInstance extends L2Attackable
{ {
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -30,8 +27,6 @@ import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -60,47 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0)); broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0));
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ);
}
}
}
@Override @Override
public int getVitalityPoints(int level, double exp, boolean isBoss) public int getVitalityPoints(int level, double exp, boolean isBoss)
{ {

View File

@ -1174,6 +1174,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -40,12 +39,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -43,10 +41,6 @@ public class L2MonsterInstance extends L2Attackable
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
/** /**
* Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br> * Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B>
@ -115,8 +109,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -134,15 +126,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -150,25 +133,12 @@ public class L2MonsterInstance extends L2Attackable
{ {
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -30,8 +27,6 @@ import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -60,47 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0)); broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0));
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ);
}
}
}
@Override @Override
public int getVitalityPoints(int level, double exp, boolean isBoss) public int getVitalityPoints(int level, double exp, boolean isBoss)
{ {

View File

@ -1174,6 +1174,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -40,12 +39,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -43,10 +41,6 @@ public class L2MonsterInstance extends L2Attackable
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
/** /**
* Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br> * Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B>
@ -115,8 +109,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -134,15 +126,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -150,25 +133,12 @@ public class L2MonsterInstance extends L2Attackable
{ {
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -30,8 +27,6 @@ import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -60,47 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0)); broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0));
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ);
}
}
}
@Override @Override
public int getVitalityPoints(int level, double exp, boolean isBoss) public int getVitalityPoints(int level, double exp, boolean isBoss)
{ {

View File

@ -1174,6 +1174,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -40,12 +39,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -43,10 +41,6 @@ public class L2MonsterInstance extends L2Attackable
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
/** /**
* Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br> * Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B>
@ -115,8 +109,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -134,15 +126,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -150,25 +133,12 @@ public class L2MonsterInstance extends L2Attackable
{ {
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -30,8 +27,6 @@ import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -60,47 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0)); broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0));
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ);
}
}
}
@Override @Override
public int getVitalityPoints(int level, double exp, boolean isBoss) public int getVitalityPoints(int level, double exp, boolean isBoss)
{ {

View File

@ -339,6 +339,12 @@ public class L2AttackableAI extends L2CharacterAI
@Override @Override
public void changeIntention(CtrlIntention intention, Object arg0, Object arg1) public void changeIntention(CtrlIntention intention, Object arg0, Object arg1)
{ {
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
if ((intention == AI_INTENTION_IDLE) || (intention == AI_INTENTION_ACTIVE)) if ((intention == AI_INTENTION_IDLE) || (intention == AI_INTENTION_ACTIVE))
{ {
// Check if actor is not dead // Check if actor is not dead

View File

@ -34,8 +34,6 @@ import com.l2jmobius.gameserver.templates.chars.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 20000;
/** /**
* Constructor for L2GrandBossInstance. This represent all grandbosses. * Constructor for L2GrandBossInstance. This represent all grandbosses.
* @param objectId ID of the instance * @param objectId ID of the instance
@ -46,12 +44,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
super(objectId, template); super(objectId, template);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -122,7 +114,7 @@ public final class L2GrandBossInstance extends L2MonsterInstance
} }
_minionList.maintainMinions(); _minionList.maintainMinions();
}, 60000, getMaintenanceInterval()); }, 60000, 20000);
} }
@Override @Override

View File

@ -41,7 +41,6 @@ import com.l2jmobius.gameserver.util.MinionList;
*/ */
public class L2MonsterInstance extends L2Attackable public class L2MonsterInstance extends L2Attackable
{ {
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
protected final MinionList _minionList; protected final MinionList _minionList;
protected ScheduledFuture<?> _minionMaintainTask = null; protected ScheduledFuture<?> _minionMaintainTask = null;
@ -151,21 +150,12 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
/**
* Gets the maintenance interval.
* @return the maintenance interval
*/
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
/** /**
* Spawn all minions at a regular interval. * Spawn all minions at a regular interval.
*/ */
protected void manageMinions() protected void manageMinions()
{ {
_minionMaintainTask = ThreadPool.schedule(() -> _minionList.spawnMinions(), getMaintenanceInterval()); _minionMaintainTask = ThreadPool.schedule(() -> _minionList.spawnMinions(), 1000);
} }
public void callMinions() public void callMinions()

View File

@ -34,7 +34,6 @@ import com.l2jmobius.gameserver.templates.chars.L2NpcTemplate;
*/ */
public final class L2RaidBossInstance extends L2MonsterInstance public final class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 20000; // 20 sec
private RaidBossSpawnManager.StatusEnum _raidStatus; private RaidBossSpawnManager.StatusEnum _raidStatus;
/** /**
@ -60,12 +59,6 @@ public final class L2RaidBossInstance extends L2MonsterInstance
return true; return true;
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -135,7 +128,7 @@ public final class L2RaidBossInstance extends L2MonsterInstance
} }
_minionList.maintainMinions(); _minionList.maintainMinions();
}, 60000, getMaintenanceInterval()); }, 60000, 20000);
} }
/** /**

View File

@ -2262,6 +2262,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -32,7 +32,6 @@ import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -47,12 +46,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
@ -38,15 +36,11 @@ import com.l2jmobius.gameserver.util.MinionList;
*/ */
public class L2MonsterInstance extends L2Attackable public class L2MonsterInstance extends L2Attackable
{ {
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
protected boolean _enableMinions = true; protected boolean _enableMinions = true;
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
/** /**
* Creates a monster. * Creates a monster.
* @param template the monster NPC template * @param template the monster NPC template
@ -109,8 +103,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -128,15 +120,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -145,24 +128,12 @@ public class L2MonsterInstance extends L2Attackable
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,12 +17,10 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.instancemanager.RaidBossPointsManager; import com.l2jmobius.gameserver.instancemanager.RaidBossPointsManager;
import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager; import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.model.entity.Hero; import com.l2jmobius.gameserver.model.entity.Hero;
@ -35,8 +33,6 @@ import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private RaidBossSpawnManager.StatusEnum _raidStatus; private RaidBossSpawnManager.StatusEnum _raidStatus;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
@ -59,12 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
super.onSpawn(); super.onSpawn();
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -102,41 +92,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
return true; return true;
} }
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ, false);
}
}
}
public void setRaidStatus(RaidBossSpawnManager.StatusEnum status) public void setRaidStatus(RaidBossSpawnManager.StatusEnum status)
{ {
_raidStatus = status; _raidStatus = status;

View File

@ -1174,6 +1174,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -40,12 +39,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -43,10 +41,6 @@ public class L2MonsterInstance extends L2Attackable
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
/** /**
* Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br> * Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B>
@ -115,8 +109,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -134,15 +126,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -150,25 +133,12 @@ public class L2MonsterInstance extends L2Attackable
{ {
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -30,8 +27,6 @@ import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -60,47 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0)); broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0));
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ);
}
}
}
@Override @Override
public int getVitalityPoints(int level, double exp, boolean isBoss) public int getVitalityPoints(int level, double exp, boolean isBoss)
{ {

View File

@ -1174,6 +1174,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -40,12 +39,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -43,10 +41,6 @@ public class L2MonsterInstance extends L2Attackable
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
/** /**
* Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br> * Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B>
@ -115,8 +109,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -134,15 +126,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -150,25 +133,12 @@ public class L2MonsterInstance extends L2Attackable
{ {
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -30,8 +27,6 @@ import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -60,47 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0)); broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0));
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ);
}
}
}
@Override @Override
public int getVitalityPoints(int level, double exp, boolean isBoss) public int getVitalityPoints(int level, double exp, boolean isBoss)
{ {

View File

@ -1174,6 +1174,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -40,12 +39,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -43,10 +41,6 @@ public class L2MonsterInstance extends L2Attackable
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
/** /**
* Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br> * Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B>
@ -115,8 +109,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -134,15 +126,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -150,25 +133,12 @@ public class L2MonsterInstance extends L2Attackable
{ {
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -30,8 +27,6 @@ import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -60,47 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0)); broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0));
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ);
}
}
}
@Override @Override
public int getVitalityPoints(int level, double exp, boolean isBoss) public int getVitalityPoints(int level, double exp, boolean isBoss)
{ {

View File

@ -1174,6 +1174,12 @@ public class L2AttackableAI extends L2CharacterAI
return; return;
} }
// Prevent thinking in non active regions.
if (!_actor.isInActiveRegion())
{
return;
}
// Start thinking action // Start thinking action
_thinking = true; _thinking = true;

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public final class L2GrandBossInstance extends L2MonsterInstance public final class L2GrandBossInstance extends L2MonsterInstance
{ {
private static final int BOSS_MAINTENANCE_INTERVAL = 10000;
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -40,12 +39,6 @@ public final class L2GrandBossInstance extends L2MonsterInstance
setLethalable(false); setLethalable(false);
} }
@Override
protected int getMaintenanceInterval()
{
return BOSS_MAINTENANCE_INTERVAL;
}
@Override @Override
public void onSpawn() public void onSpawn()
{ {

View File

@ -16,8 +16,6 @@
*/ */
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -43,10 +41,6 @@ public class L2MonsterInstance extends L2Attackable
private L2MonsterInstance _master = null; private L2MonsterInstance _master = null;
private volatile MinionList _minionList = null; private volatile MinionList _minionList = null;
protected ScheduledFuture<?> _maintenanceTask = null;
private static final int MONSTER_MAINTENANCE_INTERVAL = 1000;
/** /**
* Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br> * Constructor of L2MonsterInstance (use L2Character and L2NpcInstance constructor).<br>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B>
@ -115,8 +109,6 @@ public class L2MonsterInstance extends L2Attackable
setIsRaidMinion(_master.isRaid()); setIsRaidMinion(_master.isRaid());
_master.getMinionList().onMinionSpawn(this); _master.getMinionList().onMinionSpawn(this);
} }
startMaintenanceTask();
} }
// dynamic script-based minions spawned here, after all preparations. // dynamic script-based minions spawned here, after all preparations.
@ -134,15 +126,6 @@ public class L2MonsterInstance extends L2Attackable
} }
} }
protected int getMaintenanceInterval()
{
return MONSTER_MAINTENANCE_INTERVAL;
}
protected void startMaintenanceTask()
{
}
@Override @Override
public boolean doDie(L2Character killer) public boolean doDie(L2Character killer)
{ {
@ -150,25 +133,12 @@ public class L2MonsterInstance extends L2Attackable
{ {
return false; return false;
} }
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false); // doesn't do it?
_maintenanceTask = null;
}
return true; return true;
} }
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
if (_maintenanceTask != null)
{
_maintenanceTask.cancel(false);
_maintenanceTask = null;
}
if (hasMinions()) if (hasMinions())
{ {
getMinionList().onMasterDie(true); getMinionList().onMasterDie(true);

View File

@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.model.actor.instance; package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
@ -30,8 +27,6 @@ import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
*/ */
public class L2RaidBossInstance extends L2MonsterInstance public class L2RaidBossInstance extends L2MonsterInstance
{ {
private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
private boolean _useRaidCurse = true; private boolean _useRaidCurse = true;
/** /**
@ -60,47 +55,6 @@ public class L2RaidBossInstance extends L2MonsterInstance
broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0)); broadcastPacket(new PlaySound(1, getParameters().getString("RaidSpawnMusic", "Rm01_A"), 0, 0, 0, 0, 0));
} }
@Override
protected int getMaintenanceInterval()
{
return RAIDBOSS_MAINTENANCE_INTERVAL;
}
/**
* Spawn all minions at a regular interval Also if boss is too far from home location at the time of this check, teleport it home.
*/
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPool.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint())
{
return;
}
final L2Spawn spawn = getSpawn();
if (spawn == null)
{
return;
}
final int spawnX = spawn.getX();
final int spawnY = spawn.getY();
final int spawnZ = spawn.getZ();
if (!isInCombat() && !isMovementDisabled())
{
if (!isInsideRadius3D(spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200)))
{
teleToLocation(spawnX, spawnY, spawnZ);
}
}
}
@Override @Override
public int getVitalityPoints(int level, double exp, boolean isBoss) public int getVitalityPoints(int level, double exp, boolean isBoss)
{ {