Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 1)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
- @@ -17,6 +17,7 @@
- import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.SevenSignsFestival;
- import net.sf.l2j.gameserver.model.L2Party;
- +import net.sf.l2j.gameserver.model.RandomFight;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.model.zone.ZoneId;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- @@ -60,6 +61,13 @@
- return;
- }
- + if(RandomFight.players.contains(player))
- + {
- + player.sendMessage("You can't logout when you are in random fight event.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- if (AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && !player.isGM())
- {
- if (Config.DEBUG)
- Index: config/players.properties
- ===================================================================
- --- config/players.properties (revision 1)
- +++ config/players.properties (working copy)
- @@ -45,6 +45,15 @@
- # Death Penalty chance if killed by mob (in %), 20 by default
- DeathPenaltyChance = 20
- +#Random Fight Event
- +AllowRandomFight = True
- +#Random Fight every how many minutes
- +EveryMinutes = 3
- +#ID of the reward Item , default:LIFE STONES
- +RewardId=8762
- +#COUNT of the reward item : default : 5
- +RewardCount = 5
- +
- #=============================================================
- # Inventory / Warehouse
- #=============================================================
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 1)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -90,6 +90,7 @@
- import net.sf.l2j.gameserver.model.L2World;
- import net.sf.l2j.gameserver.model.PartyMatchRoomList;
- import net.sf.l2j.gameserver.model.PartyMatchWaitingList;
- +import net.sf.l2j.gameserver.model.RandomFight;
- import net.sf.l2j.gameserver.model.entity.Castle;
- import net.sf.l2j.gameserver.model.entity.Hero;
- import net.sf.l2j.gameserver.model.olympiad.Olympiad;
- @@ -237,6 +238,9 @@
- Olympiad.getInstance();
- Hero.getInstance();
- + if(Config.ALLOW_RANDOM_FIGHT)
- + RandomFight.getInstance();
- +
- Util.printSection("Four Sepulchers");
- FourSepulchersManager.getInstance().init();
- Index: java/net/sf/l2j/gameserver/network/clientpackets/Say2.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/Say2.java (revision 1)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/Say2.java (working copy)
- @@ -21,6 +21,7 @@
- import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.handler.ChatHandler;
- import net.sf.l2j.gameserver.handler.IChatHandler;
- +import net.sf.l2j.gameserver.model.RandomFight;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- @@ -171,6 +172,10 @@
- return;
- }
- + checkRandomFight(_text,activeChar);
- + if(_text.equalsIgnoreCase("?register") || _text.equalsIgnoreCase("?unregister"))
- + return;
- +
- if (_type == PETITION_PLAYER && activeChar.isGM())
- _type = PETITION_GM;
- @@ -214,6 +219,45 @@
- return false;
- }
- + void checkRandomFight(String text,L2PcInstance player)
- + {
- + if(text.equalsIgnoreCase("?register"))
- + {
- + if(RandomFight.players.contains(player))
- + {
- + player.sendMessage("You have already registed to the event.");
- + return;
- + }
- + if(RandomFight.state == RandomFight.State.INACTIVE)
- + return;
- + if(RandomFight.state != RandomFight.State.REGISTER)
- + {
- + player.sendMessage("Event has already started.");
- + return;
- + }
- + RandomFight.players.add(player);
- + player.sendMessage("You registed to the event!!");
- + return;
- + }
- + if(text.equalsIgnoreCase("?unregister"))
- + {
- + if(!RandomFight.players.contains(player))
- + {
- + player.sendMessage("You haven't registed to the event.");
- + return;
- + }
- + if(RandomFight.state == RandomFight.State.INACTIVE)
- + return;
- + if(RandomFight.state != RandomFight.State.REGISTER)
- + {
- + player.sendMessage("Event has already started.");
- + return;
- + }
- + RandomFight.players.remove(player);
- + player.sendMessage("You unregisted from the event!!");
- + }
- + }
- +
- @Override
- protected boolean triggersOnActionRequest()
- {
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 1)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -37,6 +37,7 @@
- import net.sf.l2j.Config;
- import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.gameserver.Announcements;
- import net.sf.l2j.gameserver.GameTimeController;
- import net.sf.l2j.gameserver.GeoData;
- import net.sf.l2j.gameserver.ItemsAutoDestroy;
- @@ -103,6 +104,7 @@
- import net.sf.l2j.gameserver.model.PartyMatchRoom;
- import net.sf.l2j.gameserver.model.PartyMatchRoomList;
- import net.sf.l2j.gameserver.model.PartyMatchWaitingList;
- +import net.sf.l2j.gameserver.model.RandomFight;
- import net.sf.l2j.gameserver.model.ShortCuts;
- import net.sf.l2j.gameserver.model.ShotType;
- import net.sf.l2j.gameserver.model.TradeList;
- @@ -4077,6 +4079,19 @@
- {
- L2PcInstance pk = killer.getActingPlayer();
- + if(RandomFight.state == RandomFight.State.FIGHT)
- + {
- + if(RandomFight.players.contains(this) && RandomFight.players.contains(pk))
- + {
- + pk.sendMessage("You are the winner!!!");
- + Announcements.announceToAll("Random Fight Results:"+pk.getName()+" is the winner.");
- + Announcements.announceToAll("Event Ended.");
- + pk.addItem("",Config.RANDOM_FIGHT_REWARD_ID, Config.RANDOM_FIGHT_REWARD_COUNT, null, true);
- + RandomFight.revert();
- + RandomFight.clean();
- + }
- + }
- +
- // Clear resurrect xp calculation
- setExpBeforeDeath(0);
- Index: java/net/sf/l2j/Config.java
- ===================================================================
- --- java/net/sf/l2j/Config.java (revision 1)
- +++ java/net/sf/l2j/Config.java (working copy)
- @@ -383,6 +383,11 @@
- public static boolean ALT_GAME_DELEVEL;
- public static int DEATH_PENALTY_CHANCE;
- + public static boolean ALLOW_RANDOM_FIGHT;
- + public static int EVERY_MINUTES;
- + public static int RANDOM_FIGHT_REWARD_ID;
- + public static int RANDOM_FIGHT_REWARD_COUNT;
- +
- /** Inventory & WH */
- public static int INVENTORY_MAXIMUM_NO_DWARF;
- public static int INVENTORY_MAXIMUM_DWARF;
- @@ -987,6 +992,12 @@
- ALT_GAME_DELEVEL = players.getProperty("Delevel", true);
- DEATH_PENALTY_CHANCE = players.getProperty("DeathPenaltyChance", 20);
- + ALLOW_RANDOM_FIGHT = players.getProperty("AllowRandomFight",true);
- + EVERY_MINUTES = players.getProperty("EveryMinutes",3);
- + RANDOM_FIGHT_REWARD_ID = players.getProperty("RewardId" , 8762);
- + RANDOM_FIGHT_REWARD_COUNT = players.getProperty("RewardCount" , 5);
- +
- +
- INVENTORY_MAXIMUM_NO_DWARF = players.getProperty("MaximumSlotsForNoDwarf", 80);
- INVENTORY_MAXIMUM_DWARF = players.getProperty("MaximumSlotsForDwarf", 100);
- INVENTORY_MAXIMUM_QUEST_ITEMS = players.getProperty("MaximumSlotsForQuestItems", 100);
- Index: java/net/sf/l2j/gameserver/model/RandomFight.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/RandomFight.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/RandomFight.java (revision 0)
- @@ -0,0 +1,273 @@
- +/*
- + * 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;
- +
- +import java.util.Vector;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.ThreadPoolManager;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +import net.sf.l2j.util.Rnd;
- +
- +/**
- + * @author lioy
- + *
- + */
- +public class RandomFight
- +{
- + public static enum State{INACTIVE,REGISTER,LOADING,FIGHT}
- + public static State state = State.INACTIVE;
- +
- + public static Vector<L2PcInstance> players = new Vector<>();
- +
- + protected void openRegistrations()
- + {
- + state = State.REGISTER;
- + Broadcast.announceToOnlinePlayers("Random Fight Event will start in 1 minute.");
- + Broadcast.announceToOnlinePlayers("To register press ?register");
- + ThreadPoolManager.getInstance().scheduleGeneral(new checkRegist(), 60000 );
- + }
- +
- + protected void checkRegistrations()
- + {
- + state=State.LOADING;
- +
- + if(players.isEmpty() || players.size() < 2)
- + {
- + Broadcast.announceToOnlinePlayers("Random Fight Event will not start cause of no many partitipations, we are sorry.");
- + clean();
- + return;
- + }
- + Broadcast.announceToOnlinePlayers("Amount of players Registed: "+players.size());
- + Broadcast.announceToOnlinePlayers("2 Random players will be choosen in 30 seconds!");
- + ThreadPoolManager.getInstance().scheduleGeneral(new pickPlayers(), 30000 );
- + }
- +
- +
- + protected void pickPlayers()
- + {
- + if(players.isEmpty() || players.size() < 2)
- + {
- + Broadcast.announceToOnlinePlayers("Random Fight Event aborted because no many partitipations, we are sorry.");
- + clean();
- + return;
- + }
- +
- + for(L2PcInstance p : players)
- + if(p.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(p))
- + {
- + players.remove(p);
- + p.sendMessage("You automatically left from event because of your olympiad obligations.");
- + }
- +
- +
- + int rnd1=Rnd.get(players.size());
- + int rnd2=Rnd.get(players.size());
- +
- + while(rnd2==rnd1)
- + rnd2=Rnd.get(players.size());
- +
- + for(L2PcInstance player : players)
- + {
- + if(player != players.get(rnd1) && player != players.get(rnd2))
- + players.remove(player);
- + }
- +
- + Broadcast.announceToOnlinePlayers("Players selected: "+players.firstElement().getName()+" || "+players.lastElement().getName());
- + Broadcast.announceToOnlinePlayers("Players will be teleported in 15 seconds");
- + ThreadPoolManager.getInstance().scheduleGeneral(new teleportPlayers(), 15000);
- + }
- +
- +
- + protected void teleport()
- + {
- + if(players.isEmpty() || players.size() < 2)
- + {
- + Broadcast.announceToOnlinePlayers("Random Fight Event aborted because no many partitipations, we are sorry.");
- + clean();
- + return;
- + }
- + Broadcast.announceToOnlinePlayers("Players teleported!");
- +
- + players.firstElement().teleToLocation(113474,15552,3968,0);
- + players.lastElement().teleToLocation(112990,15489,3968,0);
- + players.firstElement().setTeam(1);
- + players.lastElement().setTeam(2);
- +
- + //para,etc
- +
- + players.firstElement().sendMessage("Fight will begin in 15 seconds!");
- + players.lastElement().sendMessage("Fight will begin in 15 seconds!");
- +
- + ThreadPoolManager.getInstance().scheduleGeneral(new fight(), 15000);
- + }
- +
- + protected void startFight()
- + {
- +
- + if(players.isEmpty() || players.size() < 2)
- + {
- + Broadcast.announceToOnlinePlayers("One of the players isn't online, event aborted we are sorry!");
- + clean();
- + return;
- + }
- +
- + state = State.FIGHT;
- + Broadcast.announceToOnlinePlayers("FIGHT STARTED!");
- + players.firstElement().sendMessage("Start Fight!!");
- + players.lastElement().sendMessage("Start Fight!");
- + ThreadPoolManager.getInstance().scheduleGeneral(new checkLast(), 120000 );
- + }
- +
- + protected void lastCheck()
- + {
- + if(state == State.FIGHT)
- + {
- + if(players.isEmpty() || players.size() < 2)
- + {
- + revert();
- + clean();
- + return;
- + }
- +
- + int alive=0;
- + for(L2PcInstance player : players)
- + {
- + if(!player.isDead())
- + alive++;
- + }
- +
- + if(alive==2)
- + {
- + Broadcast.announceToOnlinePlayers("Random Fight ended tie!");
- + clean();
- + revert();
- + }
- + }
- + }
- +
- + public static void revert()
- + {
- + if(!players.isEmpty())
- + for(L2PcInstance p : players)
- + {
- + if(p == null)
- + continue;
- +
- + if(p.isDead())
- + p.doRevive();
- +
- + p.setCurrentHp(p.getMaxHp());
- + p.setCurrentCp(p.getMaxCp());
- + p.setCurrentMp(p.getMaxMp());
- + p.broadcastUserInfo();
- + p.teleToLocation(82698,148638,-3473,0);
- +
- + }
- + }
- +
- + public static void clean()
- + {
- +
- + if(state == State.FIGHT)
- + for(L2PcInstance p : players)
- + p.setTeam(0);
- +
- +
- + players.clear();
- + state = State.INACTIVE;
- +
- + }
- +
- + protected RandomFight()
- + {
- + ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Event(), 60000 * Config.EVERY_MINUTES , 60000 * Config.EVERY_MINUTES);
- + }
- +
- + public static RandomFight getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final RandomFight _instance = new RandomFight();
- + }
- +
- + protected class Event implements Runnable
- + {
- + @Override
- + public void run()
- + {
- + if(state == State.INACTIVE)
- + openRegistrations();
- + }
- +
- + }
- +
- + protected class checkRegist implements Runnable
- + {
- +
- + @Override
- + public void run()
- + {
- + checkRegistrations();
- + }
- +
- + }
- +
- + protected class pickPlayers implements Runnable
- + {
- + @Override
- + public void run()
- + {
- + pickPlayers();
- + }
- +
- + }
- +
- + protected class teleportPlayers implements Runnable
- + {
- + @Override
- + public void run()
- + {
- + teleport();
- + }
- +
- + }
- +
- + protected class fight implements Runnable
- + {
- +
- + @Override
- + public void run()
- + {
- + startFight();
- + }
- +
- + }
- +
- + protected class checkLast implements Runnable
- + {
- + @Override
- + public void run()
- + {
- + lastCheck();
- + }
- +
- + }
- +}
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (revision 1)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (working copy)
- @@ -17,11 +17,13 @@
- import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.SevenSignsFestival;
- import net.sf.l2j.gameserver.model.L2Party;
- +import net.sf.l2j.gameserver.model.RandomFight;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.model.zone.ZoneId;
- import net.sf.l2j.gameserver.network.L2GameClient;
- import net.sf.l2j.gameserver.network.L2GameClient.GameClientState;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- import net.sf.l2j.gameserver.network.serverpackets.CharSelectInfo;
- import net.sf.l2j.gameserver.network.serverpackets.RestartResponse;
- import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- @@ -66,6 +68,13 @@
- return;
- }
- + if(RandomFight.players.contains(player))
- + {
- + player.sendMessage("You can't restart when you are in random fight event.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- if (AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && !player.isGM())
- {
- if (Config.DEBUG)
Add Comment
Please, Sign In to add comment