Retail like AI for Valley of Saints monsters.
To do : Find a better way to prevent spawning more then 1 mob (Blade of Splendor, Punishment of Splendor, Wailing of Splendor)
Code updated with a better implementation.
Thanks DnR for the "onDecay" tip. That helped a lot
...\ai\group_template\ValleyOfSaints.java
In case DnR decides to commit this...
Code updated with a better implementation.
Thanks DnR for the "onDecay" tip. That helped a lot
...\ai\group_template\ValleyOfSaints.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.model.L2Attackable;
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.util.Rnd;
/**
* VALLEY_OF_SAINTS_AI - By Karakan for L2JLisvus
* Blade of Splendor (1524) - 30% chance to spawn clone
* Punishment of Splendor (1531) - 30% chance to spawn clone
* Wailing of Splendor (1539) - 30% chance to spawn clone
* Claws of Splendor (1521) - 30% chance to polymorph
* Anger of Splendor (1527) - 30% chance to polymorph
* Alliance of Splendor (1533) - 30% chance to polymorph
* Fang of Splendor (1537) - 30% chance to polymorph
*/
public class ValleyOfSaints extends Quest
{
public ValleyOfSaints (int questId, String name, String descr)
{
super(questId, name, descr);
int[] mobs =
{
1524, 1531, 1539, 1521, 1527, 1533, 1537
};
registerMobs(mobs);
}
@Override
public String onSkillSee(L2NpcInstance npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
{
if (skill.isOffensive() && targets[0] == npc)
{
if (npc.getNpcId() == 1524)
{
if (npc.isScriptValue(0) && Rnd.get(10) < 3)
{
L2Attackable newNpc = (L2Attackable) addSpawn (1525, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.addDamageHate(caster, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, caster);
npc.setScriptValue(1);
}
}
else if (npc.getNpcId() == 1531)
{
if (npc.isScriptValue(0) && Rnd.get(10) < 3)
{
L2Attackable newNpc = (L2Attackable) addSpawn (1658, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.addDamageHate(caster, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, caster);
npc.setScriptValue(1);
}
}
else if (npc.getNpcId() == 1539)
{
if (npc.isScriptValue(0) && Rnd.get(10) < 3)
{
L2Attackable newNpc = (L2Attackable) addSpawn (1540, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.addDamageHate(caster, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, caster);
npc.setScriptValue(1);
}
}
else if (npc.getNpcId() == 1521)
{
if (Rnd.get(10) < 3)
{
npc.onDecay();
L2Attackable newNpc = (L2Attackable) addSpawn (1522, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.onAction(caster);
newNpc.addDamageHate(caster, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, caster);
}
}
else if (npc.getNpcId() == 1527)
{
if (Rnd.get(10) < 3)
{
npc.onDecay();
L2Attackable newNpc = (L2Attackable) addSpawn (1528, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.onAction(caster);
newNpc.addDamageHate(caster, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, caster);
}
}
else if (npc.getNpcId() == 1533)
{
if (Rnd.get(10) < 3)
{
npc.onDecay();
L2Attackable newNpc = (L2Attackable) addSpawn (1534, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.onAction(caster);
newNpc.addDamageHate(caster, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, caster);
}
}
else if (npc.getNpcId() == 1537)
{
if (Rnd.get(10) < 3)
{
npc.onDecay();
L2Attackable newNpc = (L2Attackable) addSpawn (1538, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.onAction(caster);
newNpc.addDamageHate(caster, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, caster);
}
}
}
return super.onSkillSee(npc, caster, skill, targets, isPet);
}
@Override
public String onAttack (L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
{
if (npc.getNpcId() == 1524)
{
if (npc.isScriptValue(0) && Rnd.get(10) < 3)
{
L2Attackable newNpc = (L2Attackable) addSpawn (1525, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.addDamageHate(attacker, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker);
npc.setScriptValue(1);
}
}
else if (npc.getNpcId() == 1531)
{
if (npc.isScriptValue(0) && Rnd.get(10) < 3)
{
L2Attackable newNpc = (L2Attackable) addSpawn (1658, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.addDamageHate(attacker, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker);
npc.setScriptValue(1);
}
}
else if (npc.getNpcId() == 1539)
{
if (npc.isScriptValue(0) && Rnd.get(10) < 3)
{
L2Attackable newNpc = (L2Attackable) addSpawn (1540, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.addDamageHate(attacker, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker);
npc.setScriptValue(1);
}
}
else if (npc.getNpcId() == 1521)
{
if (Rnd.get(10) < 3)
{
npc.onDecay();
L2Attackable newNpc = (L2Attackable) addSpawn (1522, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.onAction(attacker);
newNpc.addDamageHate(attacker, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker);
}
}
else if (npc.getNpcId() == 1527)
{
if (Rnd.get(10) < 3)
{
npc.onDecay();
L2Attackable newNpc = (L2Attackable) addSpawn (1528, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.onAction(attacker);
newNpc.addDamageHate(attacker, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker);
}
}
else if (npc.getNpcId() == 1533)
{
if (Rnd.get(10) < 3)
{
npc.onDecay();
L2Attackable newNpc = (L2Attackable) addSpawn (1534, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.onAction(attacker);
newNpc.addDamageHate(attacker, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker);
}
}
else if (npc.getNpcId() == 1537)
{
if (Rnd.get(10) < 3)
{
npc.onDecay();
L2Attackable newNpc = (L2Attackable) addSpawn (1538, npc.getX()+10, npc.getY()+10, npc.getZ()+10, npc.getHeading(), false, 0);
newNpc.onAction(attacker);
newNpc.addDamageHate(attacker, 0, 100);
newNpc.setRunning();
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker);
}
}
return super.onAttack(npc, attacker, damage, isPet);
}
public static void main(String[] args)
{
// Quest class and state definition
new ValleyOfSaints(-1, "valleyofsaints", "ai/group_template");
}
}
In case DnR decides to commit this...
- Code:
Index: polymorphing_onAttack.py
===================================================================
--- polymorphing_onAttack.py (revision 598)
+++ polymorphing_onAttack.py (working copy)
@@ -16,11 +15,6 @@
1267: [1270, 100, 100], #Cave Ant Larva -> Cave Ant Soldier (always polymorphs)
1271: [1272, 66, 10], #Cave Ant -> Cave Ant Soldier
1272: [1273, 33, 5], #Cave Ant Soldier -> Cave Noble Ant
- 1521: [1522, 100, 30], #Claws of Splendor -> Claws of Splendor Panther
- 1524: [1525, 100, 30], #Blade of Splendor -> Blade of Splendor 2nd
- 1527: [1528, 100, 30], #Anger of Splendor -> Anger of Splendor Panther
- 1533: [1534, 100, 30], #Alliance of Splendor -> Alliance of Splendor Panther
- 1537: [1538, 100, 30] #Fang of Splendor -> Fang of Splendor Panther
}
# finally, don't forget to call the parent constructor to prepare the event triggering
# mechanisms etc.
- Code:
Index: scripts.cfg
===================================================================
--- scripts.cfg (revision 598)
+++ scripts.cfg (working copy)
@@ -15,11 +15,13 @@
ai/group_template/FrenzyOnAttack.java
ai/group_template/polymorphing_angel.py
ai/group_template/SearchingMaster.java
+ai/group_template/ValleyOfSaints.java
Last edited by Karakan on 12th July 2019, 15:29; edited 3 times in total