Sync with L2jServer HighFive Oct 2nd 2015.
This commit is contained in:
@@ -362,7 +362,7 @@ public class StatsSet implements IParserAdvUtils
|
||||
Object val = _set.get(key);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Integer value required, but not specified");
|
||||
throw new IllegalArgumentException("Long value required, but not specified");
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
@@ -374,7 +374,7 @@ public class StatsSet implements IParserAdvUtils
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Integer value required, but found: " + val);
|
||||
throw new IllegalArgumentException("Long value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ public class StatsSet implements IParserAdvUtils
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Integer value required, but found: " + val);
|
||||
throw new IllegalArgumentException("Long value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ public class StatsSet implements IParserAdvUtils
|
||||
}
|
||||
try
|
||||
{
|
||||
return (float) Double.parseDouble((String) val);
|
||||
return Float.parseFloat((String) val);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -436,7 +436,7 @@ public class StatsSet implements IParserAdvUtils
|
||||
}
|
||||
try
|
||||
{
|
||||
return (float) Double.parseDouble((String) val);
|
||||
return Float.parseFloat((String) val);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -450,7 +450,7 @@ public class StatsSet implements IParserAdvUtils
|
||||
Object val = _set.get(key);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Float value required, but not specified");
|
||||
throw new IllegalArgumentException("Double value required, but not specified");
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
@@ -462,7 +462,7 @@ public class StatsSet implements IParserAdvUtils
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Float value required, but found: " + val);
|
||||
throw new IllegalArgumentException("Double value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ public class StatsSet implements IParserAdvUtils
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Float value required, but found: " + val);
|
||||
throw new IllegalArgumentException("Double value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -607,7 +607,7 @@ public class StatsSet implements IParserAdvUtils
|
||||
Object obj = _set.get(key);
|
||||
if ((obj == null) || !(obj instanceof List<?>))
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return (List<MinionHolder>) obj;
|
||||
|
||||
@@ -111,6 +111,7 @@ public class L2Attackable extends L2Npc
|
||||
// Misc
|
||||
private boolean _mustGiveExpSp;
|
||||
protected int _onKillDelay = 5000;
|
||||
private long _lastAttack;
|
||||
|
||||
/**
|
||||
* Creates an attackable NPC.
|
||||
@@ -1575,6 +1576,16 @@ public class L2Attackable extends L2Npc
|
||||
return _onKillDelay;
|
||||
}
|
||||
|
||||
public long getLastAttack()
|
||||
{
|
||||
return _lastAttack;
|
||||
}
|
||||
|
||||
public void setLastAttack(long lastAttack)
|
||||
{
|
||||
_lastAttack = lastAttack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the server allows Random Animation.
|
||||
*/
|
||||
|
||||
@@ -5409,7 +5409,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
// Remove all its Func objects from the L2Character calculator set
|
||||
if (oldSkill != null)
|
||||
{
|
||||
|
||||
// Stop casting if this skill is used right now
|
||||
if ((getLastSkillCast() != null) && isCastingNow())
|
||||
{
|
||||
@@ -5444,7 +5443,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
*/
|
||||
public final Collection<Skill> getAllSkills()
|
||||
{
|
||||
return new ArrayList<>(_skills.values());
|
||||
return _skills.values();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,6 @@ package com.l2jserver.gameserver.model.actor;
|
||||
|
||||
import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -83,7 +82,6 @@ import com.l2jserver.gameserver.model.items.L2Weapon;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.olympiad.Olympiad;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
|
||||
import com.l2jserver.gameserver.model.variables.NpcVariables;
|
||||
import com.l2jserver.gameserver.model.zone.type.L2TownZone;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
@@ -193,14 +191,6 @@ public class L2Npc extends L2Character
|
||||
return getTemplate().getSpiritShotChance();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the primary attack skill Id
|
||||
*/
|
||||
public int getPrimarySkillId()
|
||||
{
|
||||
return getTemplate().getPrimarySkillId();
|
||||
}
|
||||
|
||||
public int getMinSkillChance()
|
||||
{
|
||||
return getTemplate().getMinSkillChance();
|
||||
@@ -211,6 +201,15 @@ public class L2Npc extends L2Character
|
||||
return getTemplate().getMaxSkillChance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the NPC can cast a skill given the minimum and maximum skill chances.
|
||||
* @return {@code true} if the NPC has chances of casting a skill
|
||||
*/
|
||||
public boolean hasSkillChance()
|
||||
{
|
||||
return Rnd.get(100) < Rnd.get(getMinSkillChance(), getMaxSkillChance());
|
||||
}
|
||||
|
||||
public boolean canMove()
|
||||
{
|
||||
return getTemplate().canMove();
|
||||
@@ -226,169 +225,57 @@ public class L2Npc extends L2Character
|
||||
return getTemplate().getDodge();
|
||||
}
|
||||
|
||||
public int getSSkillChance()
|
||||
public List<Skill> getLongRangeSkills()
|
||||
{
|
||||
return getTemplate().getShortRangeSkillChance();
|
||||
return getTemplate().getAISkills(AISkillScope.LONG_RANGE);
|
||||
}
|
||||
|
||||
public int getLSkillChance()
|
||||
public List<Skill> getShortRangeSkills()
|
||||
{
|
||||
return getTemplate().getLongRangeSkillChance();
|
||||
}
|
||||
|
||||
public boolean hasLSkill()
|
||||
{
|
||||
return getTemplate().getLongRangeSkillId() > 0;
|
||||
}
|
||||
|
||||
public boolean hasSSkill()
|
||||
{
|
||||
return getTemplate().getShortRangeSkillId() > 0;
|
||||
}
|
||||
|
||||
public List<Skill> getLongRangeSkill()
|
||||
{
|
||||
final List<Skill> skilldata = new ArrayList<>();
|
||||
if (getTemplate().getLongRangeSkillId() == 0)
|
||||
{
|
||||
return skilldata;
|
||||
}
|
||||
|
||||
switch (getTemplate().getLongRangeSkillId())
|
||||
{
|
||||
case -1:
|
||||
{
|
||||
final Collection<Skill> skills = getAllSkills();
|
||||
if (skills != null)
|
||||
{
|
||||
for (Skill sk : skills)
|
||||
{
|
||||
if ((sk == null) || sk.isPassive() || (sk.getTargetType() == L2TargetType.SELF))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sk.getCastRange() >= 200)
|
||||
{
|
||||
skilldata.add(sk);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
for (Skill sk : getTemplate().getAISkills(AISkillScope.UNIVERSAL))
|
||||
{
|
||||
if (sk.getCastRange() >= 200)
|
||||
{
|
||||
skilldata.add(sk);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
for (Skill sk : getAllSkills())
|
||||
{
|
||||
if (sk.getId() == getTemplate().getLongRangeSkillId())
|
||||
{
|
||||
skilldata.add(sk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return skilldata;
|
||||
}
|
||||
|
||||
public List<Skill> getShortRangeSkill()
|
||||
{
|
||||
final List<Skill> skilldata = new ArrayList<>();
|
||||
if (getTemplate().getShortRangeSkillId() == 0)
|
||||
{
|
||||
return skilldata;
|
||||
}
|
||||
|
||||
switch (getTemplate().getShortRangeSkillId())
|
||||
{
|
||||
case -1:
|
||||
{
|
||||
Collection<Skill> skills = getAllSkills();
|
||||
if (skills != null)
|
||||
{
|
||||
for (Skill sk : skills)
|
||||
{
|
||||
if ((sk == null) || sk.isPassive() || (sk.getTargetType() == L2TargetType.SELF))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (sk.getCastRange() <= 200)
|
||||
{
|
||||
skilldata.add(sk);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
for (Skill sk : getTemplate().getAISkills(AISkillScope.UNIVERSAL))
|
||||
{
|
||||
if (sk.getCastRange() <= 200)
|
||||
{
|
||||
skilldata.add(sk);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
for (Skill sk : getAllSkills())
|
||||
{
|
||||
if (sk.getId() == getTemplate().getShortRangeSkillId())
|
||||
{
|
||||
skilldata.add(sk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return skilldata;
|
||||
return getTemplate().getAISkills(AISkillScope.SHORT_RANGE);
|
||||
}
|
||||
|
||||
/** Task launching the function onRandomAnimation() */
|
||||
protected class RandomAnimationTask implements Runnable
|
||||
protected static class RandomAnimationTask implements Runnable
|
||||
{
|
||||
private final L2Npc _npc;
|
||||
|
||||
protected RandomAnimationTask(L2Npc npc)
|
||||
{
|
||||
_npc = npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isMob())
|
||||
if (_npc.isMob())
|
||||
{
|
||||
// Cancel further animation timers until intention is changed to ACTIVE again.
|
||||
if (getAI().getIntention() != AI_INTENTION_ACTIVE)
|
||||
if (_npc.getAI().getIntention() != AI_INTENTION_ACTIVE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isInActiveRegion())
|
||||
if (!_npc.isInActiveRegion())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(isDead() || isStunned() || isSleeping() || isParalyzed()))
|
||||
if (!(_npc.isDead() || _npc.isStunned() || _npc.isSleeping() || _npc.isParalyzed()))
|
||||
{
|
||||
onRandomAnimation(Rnd.get(2, 3));
|
||||
_npc.onRandomAnimation(Rnd.get(2, 3));
|
||||
}
|
||||
|
||||
startRandomAnimationTimer();
|
||||
_npc.startRandomAnimationTimer();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "", e);
|
||||
_log.log(Level.SEVERE, "There has been an error trying to perform a random animation for NPC " + _npc.getId() + "!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,7 +312,7 @@ public class L2Npc extends L2Character
|
||||
int interval = Rnd.get(minWait, maxWait) * 1000;
|
||||
|
||||
// Create a RandomAnimation Task that will be launched after the calculated delay
|
||||
_rAniTask = new RandomAnimationTask();
|
||||
_rAniTask = new RandomAnimationTask(this);
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(_rAniTask, interval);
|
||||
}
|
||||
|
||||
|
||||
@@ -6774,8 +6774,8 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the _accessLevel of the L2PcInstance.
|
||||
* @param level
|
||||
* Set the access level for this player.
|
||||
* @param level the access level
|
||||
* @param broadcast
|
||||
*/
|
||||
public void setAccessLevel(int level, boolean broadcast)
|
||||
@@ -6793,7 +6793,7 @@ public final class L2PcInstance extends L2Playable
|
||||
|
||||
if (!AdminData.getInstance().hasAccessLevel(level))
|
||||
{
|
||||
_log.warning("Tryed to set unregistered access level " + level + " for " + toString() + ". Setting access level without privileges!");
|
||||
_log.warning("Tried to set unregistered access level " + level + " for " + toString() + ". Setting access level without privileges!");
|
||||
}
|
||||
else if (level > 0)
|
||||
{
|
||||
|
||||
@@ -89,11 +89,6 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
||||
private int _spiritShotChance;
|
||||
private int _minSkillChance;
|
||||
private int _maxSkillChance;
|
||||
private int _primarySkillId;
|
||||
private int _shortRangeSkillId;
|
||||
private int _shortRangeSkillChance;
|
||||
private int _longRangeSkillId;
|
||||
private int _longRangeSkillChance;
|
||||
private Map<Integer, Skill> _skills;
|
||||
private Map<AISkillScope, List<Skill>> _aiSkillLists;
|
||||
private Set<Integer> _clans;
|
||||
@@ -166,11 +161,6 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
||||
|
||||
_minSkillChance = set.getInt("minSkillChance", 7);
|
||||
_maxSkillChance = set.getInt("maxSkillChance", 15);
|
||||
_primarySkillId = set.getInt("primarySkillId", 0);
|
||||
_shortRangeSkillId = set.getInt("shortRangeSkillId", 0);
|
||||
_shortRangeSkillChance = set.getInt("shortRangeSkillChance", 0);
|
||||
_longRangeSkillId = set.getInt("longRangeSkillId", 0);
|
||||
_longRangeSkillChance = set.getInt("longRangeSkillChance", 0);
|
||||
|
||||
_collisionRadiusGrown = set.getDouble("collisionRadiusGrown", 0);
|
||||
_collisionHeightGrown = set.getDouble("collisionHeightGrown", 0);
|
||||
@@ -397,31 +387,6 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
||||
return _maxSkillChance;
|
||||
}
|
||||
|
||||
public int getPrimarySkillId()
|
||||
{
|
||||
return _primarySkillId;
|
||||
}
|
||||
|
||||
public int getShortRangeSkillId()
|
||||
{
|
||||
return _shortRangeSkillId;
|
||||
}
|
||||
|
||||
public int getShortRangeSkillChance()
|
||||
{
|
||||
return _shortRangeSkillChance;
|
||||
}
|
||||
|
||||
public int getLongRangeSkillId()
|
||||
{
|
||||
return _longRangeSkillId;
|
||||
}
|
||||
|
||||
public int getLongRangeSkillChance()
|
||||
{
|
||||
return _longRangeSkillChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, Skill> getSkills()
|
||||
{
|
||||
@@ -430,18 +395,17 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
||||
|
||||
public void setSkills(Map<Integer, Skill> skills)
|
||||
{
|
||||
_skills = skills != null ? Collections.unmodifiableMap(skills) : Collections.<Integer, Skill> emptyMap();
|
||||
_skills = skills != null ? Collections.unmodifiableMap(skills) : Collections.emptyMap();
|
||||
}
|
||||
|
||||
public List<Skill> getAISkills(AISkillScope aiSkillScope)
|
||||
{
|
||||
final List<Skill> aiSkills = _aiSkillLists.get(aiSkillScope);
|
||||
return aiSkills != null ? aiSkills : Collections.<Skill> emptyList();
|
||||
return _aiSkillLists.getOrDefault(aiSkillScope, Collections.emptyList());
|
||||
}
|
||||
|
||||
public void setAISkillLists(Map<AISkillScope, List<Skill>> aiSkillLists)
|
||||
{
|
||||
_aiSkillLists = aiSkillLists != null ? Collections.unmodifiableMap(aiSkillLists) : Collections.<AISkillScope, List<Skill>> emptyMap();
|
||||
_aiSkillLists = aiSkillLists != null ? Collections.unmodifiableMap(aiSkillLists) : Collections.emptyMap();
|
||||
}
|
||||
|
||||
public Set<Integer> getClans()
|
||||
|
||||
@@ -20,7 +20,9 @@ package com.l2jserver.gameserver.model.entity;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -29,10 +31,17 @@ import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.enums.DuelResult;
|
||||
import com.l2jserver.gameserver.enums.Team;
|
||||
import com.l2jserver.gameserver.instancemanager.DuelManager;
|
||||
import com.l2jserver.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jserver.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.L2Summon;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2OlympiadManagerInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.model.zone.ZoneId;
|
||||
import com.l2jserver.gameserver.model.zone.type.L2OlympiadStadiumZone;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExDuelEnd;
|
||||
@@ -43,6 +52,7 @@ import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PlaySound;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SocialAction;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
public class Duel
|
||||
{
|
||||
@@ -56,16 +66,20 @@ public class Duel
|
||||
|
||||
private static final PlaySound B04_S01 = new PlaySound(1, "B04_S01", 0, 0, 0, 0, 0);
|
||||
|
||||
private static final int PARTY_DUEL_DURATION = 300;
|
||||
private static final int PLAYER_DUEL_DURATION = 120;
|
||||
|
||||
private final int _duelId;
|
||||
private L2PcInstance _playerA;
|
||||
private L2PcInstance _playerB;
|
||||
private final boolean _partyDuel;
|
||||
private final Calendar _duelEndTime;
|
||||
private int _surrenderRequest = 0;
|
||||
private int _countdown = 4;
|
||||
private int _countdown = 5;
|
||||
private boolean _finished = false;
|
||||
|
||||
private final List<PlayerCondition> _playerConditions = new CopyOnWriteArrayList<>();
|
||||
private final Map<Integer, PlayerCondition> _playerConditions = new ConcurrentHashMap<>();
|
||||
private int _duelInstanceId;
|
||||
|
||||
public Duel(L2PcInstance playerA, L2PcInstance playerB, int partyDuel, int duelId)
|
||||
{
|
||||
@@ -75,21 +89,12 @@ public class Duel
|
||||
_partyDuel = partyDuel == 1 ? true : false;
|
||||
|
||||
_duelEndTime = Calendar.getInstance();
|
||||
if (_partyDuel)
|
||||
{
|
||||
_duelEndTime.add(Calendar.SECOND, 300);
|
||||
}
|
||||
else
|
||||
{
|
||||
_duelEndTime.add(Calendar.SECOND, 120);
|
||||
}
|
||||
_duelEndTime.add(Calendar.SECOND, _partyDuel ? PARTY_DUEL_DURATION : PLAYER_DUEL_DURATION);
|
||||
|
||||
setFinished(false);
|
||||
|
||||
if (_partyDuel)
|
||||
{
|
||||
// increase countdown so that start task can teleport players
|
||||
_countdown++;
|
||||
// inform players that they will be ported shortly
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IN_A_MOMENT_YOU_WILL_BE_TRANSPORTED_TO_THE_SITE_WHERE_THE_DUEL_WILL_TAKE_PLACE);
|
||||
broadcastToTeam1(sm);
|
||||
@@ -107,7 +112,7 @@ public class Duel
|
||||
private double _cp;
|
||||
private boolean _paDuel;
|
||||
private int _x, _y, _z;
|
||||
private List<Skill> _debuffs;
|
||||
private Set<Skill> _debuffs;
|
||||
|
||||
public PlayerCondition(L2PcInstance player, boolean partyDuel)
|
||||
{
|
||||
@@ -159,7 +164,7 @@ public class Duel
|
||||
{
|
||||
if (_debuffs == null)
|
||||
{
|
||||
_debuffs = new CopyOnWriteArrayList<>();
|
||||
_debuffs = ConcurrentHashMap.newKeySet();
|
||||
}
|
||||
|
||||
_debuffs.add(debuff);
|
||||
@@ -169,7 +174,7 @@ public class Duel
|
||||
{
|
||||
if (_paDuel)
|
||||
{
|
||||
_player.teleToLocation(new Location(_x, _y, _z));
|
||||
_player.teleToLocation(_x, _y, _z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,28 +198,33 @@ public class Duel
|
||||
{
|
||||
try
|
||||
{
|
||||
DuelResult status = _duel.checkEndDuelCondition();
|
||||
|
||||
if (status == DuelResult.Canceled)
|
||||
switch (_duel.checkEndDuelCondition())
|
||||
{
|
||||
// do not schedule duel end if it was interrupted
|
||||
setFinished(true);
|
||||
_duel.endDuel(status);
|
||||
}
|
||||
else if (status != DuelResult.Continue)
|
||||
{
|
||||
setFinished(true);
|
||||
playKneelAnimation();
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndDuelTask(_duel, status), 5000);
|
||||
}
|
||||
else
|
||||
{
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(this, 1000);
|
||||
case Canceled:
|
||||
{
|
||||
// do not schedule duel end if it was interrupted
|
||||
setFinished(true);
|
||||
_duel.endDuel(DuelResult.Canceled);
|
||||
break;
|
||||
}
|
||||
case Continue:
|
||||
{
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(this, 1000);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
setFinished(true);
|
||||
playKneelAnimation();
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndDuelTask(_duel, _duel.checkEndDuelCondition()), 5000);
|
||||
InstanceManager.getInstance().destroyInstance(_duel.getDueldInstanceId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "", e);
|
||||
_log.log(Level.SEVERE, "There has been a problem while runing a duel task!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,13 +248,13 @@ public class Duel
|
||||
|
||||
if (count == 4)
|
||||
{
|
||||
// players need to be teleportet first
|
||||
// TODO: stadia manager needs a function to return an unused stadium for duels
|
||||
// currently only teleports to the same stadium
|
||||
_duel.teleportPlayers(-83760, -238825, -3331);
|
||||
// Save player conditions before teleporting players
|
||||
_duel.savePlayerConditions();
|
||||
|
||||
// give players 20 seconds to complete teleport and get ready (its ought to be 30 on offical..)
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
|
||||
_duel.teleportPlayers();
|
||||
|
||||
// give players 20 seconds to complete teleport and get ready (its ought to be 30 on official..)
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(this, _duel.isPartyDuel() ? 20000 : 1);
|
||||
}
|
||||
else if (count > 0) // duel not started yet - continue countdown
|
||||
{
|
||||
@@ -287,6 +297,11 @@ public class Duel
|
||||
}
|
||||
}
|
||||
|
||||
public int getDueldInstanceId()
|
||||
{
|
||||
return _duelInstanceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops all players from attacking. Used for duel timeout / interrupt.
|
||||
*/
|
||||
@@ -301,6 +316,19 @@ public class Duel
|
||||
temp.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
temp.setTarget(null);
|
||||
temp.sendPacket(af);
|
||||
if (temp.hasSummon())
|
||||
{
|
||||
for (L2Summon summon : temp.getServitors().values())
|
||||
{
|
||||
if (!summon.isDead())
|
||||
{
|
||||
summon.abortCast();
|
||||
summon.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
summon.setTarget(null);
|
||||
summon.sendPacket(af);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (L2PcInstance temp : _playerB.getParty().getMembers())
|
||||
{
|
||||
@@ -308,6 +336,19 @@ public class Duel
|
||||
temp.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
temp.setTarget(null);
|
||||
temp.sendPacket(af);
|
||||
if (temp.hasSummon())
|
||||
{
|
||||
for (L2Summon summon : temp.getServitors().values())
|
||||
{
|
||||
if (!summon.isDead())
|
||||
{
|
||||
summon.abortCast();
|
||||
summon.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
summon.setTarget(null);
|
||||
summon.sendPacket(af);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -320,6 +361,32 @@ public class Duel
|
||||
_playerB.setTarget(null);
|
||||
_playerA.sendPacket(af);
|
||||
_playerB.sendPacket(af);
|
||||
if (_playerA.hasSummon())
|
||||
{
|
||||
for (L2Summon summon : _playerA.getServitors().values())
|
||||
{
|
||||
if (!summon.isDead())
|
||||
{
|
||||
summon.abortCast();
|
||||
summon.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
summon.setTarget(null);
|
||||
summon.sendPacket(af);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_playerB.hasSummon())
|
||||
{
|
||||
for (L2Summon summon : _playerB.getServitors().values())
|
||||
{
|
||||
if (!summon.isDead())
|
||||
{
|
||||
summon.abortCast();
|
||||
summon.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
summon.setTarget(null);
|
||||
summon.sendPacket(af);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,9 +420,6 @@ public class Duel
|
||||
*/
|
||||
public void startDuel()
|
||||
{
|
||||
// Save player Conditions
|
||||
savePlayerConditions();
|
||||
|
||||
if ((_playerA == null) || (_playerB == null) || _playerA.isInDuel() || _playerB.isInDuel())
|
||||
{
|
||||
_playerConditions.clear();
|
||||
@@ -365,8 +429,7 @@ public class Duel
|
||||
|
||||
if (_partyDuel)
|
||||
{
|
||||
// set isInDuel() state
|
||||
// cancel all active trades, just in case? xD
|
||||
// Set duel state and team
|
||||
for (L2PcInstance temp : _playerA.getParty().getMembers())
|
||||
{
|
||||
temp.cancelActiveTrade();
|
||||
@@ -384,31 +447,35 @@ public class Duel
|
||||
broadcastToTeam1(new ExDuelUpdateUserInfo(temp));
|
||||
}
|
||||
|
||||
// Send duel Start packets
|
||||
ExDuelReady ready = new ExDuelReady(1);
|
||||
ExDuelStart start = new ExDuelStart(1);
|
||||
// Send duel packets
|
||||
broadcastToTeam1(ExDuelReady.PARTY_DUEL);
|
||||
broadcastToTeam2(ExDuelReady.PARTY_DUEL);
|
||||
broadcastToTeam1(ExDuelStart.PARTY_DUEL);
|
||||
broadcastToTeam2(ExDuelStart.PARTY_DUEL);
|
||||
|
||||
broadcastToTeam1(ready);
|
||||
broadcastToTeam2(ready);
|
||||
broadcastToTeam1(start);
|
||||
broadcastToTeam2(start);
|
||||
// Open arena doors
|
||||
for (L2DoorInstance door : InstanceManager.getInstance().getInstance(getDueldInstanceId()).getDoors())
|
||||
{
|
||||
if ((door != null) && !door.getOpen())
|
||||
{
|
||||
door.openMe();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// set isInDuel() state
|
||||
// Set duel state and team
|
||||
_playerA.setIsInDuel(_duelId);
|
||||
_playerA.setTeam(Team.BLUE);
|
||||
_playerB.setIsInDuel(_duelId);
|
||||
_playerB.setTeam(Team.RED);
|
||||
|
||||
// Send duel Start packets
|
||||
ExDuelReady ready = new ExDuelReady(0);
|
||||
ExDuelStart start = new ExDuelStart(0);
|
||||
|
||||
broadcastToTeam1(ready);
|
||||
broadcastToTeam2(ready);
|
||||
broadcastToTeam1(start);
|
||||
broadcastToTeam2(start);
|
||||
// Send duel packets
|
||||
broadcastToTeam1(ExDuelReady.PLAYER_DUEL);
|
||||
broadcastToTeam2(ExDuelReady.PLAYER_DUEL);
|
||||
broadcastToTeam1(ExDuelStart.PLAYER_DUEL);
|
||||
broadcastToTeam2(ExDuelStart.PLAYER_DUEL);
|
||||
|
||||
broadcastToTeam1(new ExDuelUpdateUserInfo(_playerB));
|
||||
broadcastToTeam2(new ExDuelUpdateUserInfo(_playerA));
|
||||
@@ -421,7 +488,7 @@ public class Duel
|
||||
broadcastToTeam1(B04_S01);
|
||||
broadcastToTeam2(B04_S01);
|
||||
|
||||
// start duelling task
|
||||
// start dueling task
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleDuelTask(this), 1000);
|
||||
}
|
||||
|
||||
@@ -434,17 +501,17 @@ public class Duel
|
||||
{
|
||||
for (L2PcInstance player : _playerA.getParty().getMembers())
|
||||
{
|
||||
_playerConditions.add(new PlayerCondition(player, _partyDuel));
|
||||
_playerConditions.put(player.getObjectId(), new PlayerCondition(player, _partyDuel));
|
||||
}
|
||||
for (L2PcInstance player : _playerB.getParty().getMembers())
|
||||
{
|
||||
_playerConditions.add(new PlayerCondition(player, _partyDuel));
|
||||
_playerConditions.put(player.getObjectId(), new PlayerCondition(player, _partyDuel));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerConditions.add(new PlayerCondition(_playerA, _partyDuel));
|
||||
_playerConditions.add(new PlayerCondition(_playerB, _partyDuel));
|
||||
_playerConditions.put(_playerA.getObjectId(), new PlayerCondition(_playerA, _partyDuel));
|
||||
_playerConditions.put(_playerB.getObjectId(), new PlayerCondition(_playerB, _partyDuel));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,7 +554,7 @@ public class Duel
|
||||
}
|
||||
|
||||
// restore player conditions
|
||||
_playerConditions.forEach(c -> c.restoreCondition());
|
||||
_playerConditions.values().forEach(c -> c.restoreCondition());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -546,30 +613,46 @@ public class Duel
|
||||
}
|
||||
|
||||
/**
|
||||
* teleport all players to the given coordinates
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* Teleports all players to a free arena.
|
||||
*/
|
||||
public void teleportPlayers(int x, int y, int z)
|
||||
public void teleportPlayers()
|
||||
{
|
||||
// TODO: adjust the values if needed... or implement something better (especially using more then 1 arena)
|
||||
if (!_partyDuel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int offset = 0;
|
||||
|
||||
final String instanceName = DuelManager.getInstance().getDuelArena();
|
||||
final L2OlympiadStadiumZone zone = ZoneManager.getInstance().getAllZones(L2OlympiadStadiumZone.class) //
|
||||
.stream().filter(z -> z.getInstanceTemplate().equals(instanceName)).findFirst().orElse(null);
|
||||
|
||||
if (zone == null)
|
||||
{
|
||||
throw new RuntimeException("Unable to find a party duel arena!");
|
||||
}
|
||||
|
||||
final List<Location> spawns = zone.getSpawns();
|
||||
_duelInstanceId = InstanceManager.getInstance().createDynamicInstance(instanceName);
|
||||
|
||||
// Remove Olympiad buffers
|
||||
for (L2Npc buffer : InstanceManager.getInstance().getInstance(getDueldInstanceId()).getNpcs())
|
||||
{
|
||||
if ((buffer instanceof L2OlympiadManagerInstance) && buffer.isVisible())
|
||||
{
|
||||
buffer.decayMe();
|
||||
}
|
||||
}
|
||||
|
||||
final Location spawn1 = spawns.get(Rnd.get(spawns.size() / 2));
|
||||
for (L2PcInstance temp : _playerA.getParty().getMembers())
|
||||
{
|
||||
temp.teleToLocation(new Location((x + offset) - 180, y - 150, z));
|
||||
offset += 40;
|
||||
temp.teleToLocation(spawn1.getX(), spawn1.getY(), spawn1.getZ(), 0, _duelInstanceId, 0);
|
||||
}
|
||||
offset = 0;
|
||||
|
||||
final Location spawn2 = spawns.get(Rnd.get(spawns.size() / 2, spawns.size()));
|
||||
for (L2PcInstance temp : _playerB.getParty().getMembers())
|
||||
{
|
||||
temp.teleToLocation(new Location((x + offset) - 180, y + 150, z));
|
||||
offset += 40;
|
||||
temp.teleToLocation(spawn2.getX(), spawn2.getY(), spawn2.getZ(), 0, _duelInstanceId, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,7 +747,7 @@ public class Duel
|
||||
}
|
||||
|
||||
/**
|
||||
* Playback the bow animation for all loosers
|
||||
* Playback the bow animation for all looser
|
||||
*/
|
||||
public void playKneelAnimation()
|
||||
{
|
||||
@@ -794,17 +877,7 @@ public class Duel
|
||||
break;
|
||||
}
|
||||
|
||||
// Send end duel packet
|
||||
ExDuelEnd duelEnd = null;
|
||||
if (_partyDuel)
|
||||
{
|
||||
duelEnd = new ExDuelEnd(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
duelEnd = new ExDuelEnd(0);
|
||||
}
|
||||
|
||||
final ExDuelEnd duelEnd = _partyDuel ? ExDuelEnd.PARTY_DUEL : ExDuelEnd.PLAYER_DUEL;
|
||||
broadcastToTeam1(duelEnd);
|
||||
broadcastToTeam2(duelEnd);
|
||||
|
||||
@@ -1014,7 +1087,7 @@ public class Duel
|
||||
// if he's either playerA or playerB cancel the duel and port the players back
|
||||
if ((player == _playerA) || (player == _playerB))
|
||||
{
|
||||
for (PlayerCondition cond : _playerConditions)
|
||||
for (PlayerCondition cond : _playerConditions.values())
|
||||
{
|
||||
cond.teleportBack();
|
||||
cond.getPlayer().setIsInDuel(0);
|
||||
@@ -1026,7 +1099,7 @@ public class Duel
|
||||
else
|
||||
// teleport the player back & delete his PlayerCondition record
|
||||
{
|
||||
final PlayerCondition cond = _playerConditions.stream().filter(c -> c.getPlayer() == player).findFirst().orElse(null);
|
||||
final PlayerCondition cond = _playerConditions.get(player.getObjectId());
|
||||
if (cond != null)
|
||||
{
|
||||
cond.teleportBack();
|
||||
@@ -1038,7 +1111,7 @@ public class Duel
|
||||
|
||||
public void onBuff(L2PcInstance player, Skill debuff)
|
||||
{
|
||||
final PlayerCondition cond = _playerConditions.stream().filter(c -> c.getPlayer() == player).findFirst().orElse(null);
|
||||
final PlayerCondition cond = _playerConditions.get(player.getObjectId());
|
||||
if (cond != null)
|
||||
{
|
||||
cond.registerDebuff(debuff);
|
||||
|
||||
Reference in New Issue
Block a user