mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Proper monster plant fix
This commit is contained in:
parent
54519ac4e4
commit
2e98d5d21c
@ -353,6 +353,19 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean mayScratch() {
|
||||||
|
// Monsterplant petting is available when:
|
||||||
|
// ((energy / max_energy) < 0.98) = true
|
||||||
|
// You can find the minimum deathTimestamp by solving (insert a timestamp for timestamp, solve for death_timestamp):
|
||||||
|
// (((death_timestamp - timestamp) / 259200)) < 0.98
|
||||||
|
// This information was found in the Habbo swf, com.sulake.habbo.ui.widget.infostand.InfoStandPetView.as
|
||||||
|
// this._Str_2304("pettreat", ((_local_3 / _local_4) < 0.98));
|
||||||
|
final float energy = this.getEnergy();
|
||||||
|
final float energyMax = this.getMaxEnergy();
|
||||||
|
|
||||||
|
return ((energy / energyMax) < 0.98);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxEnergy() {
|
public int getMaxEnergy() {
|
||||||
return MonsterplantPet.timeToLive;
|
return MonsterplantPet.timeToLive;
|
||||||
@ -368,7 +381,8 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scratched(Habbo habbo) {
|
public synchronized void scratched(Habbo habbo) {
|
||||||
|
if (this.mayScratch()) {
|
||||||
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantTreater"), 5);
|
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantTreater"), 5);
|
||||||
this.setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive);
|
this.setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive);
|
||||||
this.addHappyness(10);
|
this.addHappyness(10);
|
||||||
@ -376,6 +390,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
|||||||
this.room.sendComposer(new PetStatusUpdateComposer(this).compose());
|
this.room.sendComposer(new PetStatusUpdateComposer(this).compose());
|
||||||
this.room.sendComposer(new RoomPetRespectComposer(this, RoomPetRespectComposer.PET_TREATED).compose());
|
this.room.sendComposer(new RoomPetRespectComposer(this, RoomPetRespectComposer.PET_TREATED).compose());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canWalk() {
|
public boolean canWalk() {
|
||||||
|
@ -7,23 +7,21 @@ import com.eu.habbo.messages.incoming.MessageHandler;
|
|||||||
public class ScratchPetEvent extends MessageHandler {
|
public class ScratchPetEvent extends MessageHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRatelimit() {
|
public void handle() throws Exception {
|
||||||
return 1000;
|
final int petId = this.packet.readInt();
|
||||||
|
|
||||||
|
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
final Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId);
|
||||||
public void handle() throws Exception {
|
|
||||||
int petId = this.packet.readInt();
|
|
||||||
|
|
||||||
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null)
|
if (pet == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId);
|
|
||||||
|
|
||||||
if (pet != null) {
|
|
||||||
if (this.client.getHabbo().getHabboStats().petRespectPointsToGive > 0 || pet instanceof MonsterplantPet) {
|
if (this.client.getHabbo().getHabboStats().petRespectPointsToGive > 0 || pet instanceof MonsterplantPet) {
|
||||||
pet.scratched(this.client.getHabbo());
|
pet.scratched(this.client.getHabbo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user