package npc.model;
import l2p.commons.threading.RunnableImpl;
import l2p.gameserver.ThreadPoolManager;
import l2p.gameserver.ai.AI;
import l2p.gameserver.model.GameObjectsStorage;
import l2p.gameserver.model.Player;
import l2p.gameserver.model.instances.NpcInstance;
import l2p.gameserver.serverpackets.Earthquake;
import l2p.gameserver.serverpackets.PlaySound;
import l2p.gameserver.serverpackets.SocialAction;
import l2p.gameserver.tables.SkillTable;
import l2p.gameserver.templates.npc.NpcTemplate;
import l2p.gameserver.utils.Location;
import l2p.gameserver.utils.NpcUtils;
/**
* @author PaInKiLlEr
* @company J Develop Station - Инстанс для нпц Baium (29025). - Будет баюма.
*/
public class BaiumNpcInstance extends NpcInstance {
private static long _StoredId;
public BaiumNpcInstance(int objectId, NpcTemplate template) {
super(objectId, template);
}
@Override
public void onBypassFeedback(Player player, String command) {
if (command.equals("WakeBaium")) {
NpcInstance baium = GameObjectsStorage.getByNpcId(29020);
if (player.getVar("baiumPermission") != null
|| player.getVar("baiumPermission").equalsIgnoreCase("granted") && baium != null) {
_StoredId = player.getStoredId();
baium.setSpawnedLoc(new Location(116033, 17447, 10107, -25348));
baium.teleToLocation(new Location(116033, 17447, 10107, -25348));
deleteMe();
ThreadPoolManager.getInstance().schedule(new StartBaium(1), 2000);
}
} else {
super.onBypassFeedback(player, command);
}
}
private class StartBaium extends RunnableImpl {
private int _taskId;
public StartBaium(int taskId) {
_taskId = taskId;
}
@Override
public void runImpl() {
NpcInstance baium = GameObjectsStorage.getByNpcId(29020);
Player player = GameObjectsStorage.getAsPlayer(_StoredId);
switch (_taskId) {
// 1) Кричим в чат
// 2) Ставим баюму запрет ходьбы что бы не испортить картину
// 3) Проигроваем музыку
// 4) Показываем социалку
// 5) Устраеваем землятресение
case 1:
AI.BroadcastOnScreenMsgStr(baium, 4000, 5, 0, 1, 0, 0, 0, 3000, 0,
AI.MakeFString(1000521, player.getName(), "", "", "", ""));
baium.startImmobilized();
baium.broadcastPacket(new PlaySound(PlaySound.Type.MUSIC, "BS02_A", 1, 0, baium.getLoc()));
baium.broadcastPacket(new SocialAction(baium.getObjectId(), 2));
baium.broadcastPacket(new Earthquake(baium.getLoc(), 40, 10));
ThreadPoolManager.getInstance().schedule(new StartBaium(2), 9500);
break;
// 1) Показываем социалку
case 2:
baium.broadcastPacket(new SocialAction(baium.getObjectId(), 3));
ThreadPoolManager.getInstance().schedule(new StartBaium(3), 7300);
break;
// 1) Выключаем запрет ходьбы
// 2) Показываем социалку
// 3) Убиваем разбудившего и ругаемся на него
case 3:
baium.stopImmobilized();
baium.broadcastPacket(new SocialAction(baium.getObjectId(), 1));
baium.moveToLocation(player.getLoc(), 0, true);
baium.doCast(SkillTable.getInstance().getInfo(4136, 1), player, true);
baium.Say(player.getName() + ", " + AI.MakeFString(22937, "", "", "", "", ""));
ThreadPoolManager.getInstance().schedule(new StartBaium(4), 8000);
break;
// 1) Спавним ангелов
case 4:
NpcUtils.spawnSingle(29021, new Location(115792, 16608, 10136));
NpcUtils.spawnSingle(29021, new Location(115168, 17200, 10136));
NpcUtils.spawnSingle(29021, new Location(115780, 15564, 10136));
NpcUtils.spawnSingle(29021, new Location(114880, 16236, 10136));
NpcUtils.spawnSingle(29021, new Location(114239, 17168, 10136));
break;
}
}
}
}