Fixed Pet Levelling.

This commit is contained in:
KrewsOrg 2019-06-30 21:05:03 +01:00
parent c8b4848f49
commit 1638dcb758
2 changed files with 15 additions and 14 deletions

View File

@ -526,16 +526,16 @@ public class Pet implements ISerialize, Runnable {
protected void levelUp() {
if (this.level >= PetManager.experiences.length)
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, PetGestures.LVLUP.getKey());
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());

View File

@ -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;
}