Implemented imp teleporting

Added behavior to little red imps to allow them to teleport around
Imps have a 1/10 chance on each hit of teleporting away
Imps have a 1/75 chance on each tick of teleporting away
This commit is contained in:
Byte
2022-10-10 12:56:48 +00:00
committed by Ryan
parent f4d0754ed7
commit e0b9c0ab50
3 changed files with 92 additions and 0 deletions
+4
View File
@@ -7830,6 +7830,7 @@
"name": "Imp", "name": "Imp",
"defence_level": "2", "defence_level": "2",
"safespot": null, "safespot": null,
"movement_radius": "25",
"lifepoints": "8", "lifepoints": "8",
"strength_level": "2", "strength_level": "2",
"id": "708", "id": "708",
@@ -7848,6 +7849,7 @@
"name": "Imp", "name": "Imp",
"defence_level": "1", "defence_level": "1",
"safespot": null, "safespot": null,
"movement_radius": "25",
"lifepoints": "8", "lifepoints": "8",
"strength_level": "1", "strength_level": "1",
"id": "709", "id": "709",
@@ -15428,6 +15430,7 @@
"name": "Imp", "name": "Imp",
"defence_level": "1", "defence_level": "1",
"safespot": null, "safespot": null,
"movement_radius": "25",
"lifepoints": "8", "lifepoints": "8",
"strength_level": "1", "strength_level": "1",
"id": "1531", "id": "1531",
@@ -52651,6 +52654,7 @@
"name": "Imp", "name": "Imp",
"defence_level": "4", "defence_level": "4",
"safespot": null, "safespot": null,
"movement_radius": "25",
"lifepoints": "10", "lifepoints": "10",
"strength_level": "4", "strength_level": "4",
"id": "6211", "id": "6211",
@@ -3,7 +3,9 @@ package core.game.content.activity.gwd;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import api.ContentAPIKt;
import core.game.node.entity.Entity; import core.game.node.entity.Entity;
import core.game.node.entity.combat.BattleState;
import core.game.node.entity.combat.CombatStyle; import core.game.node.entity.combat.CombatStyle;
import core.game.node.entity.combat.DeathTask; import core.game.node.entity.combat.DeathTask;
import core.game.node.entity.npc.AbstractNPC; import core.game.node.entity.npc.AbstractNPC;
@@ -11,9 +13,15 @@ import core.game.node.entity.npc.NPC;
import core.game.node.entity.npc.agg.AggressiveBehavior; import core.game.node.entity.npc.agg.AggressiveBehavior;
import core.game.node.entity.npc.agg.AggressiveHandler; import core.game.node.entity.npc.agg.AggressiveHandler;
import core.game.node.entity.player.Player; import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.TeleportManager;
import core.game.world.map.Location; import core.game.world.map.Location;
import core.plugin.Initializable; import core.plugin.Initializable;
import core.game.world.map.RegionManager; import core.game.world.map.RegionManager;
import core.tools.RandomFunction;
import org.rs09.consts.NPCs;
import static api.ContentAPIKt.getPathableRandomLocalCoordinate;
import static api.ContentAPIKt.sendGraphics;
/** /**
* Handles a god wars NPC. * Handles a god wars NPC.
@@ -22,6 +30,9 @@ import core.game.world.map.RegionManager;
@Initializable @Initializable
public final class GodWarsNPC extends AbstractNPC { public final class GodWarsNPC extends AbstractNPC {
private static final int IMP_TELEPORT_CHANCE_ON_HIT = 10; // 1/10
private static final int IMP_TELEPORT_CHANCE_ON_TICK = 75; // 1/75
/** /**
* The aggressive behavior. * The aggressive behavior.
*/ */
@@ -122,4 +133,37 @@ public final class GodWarsNPC extends AbstractNPC {
return new int[] { 6210, 6211, 6212, 6213, 6214, 6215, 6216, 6217, 6218, 6219, 6220, 6221, 6229, 6230, 6231, 6232, 6233, 6234, 6235, 6236, 6237, 6238, 6239, 6240, 6241, 6242, 6243, 6244, 6245, 6246, 6254, 6255, 6256, 6257, 6258, 6259, 6267, 6268, 6269, 6270, 6271, 6272, 6273, 6274, 6275, 6276, 6277, 6278, 6279, 6280, 6281, 6282, 6283 }; return new int[] { 6210, 6211, 6212, 6213, 6214, 6215, 6216, 6217, 6218, 6219, 6220, 6221, 6229, 6230, 6231, 6232, 6233, 6234, 6235, 6236, 6237, 6238, 6239, 6240, 6241, 6242, 6243, 6244, 6245, 6246, 6254, 6255, 6256, 6257, 6258, 6259, 6267, 6268, 6269, 6270, 6271, 6272, 6273, 6274, 6275, 6276, 6277, 6278, 6279, 6280, 6281, 6282, 6283 };
} }
@Override
public void checkImpact(BattleState state) {
super.checkImpact(state);
if (getId() == NPCs.IMP_6211) {
if (RandomFunction.roll(IMP_TELEPORT_CHANCE_ON_HIT)) {
getRandomLocAndTeleport();
}
}
}
@Override
public void tick() {
super.tick();
if (getId() == NPCs.IMP_6211) {
if (RandomFunction.roll(IMP_TELEPORT_CHANCE_ON_TICK)) {
getRandomLocAndTeleport();
}
}
}
/**
* Used to teleport imps
*/
private void getRandomLocAndTeleport() {
Location teleportLocation = getPathableRandomLocalCoordinate(this, walkRadius, getProperties().getSpawnLocation(), 3);
if (getLocation() != teleportLocation) {
sendGraphics(1119, getLocation());
ContentAPIKt.teleport(this, teleportLocation, TeleportManager.TeleportType.INSTANT);
}
}
} }
@@ -1,8 +1,13 @@
package core.game.node.entity.skill.hunter; package core.game.node.entity.skill.hunter;
import api.ContentAPIKt;
import core.game.node.entity.Entity; import core.game.node.entity.Entity;
import core.game.node.entity.combat.BattleState;
import core.game.node.entity.npc.AbstractNPC; import core.game.node.entity.npc.AbstractNPC;
import core.game.node.entity.player.Player; import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.TeleportManager;
import core.game.world.map.RegionManager;
import org.rs09.consts.NPCs;
import rs09.game.world.GameWorld; import rs09.game.world.GameWorld;
import core.game.world.map.Location; import core.game.world.map.Location;
import core.tools.RandomFunction; import core.tools.RandomFunction;
@@ -10,12 +15,18 @@ import core.tools.RandomFunction;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static api.ContentAPIKt.getPathableRandomLocalCoordinate;
import static api.ContentAPIKt.sendGraphics;
/** /**
* Handles a hunter npc. * Handles a hunter npc.
* @author Vexia * @author Vexia
*/ */
public final class HunterNPC extends AbstractNPC { public final class HunterNPC extends AbstractNPC {
private static final int IMP_TELEPORT_CHANCE_ON_HIT = 10; // 1/10
private static final int IMP_TELEPORT_CHANCE_ON_TICK = 1000; // 1/75
/** /**
* The trap type. * The trap type.
*/ */
@@ -99,6 +110,28 @@ public final class HunterNPC extends AbstractNPC {
return array; return array;
} }
@Override
public void checkImpact(BattleState state) {
super.checkImpact(state);
if (this.getId() == NPCs.IMP_708 || this.getId() == NPCs.IMP_709 || this.getId() == NPCs.IMP_1531) {
if (RandomFunction.roll(IMP_TELEPORT_CHANCE_ON_HIT)) {
getRandomLocAndTeleport();
}
}
}
@Override
public void tick() {
super.tick();
if (this.getId() == NPCs.IMP_708 || this.getId() == NPCs.IMP_709 || this.getId() == NPCs.IMP_1531) {
if (RandomFunction.roll(IMP_TELEPORT_CHANCE_ON_TICK)) {
getRandomLocAndTeleport();
}
}
}
/** /**
* Gets the type. * Gets the type.
* @return The type. * @return The type.
@@ -115,4 +148,15 @@ public final class HunterNPC extends AbstractNPC {
return trap; return trap;
} }
/**
* Used to teleport imps
*/
private void getRandomLocAndTeleport() {
Location teleportLocation = getPathableRandomLocalCoordinate(this, walkRadius, getProperties().getSpawnLocation(), 3);
if (getLocation() != teleportLocation) {
sendGraphics(1119, getLocation());
ContentAPIKt.teleport(this, teleportLocation, TeleportManager.TeleportType.INSTANT);
}
}
} }