Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_datapack
- Index: data/xml/npcs/50000-50999.xml
- ===================================================================
- --- data/xml/npcs/50000-50999.xml (revision 2)
- +++ data/xml/npcs/50000-50999.xml (working copy)
- @@ -111,4 +111,41 @@
- <skill id="4416" level="18"/>
- </skills>
- </npc>
- + <npc id="50009" idTemplate="35322" name="Hestui" title="Event Manager">
- + <set name="usingServerSideName" val="true" />
- + <set name="usingServerSideTitle" val="true" />
- + <set name="level" val="20"/>
- + <set name="radius" val="34"/>
- + <set name="height" val="65"/>
- + <set name="rHand" val="0"/>
- + <set name="lHand" val="0"/>
- + <set name="type" val="EventsManager"/>
- + <set name="exp" val="0"/>
- + <set name="sp" val="10"/>
- + <set name="hp" val="342.5127"/>
- + <set name="mp" val="192"/>
- + <set name="hpRegen" val="2.5"/>
- + <set name="mpRegen" val="1.2"/>
- + <set name="pAtk" val="44.32863"/>
- + <set name="pDef" val="86.87049"/>
- + <set name="mAtk" val="30.2707"/>
- + <set name="mDef" val="63.56806"/>
- + <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"/>
- + <ai type="DEFAULT" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="false" seedable="false"/>
- + <skills>
- + <skill id="4045" level="1"/>
- + <skill id="4416" level="19"/>
- + </skills>
- + </npc>
- </list>
- \ No newline at end of file
- Index: data/html/mods/TeamVsTeam/RemoveParticipation.htm
- ===================================================================
- --- data/html/mods/TeamVsTeam/RemoveParticipation.htm (revision 0)
- +++ data/html/mods/TeamVsTeam/RemoveParticipation.htm (working copy)
- @@ -0,0 +1,6 @@
- +<html><title>Event Manager</title><body>
- +Cancel Registration yourself for the Event:<br1>
- +You are already registered for this event. Do you wish to cancel your participation in this Event?<br><center>
- +<button value="Yes" action="bypass -h npc_%objectId%_events_remove_participation" width=40 height=15 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
- +<button value="No" action="bypass -h npc_%objectId%_Close" width=40 height=15 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
- +</center></body></html>
- \ No newline at end of file
- Index: data/html/mods/TeamVsTeam/Participation.htm
- ===================================================================
- --- data/html/mods/TeamVsTeam/Participation.htm (revision 0)
- +++ data/html/mods/TeamVsTeam/Participation.htm (working copy)
- @@ -0,0 +1,7 @@
- +<html><title>Event Manager</title><body>
- +Registration for the Event:<br><br><center>
- +%playercount% players in<br>
- +Participation Fee: %fee%<br>
- +<button value="Participate" action="bypass -h npc_%objectId%_events_participation" width=50 height=15 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
- +<button value="Close" action="bypass -h npc_%objectId%_Close" width=50 height=15 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
- +</center></body></html>
- \ No newline at end of file
- Index: data/html/mods/TeamVsTeam/Status.htm
- ===================================================================
- --- data/html/mods/TeamVsTeam/Status.htm (revision 0)
- +++ data/html/mods/TeamVsTeam/Status.htm (working copy)
- @@ -0,0 +1,5 @@
- +<html><title>TvT Event</title><body>
- +Status:<br><br><center>
- +%team1name% with %team1playercount% players and %team1points% points.<br1>
- +%team2name% with %team2playercount% players and %team2points% points.<br>
- +</center></body></html>
- \ No newline at end of file
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (working copy)
- @@ -28,6 +28,8 @@
- {
- if (cha instanceof Player)
- ((Player) cha).reviveRequest((Player) activeChar, skill, false);
- + else if (cha instanceof Player)
- + ((Player) cha).isInFunEvent();
- else if (cha instanceof Pet)
- {
- if (((Pet) cha).getOwner() == activeChar)
- Index: java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (working copy)
- @@ -8,6 +8,7 @@
- import net.sf.l2j.gameserver.model.actor.Npc;
- import net.sf.l2j.gameserver.model.actor.instance.Player;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- import net.sf.l2j.gameserver.network.serverpackets.SendTradeRequest;
- import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- @@ -40,6 +41,12 @@
- player.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
- return;
- }
- +
- + if (player.isInFunEvent() || target.isInFunEvent())
- + {
- + player.sendPacket(new ExShowScreenMessage("You can't Trade when is in events.", 8000, 0x02, true));
- + return;
- + }
- if (target.isInOlympiadMode() || player.isInOlympiadMode())
- {
- Index: java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java (working copy)
- @@ -11,6 +11,7 @@
- import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- import net.sf.l2j.gameserver.model.item.type.EtcItemType;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- import net.sf.l2j.gameserver.network.serverpackets.ExUseSharedGroupItem;
- import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- @@ -35,6 +36,13 @@
- return;
- }
- + // players can not use in events
- + if (activeChar.isInFunEvent())
- + {
- + activeChar.sendPacket(new ExShowScreenMessage("You can't use Potion in event.", 8000, 0x02, true));
- + return;
- + }
- +
- final IntIntHolder[] skills = item.getEtcItem().getSkills();
- if (skills == null)
- {
- Index: java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeleport.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeleport.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeleport.java (working copy)
- @@ -0,0 +1,131 @@
- +package net.sf.l2j.gameserver.model.entity.engine.impl;
- +
- +import net.sf.l2j.commons.concurrent.ThreadPool;
- +import net.sf.l2j.commons.random.Rnd;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.SkillTable;
- +import net.sf.l2j.gameserver.model.actor.Summon;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +import net.sf.l2j.gameserver.model.actor.instance.Servitor;
- +import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
- +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
- +import net.sf.l2j.gameserver.model.group.Party.MessageType;
- +import net.sf.l2j.gameserver.network.serverpackets.Ride;
- +
- +/**
- + * @author williams
- + *
- + */
- +public class EventTeleport implements Runnable
- +{
- + /** The instance of the player to teleport */
- + public Player _player;
- + /** Coordinates of the spot to teleport to */
- + public int[] _coordinates = new int[3];
- + /** Admin removed this player from event */
- + private boolean _adminRemove;
- +
- + /**
- + * Initialize the teleport and start the delayed task
- + * @param playerInstance
- + * @param coordinates
- + * @param fastSchedule
- + * @param adminRemove
- + */
- + public EventTeleport(Player playerInstance, int[] coordinates, boolean fastSchedule, boolean adminRemove)
- + {
- + _player = playerInstance;
- + _coordinates = coordinates;
- + _adminRemove = adminRemove;
- +
- + // in config as seconds
- + long delay = (TeamVsTeam.isStarted() ? 10 : 10) * 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
- + * 6. Remove party
- + * 7. Restricted for skill
- + * 8. Remove players mounted
- + */
- + @Override
- + public void run()
- + {
- + if (_player == null)
- + return;
- +
- + if (_player.getPet() != null)
- + {
- + Summon summon = _player.getPet();
- + summon.stopAllEffects();
- +
- + if (summon instanceof Servitor)
- + summon.unSummon(_player);
- + }
- +
- + if (Config.EVENTS_EFFECTS_REMOVAL == 0 || (Config.EVENTS_EFFECTS_REMOVAL == 1 && (_player.getTeam() == 0 || (_player.isInDuel() && _player.getDuelState() != DuelState.INTERRUPTED))))
- + _player.stopAllEffectsExceptThoseThatLastThroughDeath();
- +
- + if (_player.getParty() != null)
- + _player.getParty().removePartyMember(_player, MessageType.EXPELLED);
- +
- + if (_player.isMounted())
- + {
- + if (_player.dismount())
- + {
- + if (_player.isFlying())
- + _player.removeSkill(SkillTable.FrequentSkill.WYVERN_BREATH.getSkill().getId(), false);
- +
- + final Ride dismount = new Ride(_player.getObjectId(), Ride.ACTION_DISMOUNT, 0);
- + _player.broadcastPacket(dismount);
- + _player.setMountObjectId(0);
- + }
- + }
- +
- + if (_player.isMageClass())
- + {
- + for (int[] mageBuffs : Config.EVENTS_MAGE_BUFFS)
- + {
- + if (mageBuffs == null)
- + continue;
- +
- + SkillTable.getInstance().getInfo(mageBuffs[0], mageBuffs[1]).getEffects(_player, _player);
- + }
- + }
- + else
- + {
- + for (int[] fighterBuffs : Config.EVENTS_FIGHTER_BUFFS)
- + {
- + if (fighterBuffs == null)
- + continue;
- +
- + SkillTable.getInstance().getInfo(fighterBuffs[0], fighterBuffs[1]).getEffects(_player, _player);
- + }
- + }
- +
- + if (TeamVsTeam.isStarted() && !_adminRemove)
- + _player.setTeam(TeamVsTeam.getParticipantTeamId(_player.getName()) + 1);
- + else
- + _player.setTeam(0);
- +
- + _player.doRevive();
- + _player.setCurrentHp(_player.getMaxHp());
- + _player.setCurrentCp(_player.getMaxCp());
- + _player.setCurrentMp(_player.getMaxMp());
- + _player.teleToLocation(_coordinates[0] + Rnd.get(101) - 50, _coordinates[1] + Rnd.get(101) - 50, _coordinates[2], 0);
- +
- + _player.broadcastStatusUpdate();
- + _player.broadcastUserInfo();
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (working copy)
- @@ -46,6 +46,12 @@
- requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
- return;
- }
- +
- + if (target.isInFunEvent() || requestor.isInFunEvent())
- + {
- + requestor.sendMessage("The player you tried to invite is currently in an event.");
- + return;
- + }
- if (target.isInParty())
- {
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (working copy)
- @@ -7,6 +7,7 @@
- import net.sf.l2j.gameserver.network.L2GameClient.GameClientState;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.CharSelectInfo;
- +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- import net.sf.l2j.gameserver.network.serverpackets.RestartResponse;
- import net.sf.l2j.gameserver.taskmanager.AttackStanceTaskManager;
- @@ -43,7 +44,12 @@
- sendPacket(RestartResponse.valueOf(false));
- return;
- }
- -
- + if (player.isInFunEvent())
- + {
- + player.sendPacket(new ExShowScreenMessage("You can not Restart the event.", 3000, 0x02, true));
- + sendPacket(RestartResponse.valueOf(false));
- + return;
- + }
- if (player.isFestivalParticipant() && SevenSignsFestival.getInstance().isFestivalInitialized())
- {
- player.sendPacket(SystemMessageId.NO_RESTART_HERE);
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 2)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -65,6 +65,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;
- @@ -84,6 +85,7 @@
- import net.sf.l2j.gameserver.model.boat.BoatRunePrimeval;
- import net.sf.l2j.gameserver.model.boat.BoatTalkingGludin;
- import net.sf.l2j.gameserver.model.entity.Hero;
- +import net.sf.l2j.gameserver.model.entity.engine.impl.manager.EngineManager;
- import net.sf.l2j.gameserver.model.olympiad.Olympiad;
- import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
- import net.sf.l2j.gameserver.model.partymatching.PartyMatchRoomList;
- @@ -270,6 +272,9 @@
- if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
- FishingChampionshipManager.getInstance();
- + StringUtil.printSection("Events jDevs");
- + EngineManager.getInstance();
- +
- StringUtil.printSection("Handlers");
- LOGGER.info("AutoSpawnHandler: Loaded {} handlers.", AutoSpawnManager.getInstance().size());
- LOGGER.info("Loaded {} admin command handlers.", AdminCommandHandler.getInstance().size());
- @@ -277,6 +282,7 @@
- LOGGER.info("Loaded {} item handlers.", ItemHandler.getInstance().size());
- LOGGER.info("Loaded {} skill handlers.", SkillHandler.getInstance().size());
- LOGGER.info("Loaded {} user command handlers.", UserCommandHandler.getInstance().size());
- + LOGGER.info("Loaded {} voiced command handlers." , VoicedCommandHandler.getInstance().size());
- StringUtil.printSection("System");
- Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
- Index: java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeam.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeam.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeam.java (working copy)
- @@ -0,0 +1,189 @@
- +package net.sf.l2j.gameserver.model.entity.engine.impl;
- +
- +import java.util.HashMap;
- +import java.util.Map;
- +import java.util.Vector;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +
- +/**
- + * @author williams
- + *
- + */
- +public class EventTeam
- +{
- + /** The name of the team */
- + private String _name;
- +
- + /** The team spot coordinated */
- + private int[] _coordinates = new int[3];
- +
- + /** The points of the team */
- + private short _points;
- +
- + /** Name and instance of all participated players in HashMap */
- + private Map<String, Player> _participatedPlayers = new HashMap<>();
- +
- + /** Name of all participated players in Vector */
- + private Vector<String> _participatedPlayerNames = new Vector<>();
- +
- + /**
- + * C'tor initialize the team
- + * @param name
- + * @param coordinates
- + */
- + public EventTeam(String name, int[] coordinates)
- + {
- + _name = name;
- + _coordinates = coordinates;
- + _points = 0;
- + }
- +
- + /**
- + * Adds a player to the team
- + * @param player
- + * @return boolean
- + */
- + public boolean addPlayer(Player player)
- + {
- + if (player == null)
- + return false;
- +
- + synchronized (_participatedPlayers)
- + {
- + String playerName = player.getName();
- +
- + _participatedPlayers.put(playerName, player);
- +
- + 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
- + */
- + public void increasePoints()
- + {
- + _points++;
- + }
- +
- + /**
- + * Cleanup the team and make it ready for adding players again
- + */
- + 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 HashMap
- + * @return Map<String, Player>
- + */
- + public Map<String, Player> getParticipatedPlayers()
- + {
- + Map<String, Player> participatedPlayers = null;
- +
- + synchronized (_participatedPlayers)
- + {
- + participatedPlayers = _participatedPlayers;
- + }
- +
- + return participatedPlayers;
- + }
- +
- + /**
- + * Returns name of all participated players in Vector
- + * @return Vector<String>
- + */
- + public Vector<String> getParticipatedPlayerNames()
- + {
- + Vector<String> participatedPlayerNames = null;
- +
- + synchronized (_participatedPlayers)
- + {
- + participatedPlayerNames = _participatedPlayerNames;
- + }
- +
- + return participatedPlayerNames;
- + }
- +
- + /**
- + * Returns player count of this team
- + * @return int
- + */
- + public int getParticipatedPlayerCount()
- + {
- + int participatedPlayerCount;
- +
- + synchronized (_participatedPlayers)
- + {
- + participatedPlayerCount = _participatedPlayers.size();
- + }
- +
- + return participatedPlayerCount;
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/entity/engine/TeamVsTeam.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/engine/TeamVsTeam.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/entity/engine/TeamVsTeam.java (working copy)
- @@ -0,0 +1,744 @@
- +package net.sf.l2j.gameserver.model.entity.engine;
- +
- +import net.sf.l2j.commons.concurrent.ThreadPool;
- +import net.sf.l2j.commons.random.Rnd;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.ItemTable;
- +import net.sf.l2j.gameserver.data.SpawnTable;
- +import net.sf.l2j.gameserver.data.xml.DoorData;
- +import net.sf.l2j.gameserver.data.xml.NpcData;
- +import net.sf.l2j.gameserver.model.L2Spawn;
- +import net.sf.l2j.gameserver.model.World;
- +import net.sf.l2j.gameserver.model.actor.Creature;
- +import net.sf.l2j.gameserver.model.actor.Npc;
- +import net.sf.l2j.gameserver.model.actor.Summon;
- +import net.sf.l2j.gameserver.model.actor.instance.Door;
- +import net.sf.l2j.gameserver.model.actor.instance.Pet;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +import net.sf.l2j.gameserver.model.actor.instance.Servitor;
- +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- +import net.sf.l2j.gameserver.model.entity.engine.impl.EventTeam;
- +import net.sf.l2j.gameserver.model.entity.engine.impl.EventTeleport;
- +import net.sf.l2j.gameserver.model.entity.engine.impl.EventsState;
- +import net.sf.l2j.gameserver.model.location.Location;
- +import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
- +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
- +import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
- +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +
- +/**
- + * @author williams
- + *
- + */
- +public class TeamVsTeam
- +{
- + /** The teams of the TeamVsTeam */
- + public static EventTeam[] _teams = new EventTeam[2]; // event only allow max 2 teams
- + /** The state of the TeamVsTeam */
- + public static EventsState _state = EventsState.INACTIVE;
- +
- + /**
- + * Teams initializing<br>
- + */
- + public static void init()
- + {
- + _teams[0] = new EventTeam(Config.TVT_EVENT_TEAM_1_NAME, Config.TVT_EVENT_TEAM_1_COORDINATES);
- + _teams[1] = new EventTeam(Config.TVT_EVENT_TEAM_2_NAME, Config.TVT_EVENT_TEAM_2_COORDINATES);
- + }
- +
- + /**
- + * Starts the participation of the TeamVsTeam<br>
- + * 1. Try to spawn a new npc of it<br>
- + * <br>
- + * @return boolean<br>
- + */
- + public static boolean startParticipation()
- + {
- + try
- + {
- + final NpcTemplate template = NpcData.getInstance().getTemplate(Config.EVENTS_PARTICIPATION_NPC_ID);
- + final L2Spawn spawn = new L2Spawn(template);
- + spawn.setLoc(Config.EVENTS_PARTICIPATION_NPC_COORDINATES[0], Config.EVENTS_PARTICIPATION_NPC_COORDINATES[1], Config.EVENTS_PARTICIPATION_NPC_COORDINATES[2], 0);
- +
- + SpawnTable.getInstance().addNewSpawn(spawn, false);
- + final Npc npc = spawn.doSpawn(true);
- + npc.scheduleDespawn(Config.TVT_EVENT_RUNNING_TIME * 1000 * 60);
- + npc.broadcastPacket(new MagicSkillUse(npc, npc, 1034, 1, 1, 1));
- + }
- + catch (Exception e)
- + {
- + System.out.println("TeamVsTeam: exception: " + e);
- + return false;
- + }
- + setState(EventsState.PARTICIPATING);
- + return true;
- + }
- +
- + /**
- + * Starts the TeamVsTeam fight<br>
- + * 1. Set state EventsState.STARTING<br>
- + * 2. Close doors specified in configs<br>
- + * 3. Abort if not enought participants(return false)<br>
- + * 4. Set state EventsState.STARTED<br>
- + * 5. Teleport all participants to team spot<br>
- + * <br>
- + * @return boolean<br>
- + */
- + public static boolean startFight()
- + {
- + setState(EventsState.STARTING);
- +
- + // not enought participants
- + if (_teams[0].getParticipatedPlayerCount() < Config.EVENTS_MIN_PLAYERS_IN_TEAMS || _teams[1].getParticipatedPlayerCount() < Config.EVENTS_MIN_PLAYERS_IN_TEAMS)
- + {
- + setState(EventsState.INACTIVE);
- + _teams[0].cleanMe();
- + _teams[1].cleanMe();
- + return false;
- + }
- +
- + closeDoors();
- + setState(EventsState.STARTED); // set state to STARTED here, so TeamVsTeamTeleporter know to teleport to team spot
- +
- + // teleport all participants to there team spot
- + for (EventTeam team : _teams)
- + {
- + for (String playerName : team.getParticipatedPlayerNames())
- + {
- + Player player = team.getParticipatedPlayers().get(playerName);
- +
- + if (player == null)
- + continue;
- +
- + if (isStarted())
- + player.setTeam(getParticipantTeamId(player.getName()) + 1);
- + else
- + player.setTeam(0);
- +
- + ThreadPool.schedule(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + player.sendPacket(new ExShowScreenMessage("Fight starts in 5 seconds!", 5000, 0x02, true));
- + }
- + }, 1000 * 13);
- +
- + ThreadPool.schedule(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + player.broadcastPacket(new SocialAction(player, 4));
- + player.sendPacket(new ExShowScreenMessage("Fight started!", 5000, 0x02, true));
- + }
- + }, 1000 * 20);
- +
- + if (Config.TVT_EVENT_ON_KILL.equalsIgnoreCase("pmtitle"))
- + {
- + player.setTitle("Kills: " + player.getScore());
- + player.getAppearance().setVisibleTitle("Kills: " + player.getScore());
- + player.broadcastTitleInfo();
- + }
- +
- + player.getSavedLocation().set(player.getPosition());
- + // implements Runnable and starts itself in constructor
- + new EventTeleport(player, team.getCoordinates(), false, false);
- + }
- + }
- + return true;
- + }
- +
- + /**
- + * Calculates the TeamVsTeam 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(EventsState.REWARDING);
- + return "TeamVsTeam: Event finish. No team won, cause of inactivity!";
- + }
- + sysMsgToAllParticipants("TeamVsTeam: Both teams are at a tie, next team to get a kill wins!");
- + }
- +
- + while (_teams[0].getPoints() == _teams[1].getPoints())
- + {
- + waiter(1);
- + }
- +
- + setState(EventsState.REWARDING); // after state REWARDING is set, nobody can point anymore
- +
- + byte teamId = (byte) (_teams[0].getPoints() > _teams[1].getPoints() ? 0 : 1); // which team wins?
- + EventTeam team = _teams[teamId];
- +
- + for (Player player : team.getParticipatedPlayers().values())
- + {
- + if (player == null)
- + continue;
- +
- + for (int[] reward : Config.TVT_EVENT_REWARDS)
- + {
- + if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
- + player.getInventory().addItem("TeamVsTeam", reward[0], reward[1], player, player);
- + else
- + {
- + for (int i = 0; i < reward[1]; i++)
- + player.getInventory().addItem("TeamVsTeam", reward[0], 1, player, player);
- + }
- +
- + if (reward[1] > 1)
- + {
- + SystemMessage systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
- + systemMessage.addItemName(reward[0]);
- + systemMessage.addNumber(reward[1]);
- + }
- + else
- + {
- + SystemMessage systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
- + systemMessage.addItemName(reward[0]);
- + player.sendPacket(systemMessage);
- + }
- + }
- +
- + StatusUpdate statusUpdate = new StatusUpdate(player);
- + statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
- + player.sendPacket(statusUpdate);
- +
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
- + npcHtmlMessage.setHtml("<html><head><title>Team Vs Team</title></head><body><font color=\"LEVEL\">Your team won the event!</font><br>Look in your inventory, there should be your reward.</body></html>");
- + player.sendPacket(npcHtmlMessage);
- +
- + }
- + return "TeamVsTeam: Event finish. Team " + team.getName() + " won with " + team.getPoints() + " kills.";
- + }
- +
- + /**
- + * Stops the TeamVsTeam fight<br>
- + * 1. Set state EventsState.INACTIVATING<br>
- + * 2. Remove TeamVsTeam 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 EventsState.INACTIVE<br>
- + */
- + public static void stopFight()
- + {
- + setState(EventsState.INACTIVATING);
- + openDoors();
- +
- + for (EventTeam team : _teams)
- + {
- + for (final Player player : team.getParticipatedPlayers().values())
- + {
- + if (player == null)
- + continue;
- +
- + final Location loc = player.getSavedLocation();
- + if (loc.equals(Location.DUMMY_LOC))
- + return;
- +
- + player.teleToLocation(loc, 0);
- + player.getSavedLocation().clean();
- +
- + if (isInactive())
- + player.setTeam(getParticipantTeamId(player.getName()) + 1);
- + else
- + player.setTeam(0);
- +
- + player.broadcastPacket(new SocialAction(player, 7));
- +
- + if (Config.TVT_EVENT_ON_KILL.equalsIgnoreCase("pmtitle"))
- + {
- + ThreadPool.schedule(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + player.setTitle(player.getOriginalTitle());
- + player.getAppearance().setVisibleTitle(player.getOriginalTitle());
- + player.broadcastTitleInfo();
- + player.clearPoints();
- + }
- + }, 10 * 1000);
- + }
- + }
- + }
- +
- + _teams[0].cleanMe();
- + _teams[1].cleanMe();
- + setState(EventsState.INACTIVE);
- + }
- +
- + /**
- + * Adds a player to a TeamVsTeam 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 player
- + * @return boolean
- + */
- + public static synchronized boolean addParticipant(Player player)
- + {
- + if (player == 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(player);
- + }
- +
- + /**
- + * Removes a TeamVsTeam 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;
- +
- + for (final Player player : _teams[teamId].getParticipatedPlayers().values())
- + {
- + if (player != null)
- + {
- + if (isInactive())
- + player.setTeam(getParticipantTeamId(player.getName()) + 1);
- + else
- + player.setTeam(0);
- +
- + final Location loc = player.getSavedLocation();
- + if (loc.equals(Location.DUMMY_LOC))
- + return true;
- +
- + player.teleToLocation(loc, 0);
- + player.getSavedLocation().clean();
- + }
- + }
- +
- + _teams[teamId].removePlayer(playerName);
- + return true;
- + }
- +
- + /**
- + * Send a SystemMessage to all participated players<br>
- + * 1. Send the message to all players of team number one<br>
- + * 2. Send the message to all players of team number two
- + * @param message
- + */
- + public static void sysMsgToAllParticipants(String message)
- + {
- + for (Player player : _teams[0].getParticipatedPlayers().values())
- + {
- + if (player != null)
- + player.sendMessage(message);
- + }
- +
- + for (Player player : _teams[1].getParticipatedPlayers().values())
- + {
- + if (player != null)
- + player.sendMessage(message);
- + }
- + }
- +
- + /**
- + * Close doors specified in configs
- + */
- + public static void closeDoors()
- + {
- + for (int doorId : Config.EVENTS_DOORS_IDS_TO_CLOSE)
- + {
- + Door door = DoorData.getInstance().getDoor(doorId);
- +
- + if (door != null)
- + door.closeMe();
- + }
- + }
- +
- + /**
- + * Open doors specified in configs
- + */
- + public static void openDoors()
- + {
- + for (int doorId : Config.EVENTS_DOORS_IDS_TO_OPEN)
- + {
- + Door door = DoorData.getInstance().getDoor(doorId);
- +
- + if (door != null)
- + door.openMe();
- + }
- + }
- +
- + public static void waiter(int seconds)
- + {
- + try
- + {
- + Thread.sleep(seconds * 1000);
- + }
- + catch (InterruptedException e)
- + {
- + e.printStackTrace();
- + }
- + }
- +
- + /**
- + * Called when a player logs in
- + * @param player
- + */
- + public static void onLogin(Player player)
- + {
- + if (player == null || (!isStarting() && !isStarted()))
- + return;
- +
- + byte teamId = getParticipantTeamId(player.getName());
- +
- + if (teamId == -1)
- + return;
- +
- + _teams[teamId].addPlayer(player);
- + new EventTeleport(player, _teams[teamId].getCoordinates(), true, false);
- + }
- +
- + /**
- + * Called when a player logs out
- + * @param player
- + */
- + public static void onLogout(Player player)
- + {
- + if (player == null || (!isStarting() && !isStarted()))
- + return;
- +
- + if (isInactive())
- + player.setTeam(getParticipantTeamId(player.getName()) + 1);
- + else
- + player.setTeam(0);
- +
- + if (Config.TVT_EVENT_ON_KILL.equalsIgnoreCase("pmtitle"))
- + {
- + player.setTitle(player.getOriginalTitle());
- + player.getAppearance().setVisibleTitle(player.getOriginalTitle());
- + player.broadcastTitleInfo();
- + }
- + removeParticipant(player.getName());
- + }
- +
- + /**
- + * Called on every onAction in L2PcIstance
- + * @param playerName
- + * @param targetPlayerName
- + * @return boolean
- + */
- + public static boolean onAction(String playerName, String targetPlayerName)
- + {
- + if (!isStarted())
- + return true;
- +
- + Player player = World.getInstance().getPlayer(playerName);
- +
- + if (player == null)
- + return false;
- +
- + if (player.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)
- + return false;
- +
- + return true;
- + }
- +
- + /**
- + * Is called when a player is killed
- + * @param killerCharacter
- + * @param killerPlayer
- + */
- + public static void onKill(Creature killerCharacter, Player killerPlayer)
- + {
- + if (killerPlayer == null || !isStarted())
- + return;
- +
- + byte killedTeamId = getParticipantTeamId(killerPlayer.getName());
- +
- + if (killedTeamId == -1)
- + return;
- +
- + new EventTeleport(killerPlayer, _teams[killedTeamId].getCoordinates(), false, false);
- +
- + if (killerCharacter == null)
- + return;
- +
- + if (killerCharacter instanceof Pet || killerCharacter instanceof Servitor)
- + {
- + killerPlayer = ((Summon) killerCharacter).getOwner();
- +
- + if (killerPlayer == null)
- + return;
- + }
- + else if (killerCharacter instanceof Player)
- + killerPlayer = (Player) killerCharacter;
- + else
- + return;
- +
- + for (int[] rewardKills : Config.TVT_EVENT_REWARDS_KILL)
- + {
- + killerPlayer.increaseKills();
- + switch (killerPlayer.getEventKills())
- + {
- + 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 = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
- + systemMessage.addItemName(rewardKills[0]);
- + systemMessage.addNumber(rewardKills[1]);
- + killerPlayer.sendPacket(systemMessage);
- +
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Player " + killerPlayer.getName() + " has " + killerPlayer.getEventKills() + " kills without die.", true);
- + killerPlayer.getInventory().addItem("TeamVsTeam", rewardKills[0], rewardKills[1], killerPlayer, killerPlayer);
- + break;
- + }
- + }
- +
- + byte killerTeamId = getParticipantTeamId(killerPlayer.getName());
- +
- + if (killerTeamId != -1 && killedTeamId != -1 && killerTeamId != killedTeamId)
- + {
- + EventTeam killerTeam = _teams[killerTeamId];
- +
- + killerTeam.increasePoints();
- +
- + if (Config.TVT_EVENT_ON_KILL.equalsIgnoreCase("pmtitle"))
- + {
- + sysMsgToAllParticipants(killerPlayer.getName() + " I have killed " + killerPlayer.getName()+ " !");
- + final PlaySound ps = new PlaySound(0, "ItemSound.quest_itemget");
- + _teams[killerTeamId].getParticipatedPlayers().values();
- + killerPlayer.increaseScore();
- + killerPlayer.setTitle("Kills: " + killerPlayer.getScore());
- + killerPlayer.getAppearance().setVisibleTitle("Kills: " + killerPlayer.getScore());
- + killerPlayer.broadcastTitleInfo();
- + killerPlayer.sendPacket(ps);
- + }
- + }
- + }
- +
- + /**
- + * Sets the TeamVsTeam state
- + * @param state
- + */
- + private static void setState(EventsState state)
- + {
- + synchronized (_state)
- + {
- + _state = state;
- + }
- + }
- +
- + /**
- + * Is TeamVsTeam inactive?
- + * @return boolean
- + */
- + public static boolean isInactive()
- + {
- + boolean isInactive;
- +
- + synchronized (_state)
- + {
- + isInactive = _state == EventsState.INACTIVE;
- + }
- +
- + return isInactive;
- + }
- +
- + /**
- + * Is TeamVsTeam in inactivating?
- + * @return boolean
- + */
- + public static boolean isInactivating()
- + {
- + boolean isInactivating;
- +
- + synchronized (_state)
- + {
- + isInactivating = _state == EventsState.INACTIVATING;
- + }
- +
- + return isInactivating;
- + }
- +
- + /**
- + * Is TeamVsTeam in participation?
- + * @return boolean
- + */
- + public static boolean isParticipating()
- + {
- + boolean isParticipating;
- +
- + synchronized (_state)
- + {
- + isParticipating = _state == EventsState.PARTICIPATING;
- + }
- +
- + return isParticipating;
- + }
- +
- + /**
- + * Is TeamVsTeam starting?
- + * @return boolean
- + */
- + public static boolean isStarting()
- + {
- + boolean isStarting;
- +
- + synchronized (_state)
- + {
- + isStarting = _state == EventsState.STARTING;
- + }
- +
- + return isStarting;
- + }
- +
- + /**
- + * Is TeamVsTeam started?
- + * @return boolean
- + */
- + public static boolean isStarted()
- + {
- + boolean isStarted;
- +
- + synchronized (_state)
- + {
- + isStarted = _state == EventsState.STARTED;
- + }
- +
- + return isStarted;
- + }
- +
- + /**
- + * Is TeamVsTeam rewarding?
- + * @return boolean
- + */
- + public static boolean isRewarding()
- + {
- + boolean isRewarding;
- +
- + synchronized (_state)
- + {
- + isRewarding = _state == EventsState.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/network/clientpackets/Logout.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
- @@ -5,6 +5,7 @@
- import net.sf.l2j.gameserver.model.zone.ZoneId;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- import net.sf.l2j.gameserver.taskmanager.AttackStanceTaskManager;
- public final class Logout extends L2GameClientPacket
- @@ -27,6 +28,13 @@
- return;
- }
- + if (player.isInFunEvent())
- + {
- + player.sendPacket(new ExShowScreenMessage("You can not Exit the event.", 3000, 0x02, true));
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- if (player.isInsideZone(ZoneId.NO_RESTART))
- {
- player.sendPacket(SystemMessageId.NO_LOGOUT_HERE);
- Index: java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (working copy)
- @@ -11,6 +11,7 @@
- import net.sf.l2j.gameserver.model.holder.IntIntHolder;
- import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- public class ScrollOfResurrection implements IItemHandler
- {
- @@ -39,6 +40,12 @@
- return;
- }
- + if (activeChar.isInFunEvent())
- + {
- + activeChar.sendPacket(new ExShowScreenMessage("You can't use Scroll Of Resurrection in event." , 8000, 0x02, true));
- + return;
- + }
- +
- // Pet scrolls to ress a player.
- if (item.getItemId() == 6387 && target instanceof Player)
- {
- Index: java/net/sf/l2j/gameserver/model/entity/engine/impl/EventsState.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/engine/impl/EventsState.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/entity/engine/impl/EventsState.java (working copy)
- @@ -0,0 +1,15 @@
- +package net.sf.l2j.gameserver.model.entity.engine.impl;
- +
- +/**
- + * @author williams
- + *
- + */
- +public enum EventsState
- +{
- + INACTIVE,
- + INACTIVATING,
- + PARTICIPATING,
- + STARTING,
- + STARTED,
- + REWARDING
- +}
- Index: java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java (revision 2)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java (working copy)
- @@ -122,7 +122,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/itemhandlers/SummonItems.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (working copy)
- @@ -42,6 +42,9 @@
- return;
- }
- + if (activeChar.isInFunEvent())
- + return;
- +
- if (activeChar.isInObserverMode())
- return;
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
- @@ -19,6 +19,7 @@
- import net.sf.l2j.gameserver.network.FloodProtectors.Action;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- public final class RequestBypassToServer extends L2GameClientPacket
- @@ -165,6 +166,12 @@
- return;
- }
- + if (player.isInFunEvent())
- + {
- + player.sendPacket(new ExShowScreenMessage("You can not observe games while registered for events", 5000, 0x02, true));
- + return;
- + }
- +
- if (OlympiadManager.getInstance().isRegisteredInComp(player))
- {
- player.sendPacket(SystemMessageId.WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
- Index: java/net/sf/l2j/gameserver/model/actor/instance/Player.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/Player.java (revision 2)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/Player.java (working copy)
- @@ -105,6 +105,7 @@
- import net.sf.l2j.gameserver.model.entity.Hero;
- import net.sf.l2j.gameserver.model.entity.Siege;
- import net.sf.l2j.gameserver.model.entity.Siege.SiegeSide;
- +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
- import net.sf.l2j.gameserver.model.group.CommandChannel;
- import net.sf.l2j.gameserver.model.group.Party;
- import net.sf.l2j.gameserver.model.group.Party.LootRule;
- @@ -578,6 +579,9 @@
- private Door _requestedGate;
- + private int _eventkills;
- + private short _points = 0;
- +
- /**
- * Constructor of Player (use Creature constructor).
- * <ul>
- @@ -2897,6 +2901,13 @@
- @Override
- public void onAction(Player player)
- {
- + // Check if this Player is in an event
- + if (!TeamVsTeam.onAction(player.getName(), getName()))
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- // Set the target of the player
- if (player.getTarget() != this)
- player.setTarget(this);
- @@ -2908,7 +2919,7 @@
- player.getAI().setIntention(CtrlIntention.INTERACT, this);
- return;
- }
- -
- +
- // Check if this Player is autoAttackable
- if (isAutoAttackable(player))
- {
- @@ -2941,6 +2952,13 @@
- {
- if (player.isGM())
- AdminEditChar.showCharacterInfo(player, this);
- +
- + // Check if this Player is in an event
- + if (!TeamVsTeam.onAction(player.getName(), getName()))
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- super.onActionShift(player);
- }
- @@ -3649,16 +3667,21 @@
- if (isMounted())
- stopFeed();
- + // kill the player in event
- + getEventKills();
- +
- synchronized (this)
- {
- if (isFakeDeath())
- stopFakeDeath(true);
- }
- + TeamVsTeam.onKill(killer, this);
- +
- if (killer != null)
- {
- Player pk = killer.getActingPlayer();
- -
- +
- // Clear resurrect xp calculation
- setExpBeforeDeath(0);
- @@ -3896,6 +3919,9 @@
- if (player == null)
- return;
- + if (isInFunEvent() == false)
- + return;
- +
- if (isInDuel() && player.getDuelId() == getDuelId())
- return;
- @@ -6296,6 +6322,10 @@
- if (attacker instanceof Monster)
- return true;
- + // Check if the attacker is in events started
- + if (isInFunEvent())
- + return true;
- +
- // Check if the attacker is not in the same party
- if (_party != null && _party.containsPlayer(attacker))
- return false;
- @@ -9278,6 +9308,9 @@
- if (OlympiadManager.getInstance().isRegisteredInComp(this))
- OlympiadManager.getInstance().removeDisconnectedCompetitor(this);
- +
- + if (isInFunEvent())
- + TeamVsTeam.removeParticipant(getName());
- // Open a Html message to inform the player
- final NpcHtmlMessage html = new NpcHtmlMessage(0);
- @@ -9425,7 +9458,7 @@
- if (_deathPenaltyBuffLevel >= 15) // maximum level reached
- return;
- - if ((getKarma() > 0 || Rnd.get(1, 100) <= Config.DEATH_PENALTY_CHANCE) && !(killer instanceof Player) && !isGM() && !(getCharmOfLuck() && (killer == null || killer.isRaid())) && !isPhoenixBlessed() && !(isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)))
- + if ((getKarma() > 0 || Rnd.get(1, 100) <= Config.DEATH_PENALTY_CHANCE) && !(killer instanceof Player) && !isGM() && !(getCharmOfLuck() && (killer == null || killer.isRaid())) && !isPhoenixBlessed() && !(isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)) && isInFunEvent())
- {
- if (_deathPenaltyBuffLevel != 0)
- removeSkill(5076, false);
- @@ -9808,7 +9841,7 @@
- if (summonerChar == null)
- return false;
- - if (summonerChar.isInOlympiadMode() || summonerChar.isInObserverMode() || summonerChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) || summonerChar.isMounted())
- + if (summonerChar.isInFunEvent() || summonerChar.isInOlympiadMode() || summonerChar.isInObserverMode() || summonerChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) || summonerChar.isMounted())
- return false;
- return true;
- @@ -9845,7 +9878,7 @@
- return false;
- }
- - if (targetChar.isFestivalParticipant() || targetChar.isMounted())
- + if (targetChar.isFestivalParticipant() || targetChar.isMounted() || targetChar.isInFunEvent())
- {
- summonerChar.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
- return false;
- @@ -10237,4 +10270,34 @@
- }
- }
- }
- +
- + public int getEventKills()
- + {
- + return _eventkills;
- + }
- +
- + public void increaseKills()
- + {
- + _eventkills++;
- + }
- +
- + public short getScore()
- + {
- + return _points;
- + }
- +
- + public void clearPoints()
- + {
- + _points = 0;
- + }
- +
- + public void increaseScore()
- + {
- + _points++;
- + }
- +
- + public boolean isInFunEvent()
- + {
- + return ((TeamVsTeam.isStarted() && TeamVsTeam.isPlayerParticipant(getName())) && !isGM());
- + }
- }
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (working copy)
- @@ -0,0 +1,14 @@
- +package net.sf.l2j.gameserver.handler;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +
- +/**
- + * @author Williams
- + *
- + */
- +public interface IVoicedCommandHandler
- +{
- + public boolean useVoicedCommand(String command, Player activeChar, String params);
- +
- + public String[] getVoicedCommandList();
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (revision 2)
- +++ java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (working copy)
- @@ -1,9 +1,11 @@
- package net.sf.l2j.gameserver.model.actor.appearance;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- import net.sf.l2j.gameserver.model.base.Sex;
- public final class PcAppearance
- {
- + private Player _owner;
- private byte _face;
- private byte _hairColor;
- private byte _hairStyle;
- @@ -11,6 +13,8 @@
- private boolean _invisible = false;
- private int _nameColor = 0xFFFFFF;
- private int _titleColor = 0xFFFF77;
- + private String _visibleName;
- + private String _visibleTitle;
- public PcAppearance(byte face, byte hColor, byte hStyle, Sex sex)
- {
- @@ -104,4 +108,40 @@
- {
- _titleColor = (red & 0xFF) + ((green & 0xFF) << 8) + ((blue & 0xFF) << 16);
- }
- +
- + public final void setVisibleName(String visibleName)
- + {
- + _visibleName = visibleName;
- + }
- +
- + public final String getVisibleName()
- + {
- + if (_visibleName == null)
- + _visibleName = getOwner().getName();
- +
- + return _visibleName;
- + }
- +
- + public final void setVisibleTitle(String visibleTitle)
- + {
- + _visibleTitle = visibleTitle;
- + }
- +
- + public final String getVisibleTitle()
- + {
- + if (_visibleTitle == null)
- + _visibleTitle = getOwner().getTitle();
- +
- + return _visibleTitle;
- + }
- +
- + public void setOwner(Player owner)
- + {
- + _owner = owner;
- + }
- +
- + public Player getOwner()
- + {
- + return _owner;
- + }
- }
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java (working copy)
- @@ -24,6 +24,13 @@
- final Player activeChar = getClient().getActiveChar();
- if (activeChar == null)
- return;
- +
- + // check participants can not change their title
- + if (activeChar.isInFunEvent())
- + {
- + activeChar.sendMessage("You cannot change title while participating in an event.");
- + return;
- + }
- // Noblesse can bestow a title to themselves
- if (activeChar.isNoble() && _target.matches(activeChar.getName()))
- Index: java/net/sf/l2j/gameserver/model/actor/Creature.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/Creature.java (revision 2)
- +++ java/net/sf/l2j/gameserver/model/actor/Creature.java (working copy)
- @@ -131,6 +131,8 @@
- private CreatureTemplate _template; // The link on the L2CharTemplate object containing generic and static properties
- protected String _title;
- + protected String _originalTitle;
- +
- private double _hpUpdateIncCheck = .0;
- private double _hpUpdateDecCheck = .0;
- private double _hpUpdateInterval = .0;
- @@ -1888,6 +1890,14 @@
- {
- return _title;
- }
- +
- + /**
- + * @return the Title of the Creature.
- + */
- + public final String getOriginalTitle()
- + {
- + return _originalTitle;
- + }
- /**
- * Set the Title of the Creature. Concatens it if length > 16.
- Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
- @@ -17,6 +17,7 @@
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEditNpc;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEffects;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEnchant;
- +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEvents;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminExpSp;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGeoEngine;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGm;
- @@ -63,6 +64,7 @@
- registerHandler(new AdminCursedWeapons());
- registerHandler(new AdminDelete());
- registerHandler(new AdminDoorControl());
- + registerHandler(new AdminEvents());
- registerHandler(new AdminEditChar());
- registerHandler(new AdminEditNpc());
- registerHandler(new AdminEffects());
- Index: java/net/sf/l2j/gameserver/model/actor/instance/EventsManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/EventsManager.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/EventsManager.java (working copy)
- @@ -0,0 +1,172 @@
- +package net.sf.l2j.gameserver.model.actor.instance;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.ItemTable;
- +import net.sf.l2j.gameserver.data.cache.HtmCache;
- +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
- +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +/**
- + * @author williams
- + *
- + */
- +public class EventsManager extends Folk
- +{
- + public EventsManager(int objectId, NpcTemplate template)
- + {
- + super(objectId, template);
- + }
- +
- + @Override
- + public void onBypassFeedback(Player player, String command)
- + {
- + if (player == null || !TeamVsTeam.isParticipating())
- + return;
- +
- + /**if (player.isAio())
- + {
- + player.sendPacket(new ExShowScreenMessage("Aio player can not register.", 3000, 0x02, true));
- + return;
- + }
- + */
- + if (command.equals("events_participation"))
- + {
- + /**if (DeathMatch.isPlayerParticipant(player.getName()) || CaptureTheFlag.isPlayerParticipant(player.getName()) || TeamVsTeamRound.isPlayerParticipant(player.getName()))
- + player.sendPacket(new ExShowScreenMessage("You can not participate when registered to another event.", 3000, 0x02, true));
- + else*/ if (player.isInDuel())
- + player.sendPacket(new ExShowScreenMessage("You must complete the duel before register.", 3000, 0x02, true));
- + else if (player.isMounted())
- + player.sendPacket(new ExShowScreenMessage("Revoke your pet before register.", 3000, 0x02, true));
- + else if (player.isInJail())
- + player.sendPacket(new ExShowScreenMessage("You can't register from the jail.", 3000, 0x02, true));
- + else if (player.isDead())
- + player.sendPacket(new ExShowScreenMessage("You can't register while you are dead.", 3000, 0x02, true));
- + else if (player.isCursedWeaponEquipped())
- + player.sendPacket(new ExShowScreenMessage("Cursed weapon owners are not allowed to participate.", 3000, 0x02, true));
- + else if (OlympiadManager.getInstance().isRegistered(player))
- + player.sendPacket(new ExShowScreenMessage("You can not participate when registered for Olympiad.", 3000, 0x02, true));
- + else if (Config.LIST_RESTRICTED_CLASSES_IN_EVENTS.contains(player.getTemplate().getClassId().getId()))
- + player.sendPacket(new ExShowScreenMessage("Your class isn't allowed in this event.", 3000, 0x02, true));
- + //else if (player.isAio())
- + //player.sendPacket(new ExShowScreenMessage("Aio charactes are not allowed to participate in events.", 3000, 0x02, true));
- + else if (player.getKarma() > 0)
- + player.sendPacket(new ExShowScreenMessage("Chaotic players are not allowed to participate.", 3000, 0x02, true));
- + else if (player.getLevel() < Config.EVENTS_MIN_LVL || player.getLevel() > Config.EVENTS_MAX_LVL)
- + player.sendPacket(new ExShowScreenMessage("Only players from level "+ Config.EVENTS_MIN_LVL +" to level "+ Config.EVENTS_MAX_LVL + " are allowed tro participate.", 3000, 0x02, true));
- + else if (TeamVsTeam._teams[0].getParticipatedPlayerCount() == Config.EVENTS_MAX_PLAYERS_IN_TEAMS && TeamVsTeam._teams[1].getParticipatedPlayerCount() == Config.EVENTS_MAX_PLAYERS_IN_TEAMS)
- + player.sendPacket(new ExShowScreenMessage("The event is full! Only "+ Config.EVENTS_MAX_PLAYERS_IN_TEAMS +" players are allowed per team.", 3000, 0x02, true));
- + // else if (Config.EVENTS_MAX_PARTICIPANTS_PER_IP > 0 && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.TVT_ID, player, Config.EVENTS_MAX_PARTICIPANTS_PER_IP))
- + // player.sendPacket(new ExShowScreenMessage("Maximum "+ AntiFeedManager.getInstance().getLimit(player, Config.EVENTS_MAX_PARTICIPANTS_PER_IP) +" participant(s) per IP address is allowed.", 3000, 0x02, true));
- + else if (needParticipationFee() && !hasParticipationFee(player))
- + player.sendPacket(new ExShowScreenMessage("You need "+ getParticipationFee() +" for participation.", 3000, 0x02, true));
- + else if (TeamVsTeam.addParticipant(player))
- + {
- + player.sendPacket(new ExShowScreenMessage("You are on the registration list now.", 3000, 0x02, true));
- + payParticipationFee(player);
- + }
- + else
- + return;
- + }
- + else if (command.equals("events_remove_participation"))
- + {
- + player.sendPacket(new ExShowScreenMessage("You are not longer on the registration list.", 3000, 0x02, true));
- + if (refundParticipationFee(player) != null)
- + TeamVsTeam.removeParticipant(player.getName());
- +
- + //if (Config.EVENTS_MAX_PARTICIPANTS_PER_IP > 0)
- + //AntiFeedManager.getInstance().removePlayer(AntiFeedManager.TVT_ID, player);
- + }
- + }
- +
- + @Override
- + public void showChatWindow(Player player, int val)
- + {
- + if (player == null)
- + return;
- +
- + if (TeamVsTeam.isParticipating())
- + {
- + boolean isParticipant = TeamVsTeam.isPlayerParticipant(player.getName());
- + String htmContent;
- + if (!isParticipant)
- + htmContent = HtmCache.getInstance().getHtm("data/html/mods/TeamVsTeam/Participation.htm");
- + else
- + htmContent = HtmCache.getInstance().getHtm("data/html/mods/TeamVsTeam/RemoveParticipation.htm");
- +
- + if (htmContent != null)
- + {
- + int[] teamsPlayerCounts = TeamVsTeam.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]));
- + npcHtmlMessage.replace("%playercount%", String.valueOf(teamsPlayerCounts[0] + teamsPlayerCounts[1]));
- +
- + if (!isParticipant)
- + npcHtmlMessage.replace("%fee%", getParticipationFee());
- +
- + player.sendPacket(npcHtmlMessage);
- + }
- + }
- + else if ((TeamVsTeam.isStarting()) || (TeamVsTeam.isStarted()))
- + {
- + String htmContent = HtmCache.getInstance().getHtm("data/html/mods/TeamVsTeam/Status.htm");
- + if (htmContent != null)
- + {
- + int[] teamsPlayerCounts = TeamVsTeam.getTeamsPlayerCounts();
- + int[] teamsPointsCounts = TeamVsTeam.getTeamsPoints();
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
- +
- + npcHtmlMessage.setHtml(htmContent);
- + 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]));
- + player.sendPacket(npcHtmlMessage);
- + }
- + }
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- +
- + public static boolean needParticipationFee()
- + {
- + return Config.EVENTS_PARTICIPATION_FEE[0] != 0 && Config.EVENTS_PARTICIPATION_FEE[1] != 0;
- + }
- +
- + public static boolean hasParticipationFee(Player player)
- + {
- + return player.getInventory().getInventoryItemCount(Config.EVENTS_PARTICIPATION_FEE[0], -1) >= Config.EVENTS_PARTICIPATION_FEE[1];
- + }
- +
- + public static boolean payParticipationFee(Player player)
- + {
- + return player.destroyItemByItemId("Participation Fee", Config.EVENTS_PARTICIPATION_FEE[0], Config.EVENTS_PARTICIPATION_FEE[1], null, true);
- + }
- +
- + public static ItemInstance refundParticipationFee(Player player)
- + {
- + return player.addItem("Participation Fee", Config.EVENTS_PARTICIPATION_FEE[0], Config.EVENTS_PARTICIPATION_FEE[1], null, true);
- + }
- +
- + public static String getParticipationFee()
- + {
- + int itemId = Config.EVENTS_PARTICIPATION_FEE[0];
- + int itemNum = Config.EVENTS_PARTICIPATION_FEE[1];
- +
- + if (itemId == 0 || itemNum == 0)
- + return "-";
- +
- + return String.valueOf(itemNum) + " " + ItemTable.getInstance().getTemplate(itemId).getName();
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (working copy)
- @@ -0,0 +1,53 @@
- +package net.sf.l2j.gameserver.handler;
- +
- +import java.util.HashMap;
- +import java.util.Map;
- +
- +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.RegisterEvents;
- +
- +/**
- + * @author williams
- + *
- + */
- +public class VoicedCommandHandler
- +{
- + private final Map<Integer, IVoicedCommandHandler> _datatable = new HashMap<>();
- +
- + public static VoicedCommandHandler getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + protected VoicedCommandHandler()
- + {
- + registerHandler(new RegisterEvents());
- + }
- +
- + 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/admincommandhandlers/AdminEvents.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEvents.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEvents.java (working copy)
- @@ -0,0 +1,91 @@
- +package net.sf.l2j.gameserver.handler.admincommandhandlers;
- +
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
- +import net.sf.l2j.gameserver.model.WorldObject;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
- +import net.sf.l2j.gameserver.model.entity.engine.impl.EventTeleport;
- +
- +/**
- + * @author williams
- + *
- + */
- +public class AdminEvents implements IAdminCommandHandler
- +{
- + private static final Logger GMAUDIT_LOG = Logger.getLogger("gmaudit");
- +
- + private static final String[] ADMIN_COMMANDS =
- + {
- + "admin_tvt_add",
- + "admin_tvt_remove"
- + };
- +
- + @Override
- + public boolean useAdminCommand(String command, Player adminInstance)
- + {
- + GMAUDIT_LOG.info(adminInstance.getName() + " [" + adminInstance.getObjectId() + "] used '" + command + "' command on: " + ((adminInstance.getTarget() != null) ? adminInstance.getTarget().getName() : "none"));
- +
- + if (command.equals("admin_tvt_add"))
- + {
- + WorldObject target = adminInstance.getTarget();
- +
- + if (target == null || !(target instanceof Player))
- + {
- + adminInstance.sendMessage("You should select a player!");
- + return true;
- + }
- +
- + add(adminInstance, (Player) target);
- + }
- + else if (command.equals("admin_tvt_remove"))
- + {
- + WorldObject target = adminInstance.getTarget();
- +
- + if (target == null || !(target instanceof Player))
- + {
- + adminInstance.sendMessage("You should select a player!");
- + return true;
- + }
- +
- + remove(adminInstance, (Player) target);
- + }
- +
- + return true;
- + }
- +
- + @Override
- + public String[] getAdminCommandList()
- + {
- + return ADMIN_COMMANDS;
- + }
- +
- + private static void add(Player adminInstance, Player playerInstance)
- + {
- + if (TeamVsTeam.isPlayerParticipant(playerInstance.getName()))
- + {
- + adminInstance.sendMessage("Player already participated in the event!");
- + return;
- + }
- +
- + if (!TeamVsTeam.addParticipant(playerInstance))
- + {
- + adminInstance.sendMessage("Player instance could not be added, it seems to be null!");
- + return;
- + }
- +
- + if (TeamVsTeam.isStarted())
- + // we don't need to check return value of TvTEvent.getParticipantTeamCoordinates() for null, TvTEvent.addParticipant() returned true so target is in event
- + new EventTeleport(playerInstance, TeamVsTeam.getParticipantTeamCoordinates(playerInstance.getName()), true, false);
- + }
- +
- + private static void remove(Player adminInstance, Player playerInstance)
- + {
- + if (!TeamVsTeam.removeParticipant(playerInstance.getName()))
- + {
- + adminInstance.sendMessage("Player is not part of the event!");
- + return;
- + }
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (revision 2)
- +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (working copy)
- @@ -17,7 +17,7 @@
- @Override
- public boolean useUserCommand(int id, Player activeChar)
- {
- - if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || activeChar.isInsideZone(ZoneId.BOSS))
- + if (activeChar.isInFunEvent() || activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || activeChar.isInsideZone(ZoneId.BOSS))
- {
- activeChar.sendPacket(SystemMessageId.NO_UNSTUCK_PLEASE_SEND_PETITION);
- return false;
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (working copy)
- @@ -40,6 +40,9 @@
- return;
- }
- + if (player.isInFunEvent())
- + return;
- +
- if (!player.isDead())
- return;
- Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (revision 2)
- +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (working copy)
- @@ -242,6 +242,12 @@
- player.sendPacket(SystemMessageId.ONLY_NOBLESS_CAN_PARTICIPATE_IN_THE_OLYMPIAD);
- return false;
- }
- +
- + if (player.isInFunEvent())
- + {
- + player.sendMessage("You cannot register in olympiad while registered at TvT.");
- + return false;
- + }
- if (player.isSubClassActive())
- {
- Index: java/net/sf/l2j/gameserver/model/entity/engine/impl/manager/EngineManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/engine/impl/manager/EngineManager.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/entity/engine/impl/manager/EngineManager.java (working copy)
- @@ -0,0 +1,239 @@
- +/*
- + * 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.engine.impl.manager;
- +
- +import java.util.Calendar;
- +import java.util.concurrent.ScheduledFuture;
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.Config;
- +
- +import net.sf.l2j.commons.concurrent.ThreadPool;
- +
- +import net.sf.l2j.gameserver.data.ItemTable;
- +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +
- +/**
- + * @author FBIagent
- + */
- +public class EngineManager
- +{
- + protected static final Logger _log = Logger.getLogger(EngineManager.class.getName());
- + private TVTStartTask _task;
- +
- + public EngineManager()
- + {
- + if (Config.TVT_ENABLED)
- + {
- + TeamVsTeam.init();
- + scheduleEventStart();
- + _log.info("TeamVsTeam: Started.");
- + }
- + else
- + _log.info("TeamVsTeam: Disabled.");
- + }
- +
- + public static EngineManager getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + public void scheduleEventStart()
- + {
- + try
- + {
- + Calendar currentTime = Calendar.getInstance();
- + Calendar nextStartTime = null;
- + Calendar testStartTime = null;
- + for (String timeOfDay : Config.TVT_EVENT_INTERVAL)
- + {
- + // Creating a Calendar object from the specified interval value
- + testStartTime = Calendar.getInstance();
- + testStartTime.setLenient(true);
- + String[] splitTimeOfDay = timeOfDay.split(":");
- + testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
- + testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
- +
- + // If the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
- + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
- + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
- +
- + // Check for the test date to be the minimum (smallest in the specified list)
- + if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
- + nextStartTime = testStartTime;
- + }
- + if (nextStartTime != null)
- + {
- + _task = new TVTStartTask(nextStartTime.getTimeInMillis());
- + ThreadPool.execute(_task);
- + }
- + }
- + catch (Exception e)
- + {
- + _log.warning("TeamVsTeam: Error figuring out a start time. Check TeamVsTeamInterval in config file.");
- + }
- + }
- +
- + public void startReg()
- + {
- + if (!TeamVsTeam.startParticipation())
- + {
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Event was cancelled.", true);
- + _log.warning("TeamVsTeam: Error spawning event npc for participation.");
- + scheduleEventStart();
- + }
- + else
- + {
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s).", true);
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Joinable in " + Config.EVENTS_JOIN_LOCATION + ".", true);
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Recruiting levels: " + Config.EVENTS_MIN_LVL + " to " + Config.EVENTS_MAX_LVL + ".", true);
- +
- + for (int[] reward : Config.TVT_EVENT_REWARDS)
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Reward: " + reward[1] + " " + ItemTable.getInstance().getTemplate(reward[0]).getName(), true);
- +
- + if (Config.TVT_VOICED_COMMAND)
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Commands .tvtjoin .tvtleave .tvtinfo.",true);
- +
- + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.TVT_EVENT_PARTICIPATION_TIME);
- + ThreadPool.execute(_task);
- + }
- + }
- +
- + public void startEvent()
- + {
- + if (!TeamVsTeam.startFight())
- + {
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Event cancelled due to lack of Participation.", true);
- + _log.info("TeamVsTeam: Lack of registration, abort event.");
- + scheduleEventStart();
- + }
- + else
- + {
- + TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: Teleporting participants to an arena in " + 10 + " second(s).");
- + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.TVT_EVENT_RUNNING_TIME);
- + ThreadPool.execute(_task);
- + }
- + }
- +
- + public void endEvent()
- + {
- + Broadcast.announceToOnlinePlayers(TeamVsTeam.calculateRewards(), true);
- + TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: Teleporting back to the registration npc in " + 10 + " second(s).");
- + TeamVsTeam.stopFight();
- + scheduleEventStart();
- + }
- +
- + public void skipDelay()
- + {
- + if (_task.nextRun.cancel(false))
- + {
- + _task.setStartTime(System.currentTimeMillis());
- + ThreadPool.execute(_task);
- + }
- + }
- +
- + /**
- + * Class for TVT cycles
- + */
- + class TVTStartTask implements Runnable
- + {
- + private long _startTime;
- + public ScheduledFuture<?> nextRun;
- +
- + public TVTStartTask(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + public void setStartTime(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + /**
- + * @see java.lang.Runnable#run()
- + */
- + @Override
- + public void run()
- + {
- + int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
- +
- + if (delay > 0)
- + announce(delay);
- +
- + int nextMsg = 0;
- + if (delay > 3600)
- + nextMsg = delay - 3600;
- + else if (delay > 1800)
- + nextMsg = delay - 1800;
- + else if (delay > 900)
- + nextMsg = delay - 900;
- + else if (delay > 600)
- + nextMsg = delay - 600;
- + else if (delay > 300)
- + nextMsg = delay - 300;
- + else if (delay > 60)
- + nextMsg = delay - 60;
- + else if (delay > 5)
- + nextMsg = delay - 5;
- + else if (delay > 0)
- + nextMsg = delay;
- + else
- + {
- + // start
- + if (TeamVsTeam.isInactive())
- + startReg();
- + else if (TeamVsTeam.isParticipating())
- + startEvent();
- + else
- + endEvent();
- + }
- +
- + if (delay > 0)
- + nextRun = ThreadPool.schedule(this, nextMsg * 1000);
- + }
- +
- + private void announce(long time)
- + {
- + if (time >= 3600 && time % 3600 == 0)
- + {
- + if (TeamVsTeam.isParticipating())
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: " + (time / 60 / 60) + " hour(s) until registration is closed!", true);
- + else if (TeamVsTeam.isStarted())
- + TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: " + (time / 60 / 60) + " hour(s) until event is finished!");
- + }
- + else if (time >= 60)
- + {
- + if (TeamVsTeam.isParticipating())
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: " + (time / 60) + " minute(s) until registration is closed!", true);
- + else if (TeamVsTeam.isStarted())
- + TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: " + (time / 60) + " minute(s) until the event is finished!");
- + }
- + else
- + {
- + if (TeamVsTeam.isParticipating())
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: " + time + " second(s) until registration is closed!", true);
- + else if (TeamVsTeam.isStarted())
- + TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: " + time + " second(s) until the event is finished!");
- + }
- + }
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final EngineManager _instance = new EngineManager();
- + }
- +}
- \ 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 2)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (working copy)
- @@ -1,6 +1,10 @@
- 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.Player;
- import net.sf.l2j.gameserver.network.FloodProtectors;
- @@ -20,13 +24,43 @@
- if (!FloodProtectors.performAction(activeChar.getClient(), Action.GLOBAL_CHAT))
- return;
- - final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- - for (Player player : activeChar.getKnownTypeInRadius(Player.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 (Player player : activeChar.getKnownTypeInRadius(Player.class, 1250))
- + {
- + if (!BlockList.isBlocked(player, activeChar))
- + player.sendPacket(cs);
- + }
- +
- + activeChar.sendPacket(cs);
- + }
- }
- @Override
- Index: java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (revision 2)
- +++ java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (working copy)
- @@ -38,7 +38,7 @@
- if (activeChar instanceof Player)
- {
- // Check invalid states.
- - if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
- + if (((Player) activeChar).isInFunEvent() || activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
- return;
- }
- Index: java/net/sf/l2j/Config.java
- ===================================================================
- --- java/net/sf/l2j/Config.java (revision 2)
- +++ java/net/sf/l2j/Config.java (working copy)
- @@ -30,6 +30,7 @@
- public static final String CLANS_FILE = "./config/clans.properties";
- public static final String EVENTS_FILE = "./config/events.properties";
- + public static final String EVENTS_CUSTOM_FILE = "./config/TeamVsTeam.properties";
- public static final String GEOENGINE_FILE = "./config/geoengine.properties";
- public static final String HEXID_FILE = "./config/hexid.txt";
- public static final String LOGIN_CONFIGURATION_FILE = "./config/loginserver.properties";
- @@ -204,7 +205,43 @@
- public static int ALT_FISH_CHAMPIONSHIP_REWARD_3;
- public static int ALT_FISH_CHAMPIONSHIP_REWARD_4;
- public static int ALT_FISH_CHAMPIONSHIP_REWARD_5;
- +
- + // --------------------------------------------------
- + // Events jDevs settings
- + // --------------------------------------------------
- + /**Core Engine*/
- + public static String EVENTS_JOIN_LOCATION;
- + public static int EVENTS_PARTICIPATION_NPC_ID;
- + public static int EVENTS_MIN_PLAYERS_IN_TEAMS;
- + public static int EVENTS_MAX_PLAYERS_IN_TEAMS;
- + public static int EVENTS_EFFECTS_REMOVAL;
- + public static int EVENTS_MAX_PARTICIPANTS_PER_IP;
- + public static int[] EVENTS_PARTICIPATION_NPC_COORDINATES = new int[3];
- + public static int[] EVENTS_PARTICIPATION_FEE = new int[2];
- + public static List<Integer> EVENTS_DOORS_IDS_TO_OPEN;
- + public static List<Integer> EVENTS_DOORS_IDS_TO_CLOSE;
- + public static byte EVENTS_MIN_LVL;
- + public static byte EVENTS_MAX_LVL;
- + public static int[][] EVENTS_FIGHTER_BUFFS;
- + public static int[][] EVENTS_MAGE_BUFFS;
- + public static List<Integer> LIST_RESTRICTED_CLASSES_IN_EVENTS;
- + public static String EVENTS_RESTRICTED_CLASSES;
- +
- + /** Team vs. Team */
- + public static boolean TVT_ENABLED;
- + public static boolean TVT_VOICED_COMMAND;
- + public static String[] TVT_EVENT_INTERVAL;
- + public static String TVT_EVENT_ON_KILL;
- + public static String TVT_EVENT_TEAM_1_NAME;
- + public static String TVT_EVENT_TEAM_2_NAME;
- + public static int TVT_EVENT_PARTICIPATION_TIME;
- + public static int TVT_EVENT_RUNNING_TIME;
- + public static int[] TVT_EVENT_TEAM_1_COORDINATES = new int[3];
- + public static int[] TVT_EVENT_TEAM_2_COORDINATES = new int[3];
- + public static List<int[]> TVT_EVENT_REWARDS = new ArrayList<>();
- + public static List<int[]> TVT_EVENT_REWARDS_KILL = new ArrayList<>();
- +
- // --------------------------------------------------
- // GeoEngine
- // --------------------------------------------------
- @@ -872,6 +909,114 @@
- ALT_FISH_CHAMPIONSHIP_REWARD_4 = events.getProperty("AltFishChampionshipReward4", 200000);
- ALT_FISH_CHAMPIONSHIP_REWARD_5 = events.getProperty("AltFishChampionshipReward5", 100000);
- }
- +
- + /**
- + * Loads event engine settings.<br>
- + */
- + private static final void loadEventsEngine()
- + {
- + final ExProperties jdevs = initProperties(EVENTS_CUSTOM_FILE);
- + EVENTS_JOIN_LOCATION = jdevs.getProperty("NpcRegisterLocation", "Giran");
- + EVENTS_PARTICIPATION_NPC_ID = jdevs.getProperty("EventsParticipationNpcId", 0);
- + EVENTS_RESTRICTED_CLASSES = jdevs.getProperty("EventsRestrictedClasses", "0,0");
- + EVENTS_MIN_PLAYERS_IN_TEAMS = jdevs.getProperty("EventsMinPlayersInTeams", 1);
- + EVENTS_MAX_PLAYERS_IN_TEAMS = jdevs.getProperty("EventsMaxPlayersInTeams", 2);
- + EVENTS_MIN_LVL = (byte) jdevs.getProperty("EventsMinPlayerLevel", 1);
- + EVENTS_MAX_LVL = (byte) jdevs.getProperty("EventsMaxPlayerLevel", 80);
- + EVENTS_EFFECTS_REMOVAL = jdevs.getProperty("EventsEffectsRemoval", 0);
- + EVENTS_MAX_PARTICIPANTS_PER_IP = jdevs.getProperty("EventsMaxParticipantsPerIP", 0);
- + EVENTS_FIGHTER_BUFFS = parseItemsList(jdevs.getProperty("EventsFighterBuffs", "123,456"));
- + EVENTS_MAGE_BUFFS = parseItemsList(jdevs.getProperty("EventsMageBuffs", "789,1223"));
- +
- + LIST_RESTRICTED_CLASSES_IN_EVENTS = new ArrayList<>();
- + for (String val : EVENTS_RESTRICTED_CLASSES.split(","))
- + {
- + int classId = Integer.parseInt(val);
- + LIST_RESTRICTED_CLASSES_IN_EVENTS.add(classId);
- + }
- +
- + String[] propertySplit = jdevs.getProperty("EventsParticipationNpcCoordinates", "0,0,0").split(",");
- + if (propertySplit.length < 3)
- + TVT_ENABLED = false;
- + else
- + {
- + EVENTS_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + EVENTS_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + EVENTS_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- + }
- +
- + propertySplit = jdevs.getProperty("EventsParticipationFee", "0,0").split(",");
- + try
- + {
- + EVENTS_PARTICIPATION_FEE[0] = Integer.parseInt(propertySplit[0]);
- + EVENTS_PARTICIPATION_FEE[1] = Integer.parseInt(propertySplit[1]);
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (propertySplit.length > 0)
- + _log.warning("EventEngine: invalid config property -> EventsParticipationFee");
- + }
- +
- + propertySplit = jdevs.getProperty("EventsDoorsToOpen", "").split(";");
- + EVENTS_DOORS_IDS_TO_OPEN = new ArrayList<>(propertySplit.length);
- + for (String door : propertySplit)
- + {
- + EVENTS_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
- + }
- +
- + propertySplit = jdevs.getProperty("EventsDoorsToClose", "").split(";");
- + EVENTS_DOORS_IDS_TO_CLOSE = new ArrayList<>(propertySplit.length);
- + for (String door : propertySplit)
- + {
- + EVENTS_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
- + }
- +
- + /** Team Vs Team engine */
- + TVT_ENABLED = jdevs.getProperty("TVTEnabled", false);
- + TVT_EVENT_INTERVAL = jdevs.getProperty("TvTEventInterval", "20:00").split(",");
- + TVT_EVENT_PARTICIPATION_TIME = jdevs.getProperty("TvTEventParticipationTime", 3600);
- + TVT_EVENT_RUNNING_TIME = jdevs.getProperty("TvTEventRunningTime", 1800);
- + TVT_VOICED_COMMAND = jdevs.getProperty("TvTVoicedCommand", false);
- + TVT_EVENT_ON_KILL = jdevs.getProperty("TvTEventOnKill", "pmteam");
- + TVT_EVENT_TEAM_1_NAME = jdevs.getProperty("TvTEventTeam1Name", "Team1");
- + TVT_EVENT_TEAM_2_NAME = jdevs.getProperty("TvTEventTeam2Name", "Team2");
- +
- + propertySplit = jdevs.getProperty("TvTEventTeam1Coordinates", "0,0,0").split(",");
- + if (propertySplit.length < 3)
- + TVT_ENABLED = false;
- + 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]);
- + }
- +
- + propertySplit = jdevs.getProperty("TvTEventTeam2Coordinates", "0,0,0").split(",");
- + if (propertySplit.length < 3)
- + TVT_ENABLED = false;
- + 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 = jdevs.getProperty("TvTEventReward", "57,100000").split(";");
- + for (String reward : propertySplit)
- + {
- + String[] rewardSplit = reward.split(",");
- + if (rewardSplit.length == 2)
- + TVT_EVENT_REWARDS.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
- + }
- +
- + propertySplit = jdevs.getProperty("TvTEventRewardKill", "57,2").split(";");
- + for (String reward : propertySplit)
- + {
- + String[] rewardSplit = reward.split(",");
- + if (rewardSplit.length == 2)
- + TVT_EVENT_REWARDS_KILL.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
- + }
- + }
- /**
- * Loads geoengine settings.
- @@ -1351,6 +1496,9 @@
- // events settings
- loadEvents();
- + // jdevs events settings
- + loadEventsEngine();
- +
- // geoengine settings
- loadGeoengine();
- Index: config/game/TeamVsTeam.properties
- ===================================================================
- --- config/game/TeamVsTeam.properties (revision 0)
- +++ config/game/TeamVsTeam.properties (working copy)
- @@ -0,0 +1,99 @@
- +# =================================================================
- +# Engine jDevs (by Williams)
- +# =================================================================
- +# Events npc (create a custom npc of type EventManager).
- +EventsParticipationNpcId = 50009
- +
- +# Location Npc Register
- +NpcRegisterLocation = Giran
- +
- +# Events participation fee (itemId, number).
- +# Example: 57,100000
- +EventsParticipationFee = 57,1
- +
- +# Location for events npc to spawn in form x,y,z
- +EventsParticipationNpcCoordinates = 82698,148638,-3468
- +
- +# Min/Max amount of players allowed in each team.
- +EventsMinPlayersInTeams = 1
- +EventsMaxPlayersInTeams = 20
- +
- +# Min/Max level of players that may join the events.
- +EventsMinPlayerLevel = 20
- +EventsMaxPlayerLevel = 81
- +
- +# Door ID's to open/close on start/end.
- +# Example: EventsDoorsToOpen = id1;id2;...
- +EventsDoorsToOpen = 24190001;24190002;24190003;24190004
- +EventsDoorsToClose = 24190001;24190002;24190003;24190004
- +
- +# Participant's effects handling on teleport/death.
- +# Effects lasting through death never removed.
- +# 0 - always remove all effects.
- +# 1 - remove all effects only during port to event (noblesse blessing can be used)
- +# 2 - never remove any effect
- +# Default: 0
- +EventsEffectsRemoval = 2
- +
- +# Fighter-class participants will be buffed with those buffs each respawn
- +# Format: skill1Id,skill1Level;skill2Id,skill2Level...
- +# Example: 1504,1;1501,1;1502,1;1499,1
- +EventsFighterBuffs = 1036,1;1040,1;1045,3;1068,1;1077,1;1068,1;1204,1;1240,1;1242,1;1259,4;1035,1;\
- ++264,1;267,1;268,1;269,1;304,1;271,1;274,1;275,1;
- +
- +# Mage-class participants will be buffed with those buffs each respawn
- +# Format: skill1Id,skill1Level;skill2Id,skill2Level...
- +# Example: 1504,1;1500,1;1501,1;1085,3
- +EventsMageBuffs = 1036,1;1040,1;1045,3;1048,3;1059,1;1085,1;1204,1;1303,1;1062,1;1035,1;1259,4;1389,1;\
- ++264,1;267,1;268,1;304,1;273,1;276,1;
- +
- +# Class Restriction for events.
- +# Example: classId,classId, ...
- +EventsRestrictedClasses = 0
- +
- +# Maximum number of allowed participants per IP address (dualbox check)
- +# Default: 0 (no limits)
- +EventsMaxParticipantsPerIP = 0
- +
- +# =================================================================
- +# Team vs. Team (by FBIagent) / Dev Williams
- +# =================================================================
- +# Enable/Disable Event TvT.
- +TVTEnabled = True
- +
- +# Times TvT will occur (24h format).
- +# Example: 20:00,21,00,22:00
- +TvTEventInterval = 8:00,10:00,12:00,14:00,16:00,18:00,20:00,22:00
- +
- +# Registration timer from start of event (in minutes).
- +TvTEventParticipationTime = 5
- +
- +# Event running time (in minutes).
- +TvTEventRunningTime = 5
- +
- +# First Blue - Name, Start/Death x,y,z location.
- +TvTEventTeam1Name = Blue
- +TvTEventTeam1Coordinates = 148232,46552,-3408
- +
- +# Second Red - Name, Start/Death x,y,z location.
- +TvTEventTeam2Name = Red
- +TvTEventTeam2Coordinates = 150712,46536,-3408
- +
- +# Reward for winning team.
- +# Example: TvTEventReward = itemId,amount;
- +TvTEventReward = 57,1
- +
- +# If true, gives reward for kills stage without die
- +# Example: Get 5/8/12/15/20 kills without die, and you will be rewarded
- +# Example: TvTEventRewardKill = itemId,amount;
- +TvTEventRewardKill = 57,2
- +
- +# Method to show player's kill on the TvT.
- +# Example: "Kills: number" (title will be restored at the event end).
- +# Put "pmtitle" for both methods (pmteam and title).
- +# Default: pmteam
- +TvTEventOnKill = pmtitle
- +
- +# Voiced command (.tvton, .tvtoff, .tvtinfo) working during TvT Event to get information about event status
- +# Default: True
- +TvTVoicedCommand = True
- Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/RegisterEvents.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/RegisterEvents.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/RegisterEvents.java (working copy)
- @@ -0,0 +1,120 @@
- +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.cache.HtmCache;
- +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
- +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 williams
- + *
- + */
- +public class RegisterEvents implements IVoicedCommandHandler
- +{
- + private static final String[] VOICED_COMMANDS =
- + {
- + "register",
- + "unregister",
- + "eventstatus"
- + };
- +
- + @Override
- + public boolean useVoicedCommand(final String command, final Player activeChar, final String target)
- + {
- + if (command.startsWith("register"))
- + Join(target, activeChar);
- + else if (command.startsWith("unregister"))
- + Leave(activeChar);
- + else if (command.startsWith("eventstatus"))
- + Status(activeChar);
- + return true;
- + }
- +
- + public static boolean Join(final String command, Player activeChar)
- + {
- + if (!TeamVsTeam.isParticipating())
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
- + else if (TeamVsTeam.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 (activeChar.isAio())
- + //activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "AIO player can not register!."));
- + 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 (TeamVsTeam._teams[0].getParticipatedPlayerCount() >= Config.EVENTS_MAX_PLAYERS_IN_TEAMS && TeamVsTeam._teams[1].getParticipatedPlayerCount() >= Config.EVENTS_MAX_PLAYERS_IN_TEAMS)
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Sorry the event is full!"));
- + else if (activeChar.getLevel() < Config.EVENTS_MIN_LVL || activeChar.getLevel() > Config.EVENTS_MAX_LVL)
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Only players from level " + Config.EVENTS_MIN_LVL + " until level " + Config.EVENTS_MAX_LVL + " are allowed to participate."));
- + else if (TeamVsTeam._teams[0].getParticipatedPlayerCount() > 19 && TeamVsTeam._teams[1].getParticipatedPlayerCount() > 19)
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "The event is full! Maximum of " + Config.EVENTS_MAX_PLAYERS_IN_TEAMS + " player are allowed in one team."));
- + else
- + {
- + TeamVsTeam.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 Leave(final Player activeChar)
- + {
- + if (!TeamVsTeam.isParticipating())
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
- + else if (!TeamVsTeam.isInactive() && !TeamVsTeam.isPlayerParticipant(activeChar.getName()))
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "You aren't registered in the TvT Event."));
- + else
- + {
- + TeamVsTeam.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 Status(final Player activeChar)
- + {
- + if (!TeamVsTeam.isStarted())
- + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "TvT Event is not in progress yet."));
- + else
- + {
- + String htmFile = "data/html/mods/TeamVsTeamStatus.htm";
- + String htmContent = HtmCache.getInstance().getHtm(htmFile);
- +
- + if (htmContent != null)
- + {
- + int[] teamsPlayerCounts = TeamVsTeam.getTeamsPlayerCounts();
- + int[] teamsPointsCounts = TeamVsTeam.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/network/serverpackets/Die.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/serverpackets/Die.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/serverpackets/Die.java (working copy)
- @@ -16,6 +16,7 @@
- private boolean _sweepable;
- private boolean _allowFixedRes;
- + private boolean _canTeleport;
- private Clan _clan;
- public Die(Creature cha)
- @@ -29,7 +30,7 @@
- Player player = (Player) cha;
- _allowFixedRes = player.getAccessLevel().allowFixedRes();
- _clan = player.getClan();
- -
- + _canTeleport = !player.isInFunEvent();
- }
- else if (cha instanceof Attackable)
- _sweepable = ((Attackable) cha).isSpoiled();
- @@ -43,9 +44,9 @@
- writeC(0x06);
- writeD(_charObjId);
- - writeD(0x01); // to nearest village
- + writeD(_canTeleport ? 0x01 : 0x00); // to nearest village
- - if (_clan != null)
- + if (_canTeleport && _clan != null)
- {
- SiegeSide side = null;
- Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 2)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
- @@ -28,6 +28,7 @@
- import net.sf.l2j.gameserver.model.entity.ClanHall;
- import net.sf.l2j.gameserver.model.entity.Siege;
- import net.sf.l2j.gameserver.model.entity.Siege.SiegeSide;
- +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
- import net.sf.l2j.gameserver.model.holder.IntIntHolder;
- import net.sf.l2j.gameserver.model.olympiad.Olympiad;
- import net.sf.l2j.gameserver.model.pledge.Clan;
- @@ -305,6 +306,7 @@
- PetitionManager.getInstance().checkPetitionMessages(player);
- player.onPlayerEnter();
- + TeamVsTeam.onLogin(player);
- sendPacket(new SkillCoolTime(player));
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement