From f208218b7c22c98ae0a8935306ae76527b5babfb Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Mon, 4 Dec 2017 11:06:31 +0000 Subject: [PATCH] Siege guards AI improvement. --- .../data/scripts/ai/others/SiegeGuards.java | 29 +++++++++---------- .../data/scripts/ai/others/SiegeGuards.java | 29 +++++++++---------- .../data/scripts/ai/others/SiegeGuards.java | 29 +++++++++---------- .../data/scripts/ai/others/SiegeGuards.java | 29 +++++++++---------- .../data/scripts/ai/others/SiegeGuards.java | 29 +++++++++---------- 5 files changed, 65 insertions(+), 80 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/SiegeGuards.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/SiegeGuards.java index 0ff34a2580..b14c124bd3 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/SiegeGuards.java +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/SiegeGuards.java @@ -100,32 +100,29 @@ public class SiegeGuards extends AbstractNpcAI @Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { - if (event.equals("AGGRO_CHECK")) + if ((npc != null) && !npc.isDead()) { - if ((npc != null) && !npc.isDead()) + final L2Object target = npc.getTarget(); + if (!npc.isInCombat() || (target == null) || (npc.calculateDistance(target, false, false) > npc.getAggroRange()) || target.isInvul()) { - final L2Object target = npc.getTarget(); - if (!npc.isInCombat() || (target == null) || (npc.calculateDistance(target, false, false) > npc.getAggroRange()) || target.isInvul()) + for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange())) { - for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange())) + if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby)) { - if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby)) + final L2Summon summon = nearby.isSummon() ? (L2Summon) nearby : null; + final L2PcInstance pl = summon == null ? (L2PcInstance) nearby : summon.getOwner(); + if (((pl.getSiegeState() != 2) || pl.isRegisteredOnThisSiegeField(npc.getScriptValue())) && ((pl.getSiegeState() != 0) || (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE))) { - final L2Summon summon = nearby.isSummon() ? (L2Summon) nearby : null; - final L2PcInstance pl = summon == null ? (L2PcInstance) nearby : summon.getOwner(); - if (((pl.getSiegeState() != 2) || pl.isRegisteredOnThisSiegeField(npc.getScriptValue())) && ((pl.getSiegeState() != 0) || (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE))) + if (!pl.isInvisible() && !pl.isInvul()) // skip invisible players { - if (!pl.isInvisible() && !pl.isInvul()) // skip invisible players - { - addAttackPlayerDesire(npc, pl); - break; // no need to search more - } + addAttackPlayerDesire(npc, pl); + break; // no need to search more } } } } - startQuestTimer("AGGRO_CHECK", 2000, npc, null); } + startQuestTimer("AGGRO_CHECK" + npc.getId(), 3000, npc, null); } return super.onAdvEvent(event, npc, player); } @@ -152,7 +149,7 @@ public class SiegeGuards extends AbstractNpcAI final Castle castle = npc.getCastle(); final Fort fortress = npc.getFort(); npc.setScriptValue(fortress != null ? fortress.getResidenceId() : (castle != null ? castle.getResidenceId() : 0)); - startQuestTimer("AGGRO_CHECK", 2000, npc, null); + startQuestTimer("AGGRO_CHECK" + npc.getId(), getRandom(1000, 10000), npc, null); return super.onSpawn(npc); } diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/SiegeGuards.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/SiegeGuards.java index 0ff34a2580..b14c124bd3 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/SiegeGuards.java +++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/SiegeGuards.java @@ -100,32 +100,29 @@ public class SiegeGuards extends AbstractNpcAI @Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { - if (event.equals("AGGRO_CHECK")) + if ((npc != null) && !npc.isDead()) { - if ((npc != null) && !npc.isDead()) + final L2Object target = npc.getTarget(); + if (!npc.isInCombat() || (target == null) || (npc.calculateDistance(target, false, false) > npc.getAggroRange()) || target.isInvul()) { - final L2Object target = npc.getTarget(); - if (!npc.isInCombat() || (target == null) || (npc.calculateDistance(target, false, false) > npc.getAggroRange()) || target.isInvul()) + for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange())) { - for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange())) + if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby)) { - if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby)) + final L2Summon summon = nearby.isSummon() ? (L2Summon) nearby : null; + final L2PcInstance pl = summon == null ? (L2PcInstance) nearby : summon.getOwner(); + if (((pl.getSiegeState() != 2) || pl.isRegisteredOnThisSiegeField(npc.getScriptValue())) && ((pl.getSiegeState() != 0) || (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE))) { - final L2Summon summon = nearby.isSummon() ? (L2Summon) nearby : null; - final L2PcInstance pl = summon == null ? (L2PcInstance) nearby : summon.getOwner(); - if (((pl.getSiegeState() != 2) || pl.isRegisteredOnThisSiegeField(npc.getScriptValue())) && ((pl.getSiegeState() != 0) || (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE))) + if (!pl.isInvisible() && !pl.isInvul()) // skip invisible players { - if (!pl.isInvisible() && !pl.isInvul()) // skip invisible players - { - addAttackPlayerDesire(npc, pl); - break; // no need to search more - } + addAttackPlayerDesire(npc, pl); + break; // no need to search more } } } } - startQuestTimer("AGGRO_CHECK", 2000, npc, null); } + startQuestTimer("AGGRO_CHECK" + npc.getId(), 3000, npc, null); } return super.onAdvEvent(event, npc, player); } @@ -152,7 +149,7 @@ public class SiegeGuards extends AbstractNpcAI final Castle castle = npc.getCastle(); final Fort fortress = npc.getFort(); npc.setScriptValue(fortress != null ? fortress.getResidenceId() : (castle != null ? castle.getResidenceId() : 0)); - startQuestTimer("AGGRO_CHECK", 2000, npc, null); + startQuestTimer("AGGRO_CHECK" + npc.getId(), getRandom(1000, 10000), npc, null); return super.onSpawn(npc); } diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/SiegeGuards.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/SiegeGuards.java index 0ff34a2580..b14c124bd3 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/SiegeGuards.java +++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/SiegeGuards.java @@ -100,32 +100,29 @@ public class SiegeGuards extends AbstractNpcAI @Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { - if (event.equals("AGGRO_CHECK")) + if ((npc != null) && !npc.isDead()) { - if ((npc != null) && !npc.isDead()) + final L2Object target = npc.getTarget(); + if (!npc.isInCombat() || (target == null) || (npc.calculateDistance(target, false, false) > npc.getAggroRange()) || target.isInvul()) { - final L2Object target = npc.getTarget(); - if (!npc.isInCombat() || (target == null) || (npc.calculateDistance(target, false, false) > npc.getAggroRange()) || target.isInvul()) + for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange())) { - for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange())) + if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby)) { - if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby)) + final L2Summon summon = nearby.isSummon() ? (L2Summon) nearby : null; + final L2PcInstance pl = summon == null ? (L2PcInstance) nearby : summon.getOwner(); + if (((pl.getSiegeState() != 2) || pl.isRegisteredOnThisSiegeField(npc.getScriptValue())) && ((pl.getSiegeState() != 0) || (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE))) { - final L2Summon summon = nearby.isSummon() ? (L2Summon) nearby : null; - final L2PcInstance pl = summon == null ? (L2PcInstance) nearby : summon.getOwner(); - if (((pl.getSiegeState() != 2) || pl.isRegisteredOnThisSiegeField(npc.getScriptValue())) && ((pl.getSiegeState() != 0) || (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE))) + if (!pl.isInvisible() && !pl.isInvul()) // skip invisible players { - if (!pl.isInvisible() && !pl.isInvul()) // skip invisible players - { - addAttackPlayerDesire(npc, pl); - break; // no need to search more - } + addAttackPlayerDesire(npc, pl); + break; // no need to search more } } } } - startQuestTimer("AGGRO_CHECK", 2000, npc, null); } + startQuestTimer("AGGRO_CHECK" + npc.getId(), 3000, npc, null); } return super.onAdvEvent(event, npc, player); } @@ -152,7 +149,7 @@ public class SiegeGuards extends AbstractNpcAI final Castle castle = npc.getCastle(); final Fort fortress = npc.getFort(); npc.setScriptValue(fortress != null ? fortress.getResidenceId() : (castle != null ? castle.getResidenceId() : 0)); - startQuestTimer("AGGRO_CHECK", 2000, npc, null); + startQuestTimer("AGGRO_CHECK" + npc.getId(), getRandom(1000, 10000), npc, null); return super.onSpawn(npc); } diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/SiegeGuards.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/SiegeGuards.java index 0ff34a2580..b14c124bd3 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/SiegeGuards.java +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/SiegeGuards.java @@ -100,32 +100,29 @@ public class SiegeGuards extends AbstractNpcAI @Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { - if (event.equals("AGGRO_CHECK")) + if ((npc != null) && !npc.isDead()) { - if ((npc != null) && !npc.isDead()) + final L2Object target = npc.getTarget(); + if (!npc.isInCombat() || (target == null) || (npc.calculateDistance(target, false, false) > npc.getAggroRange()) || target.isInvul()) { - final L2Object target = npc.getTarget(); - if (!npc.isInCombat() || (target == null) || (npc.calculateDistance(target, false, false) > npc.getAggroRange()) || target.isInvul()) + for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange())) { - for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange())) + if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby)) { - if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby)) + final L2Summon summon = nearby.isSummon() ? (L2Summon) nearby : null; + final L2PcInstance pl = summon == null ? (L2PcInstance) nearby : summon.getOwner(); + if (((pl.getSiegeState() != 2) || pl.isRegisteredOnThisSiegeField(npc.getScriptValue())) && ((pl.getSiegeState() != 0) || (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE))) { - final L2Summon summon = nearby.isSummon() ? (L2Summon) nearby : null; - final L2PcInstance pl = summon == null ? (L2PcInstance) nearby : summon.getOwner(); - if (((pl.getSiegeState() != 2) || pl.isRegisteredOnThisSiegeField(npc.getScriptValue())) && ((pl.getSiegeState() != 0) || (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE))) + if (!pl.isInvisible() && !pl.isInvul()) // skip invisible players { - if (!pl.isInvisible() && !pl.isInvul()) // skip invisible players - { - addAttackPlayerDesire(npc, pl); - break; // no need to search more - } + addAttackPlayerDesire(npc, pl); + break; // no need to search more } } } } - startQuestTimer("AGGRO_CHECK", 2000, npc, null); } + startQuestTimer("AGGRO_CHECK" + npc.getId(), 3000, npc, null); } return super.onAdvEvent(event, npc, player); } @@ -152,7 +149,7 @@ public class SiegeGuards extends AbstractNpcAI final Castle castle = npc.getCastle(); final Fort fortress = npc.getFort(); npc.setScriptValue(fortress != null ? fortress.getResidenceId() : (castle != null ? castle.getResidenceId() : 0)); - startQuestTimer("AGGRO_CHECK", 2000, npc, null); + startQuestTimer("AGGRO_CHECK" + npc.getId(), getRandom(1000, 10000), npc, null); return super.onSpawn(npc); } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/SiegeGuards.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/SiegeGuards.java index 2b9d377321..bbc52c5ec0 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/SiegeGuards.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/SiegeGuards.java @@ -74,32 +74,29 @@ public class SiegeGuards extends AbstractNpcAI @Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { - if (event.equals("AGGRO_CHECK")) + if ((npc != null) && !npc.isDead()) { - if ((npc != null) && !npc.isDead()) + final L2Object target = npc.getTarget(); + if (!npc.isInCombat() || (target == null) || (npc.calculateDistance(target, false, false) > npc.getAggroRange()) || target.isInvul()) { - final L2Object target = npc.getTarget(); - if (!npc.isInCombat() || (target == null) || (npc.calculateDistance(target, false, false) > npc.getAggroRange()) || target.isInvul()) + for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange())) { - for (L2Character nearby : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange())) + if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby)) { - if (nearby.isPlayable() && GeoEngine.getInstance().canSeeTarget(npc, nearby)) + final L2Summon summon = nearby.isSummon() ? (L2Summon) nearby : null; + final L2PcInstance pl = summon == null ? (L2PcInstance) nearby : summon.getOwner(); + if (((pl.getSiegeState() != 2) || pl.isRegisteredOnThisSiegeField(npc.getScriptValue())) && ((pl.getSiegeState() != 0) || (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE))) { - final L2Summon summon = nearby.isSummon() ? (L2Summon) nearby : null; - final L2PcInstance pl = summon == null ? (L2PcInstance) nearby : summon.getOwner(); - if (((pl.getSiegeState() != 2) || pl.isRegisteredOnThisSiegeField(npc.getScriptValue())) && ((pl.getSiegeState() != 0) || (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE))) + if (!pl.isInvisible() && !pl.isInvul()) // skip invisible players { - if (!pl.isInvisible() && !pl.isInvul()) // skip invisible players - { - addAttackPlayerDesire(npc, pl); - break; // no need to search more - } + addAttackPlayerDesire(npc, pl); + break; // no need to search more } } } } - startQuestTimer("AGGRO_CHECK", 2000, npc, null); } + startQuestTimer("AGGRO_CHECK" + npc.getId(), 3000, npc, null); } return super.onAdvEvent(event, npc, player); } @@ -126,7 +123,7 @@ public class SiegeGuards extends AbstractNpcAI final Castle castle = npc.getCastle(); final Fort fortress = npc.getFort(); npc.setScriptValue(fortress != null ? fortress.getResidenceId() : (castle != null ? castle.getResidenceId() : 0)); - startQuestTimer("AGGRO_CHECK", 2000, npc, null); + startQuestTimer("AGGRO_CHECK" + npc.getId(), getRandom(1000, 10000), npc, null); return super.onSpawn(npc); }