From 4ca143129a0f7425c882f8ce11a40a09ef8296ad Mon Sep 17 00:00:00 2001 From: Ceikry Date: Tue, 8 Mar 2022 02:24:34 +0000 Subject: [PATCH] Added support to the ActivityPlugin system to set a safe respawn location Fixed pest control deaths sometimes respawning in Lumbridge Admins can now kill themselves with ::killme --- .../java/core/game/content/activity/ActivityPlugin.java | 8 ++++++++ .../activity/pestcontrol/PestControlActivityPlugin.java | 1 + .../main/java/core/game/node/entity/combat/DeathTask.java | 2 +- .../main/java/core/game/node/entity/impl/Properties.java | 5 +++++ .../game/system/command/sets/DevelopmentCommandSet.kt | 4 ++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Server/src/main/java/core/game/content/activity/ActivityPlugin.java b/Server/src/main/java/core/game/content/activity/ActivityPlugin.java index 1b9657e63..454235c68 100644 --- a/Server/src/main/java/core/game/content/activity/ActivityPlugin.java +++ b/Server/src/main/java/core/game/content/activity/ActivityPlugin.java @@ -44,6 +44,12 @@ public abstract class ActivityPlugin extends MapZone implements Plugin { */ protected Location base; + /** + * A location which the player is teleported to in the case of death, if this activity is safe. + * Defaults to the home location of the server. + */ + protected Location safeRespawn = ServerConstants.HOME_LOCATION; + /** * The player. */ @@ -134,6 +140,7 @@ public abstract class ActivityPlugin extends MapZone implements Plugin { e.getProperties().setSpawnLocation(l); } e.getProperties().setSafeZone(safe); + e.getProperties().safeRespawn = this.safeRespawn; e.setAttribute("activity", this); return super.enter(e); } @@ -148,6 +155,7 @@ public abstract class ActivityPlugin extends MapZone implements Plugin { e.setLocation(l); } e.getProperties().setSafeZone(false); + e.getProperties().safeRespawn = ServerConstants.HOME_LOCATION; e.removeAttribute("activity"); return super.leave(e, logout); } diff --git a/Server/src/main/java/core/game/content/activity/pestcontrol/PestControlActivityPlugin.java b/Server/src/main/java/core/game/content/activity/pestcontrol/PestControlActivityPlugin.java index af996fd2e..31547bbd4 100644 --- a/Server/src/main/java/core/game/content/activity/pestcontrol/PestControlActivityPlugin.java +++ b/Server/src/main/java/core/game/content/activity/pestcontrol/PestControlActivityPlugin.java @@ -193,6 +193,7 @@ public final class PestControlActivityPlugin extends ActivityPlugin { */ public PestControlActivityPlugin(BoatType type) { super("pest control " + type.name().toLowerCase(), false, true, true, ZoneRestriction.CANNON); + this.safeRespawn = Location.create(2657, 2646, 0); this.type = type; } diff --git a/Server/src/main/java/core/game/node/entity/combat/DeathTask.java b/Server/src/main/java/core/game/node/entity/combat/DeathTask.java index 83922c552..1771c8e4e 100644 --- a/Server/src/main/java/core/game/node/entity/combat/DeathTask.java +++ b/Server/src/main/java/core/game/node/entity/combat/DeathTask.java @@ -86,7 +86,7 @@ public final class DeathTask extends NodeTask { Entity killer = n.length > 0 ? (Entity) n[0] : e; e.removeAttribute("state:death"); e.removeAttribute("tick:death"); - Location spawn = e.getProperties().getSpawnLocation(); + Location spawn = e.getProperties().isSafeZone() ? e.getProperties().safeRespawn : e.getProperties().getSpawnLocation(); e.getAnimator().forceAnimation(Animator.RESET_A); e.getProperties().setTeleportLocation(spawn); e.unlock(); diff --git a/Server/src/main/java/core/game/node/entity/impl/Properties.java b/Server/src/main/java/core/game/node/entity/impl/Properties.java index 081ca3c4f..f764986dd 100644 --- a/Server/src/main/java/core/game/node/entity/impl/Properties.java +++ b/Server/src/main/java/core/game/node/entity/impl/Properties.java @@ -130,6 +130,11 @@ public final class Properties { */ private boolean safeZone; + /** + * The location which the player respawns at the event of death while safeZone = true + */ + public Location safeRespawn; + /** * The combat time out ticks. */ diff --git a/Server/src/main/kotlin/rs09/game/system/command/sets/DevelopmentCommandSet.kt b/Server/src/main/kotlin/rs09/game/system/command/sets/DevelopmentCommandSet.kt index 9507ac8ca..359e17a72 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/sets/DevelopmentCommandSet.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/sets/DevelopmentCommandSet.kt @@ -1,5 +1,6 @@ package rs09.game.system.command.sets +import core.game.node.entity.combat.ImpactHandler.HitsplatType import core.game.node.entity.player.link.SpellBookManager import core.game.node.item.Item import core.plugin.Initializable @@ -30,6 +31,9 @@ class DevelopmentCommandSet : CommandSet(Command.Privilege.ADMIN) { player.spellBookManager.update(player) } + define("killme") { player, _ -> + player.impactHandler.manualHit(player, player.skills.lifepoints, HitsplatType.NORMAL) + } } } \ No newline at end of file