Advertisement
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 (revision 0)
- @@ -0,0 +1,773 @@
- +/*
- + * 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.instance.L2NpcInstance;
- +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.templates.chars.L2NpcTemplate;
- +import net.sf.l2j.util.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;
- + /** The spawn of the participation npc<br> */
- + private static L2Spawn _npcSpawn = null;
- + /** the npc instance of the participation npc<br> */
- + private static L2NpcInstance _lastNpcSpawn = null;
- +
- + /**
- + * 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 L2NpcTemplate 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()
- + {
- + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(Config.TVT_EVENT_PARTICIPATION_NPC_ID);
- +
- + if (tmpl == null)
- + {
- + System.out.println("TvTEventEngine[TvTEvent.startParticipation()]: L2NpcTemplate is a NullPointer -> Invalid npc id in configs?");
- + return false;
- + }
- +
- + try
- + {
- + _npcSpawn = new L2Spawn(tmpl);
- +
- + _npcSpawn.setLocx(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0]);
- + _npcSpawn.setLocy(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1]);
- + _npcSpawn.setLocz(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
- + _npcSpawn.getAmount();
- + _npcSpawn.setHeading(0);
- + _npcSpawn.setRespawnDelay(1);
- + // later no need to delete spawn from db, we don't store it (false)
- + SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
- + _npcSpawn.init();
- + _lastNpcSpawn = (L2NpcInstance) _npcSpawn.getLastSpawn();
- + _lastNpcSpawn.setCurrentHp(_lastNpcSpawn.getMaxHp());
- + _lastNpcSpawn.setTitle("TvT Event Participation");
- + _lastNpcSpawn.isAggressive();
- + _lastNpcSpawn.decayMe();
- + _lastNpcSpawn.spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
- + _lastNpcSpawn.broadcastPacket(new MagicSkillUse(_lastNpcSpawn, _lastNpcSpawn, 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();
- + unSpawnNpc();
- + 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);
- + unSpawnNpc();
- + 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();
- + }
- + }
- +
- + /**
- + * UnSpawns the TvTEvent npc
- + */
- + private static void unSpawnNpc()
- + {
- + _lastNpcSpawn.deleteMe();
- + _npcSpawn.stopRespawn();
- + _npcSpawn = null;
- + _lastNpcSpawn = null;
- + }
- +
- + /**
- + * 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()};
- + }
- +}
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- 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 (revision 0)
- @@ -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;
- + }
- +}
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- 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 (revision 0)
- @@ -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();
- + }
- +}
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- 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 (revision 0)
- @@ -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.Announcements;
- +import net.sf.l2j.gameserver.ThreadPoolManager;
- +
- +/**
- + * @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())
- + {
- + Announcements.announceToAll("TvT Event: Event was canceled.");
- + System.out.println("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation.");
- + continue;
- + }
- + Announcements.announceToAll("TvT Event: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s).");
- +
- + waiter(Config.TVT_EVENT_PARTICIPATION_TIME * 60); // in config given as minutes
- +
- + if (!TvTEvent.startFight())
- + {
- + Announcements.announceToAll("TvT Event: Event canceled due to lack of Participation.");
- + System.out.println("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event.");
- + continue;
- + }
- + Announcements.announceToAll("TvT Event: Registration closed!");
- + 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
- + Announcements.announceToAll(TvTEvent.calculateRewards());
- + 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())
- + Announcements.announceToAll("TvT Event: " + seconds / 60 / 60 + " hour(s) umtil registration is closed!");
- + 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())
- + Announcements.announceToAll("TvT Event: " + seconds / 60 + " minute(s) until registration is closed!");
- + 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())
- + Announcements.announceToAll("TvT Event: " + seconds + " second(s) until registration is closed!");
- + 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)
- + {}
- + }
- + }
- + }
- +}
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 2)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -126,6 +126,7 @@
- import net.sf.l2j.gameserver.model.entity.Duel;
- 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.itemcontainer.Inventory;
- import net.sf.l2j.gameserver.model.itemcontainer.ItemContainer;
- import net.sf.l2j.gameserver.model.itemcontainer.PcFreight;
- @@ -396,6 +397,7 @@
- private boolean _isInWater;
- private boolean _isIn7sDungeon = false;
- + public boolean atEvent = false;
- private PunishLevel _punishLevel = PunishLevel.NONE;
- private long _punishTimer = 0;
- @@ -3301,6 +3303,12 @@
- @Override
- public void onAction(L2PcInstance player)
- {
- + if (!TvTEvent.onAction(player.getName(), getName()))
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- // Check if the player already target this L2PcInstance
- if (player.getTarget() != this)
- {
- @@ -4060,6 +4068,8 @@
- stopFakeDeath(true);
- }
- + TvTEvent.onKill(killer, this);
- +
- if (killer != null)
- {
- L2PcInstance pk = killer.getActingPlayer();
- @@ -4216,6 +4226,11 @@
- }
- }
- + public boolean isInFunEvent()
- + {
- + return (atEvent ||(TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getName())) && !isGM());
- + }
- +
- private void onDieUpdateKarma()
- {
- // Karma lose for server that does not allow delevel
- @@ -4471,7 +4486,8 @@
- // Calculate the Experience loss
- long lostExp = 0;
- - if (lvl < Experience.MAX_LEVEL)
- + if (!atEvent)
- + if (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);
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (working copy)
- @@ -25,6 +25,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;
- @@ -68,6 +70,13 @@
- return;
- }
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- +
- for (L2Character cha : targetToRes)
- {
- if (activeChar instanceof L2PcInstance)
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (working copy)
- @@ -35,6 +35,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.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.MagicSkillLaunched;
- import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
- @@ -52,6 +53,9 @@
- if (!(playable instanceof L2PcInstance))
- return;
- + if (!TvTEvent.onItemSummon(playable.getName()))
- + return;
- +
- final L2PcInstance activeChar = (L2PcInstance) playable;
- if (activeChar.isSitting())
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java (revision 2)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java (working copy)
- @@ -19,6 +19,7 @@
- import net.sf.l2j.gameserver.model.L2ItemInstance;
- import net.sf.l2j.gameserver.model.L2Multisell;
- 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;
- @@ -208,6 +209,13 @@
- }
- 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));
- NpcHtmlMessage reply = new NpcHtmlMessage(getObjectId());
- @@ -243,6 +251,14 @@
- 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;
- + }
- +
- StringBuilder list = new StringBuilder(2000);
- OlympiadGameTask task;
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java (revision 2)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java (working copy)
- @@ -32,6 +32,7 @@
- import net.sf.l2j.gameserver.model.base.PlayerClass;
- import net.sf.l2j.gameserver.model.base.SubClass;
- import net.sf.l2j.gameserver.model.entity.Siege;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.quest.QuestState;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.AcquireSkillList;
- @@ -163,6 +164,13 @@
- }
- else if (command.startsWith("Subclass"))
- {
- +
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
- + {
- + player.sendMessage("You can not change sub class while registered at TvT");
- + return;
- + }
- +
- // Subclasses may not be changed while a skill is in use.
- if (player.isCastingNow() || player.isAllSkillsDisabled())
- {
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (working copy)
- @@ -18,10 +18,12 @@
- import net.sf.l2j.gameserver.SevenSignsFestival;
- import net.sf.l2j.gameserver.model.L2Party;
- 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;
- @@ -47,6 +49,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.isLocked())
- {
- sendPacket(RestartResponse.valueOf(false));
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/network/serverpackets/Die.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/serverpackets/Die.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/serverpackets/Die.java (working copy)
- @@ -32,6 +32,7 @@
- private L2AccessLevel _access = AccessLevels._userAccessLevel;
- private L2Clan _clan;
- L2Character _activeChar;
- + private boolean _funEvent;
- public Die(L2Character cha)
- {
- @@ -41,6 +42,8 @@
- L2PcInstance player = (L2PcInstance) cha;
- _access = player.getAccessLevel();
- _clan = player.getClan();
- + _funEvent = !player.isInFunEvent();
- +
- }
- _charObjId = cha.getObjectId();
- @@ -58,9 +61,9 @@
- writeC(0x06);
- writeD(_charObjId);
- - writeD(0x01); // to nearest village
- + writeD(_funEvent ? 0x01 : 0); // 6d 00 00 00 00 - to nearest village
- - if (_clan != null)
- + if (_funEvent && _clan != null)
- {
- L2SiegeClan siegeClan = null;
- boolean isInDefense = false;
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/Config.java
- ===================================================================
- --- java/net/sf/l2j/Config.java (revision 2)
- +++ java/net/sf/l2j/Config.java (working copy)
- @@ -206,6 +206,29 @@
- public static boolean WEDDING_SAMESEX;
- public static boolean WEDDING_FORMALWEAR;
- + /** Team vs. Team Event Engine */
- + 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;
- +
- /** Lottery */
- public static int ALT_LOTTERY_PRIZE;
- public static int ALT_LOTTERY_TICKET_PRICE;
- @@ -870,6 +893,111 @@
- ALT_FISH_CHAMPIONSHIP_REWARD_4 = events.getProperty("AltFishChampionshipReward4", 200000);
- ALT_FISH_CHAMPIONSHIP_REWARD_5 = events.getProperty("AltFishChampionshipReward5", 100000);
- + 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 + "\"");
- + }
- + }
- + }
- + }
- + }
- + }
- +
- +
- // FloodProtector
- ExProperties security = load(FLOOD_PROTECTOR_FILE);
- loadFloodProtectorConfig(security, FLOOD_PROTECTOR_ROLL_DICE, "RollDice", "42");
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 2)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -92,6 +91,7 @@
- import net.sf.l2j.gameserver.model.PartyMatchWaitingList;
- import net.sf.l2j.gameserver.model.entity.Castle;
- 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.network.L2GameClient;
- @@ -237,8 +237,8 @@
- Olympiad.getInstance();
- Hero.getInstance();
- - Util.printSection("Four Sepulchers");
- - FourSepulchersManager.getInstance().init();
- + Util.printSection("TvT Event");
- + TvTManager.getInstance();
- Util.printSection("Quests & Scripts");
- QuestManager.getInstance();
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (working copy)
- @@ -23,7 +23,9 @@
- 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.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- import net.sf.l2j.gameserver.skills.SkillHolder;
- public class ScrollOfResurrection implements IItemHandler
- @@ -41,6 +43,12 @@
- return;
- }
- + if (!TvTEvent.onEscapeUse(activeChar.getName()))
- + {
- + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- if (activeChar.isMovementDisabled())
- return;
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (working copy)
- @@ -25,6 +25,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;
- @@ -68,6 +70,13 @@
- return;
- }
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- +
- for (L2Character cha : targetToRes)
- {
- if (activeChar instanceof L2PcInstance)
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java (revision 2)
- +++ 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;
- @@ -46,6 +48,12 @@
- if (!L2PcInstance.checkSummonerStatus(activePlayer))
- return;
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(activePlayer.getName()))
- + {
- + activePlayer.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- for (L2Object obj : targets)
- {
- if (!(obj instanceof L2Character))
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (working copy)
- @@ -18,7 +18,9 @@
- import net.sf.l2j.gameserver.handler.IUserCommandHandler;
- import net.sf.l2j.gameserver.instancemanager.GrandBossManager;
- 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.PlaySound;
- public class Escape implements IUserCommandHandler
- @@ -31,6 +33,12 @@
- @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() || GrandBossManager.isInBossZone(activeChar))
- {
- activeChar.sendMessage("Your current state doesn't allow you to use the /unstuck command.");
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- 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 (revision 0)
- @@ -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.templates.chars.L2NpcTemplate;
- +
- +public class L2TvTEventNpcInstance extends L2NpcInstance
- +{
- + public L2TvTEventNpcInstance(int objectId, L2NpcTemplate 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);
- + }
- +}
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java (revision 2)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java (working copy)
- @@ -27,6 +27,7 @@
- import net.sf.l2j.gameserver.model.L2World;
- import net.sf.l2j.gameserver.model.actor.L2Npc;
- import net.sf.l2j.gameserver.model.entity.Couple;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- import net.sf.l2j.gameserver.network.serverpackets.ConfirmDlg;
- import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
- @@ -143,7 +144,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;
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (revision 2)
- +++ 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;
- @@ -259,6 +261,13 @@
- 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);
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
- @@ -34,6 +34,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.quest.Quest;
- import net.sf.l2j.gameserver.model.quest.QuestState;
- @@ -229,6 +230,8 @@
- // Attacker or spectator logging into a siege zone will be ported at town.
- if (!activeChar.isGM() && (!activeChar.isInSiege() || activeChar.getSiegeState() < 2) && activeChar.isInsideZone(ZoneId.SIEGE))
- activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
- +
- + TvTEvent.onLogin(activeChar);
- }
- private static void engage(L2PcInstance cha)
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
- @@ -18,6 +18,7 @@
- import net.sf.l2j.gameserver.SevenSignsFestival;
- import net.sf.l2j.gameserver.model.L2Party;
- 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;
- @@ -88,6 +89,7 @@
- // Remove player from Boss Zone
- player.removeFromBossZone();
- + TvTEvent.onLogout(player);
- player.logout();
- }
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- 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 (revision 0)
- @@ -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);
- + }
- +}
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
- @@ -65,6 +65,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.AdminUnblockIp;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminZone;
- @@ -127,6 +128,7 @@
- registerAdminCommandHandler(new AdminSpawn());
- registerAdminCommandHandler(new AdminTarget());
- registerAdminCommandHandler(new AdminTeleport());
- + registerAdminCommandHandler(new AdminTvTEvent());
- registerAdminCommandHandler(new AdminUnblockIp());
- registerAdminCommandHandler(new AdminZone());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement