From 1638dcb75853bad83dfb940b13810ac7afc0acb6 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Sun, 30 Jun 2019 21:05:03 +0100 Subject: [PATCH] Fixed Pet Levelling. --- .../com/eu/habbo/habbohotel/pets/Pet.java | 26 +++++++++---------- .../eu/habbo/habbohotel/pets/PetManager.java | 3 ++- 2 files changed, 15 insertions(+), 14 deletions(-) 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 35275e72..29240ad9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -518,7 +518,7 @@ public class Pet implements ISerialize, Runnable { if (this.room != null) { this.room.sendComposer(new RoomPetExperienceComposer(this, amount).compose()); - if (this.level < PetManager.experiences.length + 1 && this.experience >= PetManager.experiences[this.level - 1]) { + if(this.level < PetManager.experiences.length + 1 && this.experience >= PetManager.experiences[this.level - 1]) { this.levelUp(); } } @@ -526,20 +526,20 @@ public class Pet implements ISerialize, Runnable { protected void levelUp() { - if (this.level >= PetManager.experiences.length) - return; + if (this.level >= PetManager.experiences.length + 1) + return; - if (this.experience < PetManager.experiences[this.level]) { - this.experience = PetManager.experiences[this.level]; + if (this.experience > PetManager.experiences[this.level - 1]) { + this.experience = PetManager.experiences[this.level - 1]; + } + this.level++; + this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP)); + this.addHappyness(100); + this.roomUnit.setStatus(RoomUnitStatus.GESTURE, "exp"); + this.gestureTickTimeout = Emulator.getIntUnixTimestamp(); + AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp")); + this.room.sendComposer(new PetLevelUpdatedComposer(this).compose()); } - this.level++; - this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP)); - this.addHappyness(100); - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.LVLUP.getKey()); - this.gestureTickTimeout = Emulator.getIntUnixTimestamp(); - AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp")); - this.room.sendComposer(new PetLevelUpdatedComposer(this).compose()); - } public void addThirst(int amount) { diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java index 82301279..d4079923 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -83,7 +83,7 @@ public class PetManager { } public static int getLevel(int experience) { - int index = 0; + int index = -1; for (int i = 0; i < experiences.length; i++) { if (experiences[i] > experience) { @@ -92,6 +92,7 @@ public class PetManager { } } + if(index == -1) { index = experiences.length; } return index + 1; }