diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomCycleManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomCycleManager.java index 49e1639a..33e1cde8 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomCycleManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomCycleManager.java @@ -435,11 +435,11 @@ public class RoomCycleManager { if (!unit.isWalking() && !unit.cmdSit) { // Don't override special pet statuses with SIT - boolean hasSpecialPetStatus = unit.hasStatus(RoomUnitStatus.HANG) - || unit.hasStatus(RoomUnitStatus.SWING) - || unit.hasStatus(RoomUnitStatus.FLAME) - || unit.hasStatus(RoomUnitStatus.PLAY); - + boolean hasSpecialPetStatus = unit.hasStatus(RoomUnitStatus.HANG) + || unit.hasStatus(RoomUnitStatus.SWING) + || unit.hasStatus(RoomUnitStatus.FLAME) + || unit.hasStatus(RoomUnitStatus.PLAY); + RoomTile thisTile = this.room.getLayout().getTile(unit.getX(), unit.getY()); HabboItem topItem = this.room.getTallestChair(thisTile); @@ -473,12 +473,16 @@ public class RoomCycleManager { BedProfile bedProfile = new BedProfile(topItem); double layHeight = Item.getCurrentHeight(topItem) * 1.0D + bedProfile.getLayZOffset(); LOGGER.info("[BedProfile] item={} stackHeight={} isFlat={} isDouble={} X={} Y={} Z={}", - topItem.getBaseItem().getName(), topItem.getBaseItem().getHeight(), - bedProfile.isFlat(), bedProfile.isDouble(), - bedProfile.getLayXOffset(), bedProfile.getLayYOffset(), bedProfile.getLayZOffset()); + topItem.getBaseItem().getName(), topItem.getBaseItem().getHeight(), + bedProfile.isFlat(), bedProfile.isDouble(), + bedProfile.getLayXOffset(), bedProfile.getLayYOffset(), bedProfile.getLayZOffset()); unit.setStatus(RoomUnitStatus.LAY, layHeight + ";" + bedProfile.getLayXOffset() + ";" + bedProfile.getLayYOffset()); unit.setRotation(RoomUserRotation.values()[topItem.getRotation() % 4]); unit.setLocation(bedProfile.snapToLay(this.room, topItem, unit.getX(), unit.getY())); + + // Check love effect when a user enters a bed + this.room.getUnitManager().checkBedLoveEffect(topItem); + update = true; } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java index 70fcd4ba..9ac9c726 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.core.WiredManager; import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorMessagesComposer; @@ -42,6 +43,7 @@ import java.util.stream.Collectors; */ public class RoomUnitManager { private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnitManager.class); + static final int BED_LOVE_EFFECT_ID = 9; private final Room room; @@ -420,6 +422,10 @@ public class RoomUnitManager { } this.room.sendComposer(new RoomUserStatusComposer(roomUnits, true).compose()); } + + if (topItem != null && topItem.getBaseItem().allowLay()) { + this.checkBedLoveEffect(topItem); + } } // ==================== HABBO QUEUE ==================== @@ -1164,6 +1170,31 @@ public class RoomUnitManager { } } + public void checkBedLoveEffect(HabboItem bed) { + if (bed == null || !bed.getBaseItem().allowLay()) return; + + BedProfile bedProfile = new BedProfile(bed); + if (!bedProfile.isDouble()) return; + + THashSet habbosOnBed = this.getHabbosOnItem(bed); + + Habbo male = null; + Habbo female = null; + for (Habbo h : habbosOnBed) { + if (h.getRoomUnit() == null || !h.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) continue; + if (h.getHabboInfo().getGender() == HabboGender.M && male == null) { + male = h; + } else if (h.getHabboInfo().getGender() == HabboGender.F && female == null) { + female = h; + } + } + + if (male != null && female != null) { + this.giveEffect(male.getRoomUnit(), BED_LOVE_EFFECT_ID, 5); + this.giveEffect(female.getRoomUnit(), BED_LOVE_EFFECT_ID, 5); + } + } + /** * Gives a hand item to a Habbo. */