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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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