From 35446586e05102051bffcf22542d05a3046a68c5 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 23:46:02 +0300 Subject: [PATCH] Make pets unstay after 120 seconds --- .../com/eu/habbo/habbohotel/pets/Pet.java | 20 +++++++++++++++++++ .../habbohotel/pets/actions/ActionStay.java | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 8b41ebb2..559a1e4b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -46,6 +46,7 @@ public class Pet implements ISerialize, Runnable { private int gestureTickTimeout = Emulator.getIntUnixTimestamp(); private int randomActionTickTimeout = Emulator.getIntUnixTimestamp(); private int postureTimeout = Emulator.getIntUnixTimestamp(); + private int stayStartedAt = 0; private int idleCommandTicks = 0; private int freeCommandTicks = -1; @@ -276,6 +277,11 @@ public class Pet implements ISerialize, Runnable { this.tickTimeout = time; } + + if (this.task == PetTasks.STAY && Emulator.getIntUnixTimestamp() - this.stayStartedAt >= 120) { + this.task = null; + this.getRoomUnit().setCanWalk(true); + } } else { int timeout = Emulator.getRandom().nextInt(10) * 2; this.roomUnit.setWalkTimeOut(timeout < 20 ? 20 + time : timeout + time); @@ -331,6 +337,12 @@ public class Pet implements ISerialize, Runnable { public void handleCommand(PetCommand command, Habbo habbo, String[] data) { this.idleCommandTicks = 0; + if (this.task == PetTasks.STAY) { + this.stayStartedAt = 0; + this.task = null; + this.getRoomUnit().setCanWalk(true); + } + command.handle(this, habbo, data); @@ -731,4 +743,12 @@ public class Pet implements ISerialize, Runnable { this.room = null; this.needsUpdate = true; } + + public int getStayStartedAt() { + return stayStartedAt; + } + + public void setStayStartedAt(int stayStartedAt) { + this.stayStartedAt = stayStartedAt; + } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStay.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStay.java index 7ee56474..7b3851cf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStay.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionStay.java @@ -1,5 +1,6 @@ package com.eu.habbo.habbohotel.pets.actions; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetTasks; @@ -20,7 +21,7 @@ public class ActionStay extends PetAction { pet.clearPosture(); pet.getRoomUnit().setCanWalk(false); - + pet.setStayStartedAt(Emulator.getIntUnixTimestamp()); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); return true;