New approach for spawning minions.
This commit is contained in:
@@ -56,7 +56,7 @@ public class NpcData implements IGameXmlReader
|
||||
{
|
||||
private final Map<Integer, L2NpcTemplate> _npcs = new ConcurrentHashMap<>();
|
||||
private final Map<String, Integer> _clans = new ConcurrentHashMap<>();
|
||||
private MinionData _minionData;
|
||||
private static final List<Integer> _masterMonsterIDs = new ArrayList<>();
|
||||
|
||||
protected NpcData()
|
||||
{
|
||||
@@ -66,7 +66,7 @@ public class NpcData implements IGameXmlReader
|
||||
@Override
|
||||
public synchronized void load()
|
||||
{
|
||||
_minionData = new MinionData();
|
||||
_masterMonsterIDs.clear();
|
||||
|
||||
parseDatapackDirectory("data/stats/npcs", false);
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _npcs.size() + " NPCs.");
|
||||
@@ -78,7 +78,6 @@ public class NpcData implements IGameXmlReader
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + (_npcs.size() - npcCount) + " Custom NPCs.");
|
||||
}
|
||||
|
||||
_minionData = null;
|
||||
loadNpcsSkillLearn();
|
||||
}
|
||||
|
||||
@@ -520,15 +519,6 @@ public class NpcData implements IGameXmlReader
|
||||
template.set(set);
|
||||
}
|
||||
|
||||
if (_minionData._tempMinions.containsKey(npcId))
|
||||
{
|
||||
if (parameters == null)
|
||||
{
|
||||
parameters = new HashMap<>();
|
||||
}
|
||||
parameters.putIfAbsent("Privates", _minionData._tempMinions.get(npcId));
|
||||
}
|
||||
|
||||
template.setParameters(parameters != null ? new StatsSet(Collections.unmodifiableMap(parameters)) : StatsSet.EMPTY_STATSET);
|
||||
|
||||
if (skills != null)
|
||||
@@ -661,6 +651,14 @@ public class NpcData implements IGameXmlReader
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!template.getParameters().getMinionList("Privates").isEmpty())
|
||||
{
|
||||
if (template.getParameters().getSet().get("SummonPrivateRate") == null)
|
||||
{
|
||||
_masterMonsterIDs.add(template.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -788,55 +786,11 @@ public class NpcData implements IGameXmlReader
|
||||
}
|
||||
|
||||
/**
|
||||
* This class handles minions from Spawn System<br>
|
||||
* Once Spawn System gets reworked delete this class<br>
|
||||
* @author Zealar
|
||||
* @return the IDs of monsters that have minions.
|
||||
*/
|
||||
private final class MinionData implements IGameXmlReader
|
||||
public static List<Integer> getMasterMonsterIDs()
|
||||
{
|
||||
public final Map<Integer, List<MinionHolder>> _tempMinions = new HashMap<>();
|
||||
|
||||
protected MinionData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
_tempMinions.clear();
|
||||
parseDatapackFile("data/MinionData.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _tempMinions.size() + " minions data.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
for (Node node = doc.getFirstChild(); node != null; node = node.getNextSibling())
|
||||
{
|
||||
if ("list".equals(node.getNodeName()))
|
||||
{
|
||||
for (Node listNode = node.getFirstChild(); listNode != null; listNode = listNode.getNextSibling())
|
||||
{
|
||||
if ("npc".equals(listNode.getNodeName()))
|
||||
{
|
||||
final List<MinionHolder> minions = new ArrayList<>(1);
|
||||
NamedNodeMap attrs = listNode.getAttributes();
|
||||
final int id = parseInteger(attrs, "id");
|
||||
for (Node npcNode = listNode.getFirstChild(); npcNode != null; npcNode = npcNode.getNextSibling())
|
||||
{
|
||||
if ("minion".equals(npcNode.getNodeName()))
|
||||
{
|
||||
attrs = npcNode.getAttributes();
|
||||
minions.add(new MinionHolder(parseInteger(attrs, "id"), parseInteger(attrs, "count"), parseInteger(attrs, "respawnTime"), 0));
|
||||
}
|
||||
}
|
||||
_tempMinions.put(id, minions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return _masterMonsterIDs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -35,6 +35,7 @@ import com.l2jmobius.gameserver.datatables.NpcPersonalAIData;
|
||||
import com.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
@@ -659,6 +660,13 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
|
||||
|
||||
// Increase the current number of L2NpcInstance managed by this L2Spawn
|
||||
_currentCount++;
|
||||
|
||||
// Minions
|
||||
if (npc.isMonster() && NpcData.getMasterMonsterIDs().contains(npc.getId()))
|
||||
{
|
||||
((L2MonsterInstance) npc).getMinionList().spawnMinions(npc.getTemplate().getParameters().getMinionList("Privates"));
|
||||
}
|
||||
|
||||
return npc;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user