package net.sf.l2j.gameserver.scripting.scripts.custom;
import java.util.ArrayList;
import java.util.List;
import net.sf.l2j.gameserver.model.World;
import net.sf.l2j.gameserver.model.actor.Npc;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.scripting.Quest;
public class FafurionGhostEvent extends Quest
{
private static final int BOSS_ID = 210;
private static final int[] GHOST_IDS = {207, 208, 209, 211, 212};
// Ghost spawn coordinates: x, y, z, heading
private static final int[][] GHOST_LOCS = {
{212000, 120000, -3700, 0},
{213000, 119500, -3650, 0},
{211500, 118800, -3720, 0},
{212500, 119000, -3680, 0},
{213200, 118500, -3660, 0}
};
private final List<Npc> spawnedGhosts = new ArrayList<>();
public FafurionGhostEvent()
{
super(-1, "custom");
addSpawnId(BOSS_ID);
addKillId(BOSS_ID);
}
private Npc addSpawn(int npcId, int x, int y, int z, int heading, boolean unused1, int unused2)
{
addSpawn(npcId, x, y, z, heading);
return null;
}
private void addSpawn(int npcId, int x, int y, int z, int heading) {
}
@Override
public String onSpawn(Npc npc)
{
if (npc.getNpcId() == BOSS_ID)
{
for (int i = 0; i < GHOST_IDS.length; i++)
{
int ghostId = GHOST_IDS[i];
int[] loc = GHOST_LOCS[i % GHOST_LOCS.length];
Npc ghost = addSpawn(ghostId, loc[0], loc[1], loc[2], loc[3], false, 0);
if (ghost != null)
{
spawnedGhosts.add(ghost);
}
}
System.out.println("FafurionGhostEvent: Spawned ghosts because boss spawned.");
}
return null;
}
public String onKill(Npc npc, Player killer, boolean isPet)
{
if (npc.getNpcId() == BOSS_ID)
{
for (Object obj : World.getInstance().getObjects())
{
if (obj instanceof Npc)
{
Npc ghost = (Npc) obj;
int id = ghost.getNpcId();
if (id == 207 || id == 208 || id == 209 || id == 211 || id == 212)
ghost.deleteMe();
}
}
System.out.println("FafurionGhostEvent: Despawned ghosts because boss died.");
}
return null;
}
public static void main(String[] args)
{
new FafurionGhostEvent();
}
}