Skip to content
Snippets Groups Projects
Commit 3bf03505 authored by St3eT's avatar St3eT
Browse files

BETA: Reworking '''!FleeNpc''' AI.

* Patch by: Pandragon, Nos
* Tested by: Pandragon
parent 0bb3efe9
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -16,61 +16,79 @@
* 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;
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;
public final class FleeNpc extends AbstractNpcAI
/**
* Flee Monsters AI.
* @author Pandragon, Nos
*/
public final class FleeMonsters extends AbstractNpcAI
{
// NPCs
private static final int[] MOBS =
{
20432,
22228,
18150,
18151,
18152,
18153,
18154,
18155,
18156,
18157
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 FleeNpc()
private FleeMonsters()
{
super(FleeNpc.class.getSimpleName(), "ai/individual");
super(FleeMonsters.class.getSimpleName(), "ai/group_template");
addAttackId(MOBS);
}
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
{
if ((npc.getId() >= 18150) && (npc.getId() <= 18157))
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)
{
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;
destination = GeoData.getInstance().moveCheck(npc.getX(), npc.getY(), npc.getZ(), posX, posY, posZ, attacker.getInstanceId());
}
else if ((npc.getId() == 20432) || (npc.getId() == 22228))
else
{
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;
destination = new Location(posX, posY, posZ);
}
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination);
return super.onAttack(npc, attacker, damage, isSummon);
}
// Register the new Script at the Script System
public static void main(String[] args)
{
new FleeNpc();
new FleeMonsters();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment