Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/config/CustomMods/Events/BossEvent.ini b/config/CustomMods/Events/BossEvent.ini
- new file mode 100644
- index 0000000..cc4a763
- --- /dev/null
- +++ b/config/CustomMods/Events/BossEvent.ini
- @@ -0,0 +1,42 @@
- +# ================================================
- +# BossEvent #
- +# ================================================
- +#General
- +# Event Hour
- +EventTime = 20:55,00:00
- +# List of bosses randomly selected
- +# e.g 29046;29029
- +BossList = 29046
- +# Id of registration NPC
- +RegisterNpcID = 10003
- +# Npc location
- +RegisterNpcLocation = 82727,148605,-3471
- +# List of locations randomly selected
- +# e.g 10468,-24569,-3645;174229,-88032,-5116
- +LocationsList = 174229,-88032,-5116
- +# Min players to start event
- +MinPlayers = 1
- +# Min damage to boss to receive rewards
- +MinDamage = 2000
- +# if true countdown will be shown on screen
- +EventTimeOnScreen = True
- +
- +# Timing
- +# reg time in seconds
- +RegistrationTime = 30
- +# Wait time in seconds
- +WaitTime = 15
- +# Teleport time in seconds
- +TeleportTime = 10
- +# time to despawn boss
- +TimeToDespawnBoss = 300
- +
- +# Rewards
- +# Rewards for players who hitted min damage on boss
- +GeneralRewards = 57,100000;3470,10
- +# Reward last hit player
- +RewardLastAttacker = True
- +LastAttackerRewards = 3470,5;3470,5
- +# Reward Player with bigger dmg
- +RewardMainDamageDealer = True
- +MainDamageDealerRewards = 3470,5;3470,5
- \ No newline at end of file
- diff --git a/head-src/com/l2jfrozen/Config.java b/head-src/com/l2jfrozen/Config.java
- index f8a728a..0c125cf 100644
- --- a/head-src/com/l2jfrozen/Config.java
- +++ b/head-src/com/l2jfrozen/Config.java
- @@ -46,6 +46,7 @@
- import org.apache.log4j.Logger;
- import com.l2jfrozen.commons.config.ExProperties;
- +import com.l2jfrozen.gameserver.model.Location;
- import com.l2jfrozen.gameserver.model.entity.olympiad.OlympiadPeriod;
- import com.l2jfrozen.gameserver.model.holder.RewardHolder;
- import com.l2jfrozen.gameserver.util.FloodProtectorConfig;
- @@ -72,7 +73,7 @@
- public static final String EVENT_DM_FILE = "./config/CustomMods/Events/DM.ini";
- public static final String EVENT_TVT_FILE = "./config/CustomMods/Events/TvT.ini";
- public static final String EVENT_TW_FILE = "./config/CustomMods/Events/TW.ini";
- -
- + public static final String BOSS_EVENT_INSTANCED = "./config/CustomMods/Events/BossEvent.ini";
- //============================================================
- @@ -390,7 +391,90 @@
- throw new Error("Failed to Load " + COMMANDS + " File.");
- }
- }
- -
- + // ============================================================
- + /** Boss Event */
- + public static boolean BOSS_EVENT_TIME_ON_SCREEN;
- + public static int BOSS_EVENT_TIME_TO_DESPAWN_BOSS;
- + public static int BOSS_EVENT_REGISTRATION_NPC_ID;
- + public static Map<Integer, Integer> BOSS_EVENT_GENERAL_REWARDS = new HashMap<>();
- + public static Map<Integer, Integer> BOSS_EVENT_LAST_ATTACKER_REWARDS = new HashMap<>();
- + public static Map<Integer, Integer> BOSS_EVENT_MAIN_DAMAGE_DEALER_REWARDS = new HashMap<>();
- + public static boolean BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER;
- + public static boolean BOSS_EVENT_REWARD_LAST_ATTACKER;
- + public static List<Location> BOSS_EVENT_LOCATION = new ArrayList<>();
- + public static int BOSS_EVENT_REWARD_ID;
- + public static int BOSS_EVENT_REWARD_COUNT;
- + public static int BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD;
- + public static List<Integer> BOSS_EVENT_ID = new ArrayList<>();
- + public static Location BOSS_EVENT_NPC_REGISTER_LOC;
- + public static int BOSS_EVENT_TIME_TO_WAIT;
- + public static int BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS;
- + public static int BOSS_EVENT_MIN_PLAYERS;
- + public static int BOSS_EVENT_REGISTRATION_TIME;
- + public static String[] BOSS_EVENT_BY_TIME_OF_DAY;
- + // ============================================================
- + public static void loadEventBoss()
- + {
- + final String BOSS_EVENT_INSTANCED = Config.BOSS_EVENT_INSTANCED;
- +
- + try
- + {
- + final Properties bossEvent = new Properties();
- + final InputStream is = new FileInputStream(new File(BOSS_EVENT_INSTANCED));
- + bossEvent.load(is);
- + is.close();
- + BOSS_EVENT_BY_TIME_OF_DAY = bossEvent.getProperty("EventTime", "20:00").split(",");
- + for (String bossList : bossEvent.getProperty("BossList", "29046;29029").split(";"))
- + {
- + BOSS_EVENT_ID.add(Integer.parseInt(bossList));
- + }
- + bossEvent.getProperty("EventLocation", "174229,-88032,-5116").split(",");
- + for (String locationsList : bossEvent.getProperty("LocationsList", "10468,-24569,-3645;174229,-88032,-5116").split(";"))
- + {
- + String[] coords = locationsList.split(",");
- + int x = Integer.parseInt(coords[0]);
- + int y = Integer.parseInt(coords[1]);
- + int z = Integer.parseInt(coords[2]);
- + BOSS_EVENT_LOCATION.add(new Location(x, y, z));
- + }
- +
- + BOSS_EVENT_MIN_PLAYERS = Integer.parseInt(bossEvent.getProperty("MinPlayers", "1"));
- + BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD = Integer.parseInt(bossEvent.getProperty("MinDamage", "2000"));
- + BOSS_EVENT_REGISTRATION_TIME = Integer.parseInt(bossEvent.getProperty("RegistrationTime", "120"));
- + BOSS_EVENT_REWARD_ID = Integer.parseInt(bossEvent.getProperty("RewardId", "3470"));
- + BOSS_EVENT_REWARD_COUNT = Integer.parseInt(bossEvent.getProperty("RewardCount", "10"));
- + BOSS_EVENT_TIME_TO_WAIT = Integer.parseInt(bossEvent.getProperty("WaitTime", "30"));
- + BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS = Integer.parseInt(bossEvent.getProperty("TeleportTime", "15"));
- + BOSS_EVENT_REWARD_LAST_ATTACKER = Boolean.parseBoolean(bossEvent.getProperty("RewardLastAttacker", "true"));
- + BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER = Boolean.parseBoolean(bossEvent.getProperty("RewardMainDamageDealer", "true"));
- + for (String rewards : bossEvent.getProperty("GeneralRewards", "57,100000;3470,10").split(";"))
- + {
- + String[] reward = rewards.split(",");
- + BOSS_EVENT_GENERAL_REWARDS.put(Integer.parseInt(reward[0]), Integer.parseInt(reward[1]));
- + }
- + for (String rewards : bossEvent.getProperty("MainDamageDealerRewards", "57,100000;3470,10").split(";"))
- + {
- + String[] reward = rewards.split(",");
- + BOSS_EVENT_MAIN_DAMAGE_DEALER_REWARDS.put(Integer.parseInt(reward[0]), Integer.parseInt(reward[1]));
- + }
- + for (String rewards : bossEvent.getProperty("LastAttackerRewards", "57,100000;3470,10").split(";"))
- + {
- + String[] reward = rewards.split(",");
- + BOSS_EVENT_LAST_ATTACKER_REWARDS.put(Integer.parseInt(reward[0]), Integer.parseInt(reward[1]));
- + }
- + BOSS_EVENT_REGISTRATION_NPC_ID = Integer.parseInt(bossEvent.getProperty("RegisterNpcID", "10003"));
- + BOSS_EVENT_TIME_TO_DESPAWN_BOSS = Integer.parseInt(bossEvent.getProperty("TimeToDespawnBoss", "300"));
- + String[] regLoc = bossEvent.getProperty("RegisterNpcLocation", "82727,148605,-3471").split(",");
- + BOSS_EVENT_NPC_REGISTER_LOC = new Location(Integer.parseInt(regLoc[0]), Integer.parseInt(regLoc[1]), Integer.parseInt(regLoc[2]));
- + BOSS_EVENT_TIME_ON_SCREEN = Boolean.parseBoolean(bossEvent.getProperty("EventTimeOnScreen", "true"));
- +
- + }
- + catch (final Exception e)
- + {
- + e.printStackTrace();
- + throw new Error("Failed to Load " + BOSS_EVENT_INSTANCED + " File.");
- + }
- +}
- // ============================================================
- public static String ENTER_FLAGZONE_MESSEGE;
- @@ -5292,6 +5376,7 @@
- loadTVTConfig();
- loadTWConfig();
- loadFlagZone();
- + loadEventBoss();
- loadCommands();
- loadPTFARMConfig();
- loadNPCSConfig();
- diff --git a/head-src/com/l2jfrozen/gameserver/GameServer.java b/head-src/com/l2jfrozen/gameserver/GameServer.java
- index 0be4989..c1e530c 100644
- --- a/head-src/com/l2jfrozen/gameserver/GameServer.java
- +++ b/head-src/com/l2jfrozen/gameserver/GameServer.java
- @@ -95,6 +95,7 @@
- import com.l2jfrozen.gameserver.managers.AutoSaveManager;
- import com.l2jfrozen.gameserver.managers.AwayManager;
- import com.l2jfrozen.gameserver.managers.BoatManager;
- +import com.l2jfrozen.gameserver.managers.BossEvent;
- import com.l2jfrozen.gameserver.managers.CastleManager;
- import com.l2jfrozen.gameserver.managers.CastleManorManager;
- import com.l2jfrozen.gameserver.managers.ClanHallManager;
- @@ -612,7 +613,7 @@
- }
- else
- LOGGER.info("All events are Disabled.");
- -
- + BossEvent.getInstance();
- ArenaConfig.init();
- if (ArenaConfig.TOURNAMENT_EVENT_TIME)
- {
- diff --git a/head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/BossEventCMD.java b/head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/BossEventCMD.java
- new file mode 100644
- index 0000000..df5078e
- --- /dev/null
- +++ b/head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/BossEventCMD.java
- @@ -0,0 +1,49 @@
- +package com.l2jfrozen.gameserver.handler.voicedcommandhandlers;
- +
- +import com.l2jfrozen.gameserver.handler.IVoicedCommandHandler;
- +import com.l2jfrozen.gameserver.managers.BossEvent;
- +import com.l2jfrozen.gameserver.managers.BossEvent.EventState;
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class BossEventCMD implements IVoicedCommandHandler
- +{
- + @Override
- + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
- + {
- + if (command.startsWith("bossevent"))
- + {
- + if (BossEvent.getInstance().getState() != EventState.REGISTRATION)
- + {
- + activeChar.sendMessage("Boss Event is not running!");
- + return false;
- + }
- + if (!BossEvent.getInstance().isRegistered(activeChar))
- + {
- + if (BossEvent.getInstance().addPlayer(activeChar))
- + {
- + activeChar.sendMessage("You have been successfully registered in Boss Event!");
- + }
- +
- + }
- + else
- + {
- + if (BossEvent.getInstance().removePlayer(activeChar))
- + {
- + activeChar.sendMessage("You have been successfully removed of Boss Event!");
- + }
- + }
- + }
- + return false;
- + }
- +
- + @Override
- + public String[] getVoicedCommandList()
- + {
- +
- + return new String[]
- + {
- + "bossevent"
- + };
- + }
- +
- +}
- \ No newline at end of file
- diff --git a/head-src/com/l2jfrozen/gameserver/managers/BossEvent.java b/head-src/com/l2jfrozen/gameserver/managers/BossEvent.java
- new file mode 100644
- index 0000000..3dd5deb
- --- /dev/null
- +++ b/head-src/com/l2jfrozen/gameserver/managers/BossEvent.java
- @@ -0,0 +1,636 @@
- +package com.l2jfrozen.gameserver.managers;
- +
- +import java.util.ArrayList;
- +import java.util.Collection;
- +import java.util.HashMap;
- +import java.util.List;
- +import java.util.Map;
- +import java.util.concurrent.ScheduledFuture;
- +import java.util.logging.Logger;
- +
- +import com.l2jfrozen.Config;
- +import com.l2jfrozen.gameserver.datatables.sql.NpcTable;
- +import com.l2jfrozen.gameserver.datatables.sql.SpawnTable;
- +import com.l2jfrozen.gameserver.handler.VoicedCommandHandler;
- +import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.BossEventCMD;
- +import com.l2jfrozen.gameserver.model.L2World;
- +import com.l2jfrozen.gameserver.model.Location;
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.gameserver.model.spawn.L2Spawn;
- +import com.l2jfrozen.gameserver.network.clientpackets.Say2;
- +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
- +import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage;
- +import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage.SMPOS;
- +import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillUser;
- +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
- +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
- +import com.l2jfrozen.util.random.Rnd;
- +
- +public class BossEvent
- +{
- + public L2Spawn bossSpawn;
- + public List<Location> locList = new ArrayList<>();
- + public Location loc;
- + public List<Integer> bossList = new ArrayList<>();
- + public int bossId;
- + public int objectId;
- + public List<L2PcInstance> eventPlayers = new ArrayList<>();
- + protected static final Logger _log = Logger.getLogger(BossEvent.class.getName());
- + private EventState state = EventState.INACTIVE;
- + public boolean started = false;
- + public boolean aborted = false;
- + private L2PcInstance lastAttacker = null;
- + private Map<Integer, Integer> generalRewards = new HashMap<>();
- + @SuppressWarnings("unused")
- + private Map<Integer, Integer> lastAttackerRewards = new HashMap<>();
- + private Map<Integer, Integer> mainDamageDealerRewards = new HashMap<>();
- + public ScheduledFuture<?> despawnBoss = null;
- + public ScheduledFuture<?> countDownTask = null;
- + private String bossName = "";
- + public boolean bossKilled = false;
- + public L2Spawn eventNpc = null;
- + public long startTime;
- +
- + public enum EventState
- + {
- + REGISTRATION, TELEPORTING, WAITING, FIGHTING, FINISHING, INACTIVE
- + }
- +
- + public BossEvent()
- + {
- + VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new BossEventCMD());
- + NextBossEvent.getInstance().startCalculationOfNextEventTime();
- + _log.info("Boss Event loaded.");
- +
- + }
- +
- + public boolean addPlayer(L2PcInstance player)
- + {
- + return eventPlayers.add(player);
- + }
- +
- + public boolean removePlayer(L2PcInstance player)
- + {
- + return eventPlayers.remove(player);
- + }
- +
- + public boolean isRegistered(L2PcInstance player)
- + {
- + return eventPlayers.contains(player);
- + }
- +
- + class Registration implements Runnable
- + {
- + @Override
- + public void run()
- + {
- + startRegistration();
- +
- + }
- +
- + }
- +
- + public void teleToTown()
- + {
- + for (L2PcInstance p : eventPlayers)
- + {
- + p.teleToLocation(new Location(83374, 148081, -3407),true);
- + }
- + setState(EventState.INACTIVE);
- + }
- +
- + public void delay(int delay)
- + {
- + try
- + {
- + Thread.sleep(delay);
- + }
- + catch (InterruptedException e)
- + {
- + // TODO Auto-generated catch block
- + e.printStackTrace();
- + }
- + }
- +
- + class Teleporting implements Runnable
- + {
- + Location teleTo;
- + List<L2PcInstance> toTeleport = new ArrayList<>();
- +
- + public Teleporting(List<L2PcInstance> toTeleport, Location teleTo)
- + {
- + this.teleTo = teleTo;
- + this.toTeleport = toTeleport;
- + }
- +
- + @Override
- + public void run()
- + {
- + if (eventPlayers.size() >= Config.BOSS_EVENT_MIN_PLAYERS)
- + {
- + despawnNpc(eventNpc);
- + setState(EventState.TELEPORTING);
- + announce("Event Started!", false);
- + startCountDown(Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS, true);
- +
- + for (L2PcInstance p : toTeleport)
- + {
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- +
- + @Override
- + public void run()
- + {
- + p.teleToLocation(teleTo, true);
- +
- + }
- + }, Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS * 1000);
- +
- + }
- + delay(Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS * 1000);
- + setState(EventState.WAITING);
- + startCountDown(Config.BOSS_EVENT_TIME_TO_WAIT, true);
- + ThreadPoolManager.getInstance().scheduleGeneral(new Fighting(bossId, teleTo), Config.BOSS_EVENT_TIME_TO_WAIT * 1000);
- +
- + }
- + else
- + {
- + announce("Event was cancelled due to lack of participation!", false);
- + setState(EventState.INACTIVE);
- + despawnNpc(eventNpc);
- + eventPlayers.clear();
- + objectId = 0;
- +
- + }
- +
- + }
- +
- + }
- +
- + public void reward(L2PcInstance p, Map<Integer, Integer> rewardType)
- + {
- +
- + for (Map.Entry<Integer, Integer> entry : rewardType.entrySet())
- + {
- + p.addItem("BossEventReward", entry.getKey(), entry.getValue(), null, true);
- + }
- +
- + }
- +
- + public void rewardPlayers()
- + {
- + for (L2PcInstance p : eventPlayers)
- + {
- + if (p.getBossEventDamage() > Config.BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD)
- + {
- + reward(p, generalRewards);
- + }
- + else
- + {
- + p.sendPacket(new ExShowScreenMessage("You didn't caused min damage to receive rewards!", 5000));
- + p.sendMessage("You didn't caused min damage to receive rewards! Min. Damage: " + Config.BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD + ". Your Damage: " + p.getBossEventDamage());
- + }
- + }
- +
- + if (Config.BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER)
- + {
- + if (getMainDamageDealer() != null)
- + {
- + reward(getMainDamageDealer(), mainDamageDealerRewards);
- + getMainDamageDealer().sendMessage("Congratulations, you was the damage dealer! So you will receive wonderful rewards.");
- + //getMainDamageDealer().sendChatMessage(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", "Congratulations, you was the damage dealer! So you will receive wonderful rewards.");
- + }
- +
- + }
- + }
- +
- + public void finishEvent()
- + {
- + started = false;
- + // if (!AdminBossEvent.manual)
- + // {
- + NextBossEvent.getInstance().startCalculationOfNextEventTime();
- + // }
- + // else
- + // {
- + // AdminBossEvent.manual = false;
- + // }
- + rewardPlayers();
- + if (bossKilled) announce(bossName + " has been defeated!", false);
- + if (Config.BOSS_EVENT_REWARD_LAST_ATTACKER)
- + {
- + if (lastAttacker != null)
- + {
- + announce("LastAttacker: " + lastAttacker.getName(), false);
- + }
- + }
- +
- + if (Config.BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER)
- + {
- + if (getMainDamageDealer() != null)
- + {
- + announce("Main Damage Dealer: " + getMainDamageDealer().getName() + ". Total Damage = " + getMainDamageDealer().getBossEventDamage(), false);
- + }
- + }
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- +
- + @Override
- + public void run()
- + {
- + teleToTown();
- + eventPlayers.clear();
- +
- + }
- + }, Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS * 1000);
- +
- + setState(EventState.FINISHING);
- + startCountDown(Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS, true);
- + if (despawnBoss != null)
- + {
- + despawnBoss.cancel(true);
- + despawnBoss = null;
- + }
- + objectId = 0;
- +
- + }
- +
- + class Fighting implements Runnable
- + {
- + int bossId;
- + Location spawnLoc;
- +
- + public Fighting(int bossId, Location spawnLoc)
- + {
- + this.bossId = bossId;
- + this.spawnLoc = spawnLoc;
- + }
- +
- + @Override
- + public void run()
- + {
- + if (spawnNpc(bossId, loc.getX(), loc.getY(), loc.getZ()))
- + {
- + setState(EventState.FIGHTING);
- + if (Config.BOSS_EVENT_TIME_ON_SCREEN)
- + {
- + startCountDown(Config.BOSS_EVENT_TIME_TO_DESPAWN_BOSS, true);
- + }
- + despawnBoss = ThreadPoolManager.getInstance().scheduleGeneral(new DespawnBossTask(bossSpawn), Config.BOSS_EVENT_TIME_TO_DESPAWN_BOSS * 1000);
- + objectId = bossSpawn.getLastSpawn().getObjectId();
- + for (L2PcInstance p : eventPlayers)
- + {
- + p.sendPacket(new ExShowScreenMessage("Boss " + bossSpawn.getLastSpawn().getName() + " has been spawned. Go and Defeat him!", 5000));
- + }
- +
- + }
- +
- + }
- +
- + }
- +
- + public void despawnNpc(L2Spawn spawn)
- + {
- + if (spawn != null)
- + {
- + spawn.getLastSpawn().deleteMe();
- + spawn.stopRespawn();
- + SpawnTable.getInstance().deleteSpawn(spawn, true);
- + }
- +
- + }
- +
- + class DespawnBossTask implements Runnable
- + {
- + L2Spawn spawn;
- +
- + public DespawnBossTask(L2Spawn spawn)
- + {
- + this.spawn = spawn;
- + }
- +
- + @Override
- + public void run()
- + {
- + if (spawn != null)
- + {
- + announceScreen("Your time is over " + spawn.getLastSpawn().getName() + " returned to his home!", true);
- + announce("Your time is over " + spawn.getLastSpawn().getName() + " returned to his home!", true);
- + announce("You will be teleported to town.", true);
- + despawnNpc(spawn);
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- +
- + @Override
- + public void run()
- + {
- + teleToTown();
- + eventPlayers.clear();
- + setState(EventState.INACTIVE);
- + objectId = 0;
- +
- + }
- + }, 10000);
- + }
- + }
- +
- + }
- +
- + public void startRegistration()
- + {
- + try
- + {
- + resetPlayersDamage();
- + bossKilled = false;
- + bossList = Config.BOSS_EVENT_ID;
- + bossId = bossList.get(Rnd.get(bossList.size()));
- + locList = Config.BOSS_EVENT_LOCATION;
- + loc = locList.get(Rnd.get(locList.size()));
- + if (NpcTable.getInstance().getTemplate(bossId) != null)
- + {
- + startTime = System.currentTimeMillis() + Config.BOSS_EVENT_REGISTRATION_TIME * 1000;
- + eventNpc = spawnEventNpc(Config.BOSS_EVENT_NPC_REGISTER_LOC._x, Config.BOSS_EVENT_NPC_REGISTER_LOC._y, Config.BOSS_EVENT_NPC_REGISTER_LOC._z);
- + generalRewards = Config.BOSS_EVENT_GENERAL_REWARDS;
- + lastAttackerRewards = Config.BOSS_EVENT_LAST_ATTACKER_REWARDS;
- + mainDamageDealerRewards = Config.BOSS_EVENT_MAIN_DAMAGE_DEALER_REWARDS;
- + started = true;
- + aborted = false;
- + bossName = NpcTable.getInstance().getTemplate(bossId).getName();
- + setState(EventState.REGISTRATION);
- + announce("Registration started!", false);
- + announce("Joinable in giran or use command \".bossevent\" to register to event", false);
- + startCountDown(Config.BOSS_EVENT_REGISTRATION_TIME, false);
- +
- + ThreadPoolManager.getInstance().scheduleGeneral(new Teleporting(eventPlayers, loc), Config.BOSS_EVENT_REGISTRATION_TIME * 1000);
- +
- + }
- + else
- + {
- + _log.warning(getClass().getName() + ": cannot be started. Invalid BossId: " + bossList);
- + return;
- + }
- + }
- + catch (Exception e)
- + {
- + _log.warning("[Boss Event]: Couldn't be started");
- + e.printStackTrace();
- + }
- +
- + }
- +
- + public int timeInMillisToStart()
- + {
- + return (int) (startTime - System.currentTimeMillis()) / 1000;
- + }
- +
- + public void startCountDownEnterWorld(L2PcInstance player)
- + {
- + if (getState() == EventState.REGISTRATION)
- + {
- + ThreadPoolManager.getInstance().scheduleGeneral(new Countdown(player, timeInMillisToStart(), getState()), 0);
- + }
- + }
- +
- + public boolean spawnNpc(int npcId, int x, int y, int z)
- + {
- + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(npcId);
- + try
- + {
- + bossSpawn = new L2Spawn(tmpl);
- +
- + bossSpawn.setLocx(x);
- + bossSpawn.setLocy(y);
- + bossSpawn.setLocz(z);
- + bossSpawn.setRespawnDelay(1);
- +
- + SpawnTable.getInstance().addNewSpawn(bossSpawn, false);
- +
- + bossSpawn.doSpawn();
- + bossSpawn.getLastSpawn().isAggressive();
- + bossSpawn.getLastSpawn().decayMe();
- + bossSpawn.getLastSpawn().spawnMe(bossSpawn.getLastSpawn().getX(), bossSpawn.getLastSpawn().getY(), bossSpawn.getLastSpawn().getZ());
- + bossSpawn.getLastSpawn().broadcastPacket(new MagicSkillUser(bossSpawn.getLastSpawn(), bossSpawn.getLastSpawn(), 1034, 1, 1, 1));
- + return true;
- + }
- + catch (Exception e)
- + {
- + e.printStackTrace();
- + return false;
- + }
- + }
- +
- + public void resetPlayersDamage()
- + {
- + for (L2PcInstance p : L2World.getInstance().getAllPlayers())
- + {
- + p.setBossEventDamage(0);
- + }
- + }
- +
- + public L2Spawn spawnEventNpc(int x, int y, int z)
- + {
- + L2Spawn spawn = null;
- + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(Config.BOSS_EVENT_REGISTRATION_NPC_ID);
- + try
- + {
- + spawn = new L2Spawn(tmpl);
- + spawn.setLocx(x);
- + spawn.setLocy(y);
- + spawn.setLocz(z);
- + spawn.setRespawnDelay(1);
- + spawn.setAmount(1);
- + SpawnTable.getInstance().addNewSpawn(spawn, false);
- + spawn.doSpawn();
- + spawn.getLastSpawn().isAggressive();
- + spawn.getLastSpawn().decayMe();
- + spawn.getLastSpawn().spawnMe(spawn.getLastSpawn().getX(), spawn.getLastSpawn().getY(), spawn.getLastSpawn().getZ());
- + spawn.getLastSpawn().broadcastPacket(new MagicSkillUser(spawn.getLastSpawn(), spawn.getLastSpawn(), 1034, 1, 1, 1));
- +
- +
- + return spawn;
- + }
- + catch (Exception e)
- + {
- + e.printStackTrace();
- + return spawn;
- + }
- + }
- +
- + public final L2PcInstance getMainDamageDealer()
- + {
- + int dmg = 0;
- + L2PcInstance mainDamageDealer = null;
- + for (L2PcInstance p : eventPlayers)
- + {
- + if (p.getBossEventDamage() > dmg)
- + {
- + dmg = p.getBossEventDamage();
- + mainDamageDealer = p;
- + }
- + }
- + return mainDamageDealer;
- + }
- +
- + public static BossEvent getInstance()
- + {
- + return SingleTonHolder._instance;
- + }
- +
- + private static class SingleTonHolder
- + {
- + protected static final BossEvent _instance = new BossEvent();
- + }
- +
- + public void startCountDown(int time, boolean eventOnly)
- + {
- + Collection<L2PcInstance> players = new ArrayList<>();
- + players = eventOnly ? eventPlayers : L2World.getInstance().getAllPlayers();
- + for (L2PcInstance player : players)
- + {
- + ThreadPoolManager.getInstance().scheduleGeneral(new Countdown(player, time, getState()), 0L);
- + }
- +
- + }
- +
- + public void announce(String text, boolean eventOnly)
- + {
- + Collection<L2PcInstance> players = new ArrayList<>();
- + players = eventOnly ? eventPlayers : L2World.getInstance().getAllPlayers();
- + for (L2PcInstance player : players)
- + {
- + player.sendPacket(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", text));
- + }
- + }
- +
- + public void announceScreen(String text, boolean eventOnly)
- + {
- + Collection<L2PcInstance> players = new ArrayList<>();
- + players = eventOnly ? eventPlayers : L2World.getInstance().getAllPlayers();
- + for (L2PcInstance player : players)
- + {
- + player.sendPacket(new ExShowScreenMessage(text, 4000));
- + }
- + }
- +
- + /**
- + * @return the state
- + */
- + public EventState getState()
- + {
- + return state;
- + }
- +
- + /**
- + * @param state the state to set
- + */
- + public void setState(EventState state)
- + {
- + this.state = state;
- + }
- +
- + /**
- + * @return the lastAttacker
- + */
- + public L2PcInstance getLastAttacker()
- + {
- + return lastAttacker;
- + }
- +
- + /**
- + * @param lastAttacker the lastAttacker to set
- + */
- + public void setLastAttacker(L2PcInstance lastAttacker)
- + {
- + this.lastAttacker = lastAttacker;
- + }
- +
- + protected class Countdown implements Runnable
- + {
- + private final L2PcInstance _player;
- + private final int _time;
- + private String text = "";
- + EventState evtState;
- +
- + public Countdown(L2PcInstance player, int time, EventState evtState)
- + {
- + _time = time;
- + _player = player;
- + switch (evtState)
- + {
- + case REGISTRATION:
- + text = "Boss Event registration ends in: ";
- + break;
- + case TELEPORTING:
- + text = "You will be teleported to Boss Event in: ";
- + break;
- + case WAITING:
- + text = "Boss will spawn in: ";
- + break;
- + case FINISHING:
- + text = "You will be teleported to City in: ";
- + break;
- + }
- + this.evtState = evtState;
- + }
- +
- + @Override
- + public void run()
- + {
- + if (getState() == EventState.INACTIVE)
- + {
- + return;
- + }
- + if (_player.isOnline() == 1)
- + {
- + switch (evtState)
- + {
- + case REGISTRATION:
- + case TELEPORTING:
- + case WAITING:
- + case FINISHING:
- + switch (_time)
- + {
- +
- + case 60:
- + case 120:
- + case 180:
- + case 240:
- + case 300:
- + _player.sendPacket(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", text + _time / 60 + " minute(s)"));
- + break;
- + case 45:
- + case 30:
- + case 15:
- + case 10:
- + case 5:
- + case 4:
- + case 3:
- + case 2:
- + case 1:
- + _player.sendPacket(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", text + _time + " second(s)"));
- + break;
- +
- + }
- + if (_time > 1)
- + {
- + ThreadPoolManager.getInstance().scheduleGeneral(new Countdown(_player, _time - 1, evtState), 1000L);
- + }
- + break;
- + case FIGHTING:
- + int minutes = _time / 60;
- + int second = _time % 60;
- + String timing = ((minutes < 10) ? ("0" + minutes) : minutes) + ":" + ((second < 10) ? ("0" + second) : second);
- +
- + _player.sendPacket(new ExShowScreenMessage("Time Left: " + timing, 1100, SMPOS.BOTTOM_RIGHT, true));
- + if (_time > 1)
- + {
- + ThreadPoolManager.getInstance().scheduleGeneral(new Countdown(_player, _time - 1, evtState), 1000L);
- + }
- + break;
- + }
- +
- + }
- + }
- + }
- +
- +}
- \ No newline at end of file
- diff --git a/head-src/com/l2jfrozen/gameserver/managers/NextBossEvent.java b/head-src/com/l2jfrozen/gameserver/managers/NextBossEvent.java
- new file mode 100644
- index 0000000..43933f5
- --- /dev/null
- +++ b/head-src/com/l2jfrozen/gameserver/managers/NextBossEvent.java
- @@ -0,0 +1,95 @@
- +package com.l2jfrozen.gameserver.managers;
- +
- +import java.text.SimpleDateFormat;
- +import java.util.Calendar;
- +import java.util.concurrent.ScheduledFuture;
- +import java.util.logging.Logger;
- +
- +import com.l2jfrozen.Config;
- +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
- +
- +public class NextBossEvent
- +{
- + private static NextBossEvent _instance = null;
- + protected static final Logger _log = Logger.getLogger(NextBossEvent.class.getName());
- + private Calendar nextEvent;
- + private final SimpleDateFormat format = new SimpleDateFormat("HH:mm");
- + public ScheduledFuture<?> task = null;
- +
- + public static NextBossEvent getInstance()
- + {
- + if (_instance == null)
- + {
- + _instance = new NextBossEvent();
- + }
- + return _instance;
- + }
- +
- + public String getNextTime()
- + {
- + if (nextEvent.getTime() != null)
- + {
- + return format.format(nextEvent.getTime());
- + }
- + return "Erro";
- + }
- +
- + public void startCalculationOfNextEventTime()
- + {
- + try
- + {
- + Calendar currentTime = Calendar.getInstance();
- + Calendar testStartTime = null;
- + long flush2 = 0L;
- + long timeL = 0L;
- + int count = 0;
- + for (String timeOfDay : Config.BOSS_EVENT_BY_TIME_OF_DAY)
- + {
- + testStartTime = Calendar.getInstance();
- + testStartTime.setLenient(true);
- + String[] splitTimeOfDay = timeOfDay.split(":");
- + testStartTime.set(11, Integer.parseInt(splitTimeOfDay[0]));
- + testStartTime.set(12, Integer.parseInt(splitTimeOfDay[1]));
- + testStartTime.set(13, 0);
- + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
- + {
- + testStartTime.add(5, 1);
- + }
- + timeL = testStartTime.getTimeInMillis() - currentTime.getTimeInMillis();
- + if (count == 0)
- + {
- + flush2 = timeL;
- + nextEvent = testStartTime;
- + }
- + if (timeL < flush2)
- + {
- + flush2 = timeL;
- + nextEvent = testStartTime;
- + }
- + count++;
- + }
- + _log.info("[Boss Event]: Next Event Time -> " + nextEvent.getTime().toString());
- + ThreadPoolManager.getInstance().scheduleGeneral(new StartEventTask(), flush2);
- + }
- + catch (Exception e)
- + {
- + System.out.println("[Boss Event]: " + e);
- + }
- + }
- +
- + class StartEventTask implements Runnable
- + {
- + StartEventTask()
- + {
- + }
- +
- + @Override
- + public void run()
- + {
- + NextBossEvent._log.info("----------------------------------------------------------------------------");
- + NextBossEvent._log.info("[Boss Event]: Event Started.");
- + NextBossEvent._log.info("----------------------------------------------------------------------------");
- + BossEvent.getInstance().startRegistration();
- + }
- + }
- +}
- \ No newline at end of file
- diff --git a/head-src/com/l2jfrozen/gameserver/model/L2Character.java b/head-src/com/l2jfrozen/gameserver/model/L2Character.java
- index 3bc645a..78939bb 100644
- --- a/head-src/com/l2jfrozen/gameserver/model/L2Character.java
- +++ b/head-src/com/l2jfrozen/gameserver/model/L2Character.java
- @@ -53,6 +53,8 @@
- import com.l2jfrozen.gameserver.handler.ISkillHandler;
- import com.l2jfrozen.gameserver.handler.SkillHandler;
- import com.l2jfrozen.gameserver.handler.itemhandlers.Potions;
- +import com.l2jfrozen.gameserver.managers.BossEvent;
- +import com.l2jfrozen.gameserver.managers.BossEvent.EventState;
- import com.l2jfrozen.gameserver.managers.BotsPreventionManager;
- import com.l2jfrozen.gameserver.managers.DimensionalRiftManager;
- import com.l2jfrozen.gameserver.managers.DuelManager;
- @@ -99,6 +101,7 @@
- import com.l2jfrozen.gameserver.model.zone.type.L2BossZone;
- import com.l2jfrozen.gameserver.model.zone.type.L2TownZone;
- import com.l2jfrozen.gameserver.network.SystemMessageId;
- +import com.l2jfrozen.gameserver.network.clientpackets.Say2;
- import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
- import com.l2jfrozen.gameserver.network.serverpackets.Attack;
- import com.l2jfrozen.gameserver.network.serverpackets.BeginRotation;
- @@ -106,6 +109,7 @@
- import com.l2jfrozen.gameserver.network.serverpackets.ChangeWaitType;
- import com.l2jfrozen.gameserver.network.serverpackets.CharInfo;
- import com.l2jfrozen.gameserver.network.serverpackets.CharMoveToLocation;
- +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
- import com.l2jfrozen.gameserver.network.serverpackets.ExOlympiadSpelledInfo;
- import com.l2jfrozen.gameserver.network.serverpackets.L2GameServerPacket;
- import com.l2jfrozen.gameserver.network.serverpackets.MagicEffectIcons;
- @@ -2293,6 +2297,34 @@
- {
- BotsPreventionManager.getInstance().updatecounter(killer,this);
- }
- + if (BossEvent.getInstance().getState() == EventState.FIGHTING)
- + {
- + if (BossEvent.getInstance().bossSpawn.getLastSpawn() == this)
- + {
- + BossEvent.getInstance().finishEvent();
- + BossEvent.getInstance().bossKilled = true;
- + if (killer instanceof L2PcInstance)
- + {
- + L2PcInstance lastAttacker = killer.getActingPlayer();
- + BossEvent.getInstance().setLastAttacker(lastAttacker);
- + LOGGER.info("Boss Event Finished. Last Attacker : " + lastAttacker.getName());
- + LOGGER.info("Players rewarded: " + BossEvent.getInstance().eventPlayers.size());
- + if (Config.BOSS_EVENT_REWARD_LAST_ATTACKER)
- + {
- +
- + if (lastAttacker.getBossEventDamage() > Config.BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD)
- + {
- + BossEvent.getInstance().reward(lastAttacker, Config.BOSS_EVENT_LAST_ATTACKER_REWARDS);
- + lastAttacker.sendPacket(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", "Congratulations, you was the last attacker! So you will receive wonderful rewards."));
- + //lastAttacker.sendChatMessage(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", "Congratulations, you was the last attacker! So you will receive wonderful rewards.");
- +
- + }
- +
- + }
- + }
- +
- + }
- + }
- // Send the Server->Client packet StatusUpdate with current HP and MP to all other L2PcInstance to inform
- broadcastStatusUpdate();
- diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2BossEventInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2BossEventInstance.java
- new file mode 100644
- index 0000000..4e34195
- --- /dev/null
- +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2BossEventInstance.java
- @@ -0,0 +1,95 @@
- +package com.l2jfrozen.gameserver.model.actor.instance;
- +
- +import com.l2jfrozen.gameserver.ai.CtrlIntention;
- +import com.l2jfrozen.gameserver.managers.BossEvent;
- +import com.l2jfrozen.gameserver.managers.BossEvent.EventState;
- +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
- +import com.l2jfrozen.gameserver.network.serverpackets.MoveToPawn;
- +import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
- +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
- +import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
- +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
- +
- +public class L2BossEventInstance extends L2NpcInstance
- +{
- + /**
- + * @param objectId
- + * @param template
- + */
- + public L2BossEventInstance(int objectId, L2NpcTemplate template)
- + {
- + super(objectId, template);
- + // TODO Auto-generated constructor stub
- + }
- +
- + @Override
- + public void onAction(L2PcInstance player)
- + {
- + if (this != player.getTarget())
- + {
- + player.setTarget(this);
- + player.sendPacket(new MyTargetSelected(getObjectId(), 0));
- + player.sendPacket(new ValidateLocation(this));
- + }
- + else
- + {
- + if (!canInteract(player))
- + player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
- + else
- + {
- + // Rotate the player to face the instance
- + player.sendPacket(new MoveToPawn(player, this, L2NpcInstance.INTERACTION_DISTANCE));
- +
- + if (hasRandomAnimation())
- + onRandomAnimation();
- +
- + showMainWindow(player);
- +
- + // Send ActionFailed to the player in order to avoid he stucks
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- + }
- + }
- +
- + private void showMainWindow(L2PcInstance player)
- + {
- +
- + NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
- + html.setFile("data/html/mods/BossEvent.htm");
- + html.replace("%objectId%", String.valueOf(getObjectId()));
- + html.replace("%npcname%", getName());
- + html.replace("%regCount%", String.valueOf(BossEvent.getInstance().eventPlayers.size()));
- + player.sendPacket(html);
- + }
- +
- + @Override
- + public void onBypassFeedback(L2PcInstance activeChar, String command)
- + {
- +
- + super.onBypassFeedback(activeChar, command);
- + if (command.startsWith("register"))
- + {
- + if (BossEvent.getInstance().getState() != EventState.REGISTRATION)
- + {
- + activeChar.sendMessage("Boss Event is not running!");
- + return;
- + }
- + if (!BossEvent.getInstance().isRegistered(activeChar))
- + {
- + if (BossEvent.getInstance().addPlayer(activeChar))
- + {
- + activeChar.sendMessage("You have been successfully registered in Boss Event!");
- + }
- +
- + }
- + else
- + {
- + if (BossEvent.getInstance().removePlayer(activeChar))
- + {
- + activeChar.sendMessage("You have been successfully removed of Boss Event!");
- + }
- + }
- + }
- + }
- +
- +}
- \ No newline at end of file
- diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
- index 7498ee2..e749d0e 100644
- --- a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
- +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
- @@ -86,6 +86,8 @@
- import com.l2jfrozen.gameserver.handler.skillhandlers.SiegeFlag;
- import com.l2jfrozen.gameserver.handler.skillhandlers.StrSiegeAssault;
- import com.l2jfrozen.gameserver.handler.skillhandlers.TakeCastle;
- +import com.l2jfrozen.gameserver.managers.BossEvent;
- +import com.l2jfrozen.gameserver.managers.BossEvent.EventState;
- import com.l2jfrozen.gameserver.managers.CastleManager;
- import com.l2jfrozen.gameserver.managers.CoupleManager;
- import com.l2jfrozen.gameserver.managers.CursedWeaponsManager;
- @@ -17941,7 +17943,13 @@
- sendPacket(new SystemMessage(SystemMessageId.MISSED_TARGET));
- return;
- }
- -
- + if (BossEvent.getInstance().getState() == EventState.FIGHTING && BossEvent.getInstance().eventPlayers.contains(this))
- + {
- + if (target.getObjectId() == BossEvent.getInstance().objectId)
- + {
- + bossEventDamage += damage;
- + }
- + }
- // Check if hit is critical
- if (pcrit)
- {
- @@ -19720,6 +19728,22 @@
- {
- _nameChangeItemId = itemId;
- }
- + private int bossEventDamage = 0;
- + /**
- + * @return the bossEventDamage
- + */
- + public int getBossEventDamage()
- + {
- + return bossEventDamage;
- + }
- +
- + /**
- + * @param bossEventDamage the bossEventDamage to set
- + */
- + public void setBossEventDamage(int bossEventDamage)
- + {
- + this.bossEventDamage = bossEventDamage;
- + }
- //inicio classitem
- private int _classChangeItemId = 0;
- diff --git a/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java b/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
- index b9f83d0..436a078 100644
- --- a/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
- +++ b/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
- @@ -30,6 +30,7 @@
- import com.l2jfrozen.gameserver.GameServer;
- import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.AwayCmd;
- import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.BankingCmd;
- +import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.BossEventCMD;
- import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.BuffCommand;
- import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.CTFCmd;
- import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.DMCmd;
- @@ -74,6 +75,7 @@
- private VoicedCommandHandler()
- {
- _datatable = new FastMap<>();
- + registerVoicedCommandHandler(new BossEventCMD());
- registerVoicedCommandHandler(new Shiff_Mod());
- registerVoicedCommandHandler(new Voting());
- if(Config.ENABLE_COMMAND_XPON_OFF)
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement