Addition of Instance getAliveNpcCount methods.

This commit is contained in:
MobiusDevelopment
2021-12-25 23:04:14 +00:00
parent 9e7f8fbba7
commit 33b35efb3c
196 changed files with 2052 additions and 1317 deletions

View File

@@ -258,7 +258,7 @@ public class BalokWarzone extends AbstractInstance
final Instance world = npc.getInstanceWorld();
if (npc == _balok)
{
if (world.getAliveNpcs(BALOK).isEmpty())
if (world.getAliveNpcCount(BALOK) == 0)
{
world.getAliveNpcs(MINION, HELL_DISCIPLE, HELLS_GATE).forEach(guard -> guard.doDie(null));
world.removeNpcs();

View File

@@ -104,7 +104,7 @@ public class TautiWarzone extends AbstractInstance
for (Player member : world.getPlayers())
{
member.teleToLocation(TAUTI_TELEPORT, world);
if (world.getAliveNpcs(TAUTI_EXTREME).isEmpty() && world.getAliveNpcs(TAUTI_EXTREME_AXE).isEmpty())
if ((world.getAliveNpcCount(TAUTI_EXTREME) == 0) && (world.getAliveNpcCount(TAUTI_EXTREME_AXE) == 0))
{
startQuestTimer("PLAY_OPENING_B_MOVIE", 5000, null, member, false);
}
@@ -120,7 +120,7 @@ public class TautiWarzone extends AbstractInstance
case "SPAWN_TAUTI":
{
final Instance world = npc.getInstanceWorld();
if (world.getAliveNpcs(TAUTI_EXTREME).isEmpty() && world.getAliveNpcs(TAUTI_EXTREME_AXE).isEmpty())
if ((world.getAliveNpcCount(TAUTI_EXTREME) == 0) && (world.getAliveNpcCount(TAUTI_EXTREME_AXE) == 0))
{
world.spawnGroup("boss");
}

View File

@@ -193,7 +193,7 @@ public class CommandPost extends AbstractInstance
}
case 1:
{
if (world.getAliveNpcs(FIRST_FLOOR).isEmpty())
if (world.getAliveNpcCount(FIRST_FLOOR) == 0)
{
showOnScreenMsg(world, NpcStringId.THE_TELEPORT_GATE_TO_THE_2ND_FLOOR_HAS_BEEN_ACTIVATED, ExShowScreenMessage.TOP_CENTER, 2000, true);
world.getNpc(GEORK).teleToLocation(GEORK_FLOOR_2_SPAWN);
@@ -269,7 +269,7 @@ public class CommandPost extends AbstractInstance
}
case 4:
{
if (world.getAliveNpcs().size() == 19)
if (world.getAliveNpcCount() == 19)
{
for (Npc monster : world.getNpcsOfGroup("group_2"))
{
@@ -285,7 +285,7 @@ public class CommandPost extends AbstractInstance
}
case 5:
{
if (world.getAliveNpcs().size() == 14)
if (world.getAliveNpcCount() == 14)
{
for (Npc monster : world.getNpcsOfGroup("group_3"))
{
@@ -301,7 +301,7 @@ public class CommandPost extends AbstractInstance
}
case 6:
{
if (world.getAliveNpcs().size() == 8)
if (world.getAliveNpcCount() == 8)
{
for (Npc monster : world.getNpcsOfGroup("group_4"))
{
@@ -317,7 +317,7 @@ public class CommandPost extends AbstractInstance
}
case 7:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
showOnScreenMsg(world, NpcStringId.THE_TELEPORT_GATE_TO_THE_3RD_FLOOR_HAS_BEEN_ACTIVATED, ExShowScreenMessage.TOP_CENTER, 2000, true);
world.getNpc(GEORK).deleteMe();

View File

@@ -165,7 +165,7 @@ public class CrystalCavernsCoralGarden extends AbstractInstance
showOnScreenMsg(instance, NpcStringId.GOLEM_ENTERED_THE_REQUIRED_ZONE, ExShowScreenMessage.MIDDLE_CENTER, 5000);
npc.deleteMe();
if (instance.getAliveNpcs(GOLEM_1, GOLEM_2).isEmpty())
if (instance.getAliveNpcCount(GOLEM_1, GOLEM_2) == 0)
{
instance.openCloseDoor(BOSS_DOOR_ID, true);

View File

@@ -213,7 +213,7 @@ public class CrystalCavernsEmeraldSquare extends AbstractInstance
case VERIDAN_WEALTHY:
case VERIDAN_ARMED:
{
if (instance.getAliveNpcs(VERIDAN_NORMAL, VERIDAN_WISE, VERIDAN_WEALTHY, VERIDAN_ARMED).isEmpty())
if (instance.getAliveNpcCount(VERIDAN_NORMAL, VERIDAN_WISE, VERIDAN_WEALTHY, VERIDAN_ARMED) == 0)
{
instance.finishInstance();
}

View File

@@ -290,7 +290,7 @@ public class DarkCloudMansion extends AbstractInstance
{
case 0: // Start room
{
if (world.getAliveNpcs().isEmpty())
if (world.getAliveNpcCount() == 0)
{
world.setStatus(1);
world.spawnGroup("hall");
@@ -300,7 +300,7 @@ public class DarkCloudMansion extends AbstractInstance
}
case 1: // Hall
{
if (world.getAliveNpcs().isEmpty())
if (world.getAliveNpcCount() == 0)
{
world.setStatus(2);
world.spawnGroup("roomA");
@@ -310,7 +310,7 @@ public class DarkCloudMansion extends AbstractInstance
}
case 2: // Room A - cleared
{
if (world.getAliveNpcs().isEmpty())
if (world.getAliveNpcCount() == 0)
{
world.setStatus(3);
world.spawnGroup("roomAClear");
@@ -320,7 +320,7 @@ public class DarkCloudMansion extends AbstractInstance
}
case 3: // Hall
{
if (world.getAliveNpcs(BELETH_SUBORDINATE).isEmpty())
if (world.getAliveNpcCount(BELETH_SUBORDINATE) == 0)
{
world.setStatus(4);
world.openCloseDoor(ROOM_B_DOOR, true);
@@ -336,7 +336,7 @@ public class DarkCloudMansion extends AbstractInstance
}
case 5: // Hall
{
if (world.getAliveNpcs(BELETH_SUBORDINATE).isEmpty())
if (world.getAliveNpcCount(BELETH_SUBORDINATE) == 0)
{
world.setStatus(6);
world.spawnGroup("roomC");
@@ -346,7 +346,7 @@ public class DarkCloudMansion extends AbstractInstance
}
case 6: // Room C
{
if (world.getAliveNpcs(BELETH_SUBORDINATE).isEmpty())
if (world.getAliveNpcCount(BELETH_SUBORDINATE) == 0)
{
world.setStatus(7);
world.spawnGroup("roomD");

View File

@@ -671,7 +671,7 @@ public class DimensionalWrap extends AbstractInstance
}
}
if (world.getAliveNpcs(MONSTERS).isEmpty() && world.getParameters().getBoolean("ThirdWave", false))
if ((world.getAliveNpcCount(MONSTERS) == 0) && world.getParameters().getBoolean("ThirdWave", false))
{
if (worldState == 20)
{

View File

@@ -434,7 +434,7 @@ public class EvilIncubator extends AbstractInstance
st.setCond(12, true);
}
else if ((waveId < 8) && world.getAliveNpcs(MONSTERS).isEmpty())
else if ((waveId < 8) && (world.getAliveNpcCount(MONSTERS) == 0))
{
getTimers().addTimer("SPAWN_WAVE", 5000, e -> manageWaveSpawn(world));
}

View File

@@ -140,7 +140,7 @@ public class FortressOfTheDead extends AbstractInstance
{
if (npc.getId() == VAMPIRIC_SOLDIER)
{
if (world.getAliveNpcs(VAMPIRIC_SOLDIER).isEmpty())
if (world.getAliveNpcCount(VAMPIRIC_SOLDIER) == 0)
{
startQuestTimer("vampire_dead", 180, npc, player);
}

View File

@@ -188,7 +188,7 @@ public class Fortuna extends AbstractInstance
}
case 1:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(2);
world.spawnGroup("fortuna_2");
@@ -198,7 +198,7 @@ public class Fortuna extends AbstractInstance
}
case 2:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(3);
world.spawnGroup("fortuna_3");
@@ -208,7 +208,7 @@ public class Fortuna extends AbstractInstance
}
case 3:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(4);
world.spawnGroup("fortuna_4");
@@ -219,7 +219,7 @@ public class Fortuna extends AbstractInstance
}
case 4:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(5);
world.spawnGroup("fortuna_5");
@@ -229,7 +229,7 @@ public class Fortuna extends AbstractInstance
}
case 5:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(6);
world.spawnGroup("fortuna_6");
@@ -240,7 +240,7 @@ public class Fortuna extends AbstractInstance
}
case 6:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(7);
world.spawnGroup("fortuna_7");
@@ -250,7 +250,7 @@ public class Fortuna extends AbstractInstance
}
case 7:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(8);
world.spawnGroup("fortuna_8");
@@ -260,7 +260,7 @@ public class Fortuna extends AbstractInstance
}
case 8:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(9);
world.spawnGroup("fortuna_9");
@@ -270,7 +270,7 @@ public class Fortuna extends AbstractInstance
}
case 9:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(10);
world.spawnGroup("fortuna_10");
@@ -281,7 +281,7 @@ public class Fortuna extends AbstractInstance
}
case 10:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
startQuestTimer("boss_1_pause", 30000, npc, null);
}
@@ -293,7 +293,7 @@ public class Fortuna extends AbstractInstance
}
case 11:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(12);
world.spawnGroup("fortuna_12");
@@ -303,7 +303,7 @@ public class Fortuna extends AbstractInstance
}
case 12:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(13);
world.spawnGroup("fortuna_13");
@@ -313,7 +313,7 @@ public class Fortuna extends AbstractInstance
}
case 13:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(14);
world.spawnGroup("fortuna_14");
@@ -323,7 +323,7 @@ public class Fortuna extends AbstractInstance
}
case 14:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(15);
world.spawnGroup("fortuna_15");
@@ -334,7 +334,7 @@ public class Fortuna extends AbstractInstance
}
case 15:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
startQuestTimer("boss_2_pause", 30000, npc, null);
}
@@ -346,7 +346,7 @@ public class Fortuna extends AbstractInstance
}
case 16:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(17);
world.spawnGroup("fortuna_17");
@@ -356,7 +356,7 @@ public class Fortuna extends AbstractInstance
}
case 17:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(18);
world.spawnGroup("fortuna_18");
@@ -367,7 +367,7 @@ public class Fortuna extends AbstractInstance
}
case 18:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
startQuestTimer("boss_3_pause", 30000, npc, null);
}
@@ -379,7 +379,7 @@ public class Fortuna extends AbstractInstance
}
case 19:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(20);
world.spawnGroup("fortuna_20");
@@ -390,7 +390,7 @@ public class Fortuna extends AbstractInstance
}
case 20:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(21);
world.spawnGroup("fortuna_21");
@@ -400,7 +400,7 @@ public class Fortuna extends AbstractInstance
}
case 21:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(22);
world.spawnGroup("fortuna_22");
@@ -411,7 +411,7 @@ public class Fortuna extends AbstractInstance
}
case 22:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
startQuestTimer("boss_4_pause", 30000, npc, null);
}
@@ -423,7 +423,7 @@ public class Fortuna extends AbstractInstance
}
case 23:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(24);
world.spawnGroup("fortuna_24");
@@ -433,7 +433,7 @@ public class Fortuna extends AbstractInstance
}
case 24:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
world.setStatus(25);
world.spawnGroup("fortuna_25");
@@ -444,7 +444,7 @@ public class Fortuna extends AbstractInstance
}
case 25:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
startQuestTimer("boss_5_pause", 30000, npc, null);
showOnScreenMsg(world, NpcStringId.DARKNESS_SWALLOW_EVERYTHING_AWAY, ExShowScreenMessage.TOP_CENTER, 10000, true);
@@ -457,7 +457,7 @@ public class Fortuna extends AbstractInstance
}
case 26:
{
if (world.getAliveNpcs().size() == 1)
if (world.getAliveNpcCount() == 1)
{
startQuestTimer("boss_6_pause", 30000, npc, null);
showOnScreenMsg(world, NpcStringId.I_NOW_HAVE_TO_GO_AND_HANDLE_IT, ExShowScreenMessage.TOP_CENTER, 10000, true);

View File

@@ -508,7 +508,7 @@ public class HarnakUndergroundRuins extends AbstractInstance
{
case 0:
{
if (world.getAliveNpcs().isEmpty())
if (world.getAliveNpcCount() == 0)
{
startQuestTimer("spawn_npc2", 100, npc, killer);
world.setStatus(1);

View File

@@ -367,7 +367,7 @@ public class KartiasLabyrinth extends AbstractInstance
instance.openCloseDoor(instance.getTemplateParameters().getInt("thirdDoorId"), true);
instance.setStatus(3); // Used for notify helper's AI
}
else if (param.getBoolean("CONTINUE_AFTER_KILL", false) && instance.getAliveNpcs(MINI_BOSSES).isEmpty())
else if (param.getBoolean("CONTINUE_AFTER_KILL", false) && (instance.getAliveNpcCount(MINI_BOSSES) == 0))
{
param.set("CONTINUE_AFTER_KILL", false);
getTimers().addTimer("CALL_PROGRESS", 5000, n -> manageProgressInInstance(instance));
@@ -377,7 +377,7 @@ public class KartiasLabyrinth extends AbstractInstance
private void manageWaves(Instance instance)
{
if ((instance != null) && instance.getAliveNpcs(MONSTERS).isEmpty())
if ((instance != null) && (instance.getAliveNpcCount(MONSTERS) == 0))
{
getTimers().cancelTimers("NEXT_WAVE_DELAY");
getTimers().cancelTimers("MONITOR_WAVE");

View File

@@ -435,7 +435,7 @@ public class StoryOfTauti extends AbstractInstance
case "clone_2":
{
world.spawnGroup("clone_2");
if (world.getAliveNpcs(NPC_1).size() < _count)
if (world.getAliveNpcCount(NPC_1) < _count)
{
startQuestTimer("clone_3", 500, npc, player);
}
@@ -444,7 +444,7 @@ public class StoryOfTauti extends AbstractInstance
case "clone_3":
{
world.spawnGroup("clone_3");
if (world.getAliveNpcs(NPC_1).size() < _count)
if (world.getAliveNpcCount(NPC_1) < _count)
{
startQuestTimer("clone_4", 500, npc, player);
}
@@ -453,7 +453,7 @@ public class StoryOfTauti extends AbstractInstance
case "clone_4":
{
world.spawnGroup("clone_4");
if (world.getAliveNpcs(NPC_1).size() < _count)
if (world.getAliveNpcCount(NPC_1) < _count)
{
startQuestTimer("clone_5", 500, npc, player);
}
@@ -462,7 +462,7 @@ public class StoryOfTauti extends AbstractInstance
case "clone_5":
{
world.spawnGroup("clone_5");
if (world.getAliveNpcs(NPC_1).size() < _count)
if (world.getAliveNpcCount(NPC_1) < _count)
{
startQuestTimer("clone_6", 500, npc, player);
}

View File

@@ -108,7 +108,7 @@ public class NornilsGarden extends AbstractInstance
}
case "stage1_1":
{
if (!npc.isDead() && world.getAliveNpcs(ATTACABLE_MONSTERS).isEmpty())
if (!npc.isDead() && (world.getAliveNpcCount(ATTACABLE_MONSTERS) == 0))
{
world.spawnGroup("wave_1");
npc.setTargetable(true);
@@ -117,7 +117,7 @@ public class NornilsGarden extends AbstractInstance
}
case "stage2":
{
if (world.isStatus(5) && world.getAliveNpcs(ATTACABLE_MONSTERS).isEmpty())
if (world.isStatus(5) && (world.getAliveNpcCount(ATTACABLE_MONSTERS) == 0))
{
world.openCloseDoor(16200016, true);
cancelQuestTimer("stage2", npc, null);
@@ -127,7 +127,7 @@ public class NornilsGarden extends AbstractInstance
}
case "stage3":
{
if (world.isStatus(6) && world.getAliveNpcs(ATTACABLE_MONSTERS).isEmpty())
if (world.isStatus(6) && (world.getAliveNpcCount(ATTACABLE_MONSTERS) == 0))
{
world.openCloseDoor(16200201, true);
cancelQuestTimer("stage3", npc, null);
@@ -217,7 +217,7 @@ public class NornilsGarden extends AbstractInstance
}
case 1:
{
if ((npc.getId() == BOZ_STAGE2) && (world.getAliveNpcs(BOZ_STAGE2).size() < 6))
if ((npc.getId() == BOZ_STAGE2) && (world.getAliveNpcCount(BOZ_STAGE2) < 6))
{
world.spawnGroup("wave_2_1");
world.setStatus(2);
@@ -226,7 +226,7 @@ public class NornilsGarden extends AbstractInstance
}
case 2:
{
if ((npc.getId() == BOZ_STAGE2) && (world.getAliveNpcs(BOZ_STAGE2).size() < 5))
if ((npc.getId() == BOZ_STAGE2) && (world.getAliveNpcCount(BOZ_STAGE2) < 5))
{
world.spawnGroup("wave_2_2");
world.setStatus(3);
@@ -235,7 +235,7 @@ public class NornilsGarden extends AbstractInstance
}
case 3:
{
if ((npc.getId() == BOZ_STAGE2) && (world.getAliveNpcs(BOZ_STAGE2).size() < 4))
if ((npc.getId() == BOZ_STAGE2) && (world.getAliveNpcCount(BOZ_STAGE2) < 4))
{
world.spawnGroup("wave_2_3");
world.setStatus(4);
@@ -244,7 +244,7 @@ public class NornilsGarden extends AbstractInstance
}
case 4:
{
if ((npc.getId() == BOZ_STAGE2) && (world.getAliveNpcs(BOZ_STAGE2).size() < 3))
if ((npc.getId() == BOZ_STAGE2) && (world.getAliveNpcCount(BOZ_STAGE2) < 3))
{
world.spawnGroup("wave_2_4");
startQuestTimer("stage2", 15000, npc, null, true);

View File

@@ -578,23 +578,6 @@ public class Instance implements IIdentifiable, INamable
return _npcs;
}
/**
* Get alive NPCs from instance.
* @return set of NPCs from instance
*/
public List<Npc> getAliveNpcs()
{
final List<Npc> result = new ArrayList<>();
for (Npc npc : _npcs)
{
if (npc.getCurrentHp() > 0)
{
result.add(npc);
}
}
return result;
}
/**
* Get spawned NPCs from instance with specific IDs.
* @param id IDs of NPCs which should be found
@@ -635,6 +618,41 @@ public class Instance implements IIdentifiable, INamable
return result;
}
/**
* Get alive NPCs from instance.
* @return set of NPCs from instance
*/
public List<Npc> getAliveNpcs()
{
final List<Npc> result = new ArrayList<>();
for (Npc npc : _npcs)
{
if (npc.getCurrentHp() > 0)
{
result.add(npc);
}
}
return result;
}
/**
* Get alive NPCs from instance with specific IDs.
* @param id IDs of NPCs which should be found
* @return list of filtered NPCs from instance
*/
public List<Npc> getAliveNpcs(int... id)
{
final List<Npc> result = new ArrayList<>();
for (Npc npc : _npcs)
{
if ((npc.getCurrentHp() > 0) && CommonUtil.contains(id, npc.getId()))
{
result.add(npc);
}
}
return result;
}
/**
* Get spawned and alive NPCs from instance with specific IDs and class type.
* @param <T>
@@ -658,21 +676,38 @@ public class Instance implements IIdentifiable, INamable
}
/**
* Get alive NPCs from instance with specific IDs.
* @param id IDs of NPCs which should be found
* @return list of filtered NPCs from instance
* Get alive NPC count from instance.
* @return count of filtered NPCs from instance
*/
public List<Npc> getAliveNpcs(int... id)
public int getAliveNpcCount()
{
final List<Npc> result = new ArrayList<>();
int count = 0;
for (Npc npc : _npcs)
{
if (npc.getCurrentHp() > 0)
{
count++;
}
}
return count;
}
/**
* Get alive NPC count from instance with specific IDs.
* @param id IDs of NPCs which should be counted
* @return count of filtered NPCs from instance
*/
public int getAliveNpcCount(int... id)
{
int count = 0;
for (Npc npc : _npcs)
{
if ((npc.getCurrentHp() > 0) && CommonUtil.contains(id, npc.getId()))
{
result.add(npc);
count++;
}
}
return result;
return count;
}
/**