Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/config/CustomMods/Events/TvT.ini b/config/CustomMods/Events/TvT.ini
- new file mode 100644
- index 0000000..a217932
- --- /dev/null
- +++ b/config/CustomMods/Events/TvT.ini
- @@ -0,0 +1,63 @@
- +#---------------------------------------------------------------
- +# Team vs. Team Event Engine -
- +#---------------------------------------------------------------
- +# enable TvTEvent
- +TvTEventEnabled = true
- +# Time Between TvT events (in minutes, 300 = 5 hours)
- +TvTEventInterval = 1
- +# Registration timer (in minutes) from start of event.
- +TvTEventParticipationTime = 1
- +
- +# Event running time, in minutes
- +TvTEventRunningTime = 2
- +
- +# TvT Event NPC Details (create a custom npc of type TvTEventNpc)
- +TvTEventParticipationNpcId = 70010
- +TvTEventParticipationNpcCoordinates = 83358,148879,-3405
- +
- +# Minimum amount of players allowed in each team
- +TvTEventMinPlayersInTeams = 1
- +TvTEventMaxPlayersInTeams = 20
- +
- +# Level rules
- +TvTEventMinPlayerLevel = 70
- +TvTEventMaxPlayerLevel = 80
- +
- +# Remove buffs effect
- +TvTEventRemoveBuffs = false
- +
- +# If Enable Players cant be healed
- +TvTHealPlayersEnable = true
- +
- +# If true, gives reward for kills stage without die
- +# Example: Get 3/7/10 kills without die, and you will be rewarded
- +# No more than 1 item!
- +TvTKillsRewardEnable = true
- +TvTKillsReward = 57,500000000
- +
- +# Teleport delay Timers (in seconds)
- +TvTEventRespawnTeleportDelay = 5
- +TvTEventStartLeaveTeleportDelay = 10
- +
- +# Back to Town
- +TvTEventBack = 83013,148595,-3469
- +# First Team Details (name, start and death x,y,z tp point)
- +TvTEventTeam1Name = Good
- +TvTEventTeam1Coordinates = 148695,46725,-3414
- +# Second Team Details (name, start and death x,y,z tp point)
- +TvTEventTeam2Name = Evil
- +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
- diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
- index 2d1316a..9a2f099 100644
- --- a/java/net/sf/l2j/Config.java
- +++ b/java/net/sf/l2j/Config.java
- @@ -48,6 +48,7 @@
- public static final String DONATEMODS = "./config/CustomMods/Donate.ini";
- public static final String PCBANGEVENT = "./config/CustomMods/Events/PcBangEvent.ini";
- public static final String PARTYFARMEVENT = "./config/CustomMods/Events/PartyFarmEvent.ini";
- + public static final String TVTEVENT = "./config/CustomMods/Events/TvT.ini";
- // --------------------------------------------------
- // Clans settings
- // --------------------------------------------------
- @@ -206,6 +207,31 @@
- public static boolean RESTART_BY_TIME_OF_DAY;
- public static int RESTART_SECONDS;
- public static String[] RESTART_INTERVAL_BY_TIME_OF_DAY;
- + 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_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_BACK_COORDINATES = new int[3];
- + 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<>();
- + 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<>();
- + public static byte TVT_EVENT_MIN_LVL;
- + public static byte TVT_EVENT_MAX_LVL;
- + public static boolean TVT_EVENT_REMOVE_BUFFS;
- + public static boolean TVT_EVENT_HEAL_PLAYERS;
- + public static boolean TVT_KILLS_REWARD_ENABLED;
- + public static List<int[]> TVT_KILLS_REWARD = new ArrayList<>();
- // --------------------------------------------------
- // Events settings
- // --------------------------------------------------
- @@ -1628,7 +1654,146 @@
- MAX_BUFFS_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
- STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
- }
- -
- + private static final void loadTvTConfig()
- + {
- + final ExProperties events = initProperties(TVTEVENT);
- + 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);
- + TVT_EVENT_REMOVE_BUFFS = events.getProperty("TvTEventRemoveBuffs", false);
- + TVT_KILLS_REWARD_ENABLED = events.getProperty("TvTKillsRewardEnable", false);
- + TVT_EVENT_HEAL_PLAYERS = events.getProperty("TvTHealPlayersEnable", false);
- +
- + 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_BACK_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + TVT_EVENT_BACK_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + TVT_EVENT_BACK_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 + "\"");
- + }
- + }
- + }
- +
- + propertySplit = events.getProperty("TvTKillsReward", "57,100000").split(";");
- +
- + for (String rewardKills : propertySplit)
- + {
- + String[] rewardSplit = rewardKills.split(",");
- +
- + if (rewardSplit.length != 2)
- + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + rewardKills + "\"");
- + else
- + {
- + try
- + {
- + TVT_KILLS_REWARD.add(new int[]
- + {
- + Integer.valueOf(rewardSplit[0]),
- + Integer.valueOf(rewardSplit[1])
- + });
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!rewardKills.equals(""))
- + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + rewardKills + "\"");
- + }
- + }
- + }
- +
- + 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 + "\"");
- + }
- + }
- + }
- + }
- + }
- + }
- + }
- /**
- * Loads siege settings.
- */
- @@ -1847,7 +2012,7 @@
- loadNewChar();
- // players settings
- loadPlayers();
- -
- + loadTvTConfig();
- // siege settings
- loadSieges();
- diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java
- index da7c459..000e3d6 100644
- --- a/java/net/sf/l2j/gameserver/GameServer.java
- +++ b/java/net/sf/l2j/gameserver/GameServer.java
- @@ -79,6 +79,7 @@
- import net.sf.l2j.gameserver.data.xml.TeleportLocationData;
- import net.sf.l2j.gameserver.data.xml.WalkerRouteData;
- import net.sf.l2j.gameserver.enums.actors.OfflineStoresData;
- +import net.sf.l2j.gameserver.events.TvTEventManager;
- import net.sf.l2j.gameserver.geoengine.GeoEngine;
- import net.sf.l2j.gameserver.handler.AdminCommandHandler;
- import net.sf.l2j.gameserver.handler.ChatHandler;
- @@ -265,7 +266,8 @@
- StringUtil.printSection("Auto Spawns");
- AutoSpawnTable.getInstance();
- -
- + StringUtil.printSection("TvT Event");
- + TvTEventManager.getInstance();
- StringUtil.printSection("Seven Signs");
- SevenSignsManager.getInstance().spawnSevenSignsNPC();
- FestivalOfDarknessManager.getInstance();
- diff --git a/java/net/sf/l2j/gameserver/enums/TeamType.java b/java/net/sf/l2j/gameserver/enums/TeamType.java
- deleted file mode 100644
- index d41cc86..0000000
- --- a/java/net/sf/l2j/gameserver/enums/TeamType.java
- +++ /dev/null
- @@ -1,20 +0,0 @@
- -package net.sf.l2j.gameserver.enums;
- -
- -public enum TeamType
- -{
- - NONE(0),
- - BLUE(1),
- - RED(2);
- -
- - private int _id;
- -
- - private TeamType(int id)
- - {
- - _id = id;
- - }
- -
- - public int getId()
- - {
- - return _id;
- - }
- -}
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/events/TvTEvent.java b/java/net/sf/l2j/gameserver/events/TvTEvent.java
- new file mode 100644
- index 0000000..8ac6a0e
- --- /dev/null
- +++ b/java/net/sf/l2j/gameserver/events/TvTEvent.java
- @@ -0,0 +1,792 @@
- +/*
- + 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.events;
- +
- +import net.sf.l2j.commons.random.Rnd;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.SkillTable;
- +import net.sf.l2j.gameserver.data.sql.SpawnTable;
- +import net.sf.l2j.gameserver.data.xml.DoorData;
- +import net.sf.l2j.gameserver.data.xml.ItemData;
- +import net.sf.l2j.gameserver.data.xml.NpcData;
- +import net.sf.l2j.gameserver.enums.SayType;
- +import net.sf.l2j.gameserver.model.World;
- +import net.sf.l2j.gameserver.model.actor.Creature;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.Summon;
- +import net.sf.l2j.gameserver.model.actor.instance.Door;
- +import net.sf.l2j.gameserver.model.actor.instance.Pet;
- +import net.sf.l2j.gameserver.model.actor.instance.Servitor;
- +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- +import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
- +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
- +import net.sf.l2j.gameserver.model.spawn.Spawn;
- +import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- +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.skills.L2Skill;
- +
- +/**
- + * @author Baggos
- + */
- +public class TvTEvent
- +{
- + enum EventState
- + {
- + INACTIVE,
- + INACTIVATING,
- + PARTICIPATING,
- + STARTING,
- + STARTED,
- + REWARDING
- + }
- +
- + /** Gives Noblesse to players */
- + static L2Skill noblesse = SkillTable.getInstance().getInfo(1323, 1);
- + /**
- + * The teams of the TvTEvent<br>
- + */
- + public static TvTEventTeams[] _teams = new TvTEventTeams[2]; // event only allow max 2 teams
- + private static Spawn _npcSpawn = null;
- + /**
- + * The state of the TvTEvent<br>
- + */
- + public static EventState _state = EventState.INACTIVE;
- +
- + /**
- + * No instance of this class!<br>
- + */
- + private TvTEvent()
- + {
- + }
- +
- + /**
- + * Teams initializing<br>
- + */
- + public static void init()
- + {
- + _teams[0] = new TvTEventTeams(Config.TVT_EVENT_TEAM_1_NAME, Config.TVT_EVENT_TEAM_1_COORDINATES);
- + _teams[1] = new TvTEventTeams(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()
- + {
- + NpcTemplate tmpl = NpcData.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 Spawn(tmpl);
- + _npcSpawn.setLoc(Config.TVT_EVENT_BACK_COORDINATES[0],Config.TVT_EVENT_BACK_COORDINATES[1],Config.TVT_EVENT_BACK_COORDINATES[2], 0);
- + //_npcSpawn.setLocy(Config.TVT_EVENT_BACK_COORDINATES[1]);
- + //_npcSpawn.setLocz(Config.TVT_EVENT_BACK_COORDINATES[2]);
- + //_npcSpawn.getAmount();
- + _npcSpawn.getHeading();
- + _npcSpawn.setRespawnDelay(1);
- +
- + SpawnTable.getInstance().addSpawn(_npcSpawn, false);
- +
- + _npcSpawn.setRespawnState(true);
- + _npcSpawn.doSpawn(false);
- + _npcSpawn.getNpc().isAggressive();
- + _npcSpawn.getNpc().decayMe();
- + _npcSpawn.getNpc().spawnMe(_npcSpawn.getNpc().getX(), _npcSpawn.getNpc().getY(), _npcSpawn.getNpc().getZ());
- +
- + _npcSpawn.getNpc().broadcastPacket(new MagicSkillUse(_npcSpawn.getNpc(), _npcSpawn.getNpc(), 1034, 1, 1, 1));
- + }
- + catch (Exception e)
- + {
- + System.out.println("TvTEventEngine[TvTEvent.startParticipation()]: exception: " + e);
- + return false;
- + }
- +
- + setState(EventState.PARTICIPATING);
- + return true;
- + }
- +
- + /**
- + * Unspawn event npc.
- + */
- + public static void unspawnEventNpc()
- + {
- + if (_npcSpawn == null || _npcSpawn.getNpc() == null)
- + return;
- +
- + _npcSpawn.getNpc().deleteMe();
- + _npcSpawn.setRespawnState(false);
- + SpawnTable.getInstance().deleteSpawn(_npcSpawn, 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);
- + unspawnEventNpc();
- + _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 (TvTEventTeams team : _teams)
- + {
- + for (String playerName : team.getParticipatedPlayerNames())
- + {
- + Player playerInstance = team.getParticipatedPlayers().get(playerName);
- +
- + if (playerInstance == null)
- + continue;
- +
- + // leave party
- + // playerInstance.leaveParty();
- + playerInstance.removeMeFromPartyMatch();
- + // Get Noblesse effect
- + noblesse.getEffects(playerInstance, playerInstance);
- +
- + // implements Runnable and starts itself in constructor
- + new TvTEventTeleport(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())
- + {
- + waiter(1);
- + }
- +
- + 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?
- + TvTEventTeams team = _teams[teamId];
- +
- + for (String playerName : team.getParticipatedPlayerNames())
- + {
- + for (int[] reward : Config.TVT_EVENT_REWARDS)
- + {
- + if (team.getParticipatedPlayers().get(playerName) == null)
- + continue;
- +
- + PcInventory inv = team.getParticipatedPlayers().get(playerName).getInventory();
- +
- + if (ItemData.getInstance().createDummyItem(reward[0]).isStackable())
- + inv.addItem("TvT Event", reward[0], reward[1], team.getParticipatedPlayers().get(playerName), team.getParticipatedPlayers().get(playerName));
- + else
- + {
- + for (int i = 0; i < reward[1]; i++)
- + inv.addItem("TvT Event", reward[0], 1, team.getParticipatedPlayers().get(playerName), team.getParticipatedPlayers().get(playerName));
- + }
- +
- + 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]);
- + }
- +
- + team.getParticipatedPlayers().get(playerName).sendPacket(systemMessage);
- + }
- +
- + StatusUpdate statusUpdate = new StatusUpdate(team.getParticipatedPlayers().get(playerName));
- +
- + // statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, team.getParticipatedPlayers().get(playerName).getCurrentLoad());
- + team.getParticipatedPlayers().get(playerName).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>");
- + team.getParticipatedPlayers().get(playerName).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();
- + unspawnEventNpc();
- +
- + for (TvTEventTeams team : _teams)
- + {
- + for (String playerName : team.getParticipatedPlayerNames())
- + {
- + Player playerInstance = team.getParticipatedPlayers().get(playerName);
- +
- + if (playerInstance == null)
- + continue;
- +
- + new TvTEventTeleport(playerInstance, Config.TVT_EVENT_BACK_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(Player 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 (Player playerInstance : _teams[0].getParticipatedPlayers().values())
- + {
- + if (playerInstance != null)
- + playerInstance.sendMessage(message);
- + }
- +
- + for (Player playerInstance : _teams[1].getParticipatedPlayers().values())
- + {
- + if (playerInstance != null)
- + playerInstance.sendMessage(message);
- + }
- + }
- +
- + /**
- + * Close doors specified in configs
- + */
- + public static void closeDoors()
- + {
- + for (int doorId : Config.TVT_EVENT_DOOR_IDS)
- + {
- + Door doorInstance = DoorData.getInstance().getDoor(doorId);
- +
- + if (doorInstance != null)
- + doorInstance.closeMe();
- + }
- + }
- +
- + /**
- + * Open doors specified in configs
- + */
- + public static void openDoors()
- + {
- + for (int doorId : Config.TVT_EVENT_DOOR_IDS)
- + {
- + Door doorInstance = DoorData.getInstance().getDoor(doorId);
- +
- + if (doorInstance != null)
- + doorInstance.openMe();
- + }
- + }
- +
- + public static void waiter(int seconds)
- + {
- + try
- + {
- + Thread.sleep(seconds * 1000);
- + }
- + catch (InterruptedException e)
- + {
- + e.printStackTrace();
- + }
- + }
- +
- + /**
- + * Called when a player logs in
- + * @param playerInstance
- + * @param player
- + */
- + public static void onLogin(Player playerInstance, Player player)
- + {
- + if (playerInstance == null || (!isStarting() && !isStarted()))
- + return;
- +
- + byte teamId = getParticipantTeamId(playerInstance.getName());
- +
- + if (teamId == -1)
- + return;
- +
- + _teams[teamId].addPlayer(playerInstance);
- + new TvTEventTeleport(playerInstance, _teams[teamId].getCoordinates(), true, false);
- + }
- +
- + /**
- + * Called when a player logs out
- + * @param playerInstance
- + * @param player
- + */
- + public static void onLogout(Player playerInstance, Player player)
- + {
- + 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, Player playerInstance)
- + {
- + if (playerInstance == null || !isParticipating())
- + return;
- +
- + if (command.equals("tvt_event_participation"))
- + {
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
- + int playerLevel = playerInstance.getStatus().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;
- +
- + Player playerInstance = World.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 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(Creature killerCharacter, Player killedPlayerInstance)
- + {
- + if (killerCharacter == null || killedPlayerInstance == null || (!(killerCharacter instanceof Player) && !(killerCharacter instanceof Pet) && !(killerCharacter instanceof Servitor )) || !isStarted())
- + return;
- +
- + Player killerPlayerInstance = null;
- +
- + if (killerCharacter instanceof Pet || killerCharacter instanceof Servitor )
- + {
- + killerPlayerInstance = ((Summon) killerCharacter).getOwner();
- +
- + if (killerPlayerInstance == null)
- + return;
- + }
- + else
- + killerPlayerInstance = (Player) killerCharacter;
- +
- + if (Config.TVT_KILLS_REWARD_ENABLED)
- + for (int[] rewardKills : Config.TVT_KILLS_REWARD)
- + {
- + SystemMessage systemMessage = null;
- + // Count the kill
- + killerPlayerInstance._tvtkills++;
- + switch (killerPlayerInstance._tvtkills)
- + {
- + case 5: // Reward after 5 kills without die
- + case 8: // Reward after 8 kills without die
- + case 12: // Reward after 12 kills without die
- + case 15: // Reward after 15 kills without die
- + case 20: // Reward after 20 kills without die
- +
- + systemMessage = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
- + systemMessage.addItemName(rewardKills[0]);
- + systemMessage.addNumber(rewardKills[1]);
- +
- + World.announceToOnlinePlayers("TvT Event: Player " + killerPlayerInstance.getName() + " has " + killerPlayerInstance._tvtkills + " kills without die.", true);
- + killerPlayerInstance.getInventory().addItem("TvT Event", rewardKills[0], rewardKills[1], killerPlayerInstance, killerPlayerInstance);
- + killerPlayerInstance.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "Amazing", +killerPlayerInstance._tvtkills + " kills without die. You has been rewarded!"));
- + killerPlayerInstance.sendPacket(systemMessage);
- + break;
- + }
- + }
- +
- + 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 TvTEventTeleport(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()
- + };
- + }
- +}
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/events/TvTEventManager.java b/java/net/sf/l2j/gameserver/events/TvTEventManager.java
- new file mode 100644
- index 0000000..fcb79c4
- --- /dev/null
- +++ b/java/net/sf/l2j/gameserver/events/TvTEventManager.java
- @@ -0,0 +1,153 @@
- +/*
- + * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.events;
- +
- +import net.sf.l2j.commons.pool.ThreadPool;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.model.World;
- +
- +/**
- + * @author FBIagent
- + */
- +public class TvTEventManager implements Runnable
- +{
- + /**
- + * The one and only instance of this class<br>
- + */
- + private static TvTEventManager _instance = null;
- +
- + /**
- + * New instance only by getInstance()<br>
- + */
- + private TvTEventManager()
- + {
- + if (Config.TVT_EVENT_ENABLED)
- + {
- + ThreadPool.schedule(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 TvTEventManager getInstance()
- + {
- + if (_instance == null)
- + _instance = new TvTEventManager();
- +
- + 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())
- + {
- + World.announceToOnlinePlayers("TvT Event: Event was canceled.", true);
- + System.out.println("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation.");
- + continue;
- + }
- + World.announceToOnlinePlayers("TvT Event: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s). Type .tvtjoin or .tvtleave", true);
- +
- + waiter(Config.TVT_EVENT_PARTICIPATION_TIME * 60); // in config given as minutes
- +
- + if (!TvTEvent.startFight())
- + {
- + World.announceToOnlinePlayers("TvT Event: Event canceled due to lack of Participation.", true);
- + System.out.println("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event.");
- + continue;
- + }
- + World.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
- + World.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())
- + World.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())
- + World.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())
- + World.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;
- + }
- + }
- + TvTEvent.waiter(1);
- + }
- + }
- +}
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/events/TvTEventTeams.java b/java/net/sf/l2j/gameserver/events/TvTEventTeams.java
- new file mode 100644
- index 0000000..4f19ea6
- --- /dev/null
- +++ b/java/net/sf/l2j/gameserver/events/TvTEventTeams.java
- @@ -0,0 +1,209 @@
- +/*
- + * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.events;
- +
- +
- +import java.util.HashMap;
- +import java.util.Map;
- +import java.util.Vector;
- +
- +import net.sf.l2j.gameserver.model.actor.Player;
- +
- +/**
- + * @author FBIagent
- + */
- +public class TvTEventTeams
- +{
- + /**
- + * 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, Player> _participatedPlayers = new HashMap<>();
- + /**
- + * Name of all participated players in Vector<br>
- + */
- + private Vector<String> _participatedPlayerNames = new Vector<>();
- +
- + /**
- + * C'tor initialize the team
- + * @param name
- + * @param coordinates
- + */
- + public TvTEventTeams(String name, int[] coordinates)
- + {
- + _name = name;
- + _coordinates = coordinates;
- + _points = 0;
- + }
- +
- + /**
- + * Adds a player to the team
- + * @param playerInstance
- + * @return boolean
- + */
- + public boolean addPlayer(Player 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<>();
- + _participatedPlayerNames = new Vector<>();
- + _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, Player>
- + */
- + public Map<String, Player> getParticipatedPlayers()
- + {
- + Map<String, Player> 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;
- + }
- +}
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/events/TvTEventTeleport.java b/java/net/sf/l2j/gameserver/events/TvTEventTeleport.java
- new file mode 100644
- index 0000000..2745b70
- --- /dev/null
- +++ b/java/net/sf/l2j/gameserver/events/TvTEventTeleport.java
- @@ -0,0 +1,101 @@
- +/*
- + * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.events;
- +
- +import net.sf.l2j.commons.pool.ThreadPool;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.SkillTable;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.Summon;
- +import net.sf.l2j.gameserver.skills.AbstractEffect;
- +import net.sf.l2j.gameserver.skills.L2Skill;
- +
- +public class TvTEventTeleport implements Runnable
- +{
- + /** Gives Noblesse to players */
- + static L2Skill noblesse = SkillTable.getInstance().getInfo(1323, 1);
- + /** The instance of the player to teleport */
- + public Player _playerInstance;
- + /** Coordinates of the spot to teleport to */
- + public 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 TvTEventTeleport(Player 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;
- +
- + ThreadPool.schedule(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;
- +
- + Summon summon = _playerInstance.getSummon();
- +
- + if (summon != null)
- + summon.unSummon(_playerInstance);
- +
- + for (AbstractEffect effect : _playerInstance.getAllEffects())
- + {
- + if (Config.TVT_EVENT_REMOVE_BUFFS && effect != null)
- + effect.exit();
- + }
- +
- + ThreadPool.schedule(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + _playerInstance.doRevive();
- + _playerInstance.getStatus().setMaxCpHpMp();
- + noblesse.getEffects(_playerInstance, _playerInstance);
- + _playerInstance.teleportTo(_coordinates[0], _coordinates[1], _coordinates[2], 0);
- + }
- + }, 4000);
- +
- + if (TvTEvent.isStarted() && !_adminRemove)
- + _playerInstance.setTeam(TvTEvent.getParticipantTeamId(_playerInstance.getName()) + 1);
- + else
- + _playerInstance.setTeam(0);
- +
- + //_playerInstance.broadcastStatusUpdate();
- + _playerInstance.broadcastUserInfo();
- + }
- +}
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java b/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
- index 2abbe8b..22f66da 100644
- --- a/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
- +++ b/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
- @@ -36,6 +36,7 @@
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTarget;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTeleport;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTest;
- +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTvTEvent;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminVip;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminZone;
- @@ -45,6 +46,7 @@
- protected AdminCommandHandler()
- {
- + registerHandler(new AdminTvTEvent());
- registerHandler(new AdminLevel());
- registerHandler(new AdminCustom());
- registerHandler(new AdminVip());
- diff --git a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
- index 1c2a717..55c8191 100644
- --- a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
- +++ b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
- @@ -28,6 +28,7 @@
- import net.sf.l2j.gameserver.GameServer;
- import net.sf.l2j.gameserver.handler.voicedcommandhandlers.GainXpSp;
- import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Shiff_Mod;
- +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.TvTEventCommand;
- import net.sf.l2j.gameserver.handler.voicedcommandhandlers.VoicedBanking;
- import net.sf.l2j.gameserver.handler.voicedcommandhandlers.VoicedBossSpawn;
- import net.sf.l2j.gameserver.handler.voicedcommandhandlers.VoicedCastles;
- @@ -59,6 +60,7 @@
- private VoicedCommandHandler()
- {
- _datatable = new HashMap<>();
- + registerVoicedCommandHandler(new TvTEventCommand());
- registerVoicedCommandHandler(new Shiff_Mod());
- if(Config.ENABLE_COMMAND_RAID)
- {
- diff --git a/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java b/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java
- new file mode 100644
- index 0000000..a836558
- --- /dev/null
- +++ b/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java
- @@ -0,0 +1,90 @@
- +package net.sf.l2j.gameserver.handler.admincommandhandlers;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- +import net.sf.l2j.gameserver.events.TvTEventTeleport;
- +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
- +import net.sf.l2j.gameserver.model.WorldObject;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +
- +/**
- + * @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 void useAdminCommand(String command, Player adminInstance)
- + {
- +
- + //AdminData.auditGMAction(adminInstance.getName(), command, (adminInstance.getTarget() != null ? adminInstance.getTarget().getName() : "no-target"), "");
- +
- + if (command.equals("admin_tvt_add"))
- + {
- + WorldObject target = adminInstance.getTarget();
- +
- + if (target == null || !(target instanceof Player))
- + {
- + adminInstance.sendMessage("You should select a player!");
- + return;
- + }
- +
- + add(adminInstance, (Player) target);
- + }
- + else if (command.equals("admin_tvt_remove"))
- + {
- + WorldObject target = adminInstance.getTarget();
- +
- + if (target == null || !(target instanceof Player))
- + {
- + adminInstance.sendMessage("You should select a player!");
- + return;
- + }
- +
- + remove(adminInstance, (Player) target);
- + }
- +
- + return;
- + }
- +
- + @Override
- + public String[] getAdminCommandList()
- + {
- + return ADMIN_COMMANDS;
- + }
- +
- + private static void add(Player adminInstance, Player 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 TvTEventTeleport(playerInstance, TvTEvent.getParticipantTeamCoordinates(playerInstance.getName()), true, false);
- + }
- +
- + private static void remove(Player adminInstance, Player playerInstance)
- + {
- + if (!TvTEvent.removeParticipant(playerInstance.getName()))
- + {
- + adminInstance.sendMessage("Player is not part of the event!");
- + return;
- + }
- +
- + new TvTEventTeleport(playerInstance, Config.TVT_EVENT_BACK_COORDINATES, true, true);
- + }
- +}
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java b/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
- index 1792260..aec88a2 100644
- --- a/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
- +++ b/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
- @@ -5,6 +5,7 @@
- import net.sf.l2j.gameserver.data.SkillTable;
- import net.sf.l2j.gameserver.data.xml.NpcData;
- import net.sf.l2j.gameserver.data.xml.SummonItemData;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- import net.sf.l2j.gameserver.handler.IItemHandler;
- import net.sf.l2j.gameserver.model.actor.Npc;
- import net.sf.l2j.gameserver.model.actor.Playable;
- @@ -32,7 +33,8 @@
- player.sendPacket(SystemMessageId.CANT_MOVE_SITTING);
- return;
- }
- -
- + if (!TvTEvent.onItemSummon(playable.getName()))
- + return;
- if (player.isInObserverMode())
- return;
- diff --git a/java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java b/java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java
- index 43f7687..bc3ca1a 100644
- --- a/java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java
- +++ b/java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java
- @@ -100,6 +100,9 @@
- if (activeChar instanceof Player && ((Player) activeChar).isCursedWeaponEquipped())
- continue;
- +
- + else if (((Player) activeChar).isInFunEvent() && !Config.TVT_EVENT_HEAL_PLAYERS)
- + continue;
- }
- final double amount = target.getStatus().addHp(power * target.getStatus().calcStat(Stats.HEAL_EFFECTIVNESS, 100, null, null) / 100.);
- diff --git a/java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java b/java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java
- index 1763eac..27998ed 100644
- --- a/java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java
- +++ b/java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java
- @@ -47,7 +47,19 @@
- // Doors and flags can't be healed in any way
- if (target instanceof Door || target instanceof SiegeFlag)
- continue;
- + // Mana potions can't be used on event
- + if (((Player) activeChar).isInFunEvent() && !Config.TVT_EVENT_POTIONS_ALLOWED)
- + {
- + if (skill.getSkillType() == SkillType.MANAHEAL_PERCENT)
- + continue;
- + }
- + // Players can't be healed on event
- + if (((Player) activeChar).isInFunEvent() && !Config.TVT_EVENT_HEAL_PLAYERS)
- + {
- + if (skill.getSkillType() == SkillType.HEAL_PERCENT)
- + continue;
- + }
- final boolean isTargetPlayer = target instanceof Player;
- // Cursed weapon owner can't heal or be healed
- diff --git a/java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java b/java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
- index 128db81..d0da398 100644
- --- a/java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
- +++ b/java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
- @@ -2,6 +2,7 @@
- import net.sf.l2j.gameserver.enums.items.ShotType;
- import net.sf.l2j.gameserver.enums.skills.SkillType;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- import net.sf.l2j.gameserver.handler.ISkillHandler;
- import net.sf.l2j.gameserver.model.WorldObject;
- import net.sf.l2j.gameserver.model.actor.Creature;
- @@ -21,6 +22,11 @@
- @Override
- public void useSkill(Creature activeChar, L2Skill skill, WorldObject[] targets)
- {
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(activeChar.getName()))
- + {
- + activeChar.sendMessage("You can not use this action when it is participating in this event.");
- + return;
- + }
- for (WorldObject cha : targets)
- {
- final Creature target = (Creature) cha;
- diff --git a/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java b/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java
- index 8bac2b9..a63f474 100644
- --- a/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java
- +++ b/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java
- @@ -2,6 +2,7 @@
- import net.sf.l2j.gameserver.enums.ZoneId;
- import net.sf.l2j.gameserver.enums.skills.SkillType;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- import net.sf.l2j.gameserver.handler.ISkillHandler;
- import net.sf.l2j.gameserver.model.WorldObject;
- import net.sf.l2j.gameserver.model.actor.Creature;
- @@ -27,7 +28,12 @@
- return;
- final Player player = (Player) activeChar;
- -
- + // Players can't summon anyone on event
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
- + {
- + player.sendMessage("You can not use this action when it is participating in this event.");
- + return;
- + }
- // Check player status.
- if (!checkSummoner(player))
- return;
- diff --git a/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java b/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
- index 7d6acb3..843411b 100644
- --- a/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
- +++ b/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
- @@ -16,7 +16,7 @@
- @Override
- public void useUserCommand(int id, Player player)
- {
- - if (player.isInOlympiadMode() || player.isInObserverMode() || player.isFestivalParticipant() || player.isInJail() || player.isInsideZone(ZoneId.BOSS))
- + if (player.isInOlympiadMode() || player.isInObserverMode() || player.isFestivalParticipant() || player.isInJail() || player.isInsideZone(ZoneId.BOSS) || player.isInFunEvent())
- {
- player.sendPacket(SystemMessageId.NO_UNSTUCK_PLEASE_SEND_PETITION);
- return;
- diff --git a/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java
- new file mode 100644
- index 0000000..f8441ab
- --- /dev/null
- +++ b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java
- @@ -0,0 +1,137 @@
- +/*
- + * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
- + */
- +
- +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.cache.HtmCache;
- +import net.sf.l2j.gameserver.enums.SayType;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
- +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +/**
- + * @author Baggos
- + */
- +
- +public class TvTEventCommand implements IVoicedCommandHandler
- +{
- + private static final String[] VOICED_COMMANDS =
- + {
- + "tvtjoin",
- + "tvtleave",
- + "tvtstatus"
- + };
- +
- + @Override
- + public boolean useVoicedCommand(final String command, final Player activeChar, final String target)
- + {
- + if (command.startsWith("tvtjoin"))
- + JoinTvT(target, activeChar);
- +
- + else if (command.startsWith("tvtleave"))
- + LeaveTvT(activeChar);
- +
- + else if (command.startsWith("tvtstatus"))
- + TvTStatus(activeChar);
- +
- + return true;
- + }
- +
- + public static boolean JoinTvT(final String command, Player activeChar)
- + {
- + int playerLevel = activeChar.getStatus().getLevel();
- + if (!TvTEvent.isParticipating())
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
- + else if (TvTEvent.isPlayerParticipant(activeChar.getName()))
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "You are already on the list."));
- + else if (activeChar.isCursedWeaponEquipped())
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Cursed weapon owners are not allowed to participate."));
- + else if (activeChar.isInJail())
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Nothing for you!."));
- + else if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Olympiad participants can't register."));
- + else if (activeChar.getKarma() > 0)
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Chaotic players are not allowed to participate."));
- + else if (TvTEvent._teams[0].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && TvTEvent._teams[1].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Sorry the event is full!"));
- + else if (playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL)
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Only players from level " + Config.TVT_EVENT_MIN_LVL + " until level " + Config.TVT_EVENT_MAX_LVL + " are allowed to participate."));
- + else if (TvTEvent._teams[0].getParticipatedPlayerCount() > 19 && TvTEvent._teams[1].getParticipatedPlayerCount() > 19)
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "The event is full! Maximum of " + Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS + " player are allowed in one team."));
- + else
- + {
- + TvTEvent.addParticipant(activeChar);
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
- + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are on the registration list now.</body></html>");
- + activeChar.sendPacket(npcHtmlMessage);
- + }
- + return false;
- + }
- +
- + public boolean LeaveTvT(final Player activeChar)
- + {
- + if (!TvTEvent.isParticipating())
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
- + else if (!TvTEvent.isInactive() && !TvTEvent.isPlayerParticipant(activeChar.getName()))
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "You aren't registered in the TvT Event."));
- + else
- + {
- + TvTEvent.removeParticipant(activeChar.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>");
- + activeChar.sendPacket(npcHtmlMessage);
- + }
- + return false;
- + }
- +
- + public boolean TvTStatus(final Player activeChar)
- + {
- + if (!TvTEvent.isStarted())
- + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "TvT Event is not in progress yet."));
- + else
- + {
- + 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(5);
- +
- + 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
- + activeChar.sendPacket(npcHtmlMessage);
- + }
- + }
- + return false;
- + }
- +
- + @Override
- + public String[] getVoicedCommandList()
- + {
- + return VOICED_COMMANDS;
- + }
- +}
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/model/actor/Player.java b/java/net/sf/l2j/gameserver/model/actor/Player.java
- index 70a2fda..290b545 100644
- --- a/java/net/sf/l2j/gameserver/model/actor/Player.java
- +++ b/java/net/sf/l2j/gameserver/model/actor/Player.java
- @@ -61,7 +61,6 @@
- import net.sf.l2j.gameserver.enums.ShortcutType;
- import net.sf.l2j.gameserver.enums.SpawnType;
- import net.sf.l2j.gameserver.enums.StatusType;
- -import net.sf.l2j.gameserver.enums.TeamType;
- import net.sf.l2j.gameserver.enums.TeleportMode;
- import net.sf.l2j.gameserver.enums.ZoneId;
- import net.sf.l2j.gameserver.enums.actors.ClassId;
- @@ -81,6 +80,7 @@
- import net.sf.l2j.gameserver.enums.skills.EffectFlag;
- import net.sf.l2j.gameserver.enums.skills.EffectType;
- import net.sf.l2j.gameserver.enums.skills.Stats;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- import net.sf.l2j.gameserver.geoengine.GeoEngine;
- import net.sf.l2j.gameserver.handler.IItemHandler;
- import net.sf.l2j.gameserver.handler.ItemHandler;
- @@ -274,7 +274,8 @@
- private long _onlineBeginTime;
- private long _lastAccess;
- private long _uptime;
- -
- + public int _tvtkills;
- + public boolean atEvent = false;
- protected int _baseClass;
- protected int _activeClass;
- protected int _classIndex;
- @@ -428,7 +429,7 @@
- private final int[] _loto = new int[5];
- private final int[] _race = new int[2];
- - private TeamType _team = TeamType.NONE;
- + private int _team = 0;
- private int _alliedVarkaKetra; // lvl of alliance with ketra orcs or varka silenos, used in quests and aggro checks [-5,-1] varka, 0 neutral, [1,5] ketra
- @@ -2295,6 +2296,11 @@
- @Override
- public void onAction(Player player, boolean isCtrlPressed, boolean isShiftPressed)
- {
- + if (!TvTEvent.onAction(player.getName(), getName()))
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- if (player.getTarget() != this)
- player.setTarget(this);
- else
- @@ -2704,6 +2710,8 @@
- if (isMounted())
- stopFeed();
- + _tvtkills = 0;
- +
- // Clean player charges on death.
- clearCharges();
- @@ -2712,7 +2720,7 @@
- if (isFakeDeath())
- stopFakeDeath(true);
- }
- -
- + TvTEvent.onKill(killer, this);
- if (killer != null)
- {
- final Player pk = killer.getActingPlayer();
- @@ -2778,6 +2786,11 @@
- return true;
- }
- + public boolean isInFunEvent()
- + {
- + return (atEvent || (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getName())) && !isGM());
- + }
- +
- private void onDieDropItem(Creature killer)
- {
- if (killer == null)
- @@ -5815,12 +5828,12 @@
- return _lvlJoinedAcademy > 0;
- }
- - public void setTeam(TeamType team)
- + public void setTeam(int team)
- {
- _team = team;
- }
- - public TeamType getTeam()
- + public int getTeam()
- {
- return _team;
- }
- diff --git a/java/net/sf/l2j/gameserver/model/actor/Summon.java b/java/net/sf/l2j/gameserver/model/actor/Summon.java
- index f0b8c83..a2cba5b 100644
- --- a/java/net/sf/l2j/gameserver/model/actor/Summon.java
- +++ b/java/net/sf/l2j/gameserver/model/actor/Summon.java
- @@ -4,7 +4,6 @@
- import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.data.xml.ItemData;
- -import net.sf.l2j.gameserver.enums.TeamType;
- import net.sf.l2j.gameserver.enums.actors.NpcSkillType;
- import net.sf.l2j.gameserver.enums.items.ActionType;
- import net.sf.l2j.gameserver.enums.items.ShotType;
- @@ -171,9 +170,9 @@
- return (getOwner() != null) ? getOwner().getPvpFlag() : 0;
- }
- - public final TeamType getTeam()
- + public final int getTeam()
- {
- - return (getOwner() != null) ? getOwner().getTeam() : TeamType.NONE;
- + return getOwner() != null ? getOwner().getTeam() : 0;
- }
- public final Player getOwner()
- diff --git a/java/net/sf/l2j/gameserver/model/actor/instance/OlympiadManagerNpc.java b/java/net/sf/l2j/gameserver/model/actor/instance/OlympiadManagerNpc.java
- index d768cea..b9ba44e 100644
- --- a/java/net/sf/l2j/gameserver/model/actor/instance/OlympiadManagerNpc.java
- +++ b/java/net/sf/l2j/gameserver/model/actor/instance/OlympiadManagerNpc.java
- @@ -8,6 +8,7 @@
- import net.sf.l2j.gameserver.data.manager.HeroManager;
- import net.sf.l2j.gameserver.data.xml.MultisellData;
- import net.sf.l2j.gameserver.enums.OlympiadType;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- import net.sf.l2j.gameserver.model.actor.Player;
- import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- import net.sf.l2j.gameserver.model.olympiad.Olympiad;
- @@ -173,6 +174,11 @@
- }
- else if (command.startsWith("Olympiad"))
- {
- + if (TvTEvent.isParticipating())
- + {
- + 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());
- @@ -208,6 +214,11 @@
- break;
- case 3: // Spectator overview
- + if (TvTEvent.isParticipating() || TvTEvent.isStarting() || TvTEvent.isStarted())
- + {
- + 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;
- diff --git a/java/net/sf/l2j/gameserver/model/actor/instance/TvTEventNpc.java b/java/net/sf/l2j/gameserver/model/actor/instance/TvTEventNpc.java
- new file mode 100644
- index 0000000..400c8b8
- --- /dev/null
- +++ b/java/net/sf/l2j/gameserver/model/actor/instance/TvTEventNpc.java
- @@ -0,0 +1,82 @@
- +package net.sf.l2j.gameserver.model.actor.instance;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.cache.HtmCache;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +public class TvTEventNpc extends Folk
- +{
- + public TvTEventNpc(int objectId, NpcTemplate template)
- + {
- + super(objectId, template);
- + }
- +
- + @Override
- + public void onBypassFeedback(Player playerInstance, String command)
- + {
- + TvTEvent.onBypass(command, playerInstance);
- + }
- +
- + @Override
- + public void showChatWindow(Player 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);
- + }
- +}
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java b/java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java
- index 25385b7..220f78a 100644
- --- a/java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java
- +++ b/java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java
- @@ -93,7 +93,7 @@
- }
- // Simple checks to avoid exploits
- - if (partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
- + if (partner.isInFunEvent() || partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
- {
- player.sendMessage("Due to the current partner's status, the teleportation failed.");
- return;
- diff --git a/java/net/sf/l2j/gameserver/model/entity/Duel.java b/java/net/sf/l2j/gameserver/model/entity/Duel.java
- index 8ca5ae8..c2902a1 100644
- --- a/java/net/sf/l2j/gameserver/model/entity/Duel.java
- +++ b/java/net/sf/l2j/gameserver/model/entity/Duel.java
- @@ -8,7 +8,6 @@
- import net.sf.l2j.commons.pool.ThreadPool;
- import net.sf.l2j.gameserver.data.manager.DuelManager;
- -import net.sf.l2j.gameserver.enums.TeamType;
- import net.sf.l2j.gameserver.enums.ZoneId;
- import net.sf.l2j.gameserver.model.actor.Player;
- import net.sf.l2j.gameserver.model.actor.Summon;
- @@ -312,7 +311,7 @@
- {
- partyPlayer.cancelActiveTrade();
- partyPlayer.setDuelState(DuelState.DUELLING);
- - partyPlayer.setTeam(TeamType.BLUE);
- + partyPlayer.setTeam(1);
- partyPlayer.broadcastUserInfo();
- final Summon summon = partyPlayer.getSummon();
- @@ -326,7 +325,7 @@
- {
- partyPlayer.cancelActiveTrade();
- partyPlayer.setDuelState(DuelState.DUELLING);
- - partyPlayer.setTeam(TeamType.RED);
- + partyPlayer.setTeam(2);
- partyPlayer.broadcastUserInfo();
- final Summon summon = partyPlayer.getSummon();
- @@ -349,9 +348,9 @@
- {
- // Set states.
- _playerA.setDuelState(DuelState.DUELLING);
- - _playerA.setTeam(TeamType.BLUE);
- + _playerA.setTeam(1);
- _playerB.setDuelState(DuelState.DUELLING);
- - _playerB.setTeam(TeamType.RED);
- + _playerB.setTeam(2);
- // Send duel Start packets.
- ExDuelReady ready = new ExDuelReady(false);
- @@ -414,7 +413,7 @@
- for (Player partyPlayer : _playerA.getParty().getMembers())
- {
- partyPlayer.setInDuel(0);
- - partyPlayer.setTeam(TeamType.NONE);
- + partyPlayer.setTeam(0);
- partyPlayer.broadcastUserInfo();
- final Summon summon = partyPlayer.getSummon();
- @@ -425,7 +424,7 @@
- for (Player partyPlayer : _playerB.getParty().getMembers())
- {
- partyPlayer.setInDuel(0);
- - partyPlayer.setTeam(TeamType.NONE);
- + partyPlayer.setTeam(0);
- partyPlayer.broadcastUserInfo();
- final Summon summon = partyPlayer.getSummon();
- @@ -436,7 +435,7 @@
- else
- {
- _playerA.setInDuel(0);
- - _playerA.setTeam(TeamType.NONE);
- + _playerA.setTeam(0);
- _playerA.broadcastUserInfo();
- Summon summon = _playerA.getSummon();
- @@ -444,7 +443,7 @@
- summon.updateAbnormalEffect();
- _playerB.setInDuel(0);
- - _playerB.setTeam(TeamType.NONE);
- + _playerB.setTeam(0);
- _playerB.broadcastUserInfo();
- summon = _playerB.getSummon();
- diff --git a/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java b/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
- index 1c35a8b..bcaa4fa 100644
- --- a/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
- +++ b/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
- @@ -10,6 +10,7 @@
- import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.enums.OlympiadType;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- import net.sf.l2j.gameserver.model.World;
- import net.sf.l2j.gameserver.model.actor.Npc;
- import net.sf.l2j.gameserver.model.actor.Player;
- @@ -253,7 +254,11 @@
- player.sendPacket(SystemMessageId.ONLY_NOBLESS_CAN_PARTICIPATE_IN_THE_OLYMPIAD);
- return false;
- }
- -
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
- + {
- + 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);
- diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- index 496642d..4010615 100644
- --- a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- +++ b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- @@ -24,6 +24,7 @@
- import net.sf.l2j.gameserver.enums.SiegeSide;
- import net.sf.l2j.gameserver.enums.ZoneId;
- import net.sf.l2j.gameserver.enums.actors.ClassRace;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- import net.sf.l2j.gameserver.model.World;
- import net.sf.l2j.gameserver.model.actor.Player;
- import net.sf.l2j.gameserver.model.clanhall.ClanHall;
- @@ -233,7 +234,7 @@
- player.sendPacket(SystemMessageId.WELCOME_TO_LINEAGE);
- player.sendPacket(SevenSignsManager.getInstance().getCurrentPeriod().getMessageId());
- AnnouncementData.getInstance().showAnnouncements(player, false);
- -
- + TvTEvent.onLogin(player, player);
- if(Config.PCB_ENABLE)
- {
- player.showPcBangWindow();
- diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java b/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
- index 7a65c66..7394077 100644
- --- a/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
- +++ b/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
- @@ -2,6 +2,7 @@
- import net.sf.l2j.gameserver.data.manager.FestivalOfDarknessManager;
- import net.sf.l2j.gameserver.enums.ZoneId;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- import net.sf.l2j.gameserver.model.actor.Player;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- @@ -33,7 +34,11 @@
- player.sendPacket(ActionFailed.STATIC_PACKET);
- return;
- }
- -
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
- + {
- + player.sendMessage("You can not leave the game while attending an event.");
- + return;
- + }
- if (AttackStanceTaskManager.getInstance().isInAttackStance(player))
- {
- player.sendPacket(SystemMessageId.CANT_LOGOUT_WHILE_FIGHTING);
- diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- index 0a071c9..a8a7b2b 100644
- --- a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- +++ b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- @@ -2,6 +2,7 @@
- import net.sf.l2j.gameserver.data.manager.FestivalOfDarknessManager;
- import net.sf.l2j.gameserver.enums.ZoneId;
- +import net.sf.l2j.gameserver.events.TvTEvent;
- import net.sf.l2j.gameserver.model.actor.Player;
- import net.sf.l2j.gameserver.network.GameClient;
- import net.sf.l2j.gameserver.network.GameClient.GameClientState;
- @@ -29,7 +30,12 @@
- sendPacket(RestartResponse.valueOf(false));
- return;
- }
- -
- + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
- + {
- + player.sendMessage("You can not restart when you registering in TvTEvent.");
- + sendPacket(RestartResponse.valueOf(false));
- + return;
- + }
- if (player.isInsideZone(ZoneId.NO_RESTART))
- {
- player.sendPacket(SystemMessageId.NO_RESTART_HERE);
- diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java b/java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java
- index 80dba69..53e9f6a 100644
- --- a/java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java
- +++ b/java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java
- @@ -259,7 +259,7 @@
- writeD(_allyCrest);
- writeC(_summon.getMove().getMoveType().getId());
- - writeC(_summon.getTeam().getId());
- + writeC(_summon.getTeam());
- writeF(_collisionRadius);
- writeF(_collisionHeight);
- diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java b/java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java
- index f83da89..c56bb3d 100644
- --- a/java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java
- +++ b/java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java
- @@ -3,7 +3,6 @@
- import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.data.manager.CursedWeaponManager;
- import net.sf.l2j.gameserver.enums.Paperdoll;
- -import net.sf.l2j.gameserver.enums.TeamType;
- import net.sf.l2j.gameserver.enums.skills.AbnormalEffect;
- import net.sf.l2j.gameserver.model.actor.Player;
- import net.sf.l2j.gameserver.model.actor.Summon;
- @@ -146,7 +145,12 @@
- writeD(_player.getStatus().getMaxCp());
- writeD((int) _player.getStatus().getCp());
- writeC((_player.isMounted()) ? 0 : _player.getEnchantEffect());
- - writeC((Config.PLAYER_SPAWN_PROTECTION > 0 && _player.isSpawnProtected()) ? TeamType.BLUE.getId() : _player.getTeam().getId());
- + if (_player.getTeam() == 1 || (Config.PLAYER_SPAWN_PROTECTION > 0 && _player.isSpawnProtected()))
- + writeC(0x01); // team circle around feet 1= Blue, 2 = red
- + else if (_player.getTeam() == 2)
- + writeC(0x02); // team circle around feet 1= Blue, 2 = red
- + else
- + writeC(0x00); // team circle around feet 1= Blue, 2 = red
- writeD(_player.getClanCrestLargeId());
- writeC((_player.isNoble()) ? 1 : 0);
- writeC((_player.isHero() || (_player.isGM() && Config.GM_HERO_AURA)) ? 1 : 0);
- diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/Die.java b/java/net/sf/l2j/gameserver/network/serverpackets/Die.java
- index 50e57f0..4fe2f40 100644
- --- a/java/net/sf/l2j/gameserver/network/serverpackets/Die.java
- +++ b/java/net/sf/l2j/gameserver/network/serverpackets/Die.java
- @@ -17,6 +17,7 @@
- private boolean _sweepable;
- private boolean _allowFixedRes;
- private Clan _clan;
- + private boolean _funEvent;
- public Die(Creature creature)
- {
- @@ -29,6 +30,7 @@
- Player player = (Player) creature;
- _allowFixedRes = player.getAccessLevel().allowFixedRes();
- _clan = player.getClan();
- + _funEvent = !player.isInFunEvent();
- }
- else if (creature instanceof Monster)
- @@ -43,9 +45,9 @@
- writeC(0x06);
- writeD(_objectId);
- - writeD(0x01); // to nearest village
- + writeD(_funEvent ? 0x01 : 0); // to nearest village
- - if (_clan != null)
- + if (_funEvent && _clan != null)
- {
- SiegeSide side = null;
- diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/PetInfo.java b/java/net/sf/l2j/gameserver/network/serverpackets/PetInfo.java
- index 2b80637..4e5f4d9 100644
- --- a/java/net/sf/l2j/gameserver/network/serverpackets/PetInfo.java
- +++ b/java/net/sf/l2j/gameserver/network/serverpackets/PetInfo.java
- @@ -109,7 +109,7 @@
- writeC(_summon.getMove().getMoveType().getId());
- writeH(0); // ??
- - writeC(_summon.getTeam().getId());
- + writeC(_summon.getOwner() != null ? _summon.getOwner().getTeam() : 0); // team aura (1 = blue, 2 = red)
- writeD(_summon.getSoulShotsPerHit());
- writeD(_summon.getSpiritShotsPerHit());
- }
- diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java b/java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java
- index bb1ce74..492f8b5 100644
- --- a/java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java
- +++ b/java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java
- @@ -3,7 +3,6 @@
- import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.data.manager.CursedWeaponManager;
- import net.sf.l2j.gameserver.enums.Paperdoll;
- -import net.sf.l2j.gameserver.enums.TeamType;
- import net.sf.l2j.gameserver.enums.skills.AbnormalEffect;
- import net.sf.l2j.gameserver.model.actor.Player;
- import net.sf.l2j.gameserver.model.actor.Summon;
- @@ -201,7 +200,12 @@
- writeD(_player.getStatus().getMaxCp());
- writeD((int) _player.getStatus().getCp());
- writeC((_player.isMounted()) ? 0 : _player.getEnchantEffect());
- - writeC((Config.PLAYER_SPAWN_PROTECTION > 0 && _player.isSpawnProtected()) ? TeamType.BLUE.getId() : _player.getTeam().getId());
- + if (_player.getTeam() == 1 || (Config.PLAYER_SPAWN_PROTECTION > 0 && _player.isSpawnProtected()))
- + writeC(0x01); // team circle around feet 1= Blue, 2 = red
- + else if (_player.getTeam() == 2)
- + writeC(0x02); // team circle around feet 1= Blue, 2 = red
- + else
- + writeC(0x00); // team circle around feet 1= Blue, 2 = red
- writeD(_player.getClanCrestLargeId());
- writeC((_player.isNoble()) ? 1 : 0);
- writeC((_player.isHero() || (_player.isGM() && Config.GM_HERO_AURA)) ? 1 : 0);
- diff --git a/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java b/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
- index 6c0657e..8d6e073 100644
- --- a/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
- +++ b/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
- @@ -39,7 +39,7 @@
- if (activeChar instanceof Player)
- {
- // Check invalid states.
- - if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
- + if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS) || ((Player) activeChar).isInFunEvent())
- return;
- }
- net.sf.l2j.gameserver.data.xml/ItemData.java
- + /**
- + * Dummy item is created by setting the ID of the object in the world at null value
- + * @param itemId : int designating the item
- + * @return ItemInstance designating the dummy item created
- + */
- + public ItemInstance createDummyItem(int itemId)
- + {
- + final Item item = getTemplate(itemId);
- + if (item == null)
- + return null;
- +
- + return new ItemInstance(0, item);
- + }
- /**
- * @param id : the item id to check.
- * @return the {@link Item} corresponding to the item id.
- */
- public Item getTemplate(int id)
- {
- return (id >= _templates.length) ? null : _templates[id];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement