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
This commit is contained in:
Ceikry
2022-03-08 02:24:34 +00:00
committed by Ryan
parent 9d41d998d0
commit 4ca143129a
5 changed files with 19 additions and 1 deletions
@@ -44,6 +44,12 @@ public abstract class ActivityPlugin extends MapZone implements Plugin<Player> {
*/ */
protected Location base; 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. * The player.
*/ */
@@ -134,6 +140,7 @@ public abstract class ActivityPlugin extends MapZone implements Plugin<Player> {
e.getProperties().setSpawnLocation(l); e.getProperties().setSpawnLocation(l);
} }
e.getProperties().setSafeZone(safe); e.getProperties().setSafeZone(safe);
e.getProperties().safeRespawn = this.safeRespawn;
e.setAttribute("activity", this); e.setAttribute("activity", this);
return super.enter(e); return super.enter(e);
} }
@@ -148,6 +155,7 @@ public abstract class ActivityPlugin extends MapZone implements Plugin<Player> {
e.setLocation(l); e.setLocation(l);
} }
e.getProperties().setSafeZone(false); e.getProperties().setSafeZone(false);
e.getProperties().safeRespawn = ServerConstants.HOME_LOCATION;
e.removeAttribute("activity"); e.removeAttribute("activity");
return super.leave(e, logout); return super.leave(e, logout);
} }
@@ -193,6 +193,7 @@ public final class PestControlActivityPlugin extends ActivityPlugin {
*/ */
public PestControlActivityPlugin(BoatType type) { public PestControlActivityPlugin(BoatType type) {
super("pest control " + type.name().toLowerCase(), false, true, true, ZoneRestriction.CANNON); super("pest control " + type.name().toLowerCase(), false, true, true, ZoneRestriction.CANNON);
this.safeRespawn = Location.create(2657, 2646, 0);
this.type = type; this.type = type;
} }
@@ -86,7 +86,7 @@ public final class DeathTask extends NodeTask {
Entity killer = n.length > 0 ? (Entity) n[0] : e; Entity killer = n.length > 0 ? (Entity) n[0] : e;
e.removeAttribute("state:death"); e.removeAttribute("state:death");
e.removeAttribute("tick: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.getAnimator().forceAnimation(Animator.RESET_A);
e.getProperties().setTeleportLocation(spawn); e.getProperties().setTeleportLocation(spawn);
e.unlock(); e.unlock();
@@ -130,6 +130,11 @@ public final class Properties {
*/ */
private boolean safeZone; 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. * The combat time out ticks.
*/ */
@@ -1,5 +1,6 @@
package rs09.game.system.command.sets 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.entity.player.link.SpellBookManager
import core.game.node.item.Item import core.game.node.item.Item
import core.plugin.Initializable import core.plugin.Initializable
@@ -30,6 +31,9 @@ class DevelopmentCommandSet : CommandSet(Command.Privilege.ADMIN) {
player.spellBookManager.update(player) player.spellBookManager.update(player)
} }
define("killme") { player, _ ->
player.impactHandler.manualHit(player, player.skills.lifepoints, HitsplatType.NORMAL)
}
} }
} }