mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 08:50:51 +01:00
Merge branch 'vuln-monsterplant' into 'dev'
Added RateLimit to ScratchPetEvent See merge request morningstar/Arcturus-Community!208
This commit is contained in:
commit
f4fd43eb89
@ -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() {
|
||||||
|
@ -5,19 +5,23 @@ import com.eu.habbo.habbohotel.pets.Pet;
|
|||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
|
||||||
public class ScratchPetEvent extends MessageHandler {
|
public class ScratchPetEvent extends MessageHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
int petId = this.packet.readInt();
|
final int petId = this.packet.readInt();
|
||||||
|
|
||||||
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null)
|
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId);
|
final Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId);
|
||||||
|
|
||||||
|
if (pet == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
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