Replaced instanceof L2Attackable with isAttackable method.

This commit is contained in:
MobiusDev
2018-07-02 00:55:13 +00:00
parent 6c1d37f4ae
commit 0b09d49f8d
51 changed files with 73 additions and 86 deletions

View File

@ -270,7 +270,7 @@ public class L2AttackableAI extends L2CharacterAI
}
else
{
if (target instanceof L2Attackable)
if (target.isAttackable())
{
if (!target.isAutoAttackable(me))
{
@ -288,7 +288,7 @@ public class L2AttackableAI extends L2CharacterAI
}
}
if ((target instanceof L2Attackable) || (target instanceof L2Npc))
if (target.isAttackable() || (target instanceof L2Npc))
{
return false;
}
@ -854,7 +854,7 @@ public class L2AttackableAI extends L2CharacterAI
called.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, originalAttackTarget, 1);
EventDispatcher.getInstance().notifyEventAsync(new OnAttackableFactionCall(called, getActiveChar(), originalAttackTarget.getActingPlayer(), originalAttackTarget.isSummon()), called);
}
else if ((called instanceof L2Attackable) && (getAttackTarget() != null) && (called.getAI()._intention != AI_INTENTION_ATTACK))
else if (called.isAttackable() && (getAttackTarget() != null) && (called.getAI()._intention != AI_INTENTION_ATTACK))
{
((L2Attackable) called).addDamageHate(getAttackTarget(), 0, npc.getHating(getAttackTarget()));
called.getAI().setIntention(AI_INTENTION_ATTACK, getAttackTarget());
@ -2079,7 +2079,7 @@ public class L2AttackableAI extends L2CharacterAI
{
return obj;
}
if ((obj instanceof L2Attackable) && actor.isChaos())
if (obj.isAttackable() && actor.isChaos())
{
if (!((L2Attackable) obj).isInMyClan(actor))
{
@ -2149,7 +2149,7 @@ public class L2AttackableAI extends L2CharacterAI
actor.setTarget(obj);
setAttackTarget(obj);
}
else if (obj instanceof L2Attackable)
else if (obj.isAttackable())
{
if (actor.isChaos())
{
@ -2222,7 +2222,7 @@ public class L2AttackableAI extends L2CharacterAI
actor.setTarget(obj);
setAttackTarget(obj);
}
else if (obj instanceof L2Attackable)
else if (obj.isAttackable())
{
if (actor.isChaos())
{

View File

@ -136,7 +136,7 @@ public class L2CharacterAI extends AbstractAI
@Override
protected void onEvtAttacked(L2Character attacker)
{
if ((attacker instanceof L2Attackable) && !attacker.isCoreAIDisabled())
if ((attacker != null) && attacker.isAttackable() && !attacker.isCoreAIDisabled())
{
clientStartAutoAttack();
}
@ -204,7 +204,7 @@ public class L2CharacterAI extends AbstractAI
// Also enable random animations for this L2Character if allowed
// This is only for mobs - town npcs are handled in their constructor
if (_actor instanceof L2Attackable)
if (_actor.isAttackable())
{
((L2Npc) _actor).startRandomAnimationTask();
}
@ -672,7 +672,7 @@ public class L2CharacterAI extends AbstractAI
return;
}
if (_actor instanceof L2Attackable)
if (_actor.isAttackable())
{
((L2Attackable) _actor).setisReturningToSpawnPoint(false);
}
@ -1424,7 +1424,7 @@ public class L2CharacterAI extends AbstractAI
boolean cancast = true;
for (L2Character target : L2World.getInstance().getVisibleObjects(_actor, L2Character.class, sk.getAffectRange()))
{
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || ((target instanceof L2Attackable) && !((L2Npc) _actor).isChaos()))
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || (target.isAttackable() && !((L2Npc) _actor).isChaos()))
{
continue;
}
@ -1443,7 +1443,7 @@ public class L2CharacterAI extends AbstractAI
boolean cancast = true;
for (L2Character target : L2World.getInstance().getVisibleObjects(getAttackTarget(), L2Character.class, sk.getAffectRange()))
{
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || (target == null) || ((target instanceof L2Attackable) && !((L2Npc) _actor).isChaos()))
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || (target == null) || (target.isAttackable() && !((L2Npc) _actor).isChaos()))
{
continue;
}
@ -1463,7 +1463,7 @@ public class L2CharacterAI extends AbstractAI
boolean cancast = false;
for (L2Character target : L2World.getInstance().getVisibleObjects(_actor, L2Character.class, sk.getAffectRange()))
{
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || ((target instanceof L2Attackable) && !((L2Npc) _actor).isChaos()))
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || (target.isAttackable() && !((L2Npc) _actor).isChaos()))
{
continue;
}
@ -1482,7 +1482,7 @@ public class L2CharacterAI extends AbstractAI
boolean cancast = true;
for (L2Character target : L2World.getInstance().getVisibleObjects(getAttackTarget(), L2Character.class, sk.getAffectRange()))
{
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || ((target instanceof L2Attackable) && !((L2Npc) _actor).isChaos()))
if (!GeoEngine.getInstance().canSeeTarget(_actor, target) || (target.isAttackable() && !((L2Npc) _actor).isChaos()))
{
continue;
}

View File

@ -559,7 +559,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
npc.setHeading(_location.getHeading());
}
if (npc instanceof L2Attackable)
if (npc.isAttackable())
{
((L2Attackable) npc).setChampion(false);
}

View File

@ -88,7 +88,7 @@ public final class L2WorldRegion
{
for (L2Object o : _visibleObjects.values())
{
if (o instanceof L2Attackable)
if (o.isAttackable())
{
c++;
final L2Attackable mob = (L2Attackable) o;
@ -123,7 +123,7 @@ public final class L2WorldRegion
{
for (L2Object o : _visibleObjects.values())
{
if (o instanceof L2Attackable)
if (o.isAttackable())
{
c++;
// Start HP/MP/CP Regeneration task

View File

@ -13789,7 +13789,7 @@ public final class L2PcInstance extends L2Playable
{
return false;
}
if (cha instanceof L2Attackable)
if (cha.isAttackable())
{
return true;
}

View File

@ -17,7 +17,6 @@
package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.model.events.EventDispatcher;
@ -49,7 +48,7 @@ public final class L2QuestGuardInstance extends L2GuardInstance
{
super.addDamage(attacker, damage, skill);
if (attacker instanceof L2Attackable)
if (attacker.isAttackable())
{
EventDispatcher.getInstance().notifyEventAsync(new OnAttackableAttack(null, this, damage, skill, false), this);
}
@ -64,7 +63,7 @@ public final class L2QuestGuardInstance extends L2GuardInstance
return false;
}
if (killer instanceof L2Attackable)
if (killer.isAttackable())
{
// Delayed notification
EventDispatcher.getInstance().notifyEventAsyncDelayed(new OnAttackableKill(null, this, false), this, _onKillDelay);

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.enums.TrapAction;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.tasks.npc.trap.TrapTask;
@ -210,7 +209,7 @@ public final class L2TrapInstance extends L2Npc
// trap owned by players not attack non-flagged players
if (_owner != null)
{
if (target instanceof L2Attackable)
if (target.isAttackable())
{
return true;
}

View File

@ -61,7 +61,7 @@ public class ConditionPlayerCanSweep extends Condition
L2Attackable target;
for (L2Object objTarget : targets)
{
if (objTarget instanceof L2Attackable)
if ((objTarget != null) && objTarget.isAttackable())
{
target = (L2Attackable) objTarget;
if (target.isDead())

View File

@ -2726,7 +2726,7 @@ public abstract class AbstractScript extends ManagedScript
*/
protected void addAttackDesire(L2Npc npc, L2Character target, int desire)
{
if (npc instanceof L2Attackable)
if (npc.isAttackable())
{
((L2Attackable) npc).addDamageHate(target, 0, desire);
}
@ -2790,7 +2790,7 @@ public abstract class AbstractScript extends ManagedScript
*/
protected void addSkillCastDesire(L2Npc npc, L2Character target, Skill skill, int desire)
{
if (npc instanceof L2Attackable)
if (npc.isAttackable())
{
((L2Attackable) npc).addDamageHate(target, 0, desire);
}

View File

@ -438,7 +438,7 @@ public final class Instance
spawnDat.setInstanceId(_id);
spawnDat.setRandomWalking(set.getBoolean("allowRandomWalk"));
final L2Npc spawned = spawnDat.doSpawn();
if ((set.getInt("delay") >= 0) && (spawned instanceof L2Attackable))
if ((set.getInt("delay") >= 0) && spawned.isAttackable())
{
((L2Attackable) spawned).setOnKillDelay(set.getInt("delay"));
}

View File

@ -43,7 +43,6 @@ import com.l2jmobius.gameserver.model.L2ExtractableSkill;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2BlockInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2CubicInstance;
@ -1210,7 +1209,7 @@ public final class Skill implements IIdentifiable
else
{
// target is mob
if ((targetPlayer == null) && (target instanceof L2Attackable) && (caster instanceof L2Attackable))
if ((targetPlayer == null) && target.isAttackable() && caster.isAttackable())
{
return false;
}
@ -1253,7 +1252,7 @@ public final class Skill implements IIdentifiable
return Collections.<AbstractFunction> emptyList();
}
if (!player.isPlayable() && !(player instanceof L2Attackable))
if (!player.isPlayable() && !player.isAttackable())
{
return Collections.<AbstractFunction> emptyList();
}

View File

@ -32,7 +32,6 @@ import com.l2jmobius.gameserver.instancemanager.FortManager;
import com.l2jmobius.gameserver.instancemanager.SiegeManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2SiegeClan;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2CubicInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -590,7 +589,7 @@ public final class Formulas
final double weaponMod = attacker.getRandomDamageMultiplier();
double penaltyMod = 1;
if ((target instanceof L2Attackable) && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_DMG_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 2))
if (target.isAttackable() && !target.isRaid() && !target.isRaidMinion() && (target.getLevel() >= Config.MIN_NPC_LVL_DMG_PENALTY) && (attacker.getActingPlayer() != null) && ((target.getLevel() - attacker.getActingPlayer().getLevel()) >= 2))
{
final int lvlDiff = target.getLevel() - attacker.getActingPlayer().getLevel() - 1;
if (lvlDiff >= Config.NPC_SKILL_DMG_PENALTY.size())