MinionList related rework.
This commit is contained in:
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -19,8 +19,8 @@ package org.l2jmobius.gameserver.model.actor;
|
|||||||
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -3332,13 +3332,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
*/
|
*/
|
||||||
private List<Effect> effectQueueInsert(Effect newStackedEffect, List<Effect> stackQueue)
|
private List<Effect> effectQueueInsert(Effect newStackedEffect, List<Effect> stackQueue)
|
||||||
{
|
{
|
||||||
// Create an Iterator to go through the list of stacked effects in progress on the Creature
|
// Go through the list of stacked effects in progress on the Creature.
|
||||||
final Iterator<Effect> queueIterator = stackQueue.iterator();
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (queueIterator.hasNext())
|
for (Effect effect : stackQueue)
|
||||||
{
|
{
|
||||||
final Effect cur = queueIterator.next();
|
if (newStackedEffect.getStackOrder() < effect.getStackOrder())
|
||||||
if (newStackedEffect.getStackOrder() < cur.getStackOrder())
|
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -6280,17 +6278,13 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
|
|
||||||
if (target instanceof MinionInstance)
|
if (target instanceof MinionInstance)
|
||||||
{
|
{
|
||||||
((MinionInstance) target).getLeader().stopHating(this);
|
final MonsterInstance leader = ((MinionInstance) target).getLeader();
|
||||||
|
leader.stopHating(this);
|
||||||
final List<MinionInstance> spawnedMinions = ((MinionInstance) target).getLeader().getSpawnedMinions();
|
if (leader.hasMinions())
|
||||||
if ((spawnedMinions != null) && !spawnedMinions.isEmpty())
|
|
||||||
{
|
{
|
||||||
final Iterator<MinionInstance> itr = spawnedMinions.iterator();
|
for (MinionInstance minion : leader.getSpawnedMinions())
|
||||||
MinionInstance minion;
|
|
||||||
while (itr.hasNext())
|
|
||||||
{
|
{
|
||||||
minion = itr.next();
|
if (leader.getMostHated() == null)
|
||||||
if (((MinionInstance) target).getLeader().getMostHated() == null)
|
|
||||||
{
|
{
|
||||||
((AttackableAI) minion.getAI()).setGlobalAggro(-25);
|
((AttackableAI) minion.getAI()).setGlobalAggro(-25);
|
||||||
minion.clearAggroList();
|
minion.clearAggroList();
|
||||||
@@ -6302,7 +6296,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
((AttackableAI) minion.getAI()).setGlobalAggro(-25);
|
((AttackableAI) minion.getAI()).setGlobalAggro(-25);
|
||||||
minion.clearAggroList();
|
minion.clearAggroList();
|
||||||
minion.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
minion.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||||
minion.addDamage(((MinionInstance) target).getLeader().getMostHated(), 100);
|
minion.addDamage(leader.getMostHated(), 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6310,14 +6304,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
((Attackable) target).stopHating(this);
|
((Attackable) target).stopHating(this);
|
||||||
final List<MinionInstance> spawnedMinions = ((MonsterInstance) target).getSpawnedMinions();
|
final Collection<MinionInstance> spawnedMinions = ((MonsterInstance) target).getSpawnedMinions();
|
||||||
if ((spawnedMinions != null) && !spawnedMinions.isEmpty())
|
if ((spawnedMinions != null) && !spawnedMinions.isEmpty())
|
||||||
{
|
{
|
||||||
final Iterator<MinionInstance> itr = spawnedMinions.iterator();
|
for (MinionInstance minion : spawnedMinions)
|
||||||
MinionInstance minion;
|
|
||||||
while (itr.hasNext())
|
|
||||||
{
|
{
|
||||||
minion = itr.next();
|
|
||||||
if (((Attackable) target).getMostHated() == null)
|
if (((Attackable) target).getMostHated() == null)
|
||||||
{
|
{
|
||||||
((AttackableAI) minion.getAI()).setGlobalAggro(-25);
|
((AttackableAI) minion.getAI()).setGlobalAggro(-25);
|
||||||
@@ -8051,16 +8042,13 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
|
|
||||||
if (creature instanceof MinionInstance)
|
if (creature instanceof MinionInstance)
|
||||||
{
|
{
|
||||||
((MinionInstance) creature).getLeader().stopHating(this);
|
final MonsterInstance leader = ((MinionInstance) creature).getLeader();
|
||||||
final List<MinionInstance> spawnedMinions = ((MonsterInstance) creature).getSpawnedMinions();
|
leader.stopHating(this);
|
||||||
if ((spawnedMinions != null) && !spawnedMinions.isEmpty())
|
if (leader.hasMinions())
|
||||||
{
|
{
|
||||||
final Iterator<MinionInstance> itr = spawnedMinions.iterator();
|
for (MinionInstance minion : leader.getSpawnedMinions())
|
||||||
MinionInstance minion;
|
|
||||||
while (itr.hasNext())
|
|
||||||
{
|
{
|
||||||
minion = itr.next();
|
if (leader.getMostHated() == null)
|
||||||
if (((Attackable) creature).getMostHated() == null)
|
|
||||||
{
|
{
|
||||||
((AttackableAI) minion.getAI()).setGlobalAggro(-25);
|
((AttackableAI) minion.getAI()).setGlobalAggro(-25);
|
||||||
minion.clearAggroList();
|
minion.clearAggroList();
|
||||||
@@ -8080,14 +8068,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
((Attackable) creature).stopHating(this);
|
((Attackable) creature).stopHating(this);
|
||||||
final List<MinionInstance> spawnedMinions = ((MonsterInstance) creature).getSpawnedMinions();
|
final Collection<MinionInstance> spawnedMinions = ((MonsterInstance) creature).getSpawnedMinions();
|
||||||
if ((spawnedMinions != null) && !spawnedMinions.isEmpty())
|
if ((spawnedMinions != null) && !spawnedMinions.isEmpty())
|
||||||
{
|
{
|
||||||
final Iterator<MinionInstance> itr = spawnedMinions.iterator();
|
for (MinionInstance minion : spawnedMinions)
|
||||||
MinionInstance minion;
|
|
||||||
while (itr.hasNext())
|
|
||||||
{
|
{
|
||||||
minion = itr.next();
|
|
||||||
if (((Attackable) creature).getMostHated() == null)
|
if (((Attackable) creature).getMostHated() == null)
|
||||||
{
|
{
|
||||||
((AttackableAI) minion.getAI()).setGlobalAggro(-25);
|
((AttackableAI) minion.getAI()).setGlobalAggro(-25);
|
||||||
|
@@ -16,8 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.actor.instance;
|
package org.l2jmobius.gameserver.model.actor.instance;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -28,7 +27,6 @@ import org.l2jmobius.gameserver.model.actor.Creature;
|
|||||||
import org.l2jmobius.gameserver.model.actor.knownlist.MonsterKnownList;
|
import org.l2jmobius.gameserver.model.actor.knownlist.MonsterKnownList;
|
||||||
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||||
import org.l2jmobius.gameserver.model.spawn.Spawn;
|
import org.l2jmobius.gameserver.model.spawn.Spawn;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
|
||||||
import org.l2jmobius.gameserver.util.MinionList;
|
import org.l2jmobius.gameserver.util.MinionList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,32 +112,8 @@ public class MonsterInstance extends Attackable
|
|||||||
|
|
||||||
if (getTemplate().getMinionData() != null)
|
if (getTemplate().getMinionData() != null)
|
||||||
{
|
{
|
||||||
try
|
_minionList.clearRespawnList();
|
||||||
{
|
manageMinions();
|
||||||
for (MinionInstance minion : _minionList.getSpawnedMinions())
|
|
||||||
{
|
|
||||||
if (minion == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
_minionList.getSpawnedMinions().remove(minion);
|
|
||||||
minion.deleteMe();
|
|
||||||
}
|
|
||||||
_minionList.clearRespawnList();
|
|
||||||
|
|
||||||
manageMinions();
|
|
||||||
}
|
|
||||||
catch (NullPointerException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (getTemplate().getNpcId())
|
|
||||||
{
|
|
||||||
case 12372: // baium
|
|
||||||
{
|
|
||||||
broadcastPacket(new SocialAction(getObjectId(), 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,25 +167,18 @@ public class MonsterInstance extends Attackable
|
|||||||
{
|
{
|
||||||
if (_minionList.hasMinions())
|
if (_minionList.hasMinions())
|
||||||
{
|
{
|
||||||
final List<MinionInstance> spawnedMinions = _minionList.getSpawnedMinions();
|
for (MinionInstance minion : _minionList.getSpawnedMinions())
|
||||||
if ((spawnedMinions != null) && !spawnedMinions.isEmpty())
|
|
||||||
{
|
{
|
||||||
final Iterator<MinionInstance> itr = spawnedMinions.iterator();
|
// Trigger the aggro condition of the minion
|
||||||
MinionInstance minion;
|
if ((minion != null) && !minion.isDead())
|
||||||
while (itr.hasNext())
|
|
||||||
{
|
{
|
||||||
minion = itr.next();
|
if (this instanceof RaidBossInstance)
|
||||||
// Trigger the aggro condition of the minion
|
|
||||||
if ((minion != null) && !minion.isDead())
|
|
||||||
{
|
{
|
||||||
if (this instanceof RaidBossInstance)
|
minion.addDamage(attacker, 100);
|
||||||
{
|
}
|
||||||
minion.addDamage(attacker, 100);
|
else
|
||||||
}
|
{
|
||||||
else
|
minion.addDamage(attacker, 1);
|
||||||
{
|
|
||||||
minion.addDamage(attacker, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,7 +209,7 @@ public class MonsterInstance extends Attackable
|
|||||||
* Gets the spawned minions.
|
* Gets the spawned minions.
|
||||||
* @return the spawned minions
|
* @return the spawned minions
|
||||||
*/
|
*/
|
||||||
public List<MinionInstance> getSpawnedMinions()
|
public Collection<MinionInstance> getSpawnedMinions()
|
||||||
{
|
{
|
||||||
return _minionList.getSpawnedMinions();
|
return _minionList.getSpawnedMinions();
|
||||||
}
|
}
|
||||||
@@ -321,17 +288,6 @@ public class MonsterInstance extends Attackable
|
|||||||
*/
|
*/
|
||||||
public void deleteSpawnedMinions()
|
public void deleteSpawnedMinions()
|
||||||
{
|
{
|
||||||
for (MinionInstance minion : _minionList.getSpawnedMinions())
|
|
||||||
{
|
|
||||||
if (minion == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
minion.abortAttack();
|
|
||||||
minion.abortCast();
|
|
||||||
minion.deleteMe();
|
|
||||||
_minionList.getSpawnedMinions().remove(minion);
|
|
||||||
}
|
|
||||||
_minionList.clearRespawnList();
|
_minionList.clearRespawnList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,9 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.util;
|
package org.l2jmobius.gameserver.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -35,40 +34,32 @@ import org.l2jmobius.gameserver.model.actor.instance.MonsterInstance;
|
|||||||
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
|
* @author luisantonioa, Mobius
|
||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
/** List containing the current spawned minions for this MonsterInstance */
|
private final Set<MinionInstance> _spawnedMinions = ConcurrentHashMap.newKeySet();
|
||||||
private final List<MinionInstance> minionReferences;
|
private final Map<Long, Integer> _respawnTasks = new ConcurrentHashMap<>();
|
||||||
protected Map<Long, Integer> _respawnTasks = new ConcurrentHashMap<>();
|
private final MonsterInstance _master;
|
||||||
private final MonsterInstance master;
|
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
minionReferences = new ArrayList<>();
|
_master = master;
|
||||||
master = pMaster;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int countSpawnedMinions()
|
public int countSpawnedMinions()
|
||||||
{
|
{
|
||||||
synchronized (minionReferences)
|
return _spawnedMinions.size();
|
||||||
{
|
|
||||||
return minionReferences.size();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int countSpawnedMinionsById(int minionId)
|
public int countSpawnedMinionsById(int minionId)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
synchronized (minionReferences)
|
for (MinionInstance minion : _spawnedMinions)
|
||||||
{
|
{
|
||||||
for (MinionInstance minion : minionReferences)
|
if (minion.getNpcId() == minionId)
|
||||||
{
|
{
|
||||||
if (minion.getNpcId() == minionId)
|
count++;
|
||||||
{
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
@@ -76,26 +67,23 @@ public class MinionList
|
|||||||
|
|
||||||
public boolean hasMinions()
|
public boolean hasMinions()
|
||||||
{
|
{
|
||||||
return !minionReferences.isEmpty();
|
return !_spawnedMinions.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MinionInstance> getSpawnedMinions()
|
public Collection<MinionInstance> getSpawnedMinions()
|
||||||
{
|
{
|
||||||
return minionReferences;
|
return _spawnedMinions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSpawnedMinion(MinionInstance minion)
|
public void addSpawnedMinion(MinionInstance minion)
|
||||||
{
|
{
|
||||||
synchronized (minionReferences)
|
_spawnedMinions.add(minion);
|
||||||
{
|
|
||||||
minionReferences.add(minion);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int lazyCountSpawnedMinionsGroups()
|
public int lazyCountSpawnedMinionsGroups()
|
||||||
{
|
{
|
||||||
final Set<Integer> seenGroups = new HashSet<>();
|
final Set<Integer> seenGroups = new HashSet<>();
|
||||||
for (MinionInstance minion : minionReferences)
|
for (MinionInstance minion : _spawnedMinions)
|
||||||
{
|
{
|
||||||
seenGroups.add(minion.getNpcId());
|
seenGroups.add(minion.getNpcId());
|
||||||
}
|
}
|
||||||
@@ -104,32 +92,25 @@ public class MinionList
|
|||||||
|
|
||||||
public void removeSpawnedMinion(MinionInstance minion)
|
public void removeSpawnedMinion(MinionInstance minion)
|
||||||
{
|
{
|
||||||
synchronized (minionReferences)
|
_spawnedMinions.remove(minion);
|
||||||
{
|
|
||||||
minionReferences.remove(minion);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveMinionToRespawnList(MinionInstance minion)
|
public void moveMinionToRespawnList(MinionInstance minion)
|
||||||
{
|
{
|
||||||
final Long current = System.currentTimeMillis();
|
final Long current = System.currentTimeMillis();
|
||||||
synchronized (minionReferences)
|
_spawnedMinions.remove(minion);
|
||||||
|
if (_respawnTasks.get(current) == null)
|
||||||
{
|
{
|
||||||
minionReferences.remove(minion);
|
_respawnTasks.put(current, minion.getNpcId());
|
||||||
if (_respawnTasks.get(current) == null)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 1; i < 30; i++)
|
||||||
{
|
{
|
||||||
_respawnTasks.put(current, minion.getNpcId());
|
if (_respawnTasks.get(current + i) == null)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// nice AoE
|
|
||||||
for (int i = 1; i < 30; i++)
|
|
||||||
{
|
{
|
||||||
if (_respawnTasks.get(current + i) == null)
|
_respawnTasks.put(current + i, minion.getNpcId());
|
||||||
{
|
break;
|
||||||
_respawnTasks.put(current + i, minion.getNpcId());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,6 +118,19 @@ public class MinionList
|
|||||||
|
|
||||||
public void clearRespawnList()
|
public void clearRespawnList()
|
||||||
{
|
{
|
||||||
|
for (MinionInstance minion : _spawnedMinions)
|
||||||
|
{
|
||||||
|
if (minion == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
minion.abortAttack();
|
||||||
|
minion.abortCast();
|
||||||
|
minion.deleteMe();
|
||||||
|
}
|
||||||
|
|
||||||
|
_spawnedMinions.clear();
|
||||||
_respawnTasks.clear();
|
_respawnTasks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +139,7 @@ public class MinionList
|
|||||||
*/
|
*/
|
||||||
public void maintainMinions()
|
public void maintainMinions()
|
||||||
{
|
{
|
||||||
if ((master == null) || master.isAlikeDead())
|
if ((_master == null) || _master.isAlikeDead())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -175,27 +169,22 @@ public class MinionList
|
|||||||
*/
|
*/
|
||||||
public void spawnMinions()
|
public void spawnMinions()
|
||||||
{
|
{
|
||||||
if ((master == null) || master.isAlikeDead())
|
if ((_master == null) || _master.isAlikeDead())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MinionData> minions = master.getTemplate().getMinionData();
|
int minionCount;
|
||||||
|
int minionId;
|
||||||
synchronized (minionReferences)
|
int minionsToSpawn;
|
||||||
|
for (MinionData minion : _master.getTemplate().getMinionData())
|
||||||
{
|
{
|
||||||
int minionCount;
|
minionCount = minion.getAmount();
|
||||||
int minionId;
|
minionId = minion.getMinionId();
|
||||||
int minionsToSpawn;
|
minionsToSpawn = minionCount - countSpawnedMinionsById(minionId);
|
||||||
for (MinionData minion : minions)
|
for (int i = 0; i < minionsToSpawn; i++)
|
||||||
{
|
{
|
||||||
minionCount = minion.getAmount();
|
spawnSingleMinion(minionId);
|
||||||
minionId = minion.getMinionId();
|
|
||||||
minionsToSpawn = minionCount - countSpawnedMinionsById(minionId);
|
|
||||||
for (int i = 0; i < minionsToSpawn; i++)
|
|
||||||
{
|
|
||||||
spawnSingleMinion(minionId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,10 +210,10 @@ public class MinionList
|
|||||||
|
|
||||||
// Set the Minion HP, MP and Heading
|
// Set the Minion HP, MP and Heading
|
||||||
monster.setCurrentHpMp(monster.getMaxHp(), monster.getMaxMp());
|
monster.setCurrentHpMp(monster.getMaxHp(), monster.getMaxMp());
|
||||||
monster.setHeading(master.getHeading());
|
monster.setHeading(_master.getHeading());
|
||||||
|
|
||||||
// Set the Minion leader to this RaidBoss
|
// Set the Minion leader to this RaidBoss
|
||||||
monster.setLeader(master);
|
monster.setLeader(_master);
|
||||||
|
|
||||||
// Init the position of the Minion and add it in the world as a visible object
|
// Init the position of the Minion and add it in the world as a visible object
|
||||||
int spawnConstant;
|
int spawnConstant;
|
||||||
@@ -237,7 +226,7 @@ public class MinionList
|
|||||||
spawnConstant *= -1;
|
spawnConstant *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int newX = master.getX() + spawnConstant;
|
final int newX = _master.getX() + spawnConstant;
|
||||||
spawnConstant = Rnd.get(randSpawnLim);
|
spawnConstant = Rnd.get(randSpawnLim);
|
||||||
randPlusMin = Rnd.get(2);
|
randPlusMin = Rnd.get(2);
|
||||||
if (randPlusMin == 1)
|
if (randPlusMin == 1)
|
||||||
@@ -245,13 +234,13 @@ public class MinionList
|
|||||||
spawnConstant *= -1;
|
spawnConstant *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int newY = master.getY() + spawnConstant;
|
final int newY = _master.getY() + spawnConstant;
|
||||||
monster.spawnMe(newX, newY, master.getZ());
|
monster.spawnMe(newX, newY, _master.getZ());
|
||||||
|
|
||||||
// Assist master
|
// Assist master
|
||||||
if (!master.getAggroList().isEmpty())
|
if (!_master.getAggroList().isEmpty())
|
||||||
{
|
{
|
||||||
monster.getAggroList().putAll(master.getAggroList());
|
monster.getAggroList().putAll(_master.getAggroList());
|
||||||
monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster.getAggroList().keySet().stream().findFirst().get());
|
monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, monster.getAggroList().keySet().stream().findFirst().get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,17 +36,17 @@ import org.l2jmobius.gameserver.model.holders.MinionHolder;
|
|||||||
*/
|
*/
|
||||||
public class MinionList
|
public class MinionList
|
||||||
{
|
{
|
||||||
protected final MonsterInstance _master;
|
private final MonsterInstance _master;
|
||||||
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
private final List<MonsterInstance> _spawnedMinions = new CopyOnWriteArrayList<>();
|
||||||
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
private final List<ScheduledFuture<?>> _respawnTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public MinionList(MonsterInstance pMaster)
|
public MinionList(MonsterInstance master)
|
||||||
{
|
{
|
||||||
if (pMaster == null)
|
if (master == null)
|
||||||
{
|
{
|
||||||
throw new NullPointerException("MinionList: master is null");
|
throw new NullPointerException("MinionList: Master is null!");
|
||||||
}
|
}
|
||||||
_master = pMaster;
|
_master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user