package ai.fantasy_isle;
import l2p.gameserver.ai.DefaultAI;
import l2p.gameserver.config.DevConfig;
import l2p.gameserver.config.OtherConfig;
import l2p.gameserver.managers.GameTimeManager;
import l2p.gameserver.model.instances.NpcInstance;
/**
* Управление парадом на Fantasy Island<br>
* В 2:00/8:00/14:00/20:00 по игровому времени спавнит NPC, которые проходят по заданным маршрутам, после чего деспавнятся
*
* @author Gaikotsu
*/
public class ParadeController extends DefaultAI
{
public ParadeController(NpcInstance actor)
{
super(actor);
}
@Override
public boolean isGlobalAI()
{
return true;
}
@Override
protected void onEvtSpawn()
{
super.onEvtSpawn();
addTimer(OtherConfig.FANTASY_ISLE_PARADE_ENABLED ? 1816300 : 1816301, 1000L);
}
@Override
protected void onEvtTimer(int timerId, Object arg1, Object arg2)
{
if (timerId == 1816300)
{
i_ai0 = GameTimeManager.getInstance().getGameHour();
i_ai1 = GameTimeManager.getInstance().getGameMin();
if ((i_ai0 == 2 || i_ai0 == 8 || i_ai0 == 14 || i_ai0 == 20) && i_ai1 == 0)
{
despawnByGroup("fi_parade_0", "fi_parade_1", "fi_parade_2");
if (GameTimeManager.getInstance().isNowNight())
spawnByGroup("fi_parade_0", "fi_parade_2");
else
spawnByGroup("fi_parade_1", "fi_parade_2");
if (DevConfig.DEBUG_AI)
info("Spawned parade (" + i_ai0 + ":00" + (GameTimeManager.getInstance().isNowNight() ? " [NIGHT]" : " [DAY]") + ")");
addTimer(timerId, 60 * 1000L);
}
else
addTimer(timerId, 1000L);
}
else if (timerId == 1816301)
despawn();
}
}