Fixed training soldier AI.

This commit is contained in:
MobiusDev
2018-08-30 18:53:14 +00:00
parent d9a076ccd7
commit 2dbfdef0a8
9 changed files with 74 additions and 111 deletions

View File

@@ -16,9 +16,7 @@
*/ */
package ai.areas.TalkingIsland; package ai.areas.TalkingIsland;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -26,7 +24,7 @@ import ai.AbstractNpcAI;
/** /**
* Trainning Soldier AI. * Trainning Soldier AI.
* @author St3eT * @author Mobius
*/ */
public final class TrainningSoldier extends AbstractNpcAI public final class TrainningSoldier extends AbstractNpcAI
{ {
@@ -36,42 +34,36 @@ public final class TrainningSoldier extends AbstractNpcAI
private TrainningSoldier() private TrainningSoldier()
{ {
addSeeCreatureId(SOLDIER); addSpawnId(SOLDIER);
} }
@Override @Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{ {
if (event.equals("START_ATTACK")) if ((npc != null) && !npc.isDead())
{ {
//@formatter:off if (!npc.isInCombat())
final L2Npc dummy = L2World.getInstance().getVisibleObjects(npc, L2Npc.class, 150)
.stream()
.filter(obj -> (obj.getId() == DUMMY))
.findFirst()
.orElse(null);
//@formatter:on
if (dummy != null)
{ {
addAttackDesire(npc, dummy); for (L2Npc nearby : L2World.getInstance().getVisibleObjects(npc, L2Npc.class, 150))
} {
else if ((nearby != null) && (nearby.getId() == DUMMY))
{ {
startQuestTimer("START_ATTACK", 250, npc, null); addAttackDesire(npc, nearby);
break;
}
}
} }
startQuestTimer("START_ATTACK", 10000, npc, null);
} }
return super.onAdvEvent(event, npc, player); return super.onAdvEvent(event, npc, player);
} }
@Override @Override
public String onSeeCreature(L2Npc npc, L2Character creature, boolean isSummon) public String onSpawn(L2Npc npc)
{ {
if (creature.isPlayer() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK)) npc.setRandomAnimation(false);
{ startQuestTimer("START_ATTACK", 5000, npc, null);
startQuestTimer("START_ATTACK", 250, npc, null); return super.onSpawn(npc);
}
return super.onSeeCreature(npc, creature, isSummon);
} }
public static void main(String[] args) public static void main(String[] args)

View File

@@ -780,7 +780,7 @@
</attribute> </attribute>
<abnormalResist physical="10" magical="10" /> <abnormalResist physical="10" magical="10" />
</stats> </stats>
<status attackable="false" talkable="false" targetable="false" /> <status talkable="false" />
<skill_list> <skill_list>
<skill id="4416" level="19" /> <!-- Others --> <skill id="4416" level="19" /> <!-- Others -->
<skill id="4390" level="1" /> <!-- NPC Abnormal Immunity --> <skill id="4390" level="1" /> <!-- NPC Abnormal Immunity -->

View File

@@ -1171,13 +1171,8 @@ public class L2AttackableAI extends L2CharacterAI
@Override @Override
protected void onEvtThink() protected void onEvtThink()
{ {
// Check if the actor can't use skills // Check if the actor can't use skills and if a thinking action isn't already in progress
if (getActiveChar().isAllSkillsDisabled()) if (_thinking || getActiveChar().isAllSkillsDisabled())
{
return;
}
// Check if a thinking action isn't already in progress
if (_thinking)
{ {
return; return;
} }

View File

@@ -16,9 +16,7 @@
*/ */
package ai.areas.TalkingIsland; package ai.areas.TalkingIsland;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -26,7 +24,7 @@ import ai.AbstractNpcAI;
/** /**
* Trainning Soldier AI. * Trainning Soldier AI.
* @author St3eT * @author Mobius
*/ */
public final class TrainningSoldier extends AbstractNpcAI public final class TrainningSoldier extends AbstractNpcAI
{ {
@@ -36,42 +34,36 @@ public final class TrainningSoldier extends AbstractNpcAI
private TrainningSoldier() private TrainningSoldier()
{ {
addSeeCreatureId(SOLDIER); addSpawnId(SOLDIER);
} }
@Override @Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{ {
if (event.equals("START_ATTACK")) if ((npc != null) && !npc.isDead())
{ {
//@formatter:off if (!npc.isInCombat())
final L2Npc dummy = L2World.getInstance().getVisibleObjects(npc, L2Npc.class, 150)
.stream()
.filter(obj -> (obj.getId() == DUMMY))
.findFirst()
.orElse(null);
//@formatter:on
if (dummy != null)
{ {
addAttackDesire(npc, dummy); for (L2Npc nearby : L2World.getInstance().getVisibleObjects(npc, L2Npc.class, 150))
} {
else if ((nearby != null) && (nearby.getId() == DUMMY))
{ {
startQuestTimer("START_ATTACK", 250, npc, null); addAttackDesire(npc, nearby);
break;
}
}
} }
startQuestTimer("START_ATTACK", 10000, npc, null);
} }
return super.onAdvEvent(event, npc, player); return super.onAdvEvent(event, npc, player);
} }
@Override @Override
public String onSeeCreature(L2Npc npc, L2Character creature, boolean isSummon) public String onSpawn(L2Npc npc)
{ {
if (creature.isPlayer() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK)) npc.setRandomAnimation(false);
{ startQuestTimer("START_ATTACK", 5000, npc, null);
startQuestTimer("START_ATTACK", 250, npc, null); return super.onSpawn(npc);
}
return super.onSeeCreature(npc, creature, isSummon);
} }
public static void main(String[] args) public static void main(String[] args)

View File

@@ -780,7 +780,7 @@
</attribute> </attribute>
<abnormalResist physical="10" magical="10" /> <abnormalResist physical="10" magical="10" />
</stats> </stats>
<status attackable="false" talkable="false" targetable="false" /> <status talkable="false" />
<skill_list> <skill_list>
<skill id="4416" level="19" /> <!-- Others --> <skill id="4416" level="19" /> <!-- Others -->
<skill id="4390" level="1" /> <!-- NPC Abnormal Immunity --> <skill id="4390" level="1" /> <!-- NPC Abnormal Immunity -->

View File

@@ -16,9 +16,7 @@
*/ */
package ai.areas.TalkingIsland; package ai.areas.TalkingIsland;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -26,7 +24,7 @@ import ai.AbstractNpcAI;
/** /**
* Trainning Soldier AI. * Trainning Soldier AI.
* @author St3eT * @author Mobius
*/ */
public final class TrainningSoldier extends AbstractNpcAI public final class TrainningSoldier extends AbstractNpcAI
{ {
@@ -36,42 +34,36 @@ public final class TrainningSoldier extends AbstractNpcAI
private TrainningSoldier() private TrainningSoldier()
{ {
addSeeCreatureId(SOLDIER); addSpawnId(SOLDIER);
} }
@Override @Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{ {
if (event.equals("START_ATTACK")) if ((npc != null) && !npc.isDead())
{ {
//@formatter:off if (!npc.isInCombat())
final L2Npc dummy = L2World.getInstance().getVisibleObjects(npc, L2Npc.class, 150)
.stream()
.filter(obj -> (obj.getId() == DUMMY))
.findFirst()
.orElse(null);
//@formatter:on
if (dummy != null)
{ {
addAttackDesire(npc, dummy); for (L2Npc nearby : L2World.getInstance().getVisibleObjects(npc, L2Npc.class, 150))
} {
else if ((nearby != null) && (nearby.getId() == DUMMY))
{ {
startQuestTimer("START_ATTACK", 250, npc, null); addAttackDesire(npc, nearby);
break;
}
}
} }
startQuestTimer("START_ATTACK", 10000, npc, null);
} }
return super.onAdvEvent(event, npc, player); return super.onAdvEvent(event, npc, player);
} }
@Override @Override
public String onSeeCreature(L2Npc npc, L2Character creature, boolean isSummon) public String onSpawn(L2Npc npc)
{ {
if (creature.isPlayer() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK)) npc.setRandomAnimation(false);
{ startQuestTimer("START_ATTACK", 5000, npc, null);
startQuestTimer("START_ATTACK", 250, npc, null); return super.onSpawn(npc);
}
return super.onSeeCreature(npc, creature, isSummon);
} }
public static void main(String[] args) public static void main(String[] args)

View File

@@ -780,7 +780,7 @@
</attribute> </attribute>
<abnormalResist physical="10" magical="10" /> <abnormalResist physical="10" magical="10" />
</stats> </stats>
<status attackable="false" talkable="false" targetable="false" /> <status talkable="false" />
<skill_list> <skill_list>
<skill id="4416" level="19" /> <!-- Others --> <skill id="4416" level="19" /> <!-- Others -->
<skill id="4390" level="1" /> <!-- NPC Abnormal Immunity --> <skill id="4390" level="1" /> <!-- NPC Abnormal Immunity -->

View File

@@ -16,9 +16,7 @@
*/ */
package ai.areas.TalkingIsland; package ai.areas.TalkingIsland;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -26,7 +24,7 @@ import ai.AbstractNpcAI;
/** /**
* Trainning Soldier AI. * Trainning Soldier AI.
* @author St3eT * @author Mobius
*/ */
public final class TrainningSoldier extends AbstractNpcAI public final class TrainningSoldier extends AbstractNpcAI
{ {
@@ -36,42 +34,36 @@ public final class TrainningSoldier extends AbstractNpcAI
private TrainningSoldier() private TrainningSoldier()
{ {
addSeeCreatureId(SOLDIER); addSpawnId(SOLDIER);
} }
@Override @Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{ {
if (event.equals("START_ATTACK")) if ((npc != null) && !npc.isDead())
{ {
//@formatter:off if (!npc.isInCombat())
final L2Npc dummy = L2World.getInstance().getVisibleObjects(npc, L2Npc.class, 150)
.stream()
.filter(obj -> (obj.getId() == DUMMY))
.findFirst()
.orElse(null);
//@formatter:on
if (dummy != null)
{ {
addAttackDesire(npc, dummy); for (L2Npc nearby : L2World.getInstance().getVisibleObjects(npc, L2Npc.class, 150))
} {
else if ((nearby != null) && (nearby.getId() == DUMMY))
{ {
startQuestTimer("START_ATTACK", 250, npc, null); addAttackDesire(npc, nearby);
break;
}
}
} }
startQuestTimer("START_ATTACK", 10000, npc, null);
} }
return super.onAdvEvent(event, npc, player); return super.onAdvEvent(event, npc, player);
} }
@Override @Override
public String onSeeCreature(L2Npc npc, L2Character creature, boolean isSummon) public String onSpawn(L2Npc npc)
{ {
if (creature.isPlayer() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK)) npc.setRandomAnimation(false);
{ startQuestTimer("START_ATTACK", 5000, npc, null);
startQuestTimer("START_ATTACK", 250, npc, null); return super.onSpawn(npc);
}
return super.onSeeCreature(npc, creature, isSummon);
} }
public static void main(String[] args) public static void main(String[] args)

View File

@@ -780,7 +780,7 @@
</attribute> </attribute>
<abnormalResist physical="10" magical="10" /> <abnormalResist physical="10" magical="10" />
</stats> </stats>
<status attackable="false" talkable="false" targetable="false" /> <status talkable="false" />
<skill_list> <skill_list>
<skill id="4416" level="19" /> <!-- Others --> <skill id="4416" level="19" /> <!-- Others -->
<skill id="4390" level="1" /> <!-- NPC Abnormal Immunity --> <skill id="4390" level="1" /> <!-- NPC Abnormal Immunity -->