Make pets unstay after 120 seconds

This commit is contained in:
Alejandro 2019-05-26 23:46:02 +03:00
parent 87141be688
commit 35446586e0
2 changed files with 22 additions and 1 deletions

View File

@ -46,6 +46,7 @@ public class Pet implements ISerialize, Runnable {
private int gestureTickTimeout = Emulator.getIntUnixTimestamp(); private int gestureTickTimeout = Emulator.getIntUnixTimestamp();
private int randomActionTickTimeout = Emulator.getIntUnixTimestamp(); private int randomActionTickTimeout = Emulator.getIntUnixTimestamp();
private int postureTimeout = Emulator.getIntUnixTimestamp(); private int postureTimeout = Emulator.getIntUnixTimestamp();
private int stayStartedAt = 0;
private int idleCommandTicks = 0; private int idleCommandTicks = 0;
private int freeCommandTicks = -1; private int freeCommandTicks = -1;
@ -276,6 +277,11 @@ public class Pet implements ISerialize, Runnable {
this.tickTimeout = time; this.tickTimeout = time;
} }
if (this.task == PetTasks.STAY && Emulator.getIntUnixTimestamp() - this.stayStartedAt >= 120) {
this.task = null;
this.getRoomUnit().setCanWalk(true);
}
} else { } else {
int timeout = Emulator.getRandom().nextInt(10) * 2; int timeout = Emulator.getRandom().nextInt(10) * 2;
this.roomUnit.setWalkTimeOut(timeout < 20 ? 20 + time : timeout + time); 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) { public void handleCommand(PetCommand command, Habbo habbo, String[] data) {
this.idleCommandTicks = 0; this.idleCommandTicks = 0;
if (this.task == PetTasks.STAY) {
this.stayStartedAt = 0;
this.task = null;
this.getRoomUnit().setCanWalk(true);
}
command.handle(this, habbo, data); command.handle(this, habbo, data);
@ -731,4 +743,12 @@ public class Pet implements ISerialize, Runnable {
this.room = null; this.room = null;
this.needsUpdate = true; this.needsUpdate = true;
} }
public int getStayStartedAt() {
return stayStartedAt;
}
public void setStayStartedAt(int stayStartedAt) {
this.stayStartedAt = stayStartedAt;
}
} }

View File

@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.pets.actions; 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.Pet;
import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetAction;
import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.pets.PetTasks;
@ -20,7 +21,7 @@ public class ActionStay extends PetAction {
pet.clearPosture(); pet.clearPosture();
pet.getRoomUnit().setCanWalk(false); pet.getRoomUnit().setCanWalk(false);
pet.setStayStartedAt(Emulator.getIntUnixTimestamp());
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
return true; return true;