Skip to content
Snippets Groups Projects
Commit 85334b53 authored by St3eT's avatar St3eT
Browse files

BETA: Fixed `NullPointerException` and little updated '''!DelusionTeleport''' AI.

* Reviewed by: Nos, !UnAfraid, Adry_85
parent 5b90d2b1
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,6 @@ import com.l2jserver.gameserver.instancemanager.TownManager;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.zone.type.L2TownZone;
/**
......@@ -37,18 +36,24 @@ import com.l2jserver.gameserver.model.zone.type.L2TownZone;
public final class DelusionTeleport extends AbstractNpcAI
{
// NPCs
// @formatter:off
private static final int[] NPCS =
{
32484, 32658, 32659, 32660, 32661, 32662, 32663
32484, // Pathfinder Worker
32658, // Guardian of Eastern Seal
32659, // Guardian of Western Seal
32660, // Guardian of Southern Seal
32661, // Guardian of Northern Seal
32662, // Guardian of Great Seal
32663, // Guardian of Tower of Seal
};
// @formatter:on
// Misc
// Location
private static final Location[] HALL_LOCATIONS =
{
new Location(-114597, -152501, -6750),
new Location(-114589, -154162, -6750)
};
// Player Variables
private static final String DELUSION_RETURN = "DELUSION_RETURN";
private static final Map<Integer, Location> RETURN_LOCATIONS = new HashMap<>();
......@@ -73,22 +78,20 @@ public final class DelusionTeleport extends AbstractNpcAI
@Override
public String onTalk(L2Npc npc, L2PcInstance player)
{
final QuestState st = player.getQuestState(getName());
if (npc.getId() == NPCS[0])
if (npc.getId() == NPCS[0]) // Pathfinder Worker
{
final L2TownZone town = TownManager.getTown(npc.getX(), npc.getY(), npc.getZ());
final int townId = ((town == null) ? 0 : town.getTownId());
st.set("return_loc", Integer.toString(townId));
player.getVariables().set(DELUSION_RETURN, townId);
player.teleToLocation(HALL_LOCATIONS[getRandom(HALL_LOCATIONS.length)], false);
}
else
{
player.teleToLocation(RETURN_LOCATIONS.get(st.getInt("return_loc")), true);
st.exitQuest(true);
final int townId = player.getVariables().getInt(DELUSION_RETURN, 0);
player.teleToLocation(RETURN_LOCATIONS.get(townId), true);
player.getVariables().remove(DELUSION_RETURN);
}
return "";
return super.onTalk(npc, player);
}
public static void main(String[] args)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment