Training zone NPE fix and improvements.

This commit is contained in:
MobiusDevelopment
2022-04-23 21:13:30 +00:00
parent f33a219ee6
commit 96570970d4

View File

@@ -148,7 +148,6 @@ public class TrainingZone extends AbstractInstance
private static final Location LOCAL_AREA = new Location(-56255, 13537, -3336); private static final Location LOCAL_AREA = new Location(-56255, 13537, -3336);
private static final Location WAITING_AREA = new Location(-49550, 17189, -3016); private static final Location WAITING_AREA = new Location(-49550, 17189, -3016);
private static final Location INSOLENCE_TOWER = new Location(-52849, 5272, -240); private static final Location INSOLENCE_TOWER = new Location(-52849, 5272, -240);
private static final int TEMPLATE_ID = 224; private static final int TEMPLATE_ID = 224;
public TrainingZone() public TrainingZone()
@@ -377,7 +376,7 @@ public class TrainingZone extends AbstractInstance
final Instance world = npc.getInstanceWorld(); final Instance world = npc.getInstanceWorld();
if (world != null) if (world != null)
{ {
npc.broadcastSay(ChatType.NPC_SHOUT, "I can summon mobs for the training"); npc.broadcastSay(ChatType.NPC_SHOUT, "I can summon mobs for the training!");
startQuestTimer(event, 11500, npc, player); startQuestTimer(event, 11500, npc, player);
} }
break; break;
@@ -481,7 +480,6 @@ public class TrainingZone extends AbstractInstance
} }
else if (areaTeleport == 0) else if (areaTeleport == 0)
{ {
world.spawnGroup("PlainsOfTheLizardmen"); world.spawnGroup("PlainsOfTheLizardmen");
worldParameters.set("TRAINIG_AREA_TELEPORT", areaTeleport + 1); worldParameters.set("TRAINIG_AREA_TELEPORT", areaTeleport + 1);
return npc.getId() + "-Selected.html"; return npc.getId() + "-Selected.html";
@@ -726,7 +724,6 @@ public class TrainingZone extends AbstractInstance
world.getNpcs().stream().filter(WorldObject::isAttackable).forEach(Npc::deleteMe); world.getNpcs().stream().filter(WorldObject::isAttackable).forEach(Npc::deleteMe);
worldParameters.remove("TRAINIG_AREA_TELEPORT"); worldParameters.remove("TRAINIG_AREA_TELEPORT");
return npc.getId() + "-removeselect.html"; return npc.getId() + "-removeselect.html";
} }
else if (areaTeleport == 0) else if (areaTeleport == 0)
{ {
@@ -782,13 +779,12 @@ public class TrainingZone extends AbstractInstance
if (areaTeleport <= 4) if (areaTeleport <= 4)
{ {
player.teleToLocation(LOCAL_AREA); player.teleToLocation(LOCAL_AREA);
world.setParameter("BATTLEZONE", true);
} }
if (areaTeleport >= 5) else if (areaTeleport >= 5)
{ {
player.teleToLocation(INSOLENCE_TOWER); player.teleToLocation(INSOLENCE_TOWER);
world.setParameter("BATTLEZONE", true);
} }
world.setParameter("BATTLEZONE", true);
break; break;
} }
case "LOCAL_TELEPORT_RETURN": case "LOCAL_TELEPORT_RETURN":
@@ -832,28 +828,34 @@ public class TrainingZone extends AbstractInstance
@Override @Override
public String onFirstTalk(Npc npc, Player player) public String onFirstTalk(Npc npc, Player player)
{ {
final Instance world = npc.getInstanceWorld(); switch (npc.getId())
if (world.getParameters().getBoolean("BATTLEZONE", true) && (npc.getId() == TIND))
{ {
return npc.getId() + "-waitingzone.html"; case TIND:
} {
final int areaTeleport = world.getParameters().getInt("TRAINIG_AREA_TELEPORT", 0); final Instance world = npc.getInstanceWorld();
if ((areaTeleport >= 1) && (npc.getId() == TIND)) if (world.getParameters().getBoolean("BATTLEZONE", true))
{ {
return npc.getId() + "-teleport.html"; return npc.getId() + "-waitingzone.html";
} }
if (npc.getId() == TIND)
{ final int areaTeleport = world.getParameters().getInt("TRAINIG_AREA_TELEPORT", 0);
return npc.getId() + "-NoSummonStatus.html"; if (areaTeleport >= 1)
} {
if (npc.getId() == TOKA) return npc.getId() + "-teleport.html";
{ }
return npc.getId() + "-toka.html";
} return npc.getId() + "-NoSummonStatus.html";
if (npc.getId() == ERI) }
{ case TOKA:
return npc.getId() + "-eri.html"; {
return npc.getId() + "-toka.html";
}
case ERI:
{
return npc.getId() + "-eri.html";
}
} }
return super.onFirstTalk(npc, player); return super.onFirstTalk(npc, player);
} }
@@ -861,11 +863,10 @@ public class TrainingZone extends AbstractInstance
public String onAttack(Npc npc, Player attacker, int damage, boolean isSummon) public String onAttack(Npc npc, Player attacker, int damage, boolean isSummon)
{ {
final Instance world = npc.getInstanceWorld(); final Instance world = npc.getInstanceWorld();
if ((world != null) && !world.getParameters().getBoolean("spawnedBoss", false))
if (!world.getParameters().getBoolean("spawnedBoss", false))
{ {
startQuestTimer("SpawnBossClockList", 1000, npc, attacker);
world.getParameters().set("spawnedBoss", true); world.getParameters().set("spawnedBoss", true);
startQuestTimer("SpawnBossClockList", 1000, npc, attacker);
} }
return super.onAttack(npc, attacker, damage, isSummon); return super.onAttack(npc, attacker, damage, isSummon);
} }