Подскажите пожалуйста, бьются фракция 1 и фракция 2, гуард например фракции 1, но после того как бой заканчивается гварды переагриваются на свою фракцию.
Вот код:
[SRC="java"]package l2ft.gameserver.model.instances;
import l2ft.gameserver.ai.CtrlIntention;
import l2ft.gameserver.model.Creature;
import l2ft.gameserver.model.Player;
import l2ft.gameserver.model.Skill;
import l2ft.gameserver.network.l2.s2c.MyTargetSelected;
import l2ft.gameserver.network.l2.s2c.StaticObject;
import l2ft.gameserver.network.l2.s2c.ValidateLocation;
import l2ft.gameserver.scripts.Events;
import l2ft.gameserver.templates.npc.NpcTemplate;
public class GuardInstance extends NpcInstance
{
public GuardInstance(int objectId, NpcTemplate template)
{
super(objectId, template);
}
@Override
public boolean isAutoAttackable(Creature attacker)
{
return attacker.getFactionId() != this.getFactionId();
}
@Override
public boolean isAttackable(Creature attacker)
{
return attacker.getPlayer().getFactionId() != this.getFactionId();
}
@Override
public void onAction(Player player, boolean shift)
{
if(Events.onAction(player, this, shift))
return;
if(this != player.getTarget())
{
player.setTarget(this);
player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel()));
player.sendPacket(new ValidateLocation(this));
}
else
{
player.sendPacket(new MyTargetSelected(getObjectId(), 0));
if(isAutoAttackable(player))
{
player.getAI().Attack(this, false, shift);
return;
}
if(!isInRange(player, INTERACTION_DISTANCE))
{
if(player.getAI().getIntention() != CtrlIntention.AI_INTENTION_INTERACT)
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this, null);
return;
}
}
}
@Override
public String getHtmlPath(int npcId, int val, Player player)
{
String pom;
if(val == 0)
pom = "" + npcId;
else
pom = npcId + "-" + val;
return "guard/" + pom + ".htm";
}
@Override
public boolean isInvul()
{
return false;
}
@Override
public boolean isFearImmune()
{
return true;
}
@Override
public boolean isHealBlocked()
{
return true;
}
@Override
public boolean isParalyzeImmune()
{
return true;
}
@Override
protected void onReduceCurrentHp(double damage, Creature attacker, Skill skill, boolean awake, boolean standUp, boolean directHp)
{
getAggroList().addDamageHate(attacker, (int)damage, 0);
super.onReduceCurrentHp(damage, attacker, skill, awake, standUp, directHp);
}
}[/SRC]
Добавлено через 1 час 30 минут
Вылетает вот такое НПЕ, когда гвард бьет своего:
[SRC="java"][20:30:32] ERROR Exception: RunnableImpl.run(): java.lang.NullPointerException
java.lang.NullPointerException
at l2ft.gameserver.model.instances.GuardInstance.isAttackable(GuardInstance.java:29)
at l2ft.gameserver.model.Skill.checkTarget(Skill.java:1110)
at l2ft.gameserver.model.Skill.addTargetsToList(Skill.java:1406)
at l2ft.gameserver.model.Skill.getTargets(Skill.java:1252)
at l2ft.gameserver.model.Creature.onMagicUseTimer(Creature.java:3045)
at l2ft.gameserver.model.GameObjectTasks$MagicUseTask.runImpl(GameObjectTasks.java:350)
at l2ft.commons.threading.RunnableImpl.run(RunnableImpl.java:21)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)[/SRC]
Добавлено через 11 часов 43 минуты
1110 строка:
[SRC="java"]if(!target.isAttackable(activeChar))
return SystemMsg.INVALID_TARGET;[/SRC]
Вот код:
[SRC="java"]package l2ft.gameserver.model.instances;
import l2ft.gameserver.ai.CtrlIntention;
import l2ft.gameserver.model.Creature;
import l2ft.gameserver.model.Player;
import l2ft.gameserver.model.Skill;
import l2ft.gameserver.network.l2.s2c.MyTargetSelected;
import l2ft.gameserver.network.l2.s2c.StaticObject;
import l2ft.gameserver.network.l2.s2c.ValidateLocation;
import l2ft.gameserver.scripts.Events;
import l2ft.gameserver.templates.npc.NpcTemplate;
public class GuardInstance extends NpcInstance
{
public GuardInstance(int objectId, NpcTemplate template)
{
super(objectId, template);
}
@Override
public boolean isAutoAttackable(Creature attacker)
{
return attacker.getFactionId() != this.getFactionId();
}
@Override
public boolean isAttackable(Creature attacker)
{
return attacker.getPlayer().getFactionId() != this.getFactionId();
}
@Override
public void onAction(Player player, boolean shift)
{
if(Events.onAction(player, this, shift))
return;
if(this != player.getTarget())
{
player.setTarget(this);
player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel()));
player.sendPacket(new ValidateLocation(this));
}
else
{
player.sendPacket(new MyTargetSelected(getObjectId(), 0));
if(isAutoAttackable(player))
{
player.getAI().Attack(this, false, shift);
return;
}
if(!isInRange(player, INTERACTION_DISTANCE))
{
if(player.getAI().getIntention() != CtrlIntention.AI_INTENTION_INTERACT)
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this, null);
return;
}
}
}
@Override
public String getHtmlPath(int npcId, int val, Player player)
{
String pom;
if(val == 0)
pom = "" + npcId;
else
pom = npcId + "-" + val;
return "guard/" + pom + ".htm";
}
@Override
public boolean isInvul()
{
return false;
}
@Override
public boolean isFearImmune()
{
return true;
}
@Override
public boolean isHealBlocked()
{
return true;
}
@Override
public boolean isParalyzeImmune()
{
return true;
}
@Override
protected void onReduceCurrentHp(double damage, Creature attacker, Skill skill, boolean awake, boolean standUp, boolean directHp)
{
getAggroList().addDamageHate(attacker, (int)damage, 0);
super.onReduceCurrentHp(damage, attacker, skill, awake, standUp, directHp);
}
}[/SRC]
Добавлено через 1 час 30 минут
Вылетает вот такое НПЕ, когда гвард бьет своего:
[SRC="java"][20:30:32] ERROR Exception: RunnableImpl.run(): java.lang.NullPointerException
java.lang.NullPointerException
at l2ft.gameserver.model.instances.GuardInstance.isAttackable(GuardInstance.java:29)
at l2ft.gameserver.model.Skill.checkTarget(Skill.java:1110)
at l2ft.gameserver.model.Skill.addTargetsToList(Skill.java:1406)
at l2ft.gameserver.model.Skill.getTargets(Skill.java:1252)
at l2ft.gameserver.model.Creature.onMagicUseTimer(Creature.java:3045)
at l2ft.gameserver.model.GameObjectTasks$MagicUseTask.runImpl(GameObjectTasks.java:350)
at l2ft.commons.threading.RunnableImpl.run(RunnableImpl.java:21)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)[/SRC]
Добавлено через 11 часов 43 минуты
1110 строка:
[SRC="java"]if(!target.isAttackable(activeChar))
return SystemMsg.INVALID_TARGET;[/SRC]