{
_log.info("Olympia Result: "+_playerOneName+" vs "+_playerTwoName+" ... aborted/tie due to crashes!");
return;
}
StatsSet playerOneStat;
StatsSet playerTwoStat;
playerOneStat = _nobles.get(_playerOneID);
playerTwoStat = _nobles.get(_playerTwoID);
int playerOnePlayed = playerOneStat.getInteger(COMP_DONE);
int playerTwoPlayed = playerTwoStat.getInteger(COMP_DONE);
int playerOnePoints = playerOneStat.getInteger(POINTS);
int playerTwoPoints = playerTwoStat.getInteger(POINTS);
double playerOneHp = 0;
double hpDiffOne = 9999999;
try{
if (_playerOne != null && _playerOne.getOlympiadGameId() != -1)
{
playerOneHp = _playerOne.getCurrentHp()+_playerOne.getCurrentCp();
hpDiffOne = (_playerOne.getMaxHp()+_playerOne.getMaxCp()) - playerOneHp;
}
}catch (Exception e){
playerOneHp = 0;
hpDiffOne = 9999999;
}
double playerTwoHp = 0;
double hpDiffTwo = 9999999;
try{
if (_playerTwo != null && _playerTwo.getOlympiadGameId()!=-1)
{
playerTwoHp = _playerTwo.getCurrentHp()+_playerTwo.getCurrentCp();
hpDiffTwo = (_playerTwo.getMaxHp()+_playerTwo.getMaxCp()) - playerTwoHp;
}
}catch (Exception e){
playerTwoHp = 0;
hpDiffTwo = 9999999;
}
_sm = new SystemMessage(SystemMessageId.S1_HAS_WON_THE_GAME);
_sm2 = new SystemMessage(SystemMessageId.S1_HAS_GAINED_S2_OLYMPIAD_POINTS);
_sm3 = new SystemMessage(SystemMessageId.S1_HAS_LOST_S2_OLYMPIAD_POINTS);
String result = "";
if (playerTwoHp==0 || hpDiffOne < hpDiffTwo)
{
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);
_sm3.addString(_playerTwoName);
_sm3.addNumber(pointDiff);
broadcastMessage(_sm3, true);
_playerOne = L2World.getInstance().getPlayer(_playerOneName); // why this...
try {
result=" ("+playerOneHp+"hp vs "+playerTwoHp+"hp - "+hpDiffOne+" vs "+hpDiffTwo+") "+_playerOneName+" win "+pointDiff+" points";
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 if (playerOneHp==0 || hpDiffOne > hpDiffTwo)
{
int pointDiff;
pointDiff = (playerOnePoints / 3);
playerTwoStat.set(POINTS, playerTwoPoints + pointDiff);
playerOneStat.set(POINTS, playerOnePoints - pointDiff);
_sm.addString(_playerTwo.getName());
broadcastMessage(_sm, true);
_sm2.addString(_playerTwo.getName());
_sm2.addNumber(pointDiff);
broadcastMessage(_sm2, true);
_sm3.addString(_playerOne.getName());
_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";
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
{
result=" tie";
_sm = new SystemMessage(SystemMessageId.THE_GAME_ENDED_IN_A_TIE);
broadcastMessage(_sm, true);
}
_log.info("Olympia Result: "+_playerOneName+" vs "+_playerTwoName+" ... "+result);
playerOneStat.set(COMP_DONE, playerOnePlayed + 1);
playerTwoStat.set(COMP_DONE, playerTwoPlayed + 1);
_nobles.remove(_playerOneID);
_nobles.remove(_playerTwoID);
_nobles.put(_playerOneID, playerOneStat);