diff --git a/L2J_DataPack_BETA/dist/game/data/scripts.cfg b/L2J_DataPack_BETA/dist/game/data/scripts.cfg index f84d377330b73afb800e6cefbf4983bd456fa489..084eb809e577d72df491fb759e522f908b2825ca 100644 --- a/L2J_DataPack_BETA/dist/game/data/scripts.cfg +++ b/L2J_DataPack_BETA/dist/game/data/scripts.cfg @@ -100,6 +100,7 @@ ai/group_template/DragonValley.java ai/group_template/EnergySeeds.java ai/group_template/FairyTrees.java ai/group_template/FeedableBeasts.java +ai/group_template/FleeMonsters.java ai/group_template/FrozenLabyrinth.java ai/group_template/GiantsCave.java ai/group_template/IsleOfPrayer.java @@ -150,7 +151,6 @@ ai/individual/DivineBeast.java ai/individual/DrChaos.java ai/individual/Epidos.java ai/individual/EvasGiftBox.java -ai/individual/FleeNpc.java ai/individual/FrightenedRagnaOrc.java ai/individual/GeneralDilios.java ai/individual/Gordon.java diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/FleeMonsters.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/FleeMonsters.java new file mode 100644 index 0000000000000000000000000000000000000000..73763b30c48a35907a29d362b3db093256aca3d2 --- /dev/null +++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/group_template/FleeMonsters.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2004-2014 L2J DataPack + * + * This file is part of L2J DataPack. + * + * L2J DataPack 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. + * + * L2J DataPack 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 ai.npc.AbstractNpcAI; + +import com.l2jserver.Config; +import com.l2jserver.gameserver.GeoData; +import com.l2jserver.gameserver.ai.CtrlIntention; +import com.l2jserver.gameserver.model.Location; +import com.l2jserver.gameserver.model.actor.L2Npc; +import com.l2jserver.gameserver.model.actor.L2Summon; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.model.interfaces.ILocational; +import com.l2jserver.gameserver.util.Util; + +/** + * Flee Monsters AI. + * @author Pandragon, Nos + */ +public final class FleeMonsters extends AbstractNpcAI +{ + // NPCs + private static final int[] MOBS = + { + 18150, // Victim + 18151, // Victim + 18152, // Victim + 18153, // Victim + 18154, // Victim + 18155, // Victim + 18156, // Victim + 18157, // Victim + 20002, // Rabbit + 20432, // Elpy + 22228, // Grey Elpy + 25604, // Mutated Elpy + }; + // Misc + private static final int FLEE_DISTANCE = 500; + + private FleeMonsters() + { + super(FleeMonsters.class.getSimpleName(), "ai/group_template"); + addAttackId(MOBS); + } + + @Override + public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) + { + npc.disableCoreAI(true); + npc.setRunning(); + + final L2Summon summon = isSummon ? attacker.getSummon() : null; + final ILocational attackerLoc = summon == null ? attacker : summon; + final double radians = Math.toRadians(Util.calculateAngleFrom(attackerLoc, npc)); + final int posX = (int) (npc.getX() + (FLEE_DISTANCE * Math.cos(radians))); + final int posY = (int) (npc.getY() + (FLEE_DISTANCE * Math.sin(radians))); + final int posZ = npc.getZ(); + + final Location destination; + if (Config.GEODATA > 0) + { + destination = GeoData.getInstance().moveCheck(npc.getX(), npc.getY(), npc.getZ(), posX, posY, posZ, attacker.getInstanceId()); + } + else + { + destination = new Location(posX, posY, posZ); + } + npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination); + return super.onAttack(npc, attacker, damage, isSummon); + } + + public static void main(String[] args) + { + new FleeMonsters(); + } +} diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/individual/FleeNpc.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/individual/FleeNpc.java deleted file mode 100644 index b9127bc64f75e35905b90d2ec5b02946e894cd8b..0000000000000000000000000000000000000000 --- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/individual/FleeNpc.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2004-2014 L2J DataPack - * - * This file is part of L2J DataPack. - * - * L2J DataPack 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. - * - * L2J DataPack 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 ai.npc.AbstractNpcAI; - -import com.l2jserver.gameserver.ai.CtrlIntention; -import com.l2jserver.gameserver.model.Location; -import com.l2jserver.gameserver.model.actor.L2Npc; -import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; - -public final class FleeNpc extends AbstractNpcAI -{ - private static final int[] MOBS = - { - 20432, - 22228, - 18150, - 18151, - 18152, - 18153, - 18154, - 18155, - 18156, - 18157 - }; - - private FleeNpc() - { - super(FleeNpc.class.getSimpleName(), "ai/individual"); - addAttackId(MOBS); - } - - @Override - public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) - { - if ((npc.getId() >= 18150) && (npc.getId() <= 18157)) - { - npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location((npc.getX() + getRandom(-40, 40)), (npc.getY() + getRandom(-40, 40)), npc.getZ(), npc.getHeading())); - npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null, null); - return null; - } - else if ((npc.getId() == 20432) || (npc.getId() == 22228)) - { - if (getRandom(3) == 2) - { - npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location((npc.getX() + getRandom(-200, 200)), (npc.getY() + getRandom(-200, 200)), npc.getZ(), npc.getHeading())); - } - npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null, null); - return null; - } - return super.onAttack(npc, attacker, damage, isSummon); - } - - // Register the new Script at the Script System - public static void main(String[] args) - { - new FleeNpc(); - } -}