Hello everyone, here is the AI for PolymorphingOnAttack.
Differences from the previously posted version:
- Fixed display of phrases of monsters (now they can be seen).
- Auto switch target.
- As Karakan advised, npc.deleteMe was changed to npc.onDecay.
- Monsters listed in ValleyOfSaints.java and FallenOrcShaman.java are excluded.
I also wanted to note that ScriptValue and onSkillSee are not required for this AI to work.
PolymorphingOnAttack.java
Please understand me correctly, I do not confirm that this is the best option, it can be changed to other conditions if necessary.
I also want to offer option 2.
Divide this AI into 2 parts.
ai.individual
OlMahumTranscender.java
- requires verification.
ai.group_template
TheAntNest.java
Requires corrections.
- remove unnecessary dialogues (if any).
- after the appearance of a new monster, he does not attack, so in PolymorphingOnAttack.java (only for these monsters).
onSkillSee not used as it causes a wave effect.
Differences from the previously posted version:
- Fixed display of phrases of monsters (now they can be seen).
- Auto switch target.
- As Karakan advised, npc.deleteMe was changed to npc.onDecay.
- Monsters listed in ValleyOfSaints.java and FallenOrcShaman.java are excluded.
I also wanted to note that ScriptValue and onSkillSee are not required for this AI to work.
PolymorphingOnAttack.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 java.util.HashMap;
import java.util.Map;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.model.L2Attackable;
import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.util.Rnd;
/**
* for L2jLisvus
*/
public class PolymorphingOnAttack extends Quest
{
private static final Map<Integer,Integer[]> MOBSPAWNS = new HashMap<>();
static
{
MOBSPAWNS.put(1261, new Integer[] { 1262, 100, 20, 0 }); //Ol Mahum Transcender 1st stage
MOBSPAWNS.put(1262, new Integer[] { 1263, 100, 10, 1 }); //Ol Mahum Transcender 2nd stage
MOBSPAWNS.put(1263, new Integer[] { 1264, 100, 5, 2 }); //Ol Mahum Transcender 3rd stage
MOBSPAWNS.put(1265, new Integer[] { 1271, 100, 33, 0 }); //Cave Ant Larva -> Cave Ant
MOBSPAWNS.put(1266, new Integer[] { 1269, 100, 100, -1 }); //Cave Ant Larva -> Cave Ant (always polymorphs)
MOBSPAWNS.put(1267, new Integer[] { 1270, 100, 100, -1 }); //Cave Ant Larva -> Cave Ant Soldier (always polymorphs)
MOBSPAWNS.put(1271, new Integer[] { 1272, 66, 10, 1 }); //Cave Ant -> Cave Ant Soldier
MOBSPAWNS.put(1272, new Integer[] { 1273, 33, 5, 2 }); //Cave Ant Soldier -> Cave Noble Ant
}
protected static final String[][] MOBTEXTS =
{
new String[]{"Enough fooling around. Get ready to die!", "You idiot! I've just been toying with you!", "Now the fun starts!"},
new String[]{"I must admit, no one makes my blood boil quite like you do!", "Now the battle begins!", "Witness my true power!"},
new String[]{"Prepare to die!", "I'll double my strength!", "You have more skill than I thought"}
};
public PolymorphingOnAttack(int questId, String name, String descr)
{
super(questId, name, descr);
int[] mobs =
{
1261, 1262, 1263, 1265, 1266, 1267, 1271, 1272
};
registerMobs(mobs);
}
@Override
public String onAttack (L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
{
if (npc.isVisible() && !npc.isDead())
{
if (MOBSPAWNS.containsKey(npc.getNpcId()))
{
Integer[] tmp = MOBSPAWNS.get(npc.getNpcId());
if (npc.getCurrentHp() <= (npc.getMaxHp() * tmp[1]/100.0)&& Rnd.get(100) < tmp[2])
{
L2Attackable newNpc = (L2Attackable) addSpawn(tmp[0], npc.getX(), npc.getY(), npc.getZ()+10, npc.getHeading(), false, 0);
L2Character originalAttacker = isPet? attacker.getPet(): attacker;
if (tmp[3] >= 0)
{
String text = MOBTEXTS[tmp[3]][Rnd.get(MOBTEXTS[tmp[3]].length)];
newNpc.broadcastPacket(new CreatureSay(newNpc.getObjectId(),0,newNpc.getName(),text));
}
npc.getSpawn().decreaseCount(npc);
//npc.doDie(npc);
//npc.deleteMe();
npc.onDecay();
newNpc.onAction(attacker);
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,100);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
}
return super.onAttack (npc, attacker, damage, isPet);
}
public static void main(String[] args)
{
new PolymorphingOnAttack(-1,"polymorphing_on_attack","ai/group_template");
}
}
Please understand me correctly, I do not confirm that this is the best option, it can be changed to other conditions if necessary.
I also want to offer option 2.
Divide this AI into 2 parts.
ai.individual
OlMahumTranscender.java
- requires verification.
- Spoiler:
- 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.individual;
import java.util.HashMap;
import java.util.Map;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.model.L2Attackable;
import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.util.Rnd;
/**
* Polymorphing On Attack Ol Mahum Transcender
* for L2jLisvus
*/
public class OlMahumTranscender extends Quest
{
private static final Map<Integer,Integer[]> MOBSPAWNS = new HashMap<>();
static
{
MOBSPAWNS.put(1261, new Integer[] { 1262, 100, 20, 0 }); //Ol Mahum Transcender 1st stage
MOBSPAWNS.put(1262, new Integer[] { 1263, 100, 10, 1 }); //Ol Mahum Transcender 2nd stage
MOBSPAWNS.put(1263, new Integer[] { 1264, 100, 5, 2 }); //Ol Mahum Transcender 3rd stage
}
protected static final String[][] MOBTEXTS =
{
new String[]{"Enough fooling around. Get ready to die!", "You idiot! I've just been toying with you!", "Now the fun starts!"},
new String[]{"I must admit, no one makes my blood boil quite like you do!", "Now the battle begins!", "Witness my true power!"},
new String[]{"Prepare to die!", "I'll double my strength!", "You have more skill than I thought"}
};
public OlMahumTranscender(int questId, String name, String descr)
{
super(questId, name, descr);
int[] mobs =
{
1261, 1262, 1263
};
registerMobs(mobs);
}
@Override
public String onAttack (L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
{
if (npc.isVisible() && !npc.isDead())
{
if (MOBSPAWNS.containsKey(npc.getNpcId()))
{
Integer[] tmp = MOBSPAWNS.get(npc.getNpcId());
if (npc.getCurrentHp() <= (npc.getMaxHp() * tmp[1]/100.0)&& Rnd.get(100) < tmp[2])
{
L2Attackable newNpc = (L2Attackable) addSpawn(tmp[0], npc.getX(), npc.getY(), npc.getZ()+10, npc.getHeading(), false, 0);
L2Character originalAttacker = isPet? attacker.getPet(): attacker;
if (tmp[3] >= 0)
{
String text = MOBTEXTS[tmp[3]][Rnd.get(MOBTEXTS[tmp[3]].length)];
newNpc.broadcastPacket(new CreatureSay(newNpc.getObjectId(),0,newNpc.getName(),text));
}
npc.onDecay();
newNpc.onAction(attacker);
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,100);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
}
return super.onAttack (npc, attacker, damage, isPet);
}
public static void main(String[] args)
{
new OlMahumTranscender(-1,"OlMahumTranscender","ai/individual");
}
}
ai.group_template
TheAntNest.java
Requires corrections.
- remove unnecessary dialogues (if any).
- after the appearance of a new monster, he does not attack, so in PolymorphingOnAttack.java (only for these monsters).
- Spoiler:
- 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 java.util.HashMap;
import java.util.Map;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.model.L2Attackable;
import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.util.Rnd;
/**
* Polymorphing On Attack Cave Ant (The Ant Nest)
* for L2jLisvus
*/
public class TheAntNest extends Quest
{
private static final Map<Integer,Integer[]> MOBSPAWNS = new HashMap<>();
static
{
MOBSPAWNS.put(1265, new Integer[] { 1271, 100, 33, 0 }); //Cave Ant Larva -> Cave Ant
MOBSPAWNS.put(1266, new Integer[] { 1269, 100, 100, -1 }); //Cave Ant Larva -> Cave Ant (always polymorphs)
MOBSPAWNS.put(1267, new Integer[] { 1270, 100, 100, -1 }); //Cave Ant Larva -> Cave Ant Soldier (always polymorphs)
MOBSPAWNS.put(1271, new Integer[] { 1272, 66, 10, 1 }); //Cave Ant -> Cave Ant Soldier
MOBSPAWNS.put(1272, new Integer[] { 1273, 33, 5, 2 }); //Cave Ant Soldier -> Cave Noble Ant
}
protected static final String[][] MOBTEXTS =
{
new String[]{"Enough fooling around. Get ready to die!", "You idiot! I've just been toying with you!", "Now the fun starts!"},
new String[]{"I must admit, no one makes my blood boil quite like you do!", "Now the battle begins!", "Witness my true power!"},
new String[]{"Prepare to die!", "I'll double my strength!", "You have more skill than I thought"}
};
public TheAntNest(int questId, String name, String descr)
{
super(questId, name, descr);
int[] mobs =
{
1265, 1266, 1267, 1271, 1272
};
registerMobs(mobs);
}
@Override
public String onAttack (L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
{
if (npc.isVisible() && !npc.isDead())
{
if (MOBSPAWNS.containsKey(npc.getNpcId()))
{
Integer[] tmp = MOBSPAWNS.get(npc.getNpcId());
if (npc.getCurrentHp() <= (npc.getMaxHp() * tmp[1]/100.0)&& Rnd.get(100) < tmp[2])
{
L2Attackable newNpc = (L2Attackable) addSpawn(tmp[0], npc.getX(), npc.getY(), npc.getZ()+10, npc.getHeading(), false, 0);
L2Character originalAttacker = isPet? attacker.getPet(): attacker;
if (tmp[3] >= 0)
{
String text = MOBTEXTS[tmp[3]][Rnd.get(MOBTEXTS[tmp[3]].length)];
newNpc.broadcastPacket(new CreatureSay(newNpc.getObjectId(),0,newNpc.getName(),text));
}
npc.onDecay();
newNpc.onAction(attacker);
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,100);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
}
return super.onAttack (npc, attacker, damage, isPet);
}
public static void main(String[] args)
{
new TheAntNest(-1,"TheAntNest","ai/group_template");
}
}
onSkillSee not used as it causes a wave effect.
Last edited by xlinkinx on 26th July 2019, 05:19; edited 3 times in total