Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/model/entity/TvTEvent.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/TvTEvent.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/entity/TvTEvent.java (working copy)
- @@ -0,0 +1,737 @@
- +/*
- + * This program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * [URL]http://www.gnu.org/copyleft/gpl.html[/URL]
- + */
- +package net.sf.l2j.gameserver.model.entity;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.datatables.DoorTable;
- +import net.sf.l2j.gameserver.datatables.ItemTable;
- +import net.sf.l2j.gameserver.datatables.NpcTable;
- +import net.sf.l2j.gameserver.datatables.SpawnTable;
- +import net.sf.l2j.gameserver.model.actor.L2Character;
- +import net.sf.l2j.gameserver.model.L2Spawn;
- +import net.sf.l2j.gameserver.model.actor.L2Summon;
- +import net.sf.l2j.gameserver.model.L2World;
- +import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
- +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
- +import net.sf.l2j.gameserver.model.actor.instance.L2DoorInstance;
- +import net.sf.l2j.gameserver.model.actor.L2Npc;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
- +import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
- +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- +import net.sf.l2j.commons.random.Rnd;
- +
- +/**
- + * @author FBIagent
- + */
- +public class TvTEvent
- +{
- + enum EventState
- + {
- + INACTIVE,
- + INACTIVATING,
- + PARTICIPATING,
- + STARTING,
- + STARTED,
- + REWARDING
- + }
- +
- + /** The teams of the TvTEvent<br> */
- + private static TvTEventTeam[] _teams = new TvTEventTeam[2]; // event only allow max 2 teams
- + /** The state of the TvTEvent<br> */
- + private static EventState _state = EventState.INACTIVE;
- + /**
- + * No instance of this class!<br>
- + */
- + private TvTEvent()
- + {}
- +
- + /**
- + * Teams initializing<br>
- + */
- + public static void init()
- + {
- + _teams[0] = new TvTEventTeam(Config.TVT_EVENT_TEAM_1_NAME, Config.TVT_EVENT_TEAM_1_COORDINATES);
- + _teams[1] = new TvTEventTeam(Config.TVT_EVENT_TEAM_2_NAME, Config.TVT_EVENT_TEAM_2_COORDINATES);
- + }
- +
- + /**
- + * Starts the participation of the TvTEvent<br>
- + * 1. Get NpcTemplate by Config.TVT_EVENT_PARTICIPATION_NPC_ID<br>
- + * 2. Try to spawn a new npc of it<br><br>
- + *
- + * @return boolean<br>
- + */
- + public static boolean startParticipation()
- + {
- + final int tempo_npc_register = Config.TVT_EVENT_PARTICIPATION_TIME * 1000 * 60;
- + try
- + {
- + final NpcTemplate template = NpcTable.getInstance().getTemplate(Config.TVT_EVENT_PARTICIPATION_NPC_ID);
- + final L2Spawn spawn = new L2Spawn(template);
- + spawn.setLoc(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0], Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1], Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2], 0);
- +
- + SpawnTable.getInstance().addNewSpawn(spawn, false);
- + final L2Npc npc = spawn.doSpawn(true);
- + npc.scheduleDespawn(tempo_npc_register);
- + npc.broadcastPacket(new MagicSkillUse(npc, npc, 1034, 1, 1, 1));
- + }
- + catch (Exception e)
- + {
- + System.out.println("TvTEventEngine[TvTEvent.startParticipation()]: exception: " + e);
- + return false;
- + }
- + setState(EventState.PARTICIPATING);
- + return true;
- + }
- +
- + /**
- + * Starts the TvTEvent fight<br>
- + * 1. Set state EventState.STARTING<br>
- + * 2. Close doors specified in configs<br>
- + * 3. Abort if not enought participants(return false)<br>
- + * 4. Set state EventState.STARTED<br>
- + * 5. Teleport all participants to team spot<br><br>
- + *
- + * @return boolean<br>
- + */
- + public static boolean startFight()
- + {
- + setState(EventState.STARTING);
- +
- + // not enought participants
- + if (_teams[0].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS || _teams[1].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS)
- + {
- + setState(EventState.INACTIVE);
- + _teams[0].cleanMe();
- + _teams[1].cleanMe();
- + return false;
- + }
- +
- + closeDoors();
- + setState(EventState.STARTED); // set state to STARTED here, so TvTEventTeleporter know to teleport to team spot
- +
- + // teleport all participants to there team spot
- + for (TvTEventTeam team : _teams)
- + {
- + for (String playerName : team.getParticipatedPlayerNames())
- + {
- + L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);
- +
- + if (playerInstance == null)
- + continue;
- +
- + // implements Runnable and starts itself in constructor
- + new TvTEventTeleporter(playerInstance, team.getCoordinates(), false, false);
- + }
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Calculates the TvTEvent reward<br>
- + * 1. If both teams are at a tie(points equals), send it as system message to all participants, if one of the teams have 0 participants left online abort rewarding<br>
- + * 2. Wait till teams are not at a tie anymore<br>
- + * 3. Set state EvcentState.REWARDING<br>
- + * 4. Reward team with more points<br>
- + * 5. Show win html to wining team participants<br><br>
- + *
- + * @return String<br>
- + */
- + public static String calculateRewards()
- + {
- + if (_teams[0].getPoints() == _teams[1].getPoints())
- + {
- + if (_teams[0].getParticipatedPlayerCount() == 0 || _teams[1].getParticipatedPlayerCount() == 0)
- + {
- + // the fight cannot be completed
- + setState(EventState.REWARDING);
- + return "TvT Event: Event finish. No team won, cause of inactivity!";
- + }
- +
- + sysMsgToAllParticipants("TvT Event: Both teams are at a tie, next team to get a kill wins!");
- + }
- +
- + while (_teams[0].getPoints() == _teams[1].getPoints())
- + {
- + try
- + {
- + Thread.sleep(1);
- + }
- + catch (InterruptedException ie)
- + {}
- + }
- +
- + setState(EventState.REWARDING); // after state REWARDING is set, nobody can point anymore
- +
- + byte teamId = (byte)(_teams[0].getPoints() > _teams[1].getPoints() ? 0 : 1); // which team wins?
- + TvTEventTeam team = _teams[teamId];
- +
- + for (String playerName : team.getParticipatedPlayerNames())
- + {
- + L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);
- +
- + for (int[] reward : Config.TVT_EVENT_REWARDS)
- + {
- + if (playerInstance == null)
- + continue;
- +
- + PcInventory inv = playerInstance.getInventory();
- +
- + if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
- + inv.addItem("TvT Event", reward[0], reward[1], playerInstance, playerInstance);
- + else
- + {
- + for (int i=0;i<reward[1];i++)
- + inv.addItem("TvT Event", reward[0], 1, playerInstance, playerInstance);
- + }
- +
- + SystemMessage systemMessage = null;
- +
- + if (reward[1] > 1)
- + {
- + systemMessage = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
- + systemMessage.addItemName(reward[0]);
- + systemMessage.addNumber(reward[1]);
- + }
- + else
- + {
- + systemMessage = new SystemMessage(SystemMessageId.EARNED_ITEM_S1);
- + systemMessage.addItemName(reward[0]);
- + }
- +
- + playerInstance.sendPacket(systemMessage);
- + }
- +
- + StatusUpdate statusUpdate = new StatusUpdate(playerInstance);
- +
- + statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, playerInstance.getCurrentLoad());
- + playerInstance.sendPacket(statusUpdate);
- +
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
- +
- + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Your team won the event. Look in your inventory, there should be your reward.</body></html>");
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- +
- + return "TvT Event: Event finish. Team " + team.getName() + " won with " + team.getPoints() + " kills.";
- + }
- +
- + /**
- + * Stops the TvTEvent fight<br>
- + * 1. Set state EventState.INACTIVATING<br>
- + * 2. Remove tvt npc from world<br>
- + * 3. Open doors specified in configs<br>
- + * 4. Teleport all participants back to participation npc location<br>
- + * 5. Teams cleaning<br>
- + * 6. Set state EventState.INACTIVE<br>
- + */
- + public static void stopFight()
- + {
- + setState(EventState.INACTIVATING);
- + openDoors();
- +
- + for (TvTEventTeam team : _teams)
- + {
- + for (String playerName : team.getParticipatedPlayerNames())
- + {
- + L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);
- +
- + if (playerInstance == null)
- + continue;
- +
- + new TvTEventTeleporter(playerInstance, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
- + }
- + }
- +
- + _teams[0].cleanMe();
- + _teams[1].cleanMe();
- + setState(EventState.INACTIVE);
- + }
- +
- + /**
- + * Adds a player to a TvTEvent team<br>
- + * 1. Calculate the id of the team in which the player should be added<br>
- + * 2. Add the player to the calculated team
- + * @param playerInstance
- + * @return boolean
- + */
- + public static synchronized boolean addParticipant(L2PcInstance playerInstance)
- + {
- + if (playerInstance == null)
- + return false;
- +
- + byte teamId = 0;
- +
- + if (_teams[0].getParticipatedPlayerCount() == _teams[1].getParticipatedPlayerCount())
- + teamId = (byte)(Rnd.get(2));
- + else
- + teamId = (byte)(_teams[0].getParticipatedPlayerCount() > _teams[1].getParticipatedPlayerCount() ? 1 : 0);
- +
- + return _teams[teamId].addPlayer(playerInstance);
- + }
- +
- + /**
- + * Removes a TvTEvent player from it's team<br>
- + * 1. Get team id of the player<br>
- + * 2. Remove player from it's team
- + * @param playerName
- + * @return boolean
- + */
- + public static boolean removeParticipant(String playerName)
- + {
- + byte teamId = getParticipantTeamId(playerName);
- +
- + if (teamId == -1)
- + return false;
- +
- + _teams[teamId].removePlayer(playerName);
- + return true;
- + }
- +
- + /**
- + * Send a SystemMessage to all participated players<br>
- + * 1. Send the message to all players of team number one<br>
- + * 2. Send the message to all players of team number two
- + * @param message
- + */
- + public static void sysMsgToAllParticipants(String message)
- + {
- + for (L2PcInstance playerInstance : _teams[0].getParticipatedPlayers().values())
- + {
- + if (playerInstance != null)
- + playerInstance.sendMessage(message);
- + }
- +
- + for (L2PcInstance playerInstance : _teams[1].getParticipatedPlayers().values())
- + {
- + if (playerInstance != null)
- + playerInstance.sendMessage(message);
- + }
- + }
- +
- + /**
- + * Close doors specified in configs
- + */
- + private static void closeDoors()
- + {
- + for (int doorId : Config.TVT_EVENT_DOOR_IDS)
- + {
- + L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(doorId);
- +
- + if (doorInstance != null)
- + doorInstance.closeMe();
- + }
- + }
- +
- + /**
- + * Open doors specified in configs
- + */
- + private static void openDoors()
- + {
- + for (int doorId : Config.TVT_EVENT_DOOR_IDS)
- + {
- + L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(doorId);
- +
- + if (doorInstance != null)
- + doorInstance.openMe();
- + }
- + }
- +
- + /**
- + * Called when a player logs in
- + * @param playerInstance
- + */
- + public static void onLogin(L2PcInstance playerInstance)
- + {
- + if (playerInstance == null || (!isStarting() && !isStarted()))
- + return;
- +
- + byte teamId = getParticipantTeamId(playerInstance.getName());
- +
- + if (teamId == -1)
- + return;
- +
- + _teams[teamId].addPlayer(playerInstance);
- + new TvTEventTeleporter(playerInstance, _teams[teamId].getCoordinates(), true, false);
- + }
- +
- + /**
- + * Called when a player logs out
- + * @param playerInstance
- + */
- + public static void onLogout(L2PcInstance playerInstance)
- + {
- + if (playerInstance == null || (!isStarting() && !isStarted()))
- + return;
- +
- + removeParticipant(playerInstance.getName());
- + }
- +
- + /**
- + * Called on every bypass by npc of type L2TvTEventNpc<br>
- + * Needs synchronization cause of the max player check
- + * @param command
- + * @param playerInstance
- + */
- + public static synchronized void onBypass(String command, L2PcInstance playerInstance)
- + {
- + if (playerInstance == null || !isParticipating())
- + return;
- +
- + if (command.equals("tvt_event_participation"))
- + {
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
- + int playerLevel = playerInstance.getLevel();
- +
- + if (playerInstance.isCursedWeaponEquipped())
- + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Cursed weapon owners are not allowed to participate.</body></html>");
- + else if (OlympiadManager.getInstance().isRegisteredInComp(playerInstance))
- + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Olympiad participants can't register.</body></html>");
- + else if (playerInstance.getKarma() > 0)
- + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Chaotic players are not allowed to participate.</body></html>");
- + else if (_teams[0].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && _teams[1].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
- + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Sorry the event is full!</body></html>");
- + else if (playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL)
- + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Only players from level " + Config.TVT_EVENT_MIN_LVL + " to level " + Config.TVT_EVENT_MAX_LVL + " are allowed tro participate.</body></html>");
- + else if (_teams[0].getParticipatedPlayerCount() > 19 && _teams[1].getParticipatedPlayerCount() > 19)
- + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>The event is full! Maximum of " + Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS + " player are allowed in one team.</body></html>");
- + else if (addParticipant(playerInstance))
- + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are on the registration list now.</body></html>");
- + else // addParticipant returned false cause playerInstance == null
- + return;
- +
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- + else if (command.equals("tvt_event_remove_participation"))
- + {
- + removeParticipant(playerInstance.getName());
- +
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
- +
- + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are not longer on the registration list.</body></html>");
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- + }
- +
- + /**
- + * Called on every onAction in L2PcIstance
- + * @param playerName
- + * @param targetPlayerName
- + * @return boolean
- + */
- + public static boolean onAction(String playerName, String targetPlayerName)
- + {
- + if (!isStarted())
- + return true;
- +
- + L2PcInstance playerInstance = L2World.getInstance().getPlayer(playerName);
- +
- + if (playerInstance == null)
- + return false;
- +
- + if (playerInstance.isGM())
- + return true;
- +
- + byte playerTeamId = getParticipantTeamId(playerName);
- + byte targetPlayerTeamId = getParticipantTeamId(targetPlayerName);
- +
- + if ((playerTeamId != -1 && targetPlayerTeamId == -1) ||
- + (playerTeamId == -1 && targetPlayerTeamId != -1))
- + return false;
- +
- + if (playerTeamId != -1 && targetPlayerTeamId != -1 && playerTeamId == targetPlayerTeamId && !Config.TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED)
- + return false;
- +
- + return true;
- + }
- +
- + /**
- + * Called on every potion use
- + * @param playerName
- + * @return boolean
- + */
- + public static boolean onPotionUse(String playerName)
- + {
- + if (!isStarted())
- + return true;
- +
- + if (isPlayerParticipant(playerName) && !Config.TVT_EVENT_POTIONS_ALLOWED)
- + return false;
- +
- + return true;
- + }
- +
- + /**
- + * Called on every escape use(thanks to nbd)
- + * @param playerName
- + * @return boolean
- + */
- + public static boolean onEscapeUse(String playerName)
- + {
- + if (!isStarted())
- + return true;
- +
- + if (isPlayerParticipant(playerName))
- + return false;
- +
- + return true;
- + }
- +
- + /**
- + * Called on every summon item use
- + * @param playerName
- + * @return boolean
- + */
- + public static boolean onItemSummon(String playerName)
- + {
- + if (!isStarted())
- + return true;
- +
- + if (isPlayerParticipant(playerName) && !Config.TVT_EVENT_SUMMON_BY_ITEM_ALLOWED)
- + return false;
- +
- + return true;
- + }
- +
- + /**
- + * Is called when a player is killed
- + * @param killerCharacter
- + * @param killedPlayerInstance
- + */
- + public static void onKill(L2Character killerCharacter, L2PcInstance killedPlayerInstance)
- + {
- + if (killerCharacter == null || killedPlayerInstance == null ||
- + (!(killerCharacter instanceof L2PcInstance) &&
- + !(killerCharacter instanceof L2PetInstance) &&
- + !(killerCharacter instanceof L2SummonInstance)) ||
- + !isStarted())
- + return;
- +
- + L2PcInstance killerPlayerInstance = null;
- +
- + if (killerCharacter instanceof L2PetInstance || killerCharacter instanceof L2SummonInstance)
- + {
- + killerPlayerInstance = ((L2Summon)killerCharacter).getOwner();
- +
- + if (killerPlayerInstance == null)
- + return;
- + }
- + else
- + killerPlayerInstance = (L2PcInstance)killerCharacter;
- +
- + String playerName = killerPlayerInstance.getName();
- + byte killerTeamId = getParticipantTeamId(playerName);
- +
- + playerName = killedPlayerInstance.getName();
- +
- + byte killedTeamId = getParticipantTeamId(playerName);
- +
- + if (killerTeamId != -1 && killedTeamId != -1 && killerTeamId != killedTeamId)
- + _teams[killerTeamId].increasePoints();
- +
- + if (killedTeamId != -1)
- + new TvTEventTeleporter(killedPlayerInstance, _teams[killedTeamId].getCoordinates(), false, false);
- + }
- +
- + /**
- + * Sets the TvTEvent state
- + * @param state
- + */
- + private static void setState(EventState state)
- + {
- + synchronized (_state)
- + {
- + _state = state;
- + }
- + }
- +
- + /**
- + * Is TvTEvent inactive?
- + * @return boolean
- + */
- + public static boolean isInactive()
- + {
- + boolean isInactive;
- +
- + synchronized (_state)
- + {
- + isInactive = _state == EventState.INACTIVE;
- + }
- +
- + return isInactive;
- + }
- +
- + /**
- + * Is TvTEvent in inactivating?
- + * @return boolean
- + */
- + public static boolean isInactivating()
- + {
- + boolean isInactivating;
- +
- + synchronized (_state)
- + {
- + isInactivating = _state == EventState.INACTIVATING;
- + }
- +
- + return isInactivating;
- + }
- +
- + /**
- + * Is TvTEvent in participation?
- + * @return boolean
- + */
- + public static boolean isParticipating()
- + {
- + boolean isParticipating;
- +
- + synchronized (_state)
- + {
- + isParticipating = _state == EventState.PARTICIPATING;
- + }
- +
- + return isParticipating;
- + }
- +
- + /**
- + * Is TvTEvent starting?
- + * @return boolean
- + */
- + public static boolean isStarting()
- + {
- + boolean isStarting;
- +
- + synchronized (_state)
- + {
- + isStarting = _state == EventState.STARTING;
- + }
- +
- + return isStarting;
- + }
- +
- + /**
- + * Is TvTEvent started?
- + * @return boolean
- + */
- + public static boolean isStarted()
- + {
- + boolean isStarted;
- +
- + synchronized (_state)
- + {
- + isStarted = _state == EventState.STARTED;
- + }
- +
- + return isStarted;
- + }
- +
- + /**
- + * Is TvTEvent rewarding?
- + * @return boolean
- + */
- + public static boolean isRewarding()
- + {
- + boolean isRewarding;
- +
- + synchronized (_state)
- + {
- + isRewarding = _state == EventState.REWARDING;
- + }
- +
- + return isRewarding;
- + }
- +
- + /**
- + * Returns the team id of a player, if player is not participant it returns -1
- + * @param playerName
- + * @return byte
- + */
- + public static byte getParticipantTeamId(String playerName)
- + {
- + return (byte)(_teams[0].containsPlayer(playerName) ? 0 : (_teams[1].containsPlayer(playerName) ? 1 : -1));
- + }
- +
- + /**
- + * Returns the team coordinates in which the player is in, if player is not in a team return null
- + * @param playerName
- + * @return int[]
- + */
- + public static int[] getParticipantTeamCoordinates(String playerName)
- + {
- + return _teams[0].containsPlayer(playerName) ? _teams[0].getCoordinates() : (_teams[1].containsPlayer(playerName) ? _teams[1].getCoordinates() : null);
- + }
- +
- +
- + /**
- + * Is given player participant of the event?
- + * @param playerName
- + * @return boolean
- + */
- + public static boolean isPlayerParticipant(String playerName)
- + {
- + return _teams[0].containsPlayer(playerName) || _teams[1].containsPlayer(playerName);
- + }
- +
- + /**
- + * Returns participated player count<br><br>
- + *
- + * @return int<br>
- + */
- + public static int getParticipatedPlayersCount()
- + {
- + return _teams[0].getParticipatedPlayerCount() + _teams[1].getParticipatedPlayerCount();
- + }
- +
- + /**
- + * Returns teams names<br><br>
- + *
- + * @return String[]<br>
- + */
- + public static String[] getTeamNames()
- + {
- + return new String[]{_teams[0].getName(), _teams[1].getName()};
- + }
- +
- + /**
- + * Returns player count of both teams<br><br>
- + *
- + * @return int[]<br>
- + */
- + public static int[] getTeamsPlayerCounts()
- + {
- + return new int[]{_teams[0].getParticipatedPlayerCount(), _teams[1].getParticipatedPlayerCount()};
- + }
- +
- + /**
- + * Returns points count of both teams
- + *
- + * @return int[]
- + */
- + public static int[] getTeamsPoints()
- + {
- + return new int[]{_teams[0].getPoints(), _teams[1].getPoints()};
- + }
- +}
- Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 7)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
- @@ -36,6 +36,7 @@
- import net.sf.l2j.gameserver.model.entity.ClanHall;
- import net.sf.l2j.gameserver.model.entity.Couple;
- import net.sf.l2j.gameserver.model.entity.Siege;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.olympiad.Olympiad;
- import net.sf.l2j.gameserver.model.zone.ZoneId;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- @@ -231,6 +232,7 @@
- sendPacket(new Die(activeChar));
- activeChar.onPlayerEnter();
- + TvTEvent.onLogin(activeChar);
- sendPacket(new SkillCoolTime(activeChar));
- Index: java/net/sf/l2j/gameserver/network/serverpackets/SystemMessage.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/serverpackets/SystemMessage.java (revision 7)
- +++ java/net/sf/l2j/gameserver/network/serverpackets/SystemMessage.java (working copy)
- @@ -110,7 +110,7 @@
- private SMParam[] _params;
- private int _paramIndex;
- - private SystemMessage(final SystemMessageId smId)
- + public SystemMessage(final SystemMessageId smId)
- {
- final int paramCount = smId.getParamCount();
- _smId = smId;
- Index: java/net/sf/l2j/Config.java
- ===================================================================
- --- java/net/sf/l2j/Config.java (revision 9)
- +++ java/net/sf/l2j/Config.java (working copy)
- @@ +54,34 @@
- public static final String SIEGE_FILE = "./config/siege.properties";
- public static final String COLOR_FILE = "./config/colorsystem.properties";
- public static final String CUSTOM_FILE = "./config/custom.properties";
- + public static final String CUSTOM_EVENTS_FILE = "./config/custom_events.properties";
- // --------------------------------------------------
- + // Events settings
- + // --------------------------------------------------
- + public static boolean TVT_EVENT_ENABLED;
- + public static int TVT_EVENT_INTERVAL;
- + public static int TVT_EVENT_PARTICIPATION_TIME;
- + public static int TVT_EVENT_RUNNING_TIME;
- + public static int TVT_EVENT_PARTICIPATION_NPC_ID;
- + public static int[] TVT_EVENT_PARTICIPATION_NPC_COORDINATES = new int[3];
- + public static int TVT_EVENT_MIN_PLAYERS_IN_TEAMS;
- + public static int TVT_EVENT_MAX_PLAYERS_IN_TEAMS;
- + public static int TVT_EVENT_RESPAWN_TELEPORT_DELAY;
- + public static int TVT_EVENT_START_LEAVE_TELEPORT_DELAY;
- + public static String TVT_EVENT_TEAM_1_NAME;
- + public static int[] TVT_EVENT_TEAM_1_COORDINATES = new int[3];
- + public static String TVT_EVENT_TEAM_2_NAME;
- + public static int[] TVT_EVENT_TEAM_2_COORDINATES = new int[3];
- + public static List<int[]> TVT_EVENT_REWARDS = new ArrayList<int[]>();
- + public static boolean TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED;
- + public static boolean TVT_EVENT_POTIONS_ALLOWED;
- + public static boolean TVT_EVENT_SUMMON_BY_ITEM_ALLOWED;
- + public static List<Integer> TVT_EVENT_DOOR_IDS = new ArrayList<Integer>();
- + public static byte TVT_EVENT_MIN_LVL;
- + public static byte TVT_EVENT_MAX_LVL;
- +
- + // --------------------------------------------------
- // Custom settings
- // --------------------------------------------------
- @@ -1371,8 +1403,119 @@
- ZONE_TOWN = server.getProperty("ZoneTown", 0);
- SERVER_NEWS = server.getProperty("ShowServerNews", false);
- DISABLE_TUTORIAL = server.getProperty("DisableTutorial", false);
- + _log.info("Loading configuration file: "+SERVER_FILE);
- }
- +
- + private static final void loadCustomEvents()
- + {
- + final ExProperties events = initProperties(CUSTOM_EVENTS_FILE);
- +
- + TVT_EVENT_ENABLED = events.getProperty("TvTEventEnabled", false);
- + TVT_EVENT_INTERVAL = events.getProperty("TvTEventInterval", 18000);
- + TVT_EVENT_PARTICIPATION_TIME = events.getProperty("TvTEventParticipationTime", 3600);
- + TVT_EVENT_RUNNING_TIME = events.getProperty("TvTEventRunningTime", 1800);
- + TVT_EVENT_PARTICIPATION_NPC_ID = events.getProperty("TvTEventParticipationNpcId", 0);
- +
- + if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
- + {
- + TVT_EVENT_ENABLED = false;
- + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationNpcId");
- + }
- + else
- + {
- + String[] propertySplit = events.getProperty("TvTEventParticipationNpcCoordinates", "0,0,0").split(",");
- + if (propertySplit.length < 3)
- + {
- + TVT_EVENT_ENABLED = false;
- + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationNpcCoordinates");
- + }
- + else
- + {
- + TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- +
- + TVT_EVENT_MIN_PLAYERS_IN_TEAMS = Integer.parseInt(events.getProperty("TvTEventMinPlayersInTeams", "1"));
- + TVT_EVENT_MAX_PLAYERS_IN_TEAMS = Integer.parseInt(events.getProperty("TvTEventMaxPlayersInTeams", "20"));
- + TVT_EVENT_MIN_LVL = (byte)Integer.parseInt(events.getProperty("TvTEventMinPlayerLevel", "1"));
- + TVT_EVENT_MAX_LVL = (byte)Integer.parseInt(events.getProperty("TvTEventMaxPlayerLevel", "80"));
- + TVT_EVENT_RESPAWN_TELEPORT_DELAY = Integer.parseInt(events.getProperty("TvTEventRespawnTeleportDelay", "20"));
- + TVT_EVENT_START_LEAVE_TELEPORT_DELAY = Integer.parseInt(events.getProperty("TvTEventStartLeaveTeleportDelay", "20"));
- +
- + TVT_EVENT_TEAM_1_NAME = events.getProperty("TvTEventTeam1Name", "Team1");
- + propertySplit = events.getProperty("TvTEventTeam1Coordinates", "0,0,0").split(",");
- +
- + if (propertySplit.length < 3)
- + {
- + TVT_EVENT_ENABLED = false;
- + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventTeam1Coordinates");
- + }
- + else
- + {
- + TVT_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + TVT_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + TVT_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- +
- + TVT_EVENT_TEAM_2_NAME = events.getProperty("TvTEventTeam2Name", "Team2");
- + propertySplit = events.getProperty("TvTEventTeam2Coordinates", "0,0,0").split(",");
- +
- + if (propertySplit.length < 3)
- + {
- + TVT_EVENT_ENABLED= false;
- + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventTeam2Coordinates");
- + }
- + else
- + {
- + TVT_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + TVT_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + TVT_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- + propertySplit = events.getProperty("TvTEventReward", "57,100000").split(";");
- +
- + for (String reward : propertySplit)
- + {
- + String[] rewardSplit = reward.split(",");
- +
- + if (rewardSplit.length != 2)
- + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + reward + "\"");
- + else
- + {
- + try
- + {
- + TVT_EVENT_REWARDS.add(new int[]{Integer.valueOf(rewardSplit[0]), Integer.valueOf(rewardSplit[1])});
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!reward.equals(""))
- + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + reward + "\"");
- + }
- + }
- + }
- +
- + TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = Boolean.parseBoolean(events.getProperty("TvTEventTargetTeamMembersAllowed", "true"));
- + TVT_EVENT_POTIONS_ALLOWED = Boolean.parseBoolean(events.getProperty("TvTEventPotionsAllowed", "false"));
- + TVT_EVENT_SUMMON_BY_ITEM_ALLOWED = Boolean.parseBoolean(events.getProperty("TvTEventSummonByItemAllowed", "false"));
- + propertySplit = events.getProperty("TvTEventDoorsCloseOpenOnStartEnd", "").split(";");
- +
- + for (String door : propertySplit)
- + {
- + try
- + {
- + TVT_EVENT_DOOR_IDS.add(Integer.valueOf(door));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!door.equals(""))
- + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventDoorsCloseOpenOnStartEnd \"" + door + "\"");
- + }
- + }
- + }
- + }
- + }
- + }
- + }
- +
- private static final void loadCustomMods()
- {
- final ExProperties custom = initProperties(CUSTOM_FILE);
- @@ -1463,11 +1608,13 @@
- NORMAL_CONNECTION_TIME = server.getProperty("NormalConnectionTime", 700);
- FAST_CONNECTION_TIME = server.getProperty("FastConnectionTime", 350);
- MAX_CONNECTION_PER_IP = server.getProperty("MaxConnectionPerIP", 50);
- }
- public static final void loadGameServer()
- {
- _log.info("Loading gameserver configuration files.");
- + // events settings
- + loadCustomEvents();
- // custom settings
- loadCustomMods();
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 9)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -99,6 +99,7 @@
- import net.sf.l2j.gameserver.model.L2Manor;
- import net.sf.l2j.gameserver.model.L2World;
- import net.sf.l2j.gameserver.model.entity.Hero;
- +import net.sf.l2j.gameserver.model.entity.TvTManager;
- import net.sf.l2j.gameserver.model.olympiad.Olympiad;
- import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
- import net.sf.l2j.gameserver.model.partymatching.PartyMatchRoomList;
- @@ -296,6 +297,9 @@
- if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
- FishingChampionshipManager.getInstance();
- + StringUtil.printSection("Java Mods");
- + TvTManager.getInstance();
- +
- StringUtil.printSection("System");
- TaskManager.getInstance();
- Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (revision 7)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (working copy)
- @@ -16,10 +16,12 @@
- import net.sf.l2j.gameserver.instancemanager.SevenSignsFestival;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.zone.ZoneId;
- import net.sf.l2j.gameserver.network.L2GameClient;
- import net.sf.l2j.gameserver.network.L2GameClient.GameClientState;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- import net.sf.l2j.gameserver.network.serverpackets.CharSelectInfo;
- import net.sf.l2j.gameserver.network.serverpackets.RestartResponse;
- import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- @@ -59,6 +61,13 @@
- return;
- }
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + player.sendMessage("You can not restart when you registering in TvTEvent.");
- + return;
- + }
- +
- if (player.isFestivalParticipant())
- {
- if (SevenSignsFestival.getInstance().isFestivalInitialized())
- Index: java/net/sf/l2j/gameserver/network/serverpackets/Die.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/serverpackets/Die.java (revision 7)
- +++ java/net/sf/l2j/gameserver/network/serverpackets/Die.java (working copy)
- @@ -31,6 +31,7 @@
- private boolean _allowFixedRes;
- private L2Clan _clan;
- L2Character _activeChar;
- + private boolean _funEvent;
- public Die(L2Character cha)
- {
- @@ -43,6 +44,7 @@
- L2PcInstance player = (L2PcInstance) cha;
- _allowFixedRes = player.getAccessLevel().allowFixedRes();
- _clan = player.getClan();
- + _funEvent = !player.isInFunEvent();
- }
- else if (cha instanceof L2Attackable)
- @@ -57,9 +59,9 @@
- writeC(0x06);
- writeD(_charObjId);
- - writeD(0x01); // to nearest village
- + writeD(_funEvent ? 0x01 : 0); // to nearest village
- - if (_clan != null)
- + if (_funEvent && _clan != null)
- {
- L2SiegeClan siegeClan = null;
- boolean isInDefense = false;
- Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (revision 7)
- +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (working copy)
- @@ -21,6 +21,8 @@
- import net.sf.l2j.gameserver.model.actor.L2Character;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- import net.sf.l2j.gameserver.skills.Formulas;
- import net.sf.l2j.gameserver.taskmanager.DecayTaskManager;
- import net.sf.l2j.gameserver.templates.skills.L2SkillType;
- @@ -35,6 +37,11 @@
- @Override
- public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
- {
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(activeChar.getName()))
- + {
- + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- for (L2Object cha : targets)
- {
- final L2Character target = (L2Character) cha;
- Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (revision 7)
- +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (working copy)
- @@ -22,7 +22,9 @@
- import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- import net.sf.l2j.gameserver.templates.StatsSet;
- @@ -256,7 +258,12 @@
- player.sendPacket(SystemMessageId.ONLY_NOBLESS_CAN_PARTICIPATE_IN_THE_OLYMPIAD);
- return false;
- }
- -
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + player.sendMessage("You can not register in olympiad while registered at TvT.");
- + return false;
- + }
- if (player.isSubClassActive())
- {
- player.sendPacket(SystemMessageId.YOU_CANT_JOIN_THE_OLYMPIAD_WITH_A_SUB_JOB_CHARACTER);
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java (revision 7)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java (working copy)
- @@ -27,6 +27,7 @@
- import net.sf.l2j.gameserver.model.actor.L2Npc;
- import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- import net.sf.l2j.gameserver.model.entity.Couple;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- @@ -138,7 +139,7 @@
- }
- // Simple checks to avoid exploits
- - if (partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.inObserverMode())
- + if (!TvTEvent.onEscapeUse(partner.getName()) || partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.inObserverMode())
- {
- player.sendMessage("Due to the current partner's status, the teleportation failed.");
- return;
- Index: java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java (revision 7)
- +++ java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java (working copy)
- @@ -19,7 +19,9 @@
- import net.sf.l2j.gameserver.model.L2Skill;
- import net.sf.l2j.gameserver.model.actor.L2Character;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- import net.sf.l2j.gameserver.network.serverpackets.ConfirmDlg;
- import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- import net.sf.l2j.gameserver.templates.skills.L2SkillType;
- @@ -47,6 +49,12 @@
- if (!L2PcInstance.checkSummonerStatus(player))
- return;
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- for (L2Object obj : targets)
- {
- // The target must be a player.
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java (working copy)
- @@ -0,0 +1,99 @@
- +/*
- + * This program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * [URL]http://www.gnu.org/copyleft/gpl.html[/URL]
- + */
- +package net.sf.l2j.gameserver.model.actor.instance;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.cache.HtmCache;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- +
- +public class L2TvTEventNpcInstance extends L2NpcInstance
- +{
- + public L2TvTEventNpcInstance(int objectId, NpcTemplate template)
- + {
- + super(objectId, template);
- + }
- +
- + @Override
- + public void onBypassFeedback(L2PcInstance playerInstance, String command)
- + {
- + TvTEvent.onBypass(command, playerInstance);
- + }
- +
- + @Override
- + public void showChatWindow(L2PcInstance playerInstance, int val)
- + {
- + if (playerInstance == null)
- + return;
- +
- + if (TvTEvent.isParticipating())
- + {
- + String htmFile = "data/html/mods/";
- +
- + if (!TvTEvent.isPlayerParticipant(playerInstance.getName()))
- + htmFile += "TvTEventParticipation";
- + else
- + htmFile += "TvTEventRemoveParticipation";
- +
- + htmFile += ".htm";
- +
- + String htmContent = HtmCache.getInstance().getHtm(htmFile);
- +
- + if (htmContent != null)
- + {
- + int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
- +
- + npcHtmlMessage.setHtml(htmContent);
- + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
- + npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
- + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
- + npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
- + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- + }
- + else if (TvTEvent.isStarting() || TvTEvent.isStarted())
- + {
- + String htmFile = "data/html/mods/TvTEventStatus.htm";
- + String htmContent = HtmCache.getInstance().getHtm(htmFile);
- +
- + if (htmContent != null)
- + {
- + int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
- + int[] teamsPointsCounts = TvTEvent.getTeamsPoints();
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
- +
- + npcHtmlMessage.setHtml(htmContent);
- + //npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
- + npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
- + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
- + npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
- + npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
- + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
- + npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- + }
- +
- + playerInstance.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 7)
- +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
- @@ -62,6 +62,7 @@
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSpawn;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTarget;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTeleport;
- +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTvTEvent;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminZone;
- public class AdminCommandHandler
- @@ -120,6 +121,7 @@
- registerAdminCommandHandler(new AdminSpawn());
- registerAdminCommandHandler(new AdminTarget());
- registerAdminCommandHandler(new AdminTeleport());
- + registerAdminCommandHandler(new AdminTvTEvent());
- registerAdminCommandHandler(new AdminZone());
- }
- Index: java/net/sf/l2j/gameserver/model/entity/TvTManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/TvTManager.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/entity/TvTManager.java (working copy)
- @@ -0,0 +1,170 @@
- +/*
- + * This program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * [URL]http://www.gnu.org/copyleft/gpl.html[/URL]
- + */
- +package net.sf.l2j.gameserver.model.entity;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.ThreadPoolManager;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +
- +/**
- + * @author FBIagent
- + */
- +public class TvTManager implements Runnable
- +{
- + /** The one and only instance of this class<br> */
- + private static TvTManager _instance = null;
- +
- + /**
- + * New instance only by getInstance()<br>
- + */
- + private TvTManager()
- + {
- + if (Config.TVT_EVENT_ENABLED)
- + {
- + ThreadPoolManager.getInstance().scheduleGeneral(this, 0);
- + System.out.println("TvTEventEngine[TvTManager.TvTManager()]: Started.");
- + }
- + else
- + System.out.println("TvTEventEngine[TvTManager.TvTManager()]: Engine is disabled.");
- + }
- +
- + /**
- + * Initialize new/Returns the one and only instance<br><br>
- + *
- + * @return TvTManager<br>
- + */
- + public static TvTManager getInstance()
- + {
- + if (_instance == null)
- + _instance = new TvTManager();
- +
- + return _instance;
- + }
- +
- + /**
- + * The task method to handle cycles of the event
- + * @see java.lang.Runnable#run()
- + */
- + @Override
- + public void run()
- + {
- + TvTEvent.init();
- +
- + for (;;)
- + {
- + waiter(Config.TVT_EVENT_INTERVAL * 60); // in config given as minutes
- +
- + if (!TvTEvent.startParticipation())
- + {
- + Broadcast.announceToOnlinePlayers("TvT Event: Event was canceled.", true);
- + System.out.println("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation.");
- + continue;
- + }
- + Broadcast.announceToOnlinePlayers("TvT Event: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s).", true);
- +
- + waiter(Config.TVT_EVENT_PARTICIPATION_TIME * 60); // in config given as minutes
- +
- + if (!TvTEvent.startFight())
- + {
- + Broadcast.announceToOnlinePlayers("TvT Event: Event canceled due to lack of Participation.", true);
- + System.out.println("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event.");
- + continue;
- + }
- + Broadcast.announceToOnlinePlayers("TvT Event: Registration closed!", true);
- + TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting participants to an arena in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
- +
- + waiter(Config.TVT_EVENT_RUNNING_TIME * 60); // in config given as minutes
- + Broadcast.announceToOnlinePlayers(TvTEvent.calculateRewards(), true);
- + TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting back to the registration npc in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
- + TvTEvent.stopFight();
- + }
- + }
- +
- + /**
- + * This method waits for a period time delay
- + * @param seconds
- + */
- + void waiter(int seconds)
- + {
- + while (seconds > 1)
- + {
- + seconds--; // here because we don't want to see two time announce at the same time
- +
- + if (TvTEvent.isParticipating() || TvTEvent.isStarted())
- + {
- + switch (seconds)
- + {
- + case 3600: // 1 hour left
- + if (TvTEvent.isParticipating())
- + Broadcast.announceToOnlinePlayers("TvT Event: " + seconds / 60 / 60 + " hour(s) umtil registration is closed!", true);
- + else if (TvTEvent.isStarted())
- + TvTEvent.sysMsgToAllParticipants("TvT Event: " + seconds / 60 / 60 + " hour(s) until event is finished!");
- +
- + break;
- + case 1800: // 30 minutes left
- + case 900: // 15 minutes left
- + case 600: // 10 minutes left
- + case 300: // 5 minutes left
- + case 240: // 4 minutes left
- + case 180: // 3 minutes left
- + case 120: // 2 minutes left
- + case 60: // 1 minute left
- + if (TvTEvent.isParticipating())
- + Broadcast.announceToOnlinePlayers("TvT Event: " + seconds / 60 + " minute(s) until registration is closed!", true);
- + else if (TvTEvent.isStarted())
- + TvTEvent.sysMsgToAllParticipants("TvT Event: " + seconds / 60 + " minute(s) until the event is finished!");
- +
- + break;
- + case 30: // 30 seconds left
- + /**
- + * case 15: // 15 seconds left
- + * case 10: // 10 seconds left
- + */
- + case 5: // 5 seconds left
- +
- + /**
- + *
- + * case 4: // 4 seconds left
- + * case 3: // 3 seconds left
- + * case 2: // 2 seconds left
- + * case 1: // 1 seconds left
- + */
- + if (TvTEvent.isParticipating())
- + Broadcast.announceToOnlinePlayers("TvT Event: " + seconds + " second(s) until registration is closed!", true);
- + else if (TvTEvent.isStarted())
- + TvTEvent.sysMsgToAllParticipants("TvT Event: " + seconds + " second(s) until the event is finished!");
- +
- + break;
- + }
- + }
- +
- + long oneSecWaitStart = System.currentTimeMillis();
- +
- + while (oneSecWaitStart + 1000L > System.currentTimeMillis())
- + {
- + try
- + {
- + Thread.sleep(1);
- + }
- + catch (InterruptedException ie)
- + {}
- + }
- + }
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (revision 7)
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (working copy)
- @@ -22,9 +22,11 @@
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
- import net.sf.l2j.gameserver.model.entity.Castle;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.holder.IntIntHolder;
- import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- public class ScrollOfResurrection implements IItemHandler
- {
- @@ -40,7 +42,11 @@
- activeChar.sendPacket(SystemMessageId.CANT_MOVE_SITTING);
- return;
- }
- -
- + if (!TvTEvent.onEscapeUse(activeChar.getName()))
- + {
- + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- if (activeChar.isMovementDisabled())
- return;
- Index: java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (revision 7)
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (working copy)
- @@ -33,6 +33,7 @@
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
- import net.sf.l2j.gameserver.model.actor.instance.L2XmassTreeInstance;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- import net.sf.l2j.gameserver.model.item.SummonItem;
- import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- @@ -66,6 +67,9 @@
- if (activeChar.isAllSkillsDisabled() || activeChar.isCastingNow())
- return;
- + if (!TvTEvent.onItemSummon(playable.getName()))
- + return;
- +
- final SummonItem sitem = SummonItemsData.getInstance().getSummonItem(item.getItemId());
- if ((activeChar.getPet() != null || activeChar.isMounted()) && sitem.isPetSummon())
- Index: java/net/sf/l2j/gameserver/model/entity/TvTEventTeleporter.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/TvTEventTeleporter.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/entity/TvTEventTeleporter.java (working copy)
- @@ -0,0 +1,99 @@
- +/*
- + * This program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * [URL]http://www.gnu.org/copyleft/gpl.html[/URL]
- + */
- +package net.sf.l2j.gameserver.model.entity;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.ThreadPoolManager;
- +import net.sf.l2j.gameserver.model.L2Effect;
- +import net.sf.l2j.gameserver.model.actor.L2Summon;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class TvTEventTeleporter implements Runnable
- +{
- + /** The instance of the player to teleport */
- + private L2PcInstance _playerInstance;
- + /** Coordinates of the spot to teleport to */
- + private int[] _coordinates = new int[3];
- + /** Admin removed this player from event */
- + private boolean _adminRemove;
- +
- + /**
- + * Initialize the teleporter and start the delayed task
- + * @param playerInstance
- + * @param coordinates
- + * @param fastSchedule
- + * @param adminRemove
- + */
- + public TvTEventTeleporter(L2PcInstance playerInstance, int[] coordinates, boolean fastSchedule, boolean adminRemove)
- + {
- + _playerInstance = playerInstance;
- + _coordinates = coordinates;
- + _adminRemove = adminRemove;
- +
- + // in config as seconds
- + long delay = (TvTEvent.isStarted() ? Config.TVT_EVENT_RESPAWN_TELEPORT_DELAY : Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY) * 1000;
- +
- + if (fastSchedule)
- + delay = 0;
- +
- + ThreadPoolManager.getInstance().scheduleGeneral(this, delay);
- + }
- +
- + /**
- + * The task method to teleport the player<br>
- + * 1. Unsummon pet if there is one
- + * 2. Remove all effects
- + * 3. Revive and full heal the player
- + * 4. Teleport the player
- + * 5. Broadcast status and user info
- + *
- + * @see java.lang.Runnable#run()
- + */
- + @Override
- + public void run()
- + {
- + if (_playerInstance == null)
- + return;
- +
- + L2Summon summon = _playerInstance.getPet();
- +
- + if (summon != null)
- + summon.unSummon(_playerInstance);
- +
- + for (L2Effect effect : _playerInstance.getAllEffects())
- + {
- + if (effect != null)
- + effect.exit();
- + }
- +
- + _playerInstance.doRevive();
- + _playerInstance.setCurrentCp(_playerInstance.getMaxCp());
- + _playerInstance.setCurrentHp(_playerInstance.getMaxHp());
- + _playerInstance.setCurrentMp(_playerInstance.getMaxMp());
- + _playerInstance.teleToLocation(_coordinates[0], _coordinates[1], _coordinates[2], 0);
- +
- + if (TvTEvent.isStarted() && !_adminRemove)
- + _playerInstance.setTeam(TvTEvent.getParticipantTeamId(_playerInstance.getName())+1);
- + else
- + _playerInstance.setTeam(0);
- +
- + _playerInstance.broadcastStatusUpdate();
- + _playerInstance.broadcastUserInfo();
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java (working copy)
- @@ -0,0 +1,107 @@
- +/*
- + * This program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * [URL]http://www.gnu.org/copyleft/gpl.html[/URL]
- + */
- +package net.sf.l2j.gameserver.handler.admincommandhandlers;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
- +import net.sf.l2j.gameserver.model.L2Object;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- +import net.sf.l2j.gameserver.model.entity.TvTEventTeleporter;
- +import net.sf.l2j.gameserver.util.GMAudit;
- +
- +/**
- + * @author FBIagent
- + *
- + * The class handles administrator commands for the TvT Engine which was first implemented by FBIagent
- + */
- +public class AdminTvTEvent implements IAdminCommandHandler
- +{
- + private static final String[] ADMIN_COMMANDS = {"admin_tvt_add", "admin_tvt_remove"};
- +
- + @Override
- + public boolean useAdminCommand(String command, L2PcInstance adminInstance)
- + {
- +
- + GMAudit.auditGMAction(adminInstance.getName(), command, (adminInstance.getTarget() != null ? adminInstance.getTarget().getName() : "no-target"), "");
- +
- + if (command.equals("admin_tvt_add"))
- + {
- + L2Object target = adminInstance.getTarget();
- +
- + if (target == null || !(target instanceof L2PcInstance))
- + {
- + adminInstance.sendMessage("You should select a player!");
- + return true;
- + }
- +
- + add(adminInstance, (L2PcInstance)target);
- + }
- + else if (command.equals("admin_tvt_remove"))
- + {
- + L2Object target = adminInstance.getTarget();
- +
- + if (target == null || !(target instanceof L2PcInstance))
- + {
- + adminInstance.sendMessage("You should select a player!");
- + return true;
- + }
- +
- + remove(adminInstance, (L2PcInstance)target);
- + }
- +
- + return true;
- + }
- +
- + @Override
- + public String[] getAdminCommandList()
- + {
- + return ADMIN_COMMANDS;
- + }
- +
- + private static void add(L2PcInstance adminInstance, L2PcInstance playerInstance)
- + {
- + if (TvTEvent.isPlayerParticipant(playerInstance.getName()))
- + {
- + adminInstance.sendMessage("Player already participated in the event!");
- + return;
- + }
- +
- + if (!TvTEvent.addParticipant(playerInstance))
- + {
- + adminInstance.sendMessage("Player instance could not be added, it seems to be null!");
- + return;
- + }
- +
- + if (TvTEvent.isStarted())
- + // we don't need to check return value of TvTEvent.getParticipantTeamCoordinates() for null, TvTEvent.addParticipant() returned true so target is in event
- + new TvTEventTeleporter(playerInstance, TvTEvent.getParticipantTeamCoordinates(playerInstance.getName()), true, false);
- + }
- +
- + private static void remove(L2PcInstance adminInstance, L2PcInstance playerInstance)
- + {
- + if (!TvTEvent.removeParticipant(playerInstance.getName()))
- + {
- + adminInstance.sendMessage("Player is not part of the event!");
- + return;
- + }
- +
- + new TvTEventTeleporter(playerInstance, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, true, true);
- + }
- +}
- Index: config/custom_events.properties
- ===================================================================
- --- config/custom_events.properties (revision 0)
- +++ config/custom_events.properties (working copy)
- @@ -0,0 +1,41 @@
- +#---------------------------------------------------------------
- +# Team vs. Team Event Engine -
- +#---------------------------------------------------------------
- +# enable TvTEvent
- +TvTEventEnabled = True
- +# Time Between TvT events (in minutes, 300 = 5 hours)
- +TvTEventInterval = 300
- +# Registration timer (in minutes) from start of event.
- +TvTEventParticipationTime = 7
- +# Event running time, in minutes
- +TvTEventRunningTime = 10
- +# TvT Event NPC Details (create a custom npc of type L2TvTEventNpc)
- +TvTEventParticipationNpcId = 70010
- +TvTEventParticipationNpcCoordinates = 83425,148585,-3406
- +# Minimum amount of players allowed in each team
- +TvTEventMinPlayersInTeams = 1
- +TvTEventMaxPlayersInTeams = 20
- +# Level rules
- +TvTEventMinPlayerLevel = 1
- +TvTEventMaxPlayerLevel = 80
- +# Teleport delay Timers (in seconds)
- +TvTEventRespawnTeleportDelay = 10
- +TvTEventStartLeaveTeleportDelay = 10
- +# First Team Details (name, start and death x,y,z tp point)
- +TvTEventTeam1Name = Melyni
- +TvTEventTeam1Coordinates = 148695,46725,-3414
- +# Second Team Details (name, start and death x,y,z tp point)
- +TvTEventTeam2Name = Raudoni
- +TvTEventTeam2Coordinates = 149999,46728,-3414
- +# Reward for winning team
- +# itemId,amount;itemId,amount;itemId,amount;...
- +# no ";" at the start or end
- +TvTEventReward = 57,100000;5575,1000
- +# TvTEvent Rules
- +TvTEventTargetTeamMembersAllowed = true
- +TvTEventPotionsAllowed = false
- +TvTEventSummonByItemAllowed = false
- +# Door id's to close/open on start/end
- +# ex.: 1;2;3;4;5;6
- +# no ";" at the start or end
- +TvTEventDoorsCloseOpenOnStartEnd =
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 7)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
- @@ -16,6 +16,7 @@
- import net.sf.l2j.gameserver.instancemanager.SevenSignsFestival;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.zone.ZoneId;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- @@ -70,6 +71,7 @@
- }
- player.removeFromBossZone();
- + TvTEvent.onLogout(player);
- player.logout();
- }
- }
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/entity/TvTEventTeam.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/TvTEventTeam.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/entity/TvTEventTeam.java (working copy)
- @@ -0,0 +1,204 @@
- +/*
- + * This program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * [URL]http://www.gnu.org/copyleft/gpl.html[/URL]
- + */
- +package net.sf.l2j.gameserver.model.entity;
- +
- +import java.util.Map;
- +import java.util.Vector;
- +
- +import java.util.HashMap;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + * @author FBIagent
- + */
- +public class TvTEventTeam
- +{
- + /** The name of the team<br> */
- + private String _name;
- + /** The team spot coordinated<br> */
- + private int[] _coordinates = new int[3];
- + /** The points of the team<br> */
- + private short _points;
- + /** Name and instance of all participated players in FastMap<br> */
- + private Map<String, L2PcInstance> _participatedPlayers = new HashMap<String, L2PcInstance>();
- + /** Name of all participated players in Vector<br> */
- + private Vector<String> _participatedPlayerNames = new Vector<String>();
- +
- + /**
- + * C'tor initialize the team
- + * @param name
- + * @param coordinates
- + */
- + public TvTEventTeam(String name, int[] coordinates)
- + {
- + _name = name;
- + _coordinates = coordinates;
- + _points = 0;
- + }
- +
- + /**
- + * Adds a player to the team
- + *
- + * @param playerInstance
- + * @return boolean
- + */
- + public boolean addPlayer(L2PcInstance playerInstance)
- + {
- + if (playerInstance == null)
- + return false;
- +
- + synchronized (_participatedPlayers)
- + {
- + String playerName = playerInstance.getName();
- +
- + _participatedPlayers.put(playerName, playerInstance);
- +
- + if (!_participatedPlayerNames.contains(playerName))
- + _participatedPlayerNames.add(playerName);
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Removes a player from the team
- + * @param playerName
- + */
- + public void removePlayer(String playerName)
- + {
- + synchronized (_participatedPlayers)
- + {
- + _participatedPlayers.remove(playerName);
- + _participatedPlayerNames.remove(playerName);
- + }
- + }
- +
- + /**
- + * Increases the points of the team<br>
- + */
- + public void increasePoints()
- + {
- + _points++;
- + }
- +
- + /**
- + * Cleanup the team and make it ready for adding players again<br>
- + */
- + public void cleanMe()
- + {
- + _participatedPlayers.clear();
- + _participatedPlayerNames.clear();
- + _participatedPlayers = new HashMap<String, L2PcInstance>();
- + _participatedPlayerNames = new Vector<String>();
- + _points = 0;
- + }
- +
- + /**
- + * Is given player in this team?
- + * @param playerName
- + * @return boolean
- + */
- + public boolean containsPlayer(String playerName)
- + {
- + boolean containsPlayer;
- +
- + synchronized (_participatedPlayers)
- + {
- + containsPlayer = _participatedPlayerNames.contains(playerName);
- + }
- +
- + return containsPlayer;
- + }
- +
- + /**
- + * Returns the name of the team
- + * @return String
- + */
- + public String getName()
- + {
- + return _name;
- + }
- +
- + /**
- + * Returns the coordinates of the team spot
- + * @return int[]
- + */
- + public int[] getCoordinates()
- + {
- + return _coordinates;
- + }
- +
- + /**
- + * Returns the points of the team
- + * @return short
- + */
- + public short getPoints()
- + {
- + return _points;
- + }
- +
- + /**
- + * Returns name and instance of all participated players in FastMap
- + * @return Map<String, L2PcInstance>
- + */
- + public Map<String, L2PcInstance> getParticipatedPlayers()
- + {
- + Map<String, L2PcInstance> participatedPlayers = null;
- +
- + synchronized (_participatedPlayers)
- + {
- + participatedPlayers = _participatedPlayers;
- + }
- +
- + return participatedPlayers;
- + }
- +
- + /**
- + * Returns name of all participated players in Vector
- + * @return Vector<String>
- + */
- + public Vector<String> getParticipatedPlayerNames()
- + {
- + Vector<String> participatedPlayerNames = null;
- +
- + synchronized (_participatedPlayers)
- + {
- + participatedPlayerNames = _participatedPlayerNames;
- + }
- +
- + return participatedPlayerNames;
- + }
- +
- + /**
- + * Returns player count of this team
- + * @return int
- + */
- + public int getParticipatedPlayerCount()
- + {
- + int participatedPlayerCount;
- +
- + synchronized (_participatedPlayers)
- + {
- + participatedPlayerCount = _participatedPlayers.size();
- + }
- +
- + return participatedPlayerCount;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 7)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -123,6 +123,7 @@
- import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
- import net.sf.l2j.gameserver.model.entity.Hero;
- import net.sf.l2j.gameserver.model.entity.Siege;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.holder.IntIntHolder;
- import net.sf.l2j.gameserver.model.holder.SkillUseHolder;
- import net.sf.l2j.gameserver.model.item.Henna;
- @@ -391,6 +392,7 @@
- private boolean _isInWater;
- private boolean _isIn7sDungeon;
- + public boolean atEvent = false;
- private PunishLevel _punishLevel = PunishLevel.NONE;
- private long _punishTimer;
- @@ -3093,6 +3095,11 @@
- @Override
- public void onAction(L2PcInstance player)
- {
- + if (!TvTEvent.onAction(player.getName(), getName()))
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- // Set the target of the player
- if (player.getTarget() != this)
- player.setTarget(this);
- @@ -3864,6 +3871,8 @@
- stopFakeDeath(true);
- }
- + TvTEvent.onKill(killer, this);
- +
- if (killer != null)
- {
- L2PcInstance pk = killer.getActingPlayer();
- @@ -3940,7 +3949,10 @@
- return true;
- }
- -
- + public boolean isInFunEvent()
- + {
- + return (atEvent ||(TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getName())) && !isGM());
- + }
- private void onDieDropItem(L2Character killer)
- {
- if (killer == null)
- @@ -4186,7 +4198,7 @@
- // Calculate the Experience loss
- long lostExp = 0;
- - if (lvl < Experience.MAX_LEVEL)
- + if (!atEvent && lvl < Experience.MAX_LEVEL)
- lostExp = Math.round((getStat().getExpForLevel(lvl + 1) - getStat().getExpForLevel(lvl)) * percentLost / 100);
- else
- lostExp = Math.round((getStat().getExpForLevel(Experience.MAX_LEVEL) - getStat().getExpForLevel(Experience.MAX_LEVEL - 1)) * percentLost / 100);
- Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (revision 7)
- +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (working copy)
- @@ -19,7 +19,9 @@
- import net.sf.l2j.gameserver.instancemanager.ZoneManager;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.model.zone.type.L2BossZone;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
- public class Escape implements IUserCommandHandler
- @@ -32,6 +34,11 @@
- @Override
- public boolean useUserCommand(int id, L2PcInstance activeChar)
- {
- + if (!TvTEvent.onEscapeUse(activeChar.getName()))
- + {
- + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- + return false;
- + }
- if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || ZoneManager.getInstance().getZone(activeChar, L2BossZone.class) != null)
- {
- activeChar.sendPacket(SystemMessageId.NO_UNSTUCK_PLEASE_SEND_PETITION);
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java (revision 7)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java (working copy)
- @@ -21,6 +21,7 @@
- import net.sf.l2j.gameserver.datatables.MultisellData;
- import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- import net.sf.l2j.gameserver.model.entity.Hero;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.olympiad.CompetitionType;
- import net.sf.l2j.gameserver.model.olympiad.Olympiad;
- import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
- @@ -190,6 +191,12 @@
- }
- else if (command.startsWith("Olympiad"))
- {
- + if (TvTEvent.isParticipating())
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + player.sendMessage("You can't do that while in a event");
- + return;
- + }
- int val = Integer.parseInt(command.substring(9, 10));
- final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
- @@ -225,6 +232,12 @@
- break;
- case 3: // Spectator overview
- + if (TvTEvent.isParticipating() || TvTEvent.isStarting() || TvTEvent.isStarted())
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + player.sendMessage("You can't do that while in a event");
- + return;
- + }
- html.setFile(Olympiad.OLYMPIAD_HTML_PATH + "olympiad_observe_list.htm");
- int i = 0;
- ### Eclipse Workspace Patch 1.0
- #P datapack_friends
- Index: data/xml/npcs/70000-70099.xml
- ===================================================================
- --- data/xml/npcs/70000-70099.xml (revision 0)
- +++ data/xml/npcs/70000-70099.xml (working copy)
- @@ -0,0 +1,39 @@
- +<?xml version="1.0" encoding="utf-8"?>
- +<list>
- +<npc id="70010" idTemplate="31280" name="Sir Bastian" title="Event Manager">
- + <set name="level" val="70"/>
- + <set name="radius" val="8"/>
- + <set name="height" val="23"/>
- + <set name="rHand" val="0"/>
- + <set name="lHand" val="0"/>
- + <set name="type" val="L2TvTEventNpc"/>
- + <set name="exp" val="0"/>
- + <set name="sp" val="0"/>
- + <set name="hp" val="2444.46819"/>
- + <set name="mp" val="1345.8"/>
- + <set name="hpRegen" val="7.5"/>
- + <set name="mpRegen" val="2.7"/>
- + <set name="pAtk" val="688.86373"/>
- + <set name="pDef" val="295.91597"/>
- + <set name="mAtk" val="470.40463"/>
- + <set name="mDef" val="216.53847"/>
- + <set name="crit" val="4"/>
- + <set name="atkSpd" val="253"/>
- + <set name="str" val="40"/>
- + <set name="int" val="21"/>
- + <set name="dex" val="30"/>
- + <set name="wit" val="20"/>
- + <set name="con" val="43"/>
- + <set name="men" val="20"/>
- + <set name="corpseTime" val="7"/>
- + <set name="walkSpd" val="50"/>
- + <set name="runSpd" val="120"/>
- + <set name="dropHerbGroup" val="0"/>
- + <set name="attackRange" val="40"/>
- + <ai type="DEFAULT" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
- + <skills>
- + <skill id="4045" level="1"/>
- + <skill id="4416" level="14"/>
- + </skills>
- + </npc>
- +</list>
- \ No newline at end of file
- Index: data/html/mods/TvTEventStatus.htm
- ===================================================================
- --- data/html/mods/TvTEventStatus.htm (revision 0)
- +++ data/html/mods/TvTEventStatus.htm (working copy)
- @@ -0,0 +1,5 @@
- +<html><title>TvT Event</title><body>
- +Status:<br><br><center>
- +%team1name% with %team1playercount% players and %team1points% points.<br1>
- +%team2name% with %team2playercount% players and %team2points% points.<br>
- +</center></body></html>
- \ No newline at end of file
- Index: data/html/mods/TvTEventRemoveParticipation.htm
- ===================================================================
- --- data/html/mods/TvTEventRemoveParticipation.htm (revision 0)
- +++ data/html/mods/TvTEventRemoveParticipation.htm (working copy)
- @@ -0,0 +1,6 @@
- +<html><title>TvT Event</title><body>
- +Cancel Registration yourself for TvT Event:<br1>
- +You are already registered for this event. Do you wish to cancel your participation in this Event?<br><br><center>
- +<button value="Yes" action="bypass -h npc_%objectId%_tvt_event_remove_participation" width=40 height=15 back="sek.cbui94" fore="sek.cbui92">
- +<button value="No" action="bypass -h npc_%objectId%_Close" width=40 height=15 back="sek.cbui94" fore="sek.cbui92">
- +</center></body></html>
- \ No newline at end of file
- Index: data/html/mods/TvTEventParticipation.htm
- ===================================================================
- --- data/html/mods/TvTEventParticipation.htm (revision 0)
- +++ data/html/mods/TvTEventParticipation.htm (working copy)
- @@ -0,0 +1,7 @@
- +<html><title>TvT Event</title><body>
- +Registration for TvT Event:<br><br><center>
- +%team1name% (%team1playercount% players in)<br1>
- +%team2name% (%team2playercount% players in)<br>
- +<button value="Participate" action="bypass -h npc_%objectId%_tvt_event_participation" width=50 height=15 back="sek.cbui94" fore="sek.cbui92">
- +<button value="Close" action="bypass -h npc_%objectId%_Close" width=50 height=15 back="sek.cbui94" fore="sek.cbui92">
- +</center></body></html>
Advertisement
Add Comment
Please, Sign In to add comment