This took me a while to finish, but finally its here.
Now its working 99% C4 retail like.
Commanders will randomly shout, and call nearby lizardmen for help, who also got their shout msgs added.
As always please...feel free to make suggestions on how to improve the code or add missing stuff.
scripts.cfg
- Code:
Index: scripts.cfg
===================================================================
--- scripts.cfg (revision 624)
+++ scripts.cfg (working copy)
@@ -14,6 +14,7 @@
ai/group_template/feedable_beasts.py
ai/group_template/FleeingNpc.java
ai/group_template/FrenzyOnAttack.java
+ai/group_template/PlainsOfDion.java
ai/group_template/SearchingMaster.java
ai/group_template/TowerOfInsolence.java
ai/group_template/ValleyOfSaints.java
PlainsOfDion.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.Collection;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.geoengine.GeoData;
import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
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.network.serverpackets.CreatureSay;
import net.sf.l2j.gameserver.util.Util;
import net.sf.l2j.util.Rnd;
/**
* @author Karakan , optimized by DnR
*
* Plains Of Dion - Delu Lizardman AI.
*/
public class PlainsOfDion extends Quest
{
private static final int DELU_LIZARDMEN[] =
{
1104, // Delu Lizardman Supplier
1105, // Delu Lizardman Special Agent
};
private static final String[] NPC_STRING =
{
"$s1! How dare you interrupt our fight ? Hey guys help!",
"$s1! Hey, we are having a duel here!",
"The duel is over, attack!!",
"Foul, kill the coward!",
"How dare you interrupt a sacred duel? You must be taught a lesson!"
};
private static final String[] NPC_STRING_ON_ASSIST =
{
"Die, you coward!",
"Kill the coward!",
"What are you looking at?!"
};
public PlainsOfDion(int questId, String name, String descr)
{
super(questId, name, descr);
registerMobs(new int[]
{
1107
}); // Delu Lizardman Commander
}
@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.getScriptValue() == 0)
{
if (Rnd.get(100) < 10)
{
npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), NPC_STRING[Rnd.get(5)], attacker.getName()));
}
Collection<L2Character> characters = npc.getKnownList().getKnownCharactersInRadius(300);
for (L2Character obj : characters)
{
if (obj == null || !(obj instanceof L2MonsterInstance))
{
continue;
}
L2MonsterInstance monster = (L2MonsterInstance) obj;
if (Util.contains(DELU_LIZARDMEN, monster.getNpcId()))
{
if (!obj.isAttackingNow() && !obj.isDead() && GeoData.getInstance().canSeeTarget(obj, attacker))
{
monster.broadcastPacket(new CreatureSay(monster.getObjectId(), 0, monster.getName(), (NPC_STRING_ON_ASSIST[Rnd.get(3)])));
monster.setTarget(attacker);
monster.setRunning();
L2Character originalAttacker = isPet ? attacker.getPet() : attacker;
if (originalAttacker == null)
{
return null;
}
monster.addDamageHate(originalAttacker, 0, 100);
monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
}
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() && targets[0] == npc && npc.getScriptValue() == 0)
{
if (Rnd.get(100) < 10)
{
npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), NPC_STRING[Rnd.get(5)], caster.getName()));
}
Collection<L2Character> characters = npc.getKnownList().getKnownCharactersInRadius(300);
for (L2Character obj : characters)
{
if (obj == null || !(obj instanceof L2MonsterInstance))
{
continue;
}
L2MonsterInstance monster = (L2MonsterInstance) obj;
if (Util.contains(DELU_LIZARDMEN, monster.getNpcId()))
{
if (!obj.isAttackingNow() && !obj.isDead() && GeoData.getInstance().canSeeTarget(obj, caster))
{
monster.broadcastPacket(new CreatureSay(monster.getObjectId(), 0, monster.getName(), (NPC_STRING_ON_ASSIST[Rnd.get(3)])));
monster.setTarget(caster);
monster.setRunning();
L2Character originalCaster = isPet ? caster.getPet() : caster;
if (originalCaster == null)
{
return null;
}
monster.addDamageHate(originalCaster, 0, 100);
monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalCaster);
}
}
}
npc.setScriptValue(1);
}
return super.onSkillSee(npc, caster, skill, targets, isPet);
}
public static void main(String[] args)
{
new PlainsOfDion(-1, "plainsofdion", "ai/group_template");
}
}
Last edited by Karakan on 23rd July 2019, 02:50; edited 8 times in total