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/handler/skillhandlers/Heal.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java (revision 88)
- +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java (working copy)
- @@ -14,6 +14,7 @@
- */
- package net.sf.l2j.gameserver.handler.skillhandlers;
- +import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.handler.ISkillHandler;
- import net.sf.l2j.gameserver.handler.SkillHandler;
- import net.sf.l2j.gameserver.model.L2Object;
- @@ -113,6 +114,8 @@
- continue;
- else if (activeChar instanceof L2PcInstance && ((L2PcInstance) activeChar).isCursedWeaponEquipped())
- continue;
- + else if (((L2PcInstance) activeChar).isInFunEvent() && !Config.TVT_EVENT_HEAL_PLAYERS)
- + continue;
- }
- switch (skill.getSkillType())
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java (revision 89)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java (working copy)
- @@ -132,7 +132,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;
- Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java (nonexistent)
- +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java (working copy)
- @@ -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.cache.HtmCache;
- +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
- +import net.sf.l2j.gameserver.network.clientpackets.Say2;
- +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 L2PcInstance 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, L2PcInstance activeChar)
- + {
- + int playerLevel = activeChar.getLevel();
- + if (!TvTEvent.isParticipating())
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
- + else if (TvTEvent.isPlayerParticipant(activeChar.getName()))
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "You are already on the list."));
- + else if (activeChar.isCursedWeaponEquipped())
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Cursed weapon owners are not allowed to participate."));
- + else if (activeChar.isInJail())
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Nothing for you!."));
- + else if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Olympiad participants can't register."));
- + else if (activeChar.getKarma() > 0)
- + activeChar.sendPacket(new CreatureSay(0, Say2.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, Say2.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, Say2.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, Say2.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 L2PcInstance activeChar)
- + {
- + if (!TvTEvent.isParticipating())
- + activeChar.sendPacket(new CreatureSay(0, Say2.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, Say2.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 L2PcInstance activeChar)
- + {
- + if (!TvTEvent.isStarted())
- + activeChar.sendPacket(new CreatureSay(0, Say2.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
- Index: java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (revision 89)
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (working copy)
- @@ -36,6 +36,7 @@
- import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
- import net.sf.l2j.gameserver.model.actor.instance.L2XmassTreeInstance;
- import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.item.SummonItem;
- import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- @@ -67,7 +68,10 @@
- if (activeChar.isAllSkillsDisabled() || activeChar.isCastingNow())
- return;
- -
- +
- + if (!TvTEvent.onItemSummon(playable.getName()))
- + return;
- +
- final SummonItem sitem = SummonItemsData.getInstance().getSummonItem(item.getItemId());
- if ((activeChar.getPet() != null || activeChar.isMounted()) && sitem.isPetSummon())
- Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java (nonexistent)
- +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java (working copy)
- @@ -0,0 +1,91 @@
- +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.TvTEventTeleport;
- +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 TvTEventTeleport(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 TvTEventTeleport(playerInstance, Config.TVT_EVENT_BACK_COORDINATES, true, true);
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (nonexistent)
- +++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (working copy)
- @@ -0,0 +1,10 @@
- +package net.sf.l2j.gameserver.handler;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public interface IVoicedCommandHandler
- +{
- + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params);
- +
- + public String[] getVoicedCommandList();
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/entity/TvTEventTeleport.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/TvTEventTeleport.java (nonexistent)
- +++ java/net/sf/l2j/gameserver/model/entity/TvTEventTeleport.java (working copy)
- @@ -0,0 +1,89 @@
- +package net.sf.l2j.gameserver.model.entity;
- +
- +import net.sf.l2j.commons.concurrent.ThreadPool;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.datatables.SkillTable;
- +import net.sf.l2j.gameserver.model.L2Effect;
- +import net.sf.l2j.gameserver.model.L2Skill;
- +import net.sf.l2j.gameserver.model.actor.L2Summon;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +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 L2PcInstance _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(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;
- +
- + 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;
- +
- + L2Summon summon = _playerInstance.getPet();
- +
- + if (summon != null)
- + summon.unSummon(_playerInstance);
- +
- + for (L2Effect effect : _playerInstance.getAllEffects())
- + {
- + if (Config.TVT_EVENT_REMOVE_BUFFS && effect != null)
- + effect.exit();
- + }
- +
- + ThreadPool.schedule(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + _playerInstance.doRevive();
- + _playerInstance.setCurrentHp(_playerInstance.getMaxHp());
- + _playerInstance.setCurrentCp(_playerInstance.getMaxCp());
- + _playerInstance.setCurrentMp(_playerInstance.getMaxMp());
- + noblesse.getEffects(_playerInstance, _playerInstance);
- + _playerInstance.teleToLocation(_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
- Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (nonexistent)
- +++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (working copy)
- @@ -0,0 +1,50 @@
- +package net.sf.l2j.gameserver.handler;
- +
- +import java.util.HashMap;
- +import java.util.Map;
- +
- +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.TvTEventCommand;
- +
- +public class VoicedCommandHandler
- +{
- + private final Map<Integer, IVoicedCommandHandler> _datatable = new HashMap<>();
- +
- + public static VoicedCommandHandler getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + protected VoicedCommandHandler()
- + {
- + // coloque aqui os comandos
- + registerHandler(new TvTEventCommand());
- + }
- +
- + public void registerHandler(IVoicedCommandHandler handler)
- + {
- + String[] ids = handler.getVoicedCommandList();
- +
- + for (int i = 0; i < ids.length; i++)
- + _datatable.put(ids[i].hashCode(), handler);
- + }
- +
- + public IVoicedCommandHandler getHandler(String voicedCommand)
- + {
- + String command = voicedCommand;
- +
- + if (voicedCommand.indexOf(" ") != -1)
- + command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
- +
- + return _datatable.get(command.hashCode());
- + }
- +
- + public int size()
- + {
- + return _datatable.size();
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final VoicedCommandHandler _instance = new VoicedCommandHandler();
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java (nonexistent)
- +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java (working copy)
- @@ -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.cache.HtmCache;
- +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
- +import net.sf.l2j.gameserver.network.clientpackets.Say2;
- +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 L2PcInstance 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, L2PcInstance activeChar)
- + {
- + int playerLevel = activeChar.getLevel();
- + if (!TvTEvent.isParticipating())
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
- + else if (TvTEvent.isPlayerParticipant(activeChar.getName()))
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "You are already on the list."));
- + else if (activeChar.isCursedWeaponEquipped())
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Cursed weapon owners are not allowed to participate."));
- + else if (activeChar.isInJail())
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Nothing for you!."));
- + else if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Olympiad participants can't register."));
- + else if (activeChar.getKarma() > 0)
- + activeChar.sendPacket(new CreatureSay(0, Say2.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, Say2.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, Say2.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, Say2.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 L2PcInstance activeChar)
- + {
- + if (!TvTEvent.isParticipating())
- + activeChar.sendPacket(new CreatureSay(0, Say2.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, Say2.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 L2PcInstance activeChar)
- + {
- + if (!TvTEvent.isStarted())
- + activeChar.sendPacket(new CreatureSay(0, Say2.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
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 89)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (working copy)
- @@ -14,7 +14,11 @@
- */
- package net.sf.l2j.gameserver.handler.chathandlers;
- +import java.util.StringTokenizer;
- +
- import net.sf.l2j.gameserver.handler.IChatHandler;
- +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
- import net.sf.l2j.gameserver.model.BlockList;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- @@ -34,13 +38,42 @@
- if (!FloodProtectors.performAction(activeChar.getClient(), Action.GLOBAL_CHAT))
- return;
- - final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- - for (L2PcInstance player : activeChar.getKnownTypeInRadius(L2PcInstance.class, 1250))
- + boolean vcd_used = false;
- + if (text.startsWith("."))
- {
- - if (!BlockList.isBlocked(player, activeChar))
- - player.sendPacket(cs);
- + StringTokenizer st = new StringTokenizer(text);
- + IVoicedCommandHandler vch;
- + String command = "";
- + if (st.countTokens() > 1)
- + {
- + command = st.nextToken().substring(1);
- + params = text.substring(command.length() + 2);
- + vch = VoicedCommandHandler.getInstance().getHandler(command);
- + }
- + else
- + {
- + command = text.substring(1);
- + vch = VoicedCommandHandler.getInstance().getHandler(command);
- + }
- +
- + if (vch != null)
- + {
- + vch.useVoicedCommand(command, activeChar, params);
- + vcd_used = true;
- + }
- }
- - activeChar.sendPacket(cs);
- + if (!vcd_used)
- + {
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- +
- + for (L2PcInstance player : activeChar.getKnownTypeInRadius(L2PcInstance.class, 1250))
- + {
- + if (!BlockList.isBlocked(player, activeChar))
- + player.sendPacket(cs);
- + }
- +
- + activeChar.sendPacket(cs);
- + }
- }
- @Override
- Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 89)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
- @@ -44,6 +44,7 @@
- import net.sf.l2j.gameserver.model.entity.Castle;
- import net.sf.l2j.gameserver.model.entity.ClanHall;
- import net.sf.l2j.gameserver.model.entity.Siege;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.holder.IntIntHolder;
- import net.sf.l2j.gameserver.model.olympiad.Olympiad;
- import net.sf.l2j.gameserver.model.zone.ZoneId;
- @@ -319,6 +320,7 @@
- PetitionManager.getInstance().checkPetitionMessages(activeChar);
- activeChar.onPlayerEnter();
- + TvTEvent.onLogin(activeChar, activeChar);
- sendPacket(new SkillCoolTime(activeChar));
- Index: config/events.properties
- ===================================================================
- --- config/events.properties (revision 89)
- +++ config/events.properties (working copy)
- @@ -235,4 +235,58 @@
- AltFishChampionshipReward2 = 500000
- AltFishChampionshipReward3 = 300000
- AltFishChampionshipReward4 = 200000
- -AltFishChampionshipReward5 = 100000
- \ No newline at end of file
- +AltFishChampionshipReward5 = 100000
- +
- +#---------------------------------------------------------------
- +# 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 = 5
- +# TvT Event NPC Details (create a custom npc of type L2TvTEventNpc)
- +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
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (revision 88)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (working copy)
- @@ -16,6 +16,7 @@
- import net.sf.l2j.gameserver.instancemanager.SevenSignsFestival;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.zone.ZoneId;
- import net.sf.l2j.gameserver.network.L2GameClient;
- import net.sf.l2j.gameserver.network.L2GameClient.GameClientState;
- @@ -51,7 +52,14 @@
- 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 (AttackStanceTaskManager.getInstance().isInAttackStance(player))
- {
- player.sendPacket(SystemMessageId.CANT_RESTART_WHILE_FIGHTING);
- Index: java/net/sf/l2j/gameserver/network/serverpackets/Die.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/serverpackets/Die.java (revision 88)
- +++ java/net/sf/l2j/gameserver/network/serverpackets/Die.java (working copy)
- @@ -26,7 +26,7 @@
- {
- private final int _charObjId;
- private final boolean _fake;
- -
- + private boolean _funEvent;
- private boolean _sweepable;
- private boolean _allowFixedRes;
- private L2Clan _clan;
- @@ -43,6 +43,7 @@
- L2PcInstance player = (L2PcInstance) cha;
- _allowFixedRes = player.getAccessLevel().allowFixedRes();
- _clan = player.getClan();
- + _funEvent = !player.isInFunEvent();
- }
- else if (cha instanceof L2Attackable)
- @@ -57,9 +58,9 @@
- writeC(0x06);
- writeD(_charObjId);
- - writeD(0x01); // to nearest village
- + writeD(_funEvent ? 0x01 : 0); // to nearest village
- - if (_clan != null)
- + if (_funEvent && _clan != null)
- {
- L2SiegeClan siegeClan = null;
- boolean isInDefense = false;
- Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (revision 88)
- +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (working copy)
- @@ -21,6 +21,7 @@
- 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.skills.Formulas;
- import net.sf.l2j.gameserver.taskmanager.DecayTaskManager;
- import net.sf.l2j.gameserver.templates.skills.L2SkillType;
- @@ -35,6 +36,12 @@
- @Override
- public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] 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 (L2Object cha : targets)
- {
- final L2Character target = (L2Character) cha;
- Index: java/net/sf/l2j/gameserver/model/entity/TvTEventManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/TvTEventManager.java (nonexistent)
- +++ java/net/sf/l2j/gameserver/model/entity/TvTEventManager.java (working copy)
- @@ -0,0 +1,139 @@
- +package net.sf.l2j.gameserver.model.entity;
- +
- +import net.sf.l2j.commons.concurrent.ThreadPool;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +
- +/**
- + * @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())
- + {
- + Broadcast.announceToOnlinePlayers("TvT: Event was canceled.", true);
- + System.out.println("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation.");
- + continue;
- + }
- + Broadcast.announceToOnlinePlayers("TvT: 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())
- + {
- + Broadcast.announceToOnlinePlayers("TvT: Event canceled due to lack of Participation.", true);
- + System.out.println("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event.");
- + continue;
- + }
- + Broadcast.announceToOnlinePlayers("TvT: Registration closed!", true);
- + TvTEvent.sysMsgToAllParticipants("TvT: Teleporting participants to an arena in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
- +
- + waiter(Config.TVT_EVENT_RUNNING_TIME * 60); // in config given as minutes
- + Broadcast.announceToOnlinePlayers(TvTEvent.calculateRewards(), true);
- + TvTEvent.sysMsgToAllParticipants("TvT: Teleporting back to the registration npc in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
- + TvTEvent.stopFight();
- + }
- + }
- +
- + /**
- + * This method waits for a period time delay
- + * @param seconds
- + */
- + void waiter(int seconds)
- + {
- + while (seconds > 1)
- + {
- + seconds--; // here because we don't want to see two time announce at the same time
- +
- + if (TvTEvent.isParticipating() || TvTEvent.isStarted())
- + {
- + switch (seconds)
- + {
- + case 3600: // 1 hour left
- + if (TvTEvent.isParticipating())
- + Broadcast.announceToOnlinePlayers("TvT: " + seconds / 60 / 60 + " hour(s) umtil registration is closed!", true);
- + else if (TvTEvent.isStarted())
- + TvTEvent.sysMsgToAllParticipants("TvT: " + seconds / 60 / 60 + " hour(s) until event is finished!");
- +
- + break;
- + case 1800: // 30 minutes left
- + case 900: // 15 minutes left
- + case 600: // 10 minutes left
- + case 300: // 5 minutes left
- + case 240: // 4 minutes left
- + case 180: // 3 minutes left
- + case 120: // 2 minutes left
- + case 60: // 1 minute left
- + if (TvTEvent.isParticipating())
- + Broadcast.announceToOnlinePlayers("TvT: " + seconds / 60 + " minute(s) until registration is closed!", true);
- + else if (TvTEvent.isStarted())
- + TvTEvent.sysMsgToAllParticipants("TvT: " + seconds / 60 + " minute(s) until the event is finished!");
- +
- + break;
- + case 30: // 30 seconds left
- + /**
- + * case 15: // 15 seconds left case 10: // 10 seconds left
- + */
- + case 5: // 5 seconds left
- +
- + /**
- + * case 4: // 4 seconds left case 3: // 3 seconds left case 2: // 2 seconds left case 1: // 1 seconds left
- + */
- + if (TvTEvent.isParticipating())
- + Broadcast.announceToOnlinePlayers("TvT: " + seconds + " second(s) until registration is closed!", true);
- + else if (TvTEvent.isStarted())
- + TvTEvent.sysMsgToAllParticipants("TvT: " + seconds + " second(s) until the event is finished!");
- +
- + break;
- + }
- + }
- + TvTEvent.waiter(1);
- + }
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (revision 88)
- +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (working copy)
- @@ -22,6 +22,7 @@
- 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.NpcHtmlMessage;
- import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- @@ -256,7 +257,13 @@
- 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);
- Index: java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java (revision 89)
- +++ java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java (working copy)
- @@ -19,6 +19,7 @@
- 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.ConfirmDlg;
- import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- @@ -46,7 +47,14 @@
- // Check player status.
- if (!L2PcInstance.checkSummonerStatus(player))
- return;
- -
- +
- + // 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;
- + }
- +
- for (L2Object obj : targets)
- {
- // The target must be a player.
- Index: java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (revision 88)
- +++ java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (working copy)
- @@ -53,7 +53,7 @@
- if (activeChar instanceof L2PcInstance)
- {
- // Check invalid states.
- - if (activeChar.isAfraid() || ((L2PcInstance) activeChar).isInOlympiadMode() || ZoneManager.getInstance().getZone(activeChar, L2BossZone.class) != null)
- + if (activeChar.isAfraid() || ((L2PcInstance) activeChar).isInOlympiadMode() || ZoneManager.getInstance().getZone(activeChar, L2BossZone.class) != null || ((L2PcInstance) activeChar).isInFunEvent())
- return;
- }
- Index: java/net/sf/l2j/Config.java
- ===================================================================
- --- java/net/sf/l2j/Config.java (revision 91)
- +++ java/net/sf/l2j/Config.java (working copy)
- @@ -218,6 +218,33 @@
- public static int ALT_FISH_CHAMPIONSHIP_REWARD_4;
- public static int ALT_FISH_CHAMPIONSHIP_REWARD_5;
- + /** TvT Event */
- + 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<>();
- +
- // --------------------------------------------------
- // GeoEngine
- // --------------------------------------------------
- @@ -899,6 +926,144 @@
- ALT_FISH_CHAMPIONSHIP_REWARD_3 = events.getProperty("AltFishChampionshipReward3", 300000);
- 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);
- + 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 = events.getProperty("TvTEventMinPlayersInTeams", 1);
- + TVT_EVENT_MAX_PLAYERS_IN_TEAMS = events.getProperty("TvTEventMaxPlayersInTeams", 20);
- + TVT_EVENT_MIN_LVL = (byte) events.getProperty("TvTEventMinPlayerLevel", 1);
- + TVT_EVENT_MAX_LVL = (byte) events.getProperty("TvTEventMaxPlayerLevel", 80);
- + TVT_EVENT_RESPAWN_TELEPORT_DELAY = events.getProperty("TvTEventRespawnTeleportDelay", 20);
- + TVT_EVENT_START_LEAVE_TELEPORT_DELAY = 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 = events.getProperty("TvTEventTargetTeamMembersAllowed", true);
- + TVT_EVENT_POTIONS_ALLOWED = events.getProperty("TvTEventPotionsAllowed", false);
- + TVT_EVENT_SUMMON_BY_ITEM_ALLOWED = 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 + "\"");
- + }
- + }
- + }
- + }
- + }
- + }
- +
- }
- /**
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 89)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -72,6 +72,7 @@
- import net.sf.l2j.gameserver.handler.ItemHandler;
- import net.sf.l2j.gameserver.handler.SkillHandler;
- import net.sf.l2j.gameserver.handler.UserCommandHandler;
- +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
- import net.sf.l2j.gameserver.idfactory.IdFactory;
- import net.sf.l2j.gameserver.instancemanager.AuctionManager;
- import net.sf.l2j.gameserver.instancemanager.AutoSpawnManager;
- @@ -96,6 +97,7 @@
- import net.sf.l2j.gameserver.instancemanager.games.MonsterRace;
- import net.sf.l2j.gameserver.model.World;
- import net.sf.l2j.gameserver.model.entity.Hero;
- +import net.sf.l2j.gameserver.model.entity.TvTEventManager;
- import net.sf.l2j.gameserver.model.olympiad.Olympiad;
- import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
- import net.sf.l2j.gameserver.model.partymatching.PartyMatchRoomList;
- @@ -283,7 +285,11 @@
- _log.config("ItemHandler: Loaded " + ItemHandler.getInstance().size() + " handlers.");
- _log.config("SkillHandler: Loaded " + SkillHandler.getInstance().size() + " handlers.");
- _log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
- -
- + _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
- +
- + StringUtil.printSection("TvT Event");
- + TvTEventManager.getInstance();
- +
- StringUtil.printSection("System");
- Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
- ForumsBBSManager.getInstance();
- Index: java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java (revision 88)
- +++ java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java (working copy)
- @@ -14,6 +14,7 @@
- */
- package net.sf.l2j.gameserver.handler.skillhandlers;
- +import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.handler.ISkillHandler;
- import net.sf.l2j.gameserver.handler.SkillHandler;
- import net.sf.l2j.gameserver.model.L2Object;
- @@ -75,7 +76,21 @@
- // Doors and flags can't be healed in any way
- if (target instanceof L2DoorInstance || target instanceof L2SiegeFlagInstance)
- continue;
- +
- + // Mana potions can't be used on event
- + if (((L2PcInstance) activeChar).isInFunEvent() && !Config.TVT_EVENT_POTIONS_ALLOWED)
- + {
- + if (skill.getSkillType() == L2SkillType.MANAHEAL_PERCENT)
- + continue;
- + }
- + // Players can't be healed on event
- + if (((L2PcInstance) activeChar).isInFunEvent() && !Config.TVT_EVENT_HEAL_PLAYERS)
- + {
- + if (skill.getSkillType() == L2SkillType.HEAL_PERCENT)
- + continue;
- + }
- +
- targetPlayer = target instanceof L2PcInstance;
- // Cursed weapon owner can't heal or be healed
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java (nonexistent)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java (working copy)
- @@ -0,0 +1,81 @@
- +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.actor.template.NpcTemplate;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +public class L2TvTEventNpcInstance extends L2NpcInstance
- +{
- + public L2TvTEventNpcInstance(int objectId, NpcTemplate template)
- + {
- + super(objectId, template);
- + }
- +
- + @Override
- + public void onBypassFeedback(L2PcInstance playerInstance, String command)
- + {
- + TvTEvent.onBypass(command, playerInstance);
- + }
- +
- + @Override
- + public void showChatWindow(L2PcInstance playerInstance, int val)
- + {
- + if (playerInstance == null)
- + return;
- +
- + if (TvTEvent.isParticipating())
- + {
- + String htmFile = "data/html/mods/";
- +
- + if (!TvTEvent.isPlayerParticipant(playerInstance.getName()))
- + htmFile += "TvTEventParticipation";
- + else
- + htmFile += "TvTEventRemoveParticipation";
- +
- + htmFile += ".htm";
- +
- + String htmContent = HtmCache.getInstance().getHtm(htmFile);
- +
- + if (htmContent != null)
- + {
- + int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
- +
- + npcHtmlMessage.setHtml(htmContent);
- + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
- + npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
- + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
- + npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
- + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- + }
- + else if (TvTEvent.isStarting() || TvTEvent.isStarted())
- + {
- + String htmFile = "data/html/mods/TvTEventStatus.htm";
- + String htmContent = HtmCache.getInstance().getHtm(htmFile);
- +
- + if (htmContent != null)
- + {
- + int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
- + int[] teamsPointsCounts = TvTEvent.getTeamsPoints();
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
- +
- + npcHtmlMessage.setHtml(htmContent);
- + // npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
- + npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
- + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
- + npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
- + npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
- + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
- + npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- + }
- +
- + playerInstance.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/entity/TvTEventTeams.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/TvTEventTeams.java (nonexistent)
- +++ java/net/sf/l2j/gameserver/model/entity/TvTEventTeams.java (working copy)
- @@ -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.model.entity;
- +
- +
- +import java.util.HashMap;
- +import java.util.Map;
- +import java.util.Vector;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + * @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, L2PcInstance> _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(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<>();
- + _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, 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;
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 88)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
- @@ -16,6 +16,7 @@
- import net.sf.l2j.gameserver.instancemanager.SevenSignsFestival;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.zone.ZoneId;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- @@ -48,7 +49,13 @@
- 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);
- Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (revision 89)
- +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (working copy)
- @@ -32,7 +32,7 @@
- @Override
- public boolean useUserCommand(int id, L2PcInstance activeChar)
- {
- - if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || ZoneManager.getInstance().getZone(activeChar, L2BossZone.class) != null)
- + if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || ZoneManager.getInstance().getZone(activeChar, L2BossZone.class) != null || activeChar.isInFunEvent())
- {
- activeChar.sendPacket(SystemMessageId.NO_UNSTUCK_PLEASE_SEND_PETITION);
- return false;
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 89)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -126,6 +126,7 @@
- import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
- import net.sf.l2j.gameserver.model.entity.Hero;
- import net.sf.l2j.gameserver.model.entity.Siege;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.holder.IntIntHolder;
- import net.sf.l2j.gameserver.model.holder.SkillUseHolder;
- import net.sf.l2j.gameserver.model.item.Henna;
- @@ -388,6 +389,7 @@
- private PcAppearance _appearance;
- private long _expBeforeDeath;
- + public int _tvtkills;
- private int _karma;
- private int _pvpKills;
- private int _pkKills;
- @@ -398,6 +400,7 @@
- private int _lastCompassZone; // the last compass zone update send to the client
- private boolean _isIn7sDungeon;
- + public boolean atEvent = false;
- private PunishLevel _punishLevel = PunishLevel.NONE;
- private long _punishTimer;
- @@ -3186,6 +3189,11 @@
- @Override
- public void onAction(L2PcInstance player)
- {
- + if (!TvTEvent.onAction(player.getName(), getName()))
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- // Set the target of the player
- if (player.getTarget() != this)
- player.setTarget(this);
- @@ -3943,6 +3951,8 @@
- if (isMounted())
- stopFeed();
- + _tvtkills = 0;
- +
- synchronized (this)
- {
- if (isFakeDeath())
- @@ -3949,6 +3959,8 @@
- stopFakeDeath(true);
- }
- + TvTEvent.onKill(killer, this);
- +
- if (killer != null)
- {
- L2PcInstance pk = killer.getActingPlayer();
- @@ -10607,4 +10619,9 @@
- }
- }
- }
- +
- + public boolean isInFunEvent()
- + {
- + return (atEvent || (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getName())) && !isGM());
- + }
- }
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/entity/TvTEvent.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/TvTEvent.java (nonexistent)
- +++ java/net/sf/l2j/gameserver/model/entity/TvTEvent.java (working copy)
- @@ -0,0 +1,757 @@
- +/* 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.model.entity;
- +
- +import net.sf.l2j.commons.random.Rnd;
- +
- +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.SkillTable;
- +import net.sf.l2j.gameserver.datatables.SpawnTable;
- +import net.sf.l2j.gameserver.model.L2Skill;
- +import net.sf.l2j.gameserver.model.L2Spawn;
- +import net.sf.l2j.gameserver.model.World;
- +import net.sf.l2j.gameserver.model.actor.L2Character;
- +import net.sf.l2j.gameserver.model.actor.L2Npc;
- +import net.sf.l2j.gameserver.model.actor.L2Summon;
- +import net.sf.l2j.gameserver.model.actor.instance.L2DoorInstance;
- +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.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.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.clientpackets.Say2;
- +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;
- +
- +/**
- + * @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
- + /**
- + * 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()
- + {
- + final int npcc = Config.TVT_EVENT_PARTICIPATION_TIME * 1000 * 60;
- + try
- + {
- + final NpcTemplate template = NpcTable.getInstance().getTemplate(Config.TVT_EVENT_PARTICIPATION_NPC_ID);
- + final L2Spawn spawn = new L2Spawn(template);
- + spawn.setLoc(Config.TVT_EVENT_BACK_COORDINATES[0], Config.TVT_EVENT_BACK_COORDINATES[1], Config.TVT_EVENT_BACK_COORDINATES[2], 0);
- +
- + SpawnTable.getInstance().addNewSpawn(spawn, false);
- + final L2Npc npc = spawn.doSpawn(true);
- + npc.scheduleDespawn(npcc);
- + npc.broadcastPacket(new MagicSkillUse(npc, npc, 1034, 1, 1, 1));
- + }
- + catch (Exception e)
- + {
- + System.out.println("TvTEventEngine[TvTEvent.startParticipation()]: exception: " + e);
- + return false;
- + }
- + setState(EventState.PARTICIPATING);
- + return true;
- + }
- + /**
- + * Starts the TvTEvent fight<br>
- + * 1. Set state EventState.STARTING<br>
- + * 2. Close doors specified in configs<br>
- + * 3. Abort if not enought participants(return false)<br>
- + * 4. Set state EventState.STARTED<br>
- + * 5. Teleport all participants to team spot<br>
- + * <br>
- + * @return boolean<br>
- + */
- + public static boolean startFight()
- + {
- + setState(EventState.STARTING);
- +
- + // not enought participants
- + if (_teams[0].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS || _teams[1].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS)
- + {
- + setState(EventState.INACTIVE);
- + _teams[0].cleanMe();
- + _teams[1].cleanMe();
- + return false;
- + }
- +
- + closeDoors();
- + setState(EventState.STARTED); // set state to STARTED here, so TvTEventTeleporter know to teleport to team spot
- +
- + // teleport all participants to there team spot
- + for (TvTEventTeams team : _teams)
- + {
- + for (String playerName : team.getParticipatedPlayerNames())
- + {
- + L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);
- +
- + if (playerInstance == null)
- + continue;
- +
- + // leave party
- + playerInstance.leaveParty();
- +
- + // 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 (ItemTable.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 = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
- + systemMessage.addItemName(reward[0]);
- + systemMessage.addNumber(reward[1]);
- + }
- + else
- + {
- + systemMessage = SystemMessage.getSystemMessage(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();
- +
- + for (TvTEventTeams team : _teams)
- + {
- + for (String playerName : team.getParticipatedPlayerNames())
- + {
- + L2PcInstance 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(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
- + */
- + public 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
- + */
- + public static void openDoors()
- + {
- + for (int doorId : Config.TVT_EVENT_DOOR_IDS)
- + {
- + L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(doorId);
- +
- + if (doorInstance != null)
- + doorInstance.openMe();
- + }
- + }
- +
- + public static void waiter(int seconds)
- + {
- + try
- + {
- + Thread.sleep(seconds * 1000);
- + }
- + catch (InterruptedException e)
- + {
- + }
- + }
- +
- + /**
- + * Called when a player logs in
- + * @param playerInstance
- + * @param player
- + */
- + public static void onLogin(L2PcInstance playerInstance, L2PcInstance 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(L2PcInstance playerInstance, L2PcInstance 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, 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 = 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(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;
- +
- + 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 = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
- + systemMessage.addItemName(rewardKills[0]);
- + systemMessage.addNumber(rewardKills[1]);
- +
- + killerPlayerInstance.getInventory().addItem("TvT Event", rewardKills[0], rewardKills[1], killerPlayerInstance, killerPlayerInstance);
- + killerPlayerInstance.sendPacket(new CreatureSay(0, Say2.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
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java (revision 88)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java (working copy)
- @@ -22,6 +22,7 @@
- import net.sf.l2j.gameserver.datatables.MultisellData;
- import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- import net.sf.l2j.gameserver.model.entity.Hero;
- +import net.sf.l2j.gameserver.model.entity.TvTEvent;
- import net.sf.l2j.gameserver.model.olympiad.CompetitionType;
- import net.sf.l2j.gameserver.model.olympiad.Olympiad;
- import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
- @@ -191,6 +192,12 @@
- }
- 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());
- @@ -228,6 +235,12 @@
- case 3: // Spectator overview
- html.setFile(Olympiad.OLYMPIAD_HTML_PATH + "olympiad_observe_list.htm");
- + if (TvTEvent.isParticipating() || TvTEvent.isStarting() || TvTEvent.isStarted())
- + {
- + player.sendMessage("You can't do that while in a event");
- + return;
- + }
- +
- int i = 0;
- final StringBuilder sb = new StringBuilder(2000);
- #P aCis_datapack
- Index: data/xml/npcs/70000-70099.xml
- ===================================================================
- --- data/xml/npcs/70000-70099.xml (nonexistent)
- +++ data/xml/npcs/70000-70099.xml (working copy)
- @@ -0,0 +1,39 @@
- +<?xml version="1.0" encoding="utf-8"?>
- +<list>
- +<npc id="70010" idTemplate="31280" name="Sir Bastian" title="Event Manager">
- +<set name="level" val="70"/>
- +<set name="radius" val="8"/>
- +<set name="height" val="23"/>
- +<set name="rHand" val="0"/>
- +<set name="lHand" val="0"/>
- +<set name="type" val="L2TvTEventNpc"/>
- +<set name="exp" val="0"/>
- +<set name="sp" val="0"/>
- +<set name="hp" val="2444.46819"/>
- +<set name="mp" val="1345.8"/>
- +<set name="hpRegen" val="7.5"/>
- +<set name="mpRegen" val="2.7"/>
- +<set name="pAtk" val="688.86373"/>
- +<set name="pDef" val="295.91597"/>
- +<set name="mAtk" val="470.40463"/>
- +<set name="mDef" val="216.53847"/>
- +<set name="crit" val="4"/>
- +<set name="atkSpd" val="253"/>
- +<set name="str" val="40"/>
- +<set name="int" val="21"/>
- +<set name="dex" val="30"/>
- +<set name="wit" val="20"/>
- +<set name="con" val="43"/>
- +<set name="men" val="20"/>
- +<set name="corpseTime" val="7"/>
- +<set name="walkSpd" val="50"/>
- +<set name="runSpd" val="120"/>
- +<set name="dropHerbGroup" val="0"/>
- +<set name="attackRange" val="40"/>
- +<ai type="DEFAULT" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
- +<skills>
- +<skill id="4045" level="1"/>
- +<skill id="4416" level="14"/>
- +</skills>
- +</npc>
- +</list>
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment