Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: /trunk/L2_Gameserver/java/net/sf/l2j/gameserver/Olympiad.java
- ===================================================================
- --- /trunk/L2_Gameserver/java/net/sf/l2j/gameserver/Olympiad.java (revision 7)
- +++ /trunk/L2_Gameserver/java/net/sf/l2j/gameserver/Olympiad.java (revision 20)
- @@ -1,25 +1,2 @@
- -/*
- - * This program is free software; you can redistribute it and/or modify
- - * it under the terms of the GNU General Public License as published by
- - * the Free Software Foundation; either version 2, or (at your option)
- - * any later version.
- - *
- - * This program is distributed in the hope that it will be useful,
- - * but WITHOUT ANY WARRANTY; without even the implied warranty of
- - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- - * GNU General Public License for more details.
- - *
- - * You should have received a copy of the GNU General Public License
- - * along with this program; if not, write to the Free Software
- - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- - * 02111-1307, USA.
- - *
- - * http://www.gnu.org/copyleft/gpl.html
- - */
- -
- -/**
- - * @author godson
- - */
- -
- package net.sf.l2j.gameserver;
- @@ -99,14 +76,4 @@
- protected static final long VALIDATION_PERIOD = Config.ALT_OLY_VPERIOD; // 24 hours
- - /* FOR TESTING
- - private static final int COMP_START = 8; // 1PM - 2PM
- - private static final int COMP_MIN = 15; // 20mins
- - private static final long COMP_PERIOD = 7200000; // 2hours
- - private static final long BATTLE_PERIOD = 180000; // 3mins
- - private static final long BATTLE_WAIT = 600000; // 10mins
- - private static final long INITIAL_WAIT = 300000; // 5mins
- - private static final long WEEKLY_PERIOD = 7200000; // 2 hours
- - private static final long VALIDATION_PERIOD = 3600000; // 1 hour */
- -
- private static final int COLLISIEUMS = 11; // 22 in all, 11 each for (Classed and NonClassed)
- @@ -131,10 +98,10 @@
- protected static boolean _compStarted;
- protected static boolean _battleStarted;
- - protected ScheduledFuture _scheduledCompStart;
- - protected ScheduledFuture _scheduledCompEnd;
- - protected ScheduledFuture _scheduledOlympiadEnd;
- - protected ScheduledFuture _scheduledManagerTask;
- - protected ScheduledFuture _scheduledWeeklyTask;
- - protected ScheduledFuture _scheduledValdationTask;
- + protected ScheduledFuture<?> _scheduledCompStart;
- + protected ScheduledFuture<?> _scheduledCompEnd;
- + protected ScheduledFuture<?> _scheduledOlympiadEnd;
- + protected ScheduledFuture<?> _scheduledManagerTask;
- + protected ScheduledFuture<?> _scheduledWeeklyTask;
- + protected ScheduledFuture<?> _scheduledValdationTask;
- protected static final int[][] STADIUMS =
- @@ -573,4 +540,11 @@
- return true;
- }
- +
- + public void removeDisconnectedCompetitor(L2PcInstance player)
- + {
- + if (_manager == null || (_manager.getOlympiadInstance(player.getOlympiadGameId()) == null)) return;
- +
- + _manager.getOlympiadInstance(player.getOlympiadGameId()).handleDisconnect(player);
- + }
- private void updateCompStatus()
- @@ -837,4 +811,6 @@
- public List<L2PcInstance> getSpectators(int id)
- {
- + if (_manager == null || _manager.getOlympiadInstance(id) == null)
- + return null;
- return _manager.getOlympiadInstance(id).getSpectators();
- }
- @@ -1156,6 +1132,4 @@
- if (_nobles.size() == 0)
- return;
- -
- - _compStarted = true;
- try{
- @@ -1184,10 +1158,16 @@
- }
- + _compStarted = false;
- if (_olympiadInstances.size() == 0)
- - {
- - _compStarted = false;
- return;
- - }
- -
- + for (L2OlympiadGame instance : _olympiadInstances.values())
- + {
- + if (!instance.isAborted())
- + _compStarted = true;
- + }
- +
- + if (!_compStarted)
- + return;
- +
- for (L2OlympiadGame instance : _olympiadInstances.values())
- instance.sendMessageToPlayers(false,30);
- @@ -1248,7 +1228,8 @@
- {
- instance.makeCompetitionStart();
- - }
- -
- - //Wait 6 mins (Battle)
- + instance.makePlayersVisible();
- + }
- +
- + //Wait 6 minutes (Battle)
- try{
- wait(BATTLE_PERIOD);
- @@ -1402,4 +1383,6 @@
- protected COMP_TYPE _type;
- private boolean _aborted;
- + private boolean _playerOneDisconnected;
- + private boolean _playerTwoDisconnected;
- private String _playerOneName;
- private String _playerTwoName;
- @@ -1420,4 +1403,6 @@
- {
- _aborted = false;
- + _playerOneDisconnected = false;
- + _playerTwoDisconnected = false;
- _type = type;
- _stadiumPort = stadiumPort;
- @@ -1451,4 +1436,28 @@
- }
- }
- +
- + public boolean isAborted()
- + {
- + return _aborted;
- + }
- +
- + protected void clearPlayers()
- + {
- + _playerOne = null;
- + _playerTwo = null;
- + _players = null;
- + _playerOneName = "";
- + _playerTwoName = "";
- + _playerOneID = 0;
- + _playerTwoID = 0;
- + }
- +
- + protected void handleDisconnect(L2PcInstance player)
- + {
- + if (player == _playerOne)
- + _playerOneDisconnected = true;
- + else if (player == _playerTwo)
- + _playerTwoDisconnected = true;
- + }
- protected void removals()
- @@ -1457,5 +1466,6 @@
- if (_playerOne == null || _playerTwo == null) return;
- -
- + if (_playerOneDisconnected || _playerTwoDisconnected) return;
- +
- for (L2PcInstance player : _players)
- {
- @@ -1514,19 +1524,6 @@
- L2ItemInstance wpn = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
- if (wpn == null) wpn = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND);
- - if (wpn != null &&
- - (
- - (wpn.getItemId() >= 6611 && wpn.getItemId() <= 6621) ||
- - wpn.getItemId() == 6842 ||
- - wpn.getItemId() == 5597 ||
- - wpn.getItemId() == 5605 ||
- - wpn.getItemId() == 6314 ||
- - wpn.getItemId() == 7715 ||
- - wpn.getItemId() == 8119 ||
- - wpn.getItemId() == 8138 ||
- - wpn.getItemId() == 8146 ||
- - wpn.getItemId() == 8815
- - )
- - )
- - {
- + if (wpn != null && wpn.isHeroItem())
- + {
- L2ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
- InventoryUpdate iu = new InventoryUpdate();
- @@ -1555,5 +1552,5 @@
- }
- - //Remove ss/sps/bsps automation
- + //Remove shot automation
- Map<Integer, Integer> activeSoulShots = player.getAutoSoulShot();
- for (int itemId : activeSoulShots.values())
- @@ -1566,15 +1563,4 @@
- _sm.addNumber(120);
- broadcastMessage(_sm, false);
- - }
- -
- - protected void clearPlayers()
- - {
- - _playerOne = null;
- - _playerTwo = null;
- - _players = null;
- - _playerOneName = "";
- - _playerTwoName = "";
- - _playerOneID = 0;
- - _playerTwoID = 0;
- }
- @@ -1584,16 +1570,6 @@
- _playerTwoLocation = new int[3];
- - boolean _playerOneCrash = true;
- - boolean _playerTwoCrash = true;
- -
- - try {
- - if (_playerOne != null && _playerOne.getOlympiadGameId() != -1)
- - _playerOneCrash=false;
- - } catch (Exception e) {}
- -
- - try {
- - if (_playerTwo != null && _playerTwo.getOlympiadGameId() != -1)
- - _playerTwoCrash=false;
- - } catch (Exception e){ }
- + boolean _playerOneCrash = (_playerOne == null || _playerOneDisconnected);
- + boolean _playerTwoCrash = (_playerTwo == null || _playerTwoDisconnected);
- if (_playerOneCrash){
- @@ -1613,5 +1589,6 @@
- }
- - if (_playerOneCrash || _playerTwoCrash){
- + if (_playerOneCrash || _playerTwoCrash || _aborted)
- + {
- _playerOne=null;
- _playerTwo=null;
- @@ -1629,12 +1606,12 @@
- _playerTwoLocation[2] = _playerTwo.getZ();
- - //_playerOne.getAppearance().setInvisible();
- - //_playerOne.broadcastUserInfo();
- - //_playerOne.decayMe();
- - //_playerOne.spawnMe();
- - //_playerTwo.getAppearance().setInvisible();
- - //_playerTwo.broadcastUserInfo();
- - //_playerTwo.decayMe();
- - //_playerTwo.spawnMe();
- + _playerOne.getAppearance().setInvisible();
- + _playerOne.broadcastUserInfo();
- + _playerOne.decayMe();
- + _playerOne.spawnMe();
- + _playerTwo.getAppearance().setInvisible();
- + _playerTwo.broadcastUserInfo();
- + _playerTwo.decayMe();
- + _playerTwo.spawnMe();
- if (_playerOne.isSitting())
- @@ -1647,6 +1624,6 @@
- _playerTwo.setTarget(null);
- - _playerOne.teleToLocation(_stadiumPort[0], _stadiumPort[1], _stadiumPort[2], true);
- - _playerTwo.teleToLocation(_stadiumPort[0], _stadiumPort[1], _stadiumPort[2], true);
- + _playerOne.teleToLocation(_stadiumPort[0]+1100, _stadiumPort[1], _stadiumPort[2], true);
- + _playerTwo.teleToLocation(_stadiumPort[0]-1100, _stadiumPort[1], _stadiumPort[2], true);
- _playerOne.setIsInOlympiadMode(true);
- @@ -1655,6 +1632,6 @@
- _playerTwo.setIsInOlympiadMode(true);
- _playerTwo.setIsOlympiadStart(false);
- - } catch (Exception e) {
- - return false;
- + } catch (NullPointerException e) {
- + return false;
- }
- return true;
- @@ -1724,5 +1701,5 @@
- protected void validateWinner()
- {
- - if (_aborted || (_playerOne == null && _playerTwo == null))
- + if (_aborted || (_playerOne == null && _playerTwo == null) || (_playerOneDisconnected && _playerTwoDisconnected))
- {
- _log.info("Olympia Result: "+_playerOneName+" vs "+_playerTwoName+" ... aborted/tie due to crashes!");
- @@ -1745,5 +1722,5 @@
- double hpDiffOne = 9999999;
- try{
- - if (_playerOne != null && _playerOne.getOlympiadGameId() != -1)
- + if (_playerOne != null && !_playerOneDisconnected)
- {
- playerOneHp = _playerOne.getCurrentHp()+_playerOne.getCurrentCp();
- @@ -1758,5 +1735,5 @@
- double hpDiffTwo = 9999999;
- try{
- - if (_playerTwo != null && _playerTwo.getOlympiadGameId()!=-1)
- + if (_playerTwo != null && !_playerTwoDisconnected)
- {
- playerTwoHp = _playerTwo.getCurrentHp()+_playerTwo.getCurrentCp();
- @@ -1774,5 +1751,11 @@
- String result = "";
- - if (playerTwoHp==0 || hpDiffOne < hpDiffTwo)
- + // if players crashed, search if they've relogged
- + _playerOne = L2World.getInstance().getPlayer(_playerOneName);
- + _players.set(0, _playerOne);
- + _playerTwo = L2World.getInstance().getPlayer(_playerTwoName);
- + _players.set(1, _playerTwo);
- +
- + if ((playerTwoHp == 0 && playerOneHp != 0) || (hpDiffOne < hpDiffTwo && playerTwoHp != 0))
- {
- int pointDiff;
- @@ -1790,5 +1773,4 @@
- broadcastMessage(_sm3, true);
- - _playerOne = L2World.getInstance().getPlayer(_playerOneName); // why this...
- try {
- result=" ("+playerOneHp+"hp vs "+playerTwoHp+"hp - "+hpDiffOne+" vs "+hpDiffTwo+") "+_playerOneName+" win "+pointDiff+" points";
- @@ -1804,5 +1786,5 @@
- } catch (Exception e) { }
- }
- - else if (playerOneHp==0 || hpDiffOne > hpDiffTwo)
- + else if ((playerOneHp == 0 && playerTwoHp != 0) || (hpDiffOne > hpDiffTwo && playerOneHp != 0))
- {
- int pointDiff;
- @@ -1811,14 +1793,13 @@
- playerOneStat.set(POINTS, playerOnePoints - pointDiff);
- - _sm.addString(_playerTwo.getName());
- + _sm.addString(_playerTwoName);
- broadcastMessage(_sm, true);
- - _sm2.addString(_playerTwo.getName());
- + _sm2.addString(_playerTwoName);
- _sm2.addNumber(pointDiff);
- broadcastMessage(_sm2, true);
- - _sm3.addString(_playerOne.getName());
- + _sm3.addString(_playerOneName);
- _sm3.addNumber(pointDiff);
- broadcastMessage(_sm3, true);
- - _playerTwo = L2World.getInstance().getPlayer(_playerTwoName); // why this...
- try {
- result=" ("+playerOneHp+"hp vs "+playerTwoHp+"hp - "+hpDiffOne+" vs "+hpDiffTwo+") "+_playerTwoName+" win "+pointDiff+" points";
- @@ -1834,4 +1815,56 @@
- } catch (Exception e) { }
- }
- + else if (_playerOne == null || _playerOneDisconnected)
- + {
- + int pointDiff;
- + pointDiff = (playerOnePoints / 3);
- + playerTwoStat.set(POINTS, playerTwoPoints + pointDiff);
- + playerOneStat.set(POINTS, playerOnePoints - pointDiff);
- +
- + _sm.addString(_playerTwoName);
- + broadcastMessage(_sm, true);
- + _sm2.addString(_playerTwoName);
- + _sm2.addNumber(pointDiff);
- + broadcastMessage(_sm2, true);
- +
- + try {
- + result=" ("+_playerOne+" lost the game due crashes and "+_playerTwo+" won.";
- + L2ItemInstance item = _playerTwo.getInventory().addItem("Olympiad", 6651, 30, _playerTwo, null);
- + InventoryUpdate iu = new InventoryUpdate();
- + iu.addModifiedItem(item);
- + _playerTwo.sendPacket(iu);
- +
- + SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
- + sm.addItemName(item.getItemId());
- + sm.addNumber(30);
- + _playerTwo.sendPacket(sm);
- + } catch (Exception e) { }
- + }
- + else if (_playerTwo == null || _playerTwoDisconnected)
- + {
- + int pointDiff;
- + pointDiff = (playerTwoPoints / 3);
- + playerOneStat.set(POINTS, playerOnePoints + pointDiff);
- + playerTwoStat.set(POINTS, playerTwoPoints - pointDiff);
- +
- + _sm.addString(_playerOneName);
- + broadcastMessage(_sm, true);
- + _sm2.addString(_playerOneName);
- + _sm2.addNumber(pointDiff);
- + broadcastMessage(_sm2, true);
- +
- + try {
- + result=" ("+_playerTwo+" lost the game due crashes and "+_playerOne+" won.";
- + L2ItemInstance item = _playerOne.getInventory().addItem("Olympiad", 6651, 30, _playerOne, null);
- + InventoryUpdate iu = new InventoryUpdate();
- + iu.addModifiedItem(item);
- + _playerOne.sendPacket(iu);
- +
- + SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
- + sm.addItemName(item.getItemId());
- + sm.addNumber(30);
- + _playerOne.sendPacket(sm);
- + } catch (Exception e) { }
- + }
- else
- {
- @@ -1918,11 +1951,7 @@
- protected boolean makeCompetitionStart()
- {
- - if (_playerOne == null || _playerTwo == null)
- - {
- - _aborted = true;
- - return false;
- - }
- -
- - _sm = new SystemMessage(SystemMessageId.STARTS_THE_GAME);
- + if (_aborted) return false;
- +
- + _sm = new SystemMessage(SystemMessageId.STARTS_THE_GAME);
- try {
- @@ -1991,13 +2020,15 @@
- private void broadcastMessage(SystemMessage sm, boolean toAll)
- {
- - try { _playerOne.sendPacket(sm); } catch (Exception e) {}
- - try { _playerTwo.sendPacket(sm); } catch (Exception e) {}
- + try {
- + _playerOne.sendPacket(sm);
- + _playerTwo.sendPacket(sm);
- + } catch (Exception e) {}
- if (toAll && _spectators != null)
- {
- - for (L2PcInstance spec : _spectators)
- - {
- - try { spec.sendPacket(sm); } catch (NullPointerException e) {}
- - }
- + for (L2PcInstance spec : _spectators)
- + {
- + try { spec.sendPacket(sm); } catch (NullPointerException e) {}
- + }
- }
- }
- Index: /trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/L2ItemInstance.java
- ===================================================================
- --- /trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/L2ItemInstance.java (revision 2)
- +++ /trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/L2ItemInstance.java (revision 21)
- @@ -491,4 +491,9 @@
- {
- return _item.isStackable();
- + }
- +
- + public boolean isHeroItem()
- + {
- + return ((_itemId >= 6611 && _itemId <= 6621) || (_itemId >= 9388 && _itemId <= 9390) || _itemId == 6842);
- }
- Index: /trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- /trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 10)
- +++ /trunk/L2_Gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 21)
- @@ -9405,7 +9405,10 @@
- try { decayMe(); } catch (Throwable t) {_log.log(Level.SEVERE, "deleteMe()", t); }
- - // If a Party is in progress, leave it
- + // If a Party or Festival is in progress, leave it
- if (isInParty()) try { leaveParty(); } catch (Throwable t) {_log.log(Level.SEVERE, "deleteMe()", t); }
- + if (getOlympiadGameId() != -1)
- + Olympiad.getInstance().removeDisconnectedCompetitor(this);
- +
- // If the L2PcInstance has Pet, unsummon it
- if (getPet() != null)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement