diff --git a/gameserver/src/main/java/brainwine/gameserver/behavior/parts/IdleBehavior.java b/gameserver/src/main/java/brainwine/gameserver/behavior/parts/IdleBehavior.java index 64bb753..0ef11ad 100644 --- a/gameserver/src/main/java/brainwine/gameserver/behavior/parts/IdleBehavior.java +++ b/gameserver/src/main/java/brainwine/gameserver/behavior/parts/IdleBehavior.java @@ -10,12 +10,14 @@ import com.fasterxml.jackson.annotation.JsonSetter; import brainwine.gameserver.behavior.Behavior; import brainwine.gameserver.entity.FacingDirection; import brainwine.gameserver.entity.npc.Npc; +import brainwine.gameserver.util.Vector2i; public class IdleBehavior extends Behavior { protected int delay = 60; protected int duration = 60; protected double random = 0.5; + protected Vector2i groundOffset = new Vector2i(0, 1); protected String[] animations = new String[] {"idle"}; protected long until; protected boolean idle; @@ -33,7 +35,7 @@ public class IdleBehavior extends Behavior { Random random = ThreadLocalRandom.current(); long now = System.currentTimeMillis(); - if(entity.isOnGround()) { + if(entity.isBlocked(groundOffset.getX(), groundOffset.getY())) { if(now > until) { idle = !idle; until = getNextUntil(); @@ -78,6 +80,11 @@ public class IdleBehavior extends Behavior { this.random = random; } + @JsonSetter("grounded") + public void setGroundOffset(Vector2i groundOffset) { + this.groundOffset = groundOffset; + } + @JsonSetter("animation") public void setAnimations(String... animations) { this.animations = animations;