diff --git a/Server/data/configs/npc_configs.json b/Server/data/configs/npc_configs.json index 098887d58..92cd41d90 100644 --- a/Server/data/configs/npc_configs.json +++ b/Server/data/configs/npc_configs.json @@ -7830,6 +7830,7 @@ "name": "Imp", "defence_level": "2", "safespot": null, + "movement_radius": "25", "lifepoints": "8", "strength_level": "2", "id": "708", @@ -7848,6 +7849,7 @@ "name": "Imp", "defence_level": "1", "safespot": null, + "movement_radius": "25", "lifepoints": "8", "strength_level": "1", "id": "709", @@ -15428,6 +15430,7 @@ "name": "Imp", "defence_level": "1", "safespot": null, + "movement_radius": "25", "lifepoints": "8", "strength_level": "1", "id": "1531", @@ -52651,6 +52654,7 @@ "name": "Imp", "defence_level": "4", "safespot": null, + "movement_radius": "25", "lifepoints": "10", "strength_level": "4", "id": "6211", diff --git a/Server/src/main/java/core/game/content/activity/gwd/GodWarsNPC.java b/Server/src/main/java/core/game/content/activity/gwd/GodWarsNPC.java index a2778377b..52df17121 100644 --- a/Server/src/main/java/core/game/content/activity/gwd/GodWarsNPC.java +++ b/Server/src/main/java/core/game/content/activity/gwd/GodWarsNPC.java @@ -3,7 +3,9 @@ package core.game.content.activity.gwd; import java.util.ArrayList; import java.util.List; +import api.ContentAPIKt; 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.DeathTask; 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.AggressiveHandler; import core.game.node.entity.player.Player; +import core.game.node.entity.player.link.TeleportManager; import core.game.world.map.Location; import core.plugin.Initializable; 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. @@ -22,6 +30,9 @@ import core.game.world.map.RegionManager; @Initializable 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. */ @@ -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 }; } + @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); + } + } } diff --git a/Server/src/main/java/core/game/node/entity/skill/hunter/HunterNPC.java b/Server/src/main/java/core/game/node/entity/skill/hunter/HunterNPC.java index e47ef4733..1ee31d0a5 100644 --- a/Server/src/main/java/core/game/node/entity/skill/hunter/HunterNPC.java +++ b/Server/src/main/java/core/game/node/entity/skill/hunter/HunterNPC.java @@ -1,8 +1,13 @@ package core.game.node.entity.skill.hunter; +import api.ContentAPIKt; 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.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 core.game.world.map.Location; import core.tools.RandomFunction; @@ -10,12 +15,18 @@ import core.tools.RandomFunction; import java.util.ArrayList; import java.util.List; +import static api.ContentAPIKt.getPathableRandomLocalCoordinate; +import static api.ContentAPIKt.sendGraphics; + /** * Handles a hunter npc. * @author Vexia */ 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. */ @@ -99,6 +110,28 @@ public final class HunterNPC extends AbstractNPC { 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. * @return The type. @@ -115,4 +148,15 @@ public final class HunterNPC extends AbstractNPC { 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); + } + } }