Previous commit for HighFive branch.
This commit is contained in:
parent
e1a534e2bd
commit
e0e2bde017
@ -18,11 +18,11 @@ package com.l2jmobius.gameserver.enums;
|
|||||||
|
|
||||||
public enum DuelResult
|
public enum DuelResult
|
||||||
{
|
{
|
||||||
Continue,
|
CONTINUE,
|
||||||
Team1Win,
|
TEAM_1_WIN,
|
||||||
Team2Win,
|
TEAM_2_WIN,
|
||||||
Team1Surrender,
|
TEAM_1_SURRENDER,
|
||||||
Team2Surrender,
|
TEAM_2_SURRENDER,
|
||||||
Canceled,
|
CANCELED,
|
||||||
Timeout
|
TIMEOUT
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class Duel
|
|||||||
_duelId = duelId;
|
_duelId = duelId;
|
||||||
_playerA = playerA;
|
_playerA = playerA;
|
||||||
_playerB = playerB;
|
_playerB = playerB;
|
||||||
_partyDuel = partyDuel == 1 ? true : false;
|
_partyDuel = partyDuel == 1;
|
||||||
|
|
||||||
_duelEndTime = Calendar.getInstance();
|
_duelEndTime = Calendar.getInstance();
|
||||||
_duelEndTime.add(Calendar.SECOND, _partyDuel ? PARTY_DUEL_DURATION : PLAYER_DUEL_DURATION);
|
_duelEndTime.add(Calendar.SECOND, _partyDuel ? PARTY_DUEL_DURATION : PLAYER_DUEL_DURATION);
|
||||||
@ -197,14 +197,14 @@ public class Duel
|
|||||||
{
|
{
|
||||||
switch (_duel.checkEndDuelCondition())
|
switch (_duel.checkEndDuelCondition())
|
||||||
{
|
{
|
||||||
case Canceled:
|
case CANCELED:
|
||||||
{
|
{
|
||||||
// do not schedule duel end if it was interrupted
|
// do not schedule duel end if it was interrupted
|
||||||
setFinished(true);
|
setFinished(true);
|
||||||
_duel.endDuel(DuelResult.Canceled);
|
_duel.endDuel(DuelResult.CANCELED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Continue:
|
case CONTINUE:
|
||||||
{
|
{
|
||||||
ThreadPoolManager.schedule(this, 1000);
|
ThreadPoolManager.schedule(this, 1000);
|
||||||
break;
|
break;
|
||||||
@ -793,45 +793,29 @@ public class Duel
|
|||||||
SystemMessage sm = null;
|
SystemMessage sm = null;
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case Team1Win:
|
case TEAM_1_WIN:
|
||||||
case Team2Surrender:
|
case TEAM_2_SURRENDER:
|
||||||
{
|
{
|
||||||
restorePlayerConditions(false);
|
restorePlayerConditions(false);
|
||||||
// send SystemMessage
|
sm = _partyDuel ? SystemMessage.getSystemMessage(SystemMessageId.C1_S_PARTY_HAS_WON_THE_DUEL) : SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
|
||||||
if (_partyDuel)
|
|
||||||
{
|
|
||||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_PARTY_HAS_WON_THE_DUEL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
|
|
||||||
}
|
|
||||||
sm.addString(_playerA.getName());
|
sm.addString(_playerA.getName());
|
||||||
|
|
||||||
broadcastToTeam1(sm);
|
broadcastToTeam1(sm);
|
||||||
broadcastToTeam2(sm);
|
broadcastToTeam2(sm);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Team1Surrender:
|
case TEAM_1_SURRENDER:
|
||||||
case Team2Win:
|
case TEAM_2_WIN:
|
||||||
{
|
{
|
||||||
restorePlayerConditions(false);
|
restorePlayerConditions(false);
|
||||||
// send SystemMessage
|
sm = _partyDuel ? SystemMessage.getSystemMessage(SystemMessageId.C1_S_PARTY_HAS_WON_THE_DUEL) : SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
|
||||||
if (_partyDuel)
|
|
||||||
{
|
|
||||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_PARTY_HAS_WON_THE_DUEL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
|
|
||||||
}
|
|
||||||
sm.addString(_playerB.getName());
|
sm.addString(_playerB.getName());
|
||||||
|
|
||||||
broadcastToTeam1(sm);
|
broadcastToTeam1(sm);
|
||||||
broadcastToTeam2(sm);
|
broadcastToTeam2(sm);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Canceled:
|
case CANCELED:
|
||||||
{
|
{
|
||||||
stopFighting();
|
stopFighting();
|
||||||
// Don't restore hp, mp, cp
|
// Don't restore hp, mp, cp
|
||||||
@ -844,7 +828,7 @@ public class Duel
|
|||||||
broadcastToTeam2(sm);
|
broadcastToTeam2(sm);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Timeout:
|
case TIMEOUT:
|
||||||
{
|
{
|
||||||
stopFighting();
|
stopFighting();
|
||||||
// hp,mp,cp seem to be restored in a timeout too...
|
// hp,mp,cp seem to be restored in a timeout too...
|
||||||
@ -858,6 +842,7 @@ public class Duel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send end duel packet
|
||||||
final ExDuelEnd duelEnd = _partyDuel ? ExDuelEnd.PARTY_DUEL : ExDuelEnd.PLAYER_DUEL;
|
final ExDuelEnd duelEnd = _partyDuel ? ExDuelEnd.PARTY_DUEL : ExDuelEnd.PLAYER_DUEL;
|
||||||
broadcastToTeam1(duelEnd);
|
broadcastToTeam1(duelEnd);
|
||||||
broadcastToTeam2(duelEnd);
|
broadcastToTeam2(duelEnd);
|
||||||
@ -876,35 +861,31 @@ public class Duel
|
|||||||
// one of the players might leave during duel
|
// one of the players might leave during duel
|
||||||
if ((_playerA == null) || (_playerB == null))
|
if ((_playerA == null) || (_playerB == null))
|
||||||
{
|
{
|
||||||
return DuelResult.Canceled;
|
return DuelResult.CANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// got a duel surrender request?
|
// got a duel surrender request?
|
||||||
if (_surrenderRequest != 0)
|
if (_surrenderRequest != 0)
|
||||||
{
|
{
|
||||||
if (_surrenderRequest == 1)
|
return _surrenderRequest == 1 ? DuelResult.TEAM_1_SURRENDER : DuelResult.TEAM_2_SURRENDER;
|
||||||
{
|
|
||||||
return DuelResult.Team1Surrender;
|
|
||||||
}
|
|
||||||
return DuelResult.Team2Surrender;
|
|
||||||
}
|
}
|
||||||
// duel timed out
|
// duel timed out
|
||||||
else if (getRemainingTime() <= 0)
|
else if (getRemainingTime() <= 0)
|
||||||
{
|
{
|
||||||
return DuelResult.Timeout;
|
return DuelResult.TIMEOUT;
|
||||||
}
|
}
|
||||||
// Has a player been declared winner yet?
|
// Has a player been declared winner yet?
|
||||||
else if (_playerA.getDuelState() == DUELSTATE_WINNER)
|
else if (_playerA.getDuelState() == DUELSTATE_WINNER)
|
||||||
{
|
{
|
||||||
// If there is a Winner already there should be no more fighting going on
|
// If there is a Winner already there should be no more fighting going on
|
||||||
stopFighting();
|
stopFighting();
|
||||||
return DuelResult.Team1Win;
|
return DuelResult.TEAM_1_WIN;
|
||||||
}
|
}
|
||||||
else if (_playerB.getDuelState() == DUELSTATE_WINNER)
|
else if (_playerB.getDuelState() == DUELSTATE_WINNER)
|
||||||
{
|
{
|
||||||
// If there is a Winner already there should be no more fighting going on
|
// If there is a Winner already there should be no more fighting going on
|
||||||
stopFighting();
|
stopFighting();
|
||||||
return DuelResult.Team2Win;
|
return DuelResult.TEAM_2_WIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// More end duel conditions for 1on1 duels
|
// More end duel conditions for 1on1 duels
|
||||||
@ -913,29 +894,29 @@ public class Duel
|
|||||||
// Duel was interrupted e.g.: player was attacked by mobs / other players
|
// Duel was interrupted e.g.: player was attacked by mobs / other players
|
||||||
if ((_playerA.getDuelState() == DUELSTATE_INTERRUPTED) || (_playerB.getDuelState() == DUELSTATE_INTERRUPTED))
|
if ((_playerA.getDuelState() == DUELSTATE_INTERRUPTED) || (_playerB.getDuelState() == DUELSTATE_INTERRUPTED))
|
||||||
{
|
{
|
||||||
return DuelResult.Canceled;
|
return DuelResult.CANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are the players too far apart?
|
// Are the players too far apart?
|
||||||
if (!_playerA.isInsideRadius(_playerB, 1600, false, false))
|
if (!_playerA.isInsideRadius(_playerB, 1600, false, false))
|
||||||
{
|
{
|
||||||
return DuelResult.Canceled;
|
return DuelResult.CANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Did one of the players engage in PvP combat?
|
// Did one of the players engage in PvP combat?
|
||||||
if (isDuelistInPvp(true))
|
if (isDuelistInPvp(true))
|
||||||
{
|
{
|
||||||
return DuelResult.Canceled;
|
return DuelResult.CANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// is one of the players in a Siege, Peace or PvP zone?
|
// is one of the players in a Siege, Peace or PvP zone?
|
||||||
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
|
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
|
||||||
{
|
{
|
||||||
return DuelResult.Canceled;
|
return DuelResult.CANCELED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DuelResult.Continue;
|
return DuelResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -982,9 +963,7 @@ public class Duel
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (player == _playerA)
|
||||||
{
|
|
||||||
if (player == _playerA)
|
|
||||||
{
|
{
|
||||||
_surrenderRequest = 1;
|
_surrenderRequest = 1;
|
||||||
_playerA.setDuelState(DUELSTATE_DEAD);
|
_playerA.setDuelState(DUELSTATE_DEAD);
|
||||||
@ -997,7 +976,6 @@ public class Duel
|
|||||||
_playerA.setDuelState(DUELSTATE_WINNER);
|
_playerA.setDuelState(DUELSTATE_WINNER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is called whenever a player was defeated in a duel
|
* This function is called whenever a player was defeated in a duel
|
||||||
@ -1022,12 +1000,7 @@ public class Duel
|
|||||||
|
|
||||||
if (teamdefeated)
|
if (teamdefeated)
|
||||||
{
|
{
|
||||||
L2PcInstance winner = _playerA;
|
final L2PcInstance winner = _playerA.getParty().getMembers().contains(player) ? _playerB : _playerA;
|
||||||
if (_playerA.getParty().getMembers().contains(player))
|
|
||||||
{
|
|
||||||
winner = _playerB;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (L2PcInstance temp : winner.getParty().getMembers())
|
for (L2PcInstance temp : winner.getParty().getMembers())
|
||||||
{
|
{
|
||||||
temp.setDuelState(DUELSTATE_WINNER);
|
temp.setDuelState(DUELSTATE_WINNER);
|
||||||
|
Loading…
Reference in New Issue
Block a user