Sync with L2jServer HighFive Oct 2nd 2015.

This commit is contained in:
MobiusDev
2015-10-03 13:41:08 +00:00
parent c90d8eb135
commit 7259087da5
18 changed files with 469 additions and 602 deletions

View File

@@ -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.
*/

View File

@@ -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();
}
/**

View File

@@ -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);
}

View File

@@ -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)
{

View File

@@ -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()