Since this is a a pretty strong self-buff (like frenzy, ultimate defense) monsters shouldn't cast it immediatly (or multiple times) during a fight.
scripts/group_template/NpcUltimateEvasion.java
npcskills.sql
scripts/group_template/NpcUltimateEvasion.java
- Code:
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ai.group_template;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.util.Util;
import net.sf.l2j.util.Rnd;
/**
* NpcUltimateEvasion behavior on low health.
* By Karakan for L2JLisvus
*/
public class NpcUltimateEvasion extends Quest
{
public static void main(String[] args)
{
// Quest class
new NpcUltimateEvasion();
}
public NpcUltimateEvasion()
{
super(-1, "npcultimateevasion", "ai/group_template");
int[] mobs =
{
808, // Nos Lad
936, // Tanor Silenos
1524, // Blade of Splendor
1525, // Blade of Splendor
1531, // Punishment of Splendor
1539, // Wailing of Splendor
1540, // Wailing of Splendor
1658 // Punishment of Splendor
};
for (int id : mobs)
{
registerNPC(id);
}
}
@Override
public String onSpawn(L2NpcInstance npc)
{
if (npc.getScriptValue() > 0)
{
npc.setScriptValue(0);
}
return super.onSpawn(npc);
}
@Override
public String onAttack(L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
{
if (npc.getCurrentHp() / npc.getMaxHp() < 0.2 && Rnd.get(100) < 30 && npc.getScriptValue() == 0) // 20% Hp - 30% Chance
{
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
npc.setTarget(npc);
npc.doCast(SkillTable.getInstance().getInfo(4103,2));
npc.setScriptValue(1);
}
return super.onAttack(npc, attacker, damage, isPet);
}
@Override
public String onSkillSee(L2NpcInstance npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
{
if (skill.isOffensive() && Util.contains(targets, npc))
{
if (npc.getCurrentHp() / npc.getMaxHp() < 0.2 && Rnd.get(100) < 30 && npc.getScriptValue() == 0) // 20% Hp - 30% Chance
{
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
npc.setTarget(npc);
npc.doCast(SkillTable.getInstance().getInfo(4103,1));
npc.setScriptValue(1);
}
}
return super.onSkillSee(npc, caster, skill, targets, isPet);
}
}
npcskills.sql
- Code:
Index: npcskills.sql
===================================================================
--- npcskills.sql (revision 727)
+++ npcskills.sql (working copy)
@@ -3175,7 +3175,6 @@
(808, 4071, 3), -- Resist Archery
(808, 4085, 1), -- Critical Power
(808, 4086, 1), -- Critical Chance
-(808, 4103, 2), -- NPC Ultimate Evasion
-- Ghost of the Tower
(809, 4290, 1), -- Race
(809, 4304, 1), -- Strong Type
@@ -3913,7 +3912,6 @@
-- Tanor Silenos
(936, 4295, 1), -- Race
(936, 4311, 1), -- Feeble Type
-(936, 4103, 2), -- NPC Ultimate Evasion
-- Tanor Silenos Grunt
(937, 4295, 1), -- Race
(937, 4311, 1), -- Feeble Type
@@ -7952,7 +7950,6 @@
(1524, 4085, 1), -- Critical Power
(1524, 4086, 1), -- Critical Chance
(1524, 4641, 6), -- NPC Super Strike
-(1524, 4103, 2), -- NPC Ultimate Evasion
(1524, 4671, 1), -- AV - Teleport
-- Blade of Splendor
(1525, 4297, 1), -- Race
@@ -7959,7 +7956,6 @@
(1525, 4085, 1), -- Critical Power
(1525, 4086, 1), -- Critical Chance
(1525, 4641, 6), -- NPC Super Strike
-(1525, 4103, 2), -- NPC Ultimate Evasion
(1525, 4671, 1), -- AV - Teleport
-- Wisdom of Splendor
(1526, 4297, 1), -- Race
@@ -8001,7 +7997,6 @@
(1531, 4085, 1), -- Critical Power
(1531, 4086, 1), -- Critical Chance
(1531, 4641, 6), -- NPC Super Strike
-(1531, 4103, 2), -- NPC Ultimate Evasion
(1531, 4671, 1), -- AV - Teleport
-- Shout of Splendor
(1532, 4297, 1), -- Race
@@ -8059,7 +8054,6 @@
(1539, 4085, 1), -- Critical Power
(1539, 4086, 1), -- Critical Chance
(1539, 4641, 6), -- NPC Super Strike
-(1539, 4103, 2), -- NPC Ultimate Evasion
(1539, 4671, 1), -- AV - Teleport
-- Wailing of Splendor
(1540, 4297, 1), -- Race
@@ -8066,7 +8060,6 @@
(1540, 4085, 1), -- Critical Power
(1540, 4086, 1), -- Critical Chance
(1540, 4641, 6), -- NPC Super Strike
-(1540, 4103, 2), -- NPC Ultimate Evasion
(1540, 4671, 1), -- AV - Teleport
-- Pilgrim of Splendor
(1541, 4297, 1), -- Race
@@ -8972,7 +8965,6 @@
(1658, 4085, 1), -- Critical Power
(1658, 4086, 1), -- Critical Chance
(1658, 4641, 6), -- NPC Super Strike
-(1658, 4103, 2), -- NPC Ultimate Evasion
(1658, 4671, 1), -- AV - Teleport
-- Otherworldly Invader Soldier
(1659, 4290, 1), -- Race