Merge branch 'fix-games' into 'ms4/dev'

Fix GymEquipment, Freeze, BattleBanzai and Wired game effects

See merge request morningstar/Arcturus-Community!1
This commit is contained in:
brenoepic 2022-12-21 14:06:41 +00:00
commit 9516e25da7
8 changed files with 207 additions and 39 deletions

View File

@ -4,8 +4,13 @@ import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.GamePlayer;
import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
public class BattleBanzaiGameTeam extends GameTeam {
public BattleBanzaiGameTeam(GameTeamColors teamColor) {
@ -15,21 +20,51 @@ public class BattleBanzaiGameTeam extends GameTeam {
@Override
public void addMember(GamePlayer gamePlayer) {
super.addMember(gamePlayer);
RoomUnit roomUnit = gamePlayer.getHabbo().getRoomUnit();
if (roomUnit.getEffectId() > 0)
roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), BattleBanzaiGame.effectId + this.teamColor.type, -1);
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), BattleBanzaiGame.effectId + this.teamColor.type, -1, true);
}
@Override
public void removeMember(GamePlayer gamePlayer) {
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(gamePlayer.getHabbo().getHabboInfo().getCurrentGame());
Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
super.removeMember(gamePlayer);
if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getHabboInfo().getCurrentRoom() == null)
return;
if (room != null && room.getRoomSpecialTypes() != null) {
Habbo habbo = gamePlayer.getHabbo();
Game game = habbo.getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
RoomUnit roomUnit = habbo.getRoomUnit();
Room room = roomUnit.getRoom();
if(room == null) return;
HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y);
int nextEffectM = 0;
int nextEffectF = 0;
int nextEffectDuration = -1;
if (topItem != null) {
nextEffectM = topItem.getBaseItem().getEffectM();
nextEffectF = topItem.getBaseItem().getEffectF();
} else if (roomUnit.getPreviousEffectId() > 0) {
nextEffectF = roomUnit.getPreviousEffectId();
nextEffectM = roomUnit.getPreviousEffectId();
nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
}
roomUnit.setCanWalk(true);
if (room.getRoomSpecialTypes() != null) {
for (InteractionGameGate gate : room.getRoomSpecialTypes().getBattleBanzaiGates().values()) {
gate.updateState(game, 5);
}

View File

@ -15,7 +15,7 @@ import java.util.Map;
public class FootballGame extends Game {
private Room room;
private final Room room;
public FootballGame(Room room) {
super(null, null, room, true);

View File

@ -210,6 +210,6 @@ public class FreezeGamePlayer extends GamePlayer {
if (this.dead)
return;
super.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(super.getHabbo(), this.correctEffectId(), -1);
super.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(super.getHabbo(), this.correctEffectId(), -1, true);
}
}

View File

@ -6,6 +6,11 @@ import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
public class FreezeGameTeam extends GameTeam {
public FreezeGameTeam(GameTeamColors teamColor) {
@ -14,17 +19,42 @@ public class FreezeGameTeam extends GameTeam {
@Override
public void removeMember(GamePlayer gamePlayer) {
if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getHabboInfo().getCurrentRoom() == null) return;
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
super.removeMember(gamePlayer);
if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getHabboInfo().getCurrentRoom() == null)
return;
if (room != null && room.getRoomSpecialTypes() != null) {
Habbo habbo = gamePlayer.getHabbo();
Game game = habbo.getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
RoomUnit roomUnit = habbo.getRoomUnit();
Room room = roomUnit.getRoom();
if(room == null) return;
HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y);
int nextEffectM = 0;
int nextEffectF = 0;
int nextEffectDuration = -1;
if (topItem != null) {
nextEffectM = topItem.getBaseItem().getEffectM();
nextEffectF = topItem.getBaseItem().getEffectF();
} else if (roomUnit.getPreviousEffectId() > 0) {
nextEffectF = roomUnit.getPreviousEffectId();
nextEffectM = roomUnit.getPreviousEffectId();
nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
}
roomUnit.setCanWalk(true);
if (room.getRoomSpecialTypes() != null) {
for (InteractionGameGate gate : room.getRoomSpecialTypes().getFreezeGates().values()) {
gate.updateState(game, 5);
}
@ -35,6 +65,9 @@ public class FreezeGameTeam extends GameTeam {
public void addMember(GamePlayer gamePlayer) {
super.addMember(gamePlayer);
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), FreezeGame.effectId + this.teamColor.type, -1);
RoomUnit roomUnit = gamePlayer.getHabbo().getRoomUnit();
if (roomUnit.getEffectId() > 0)
roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), FreezeGame.effectId + this.teamColor.type, -1, true);
}
}

View File

@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -129,6 +130,7 @@ public abstract class TagGame extends Game {
public synchronized boolean addHabbo(Habbo habbo, GameTeamColors teamColor) {
super.addHabbo(habbo, GameTeamColors.RED);
RoomUnit roomUnit = habbo.getRoomUnit();
if (this.getTagPole() != null) {
THashSet<HabboItem> poles = habbo.getHabboInfo().getCurrentRoom().getRoomSpecialTypes().getItemsOfType(this.getTagPole());
@ -140,22 +142,27 @@ public abstract class TagGame extends Game {
TObjectHashIterator<HabboItem> iterator = poles.iterator();
if ((iterator.hasNext())) {
HabboItem item = iterator.next();
habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1);
this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1));
if (roomUnit.getEffectId() > 0)
roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1, true);
this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true));
this.taggers.put(habbo, (InteractionTagPole) item);
return true;
}
}
} else {
if (this.taggers.isEmpty()) {
habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1);
this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1));
if (roomUnit.getEffectId() > 0)
roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1, true);
this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true));
this.taggers.put(habbo, null);
return true;
}
}
habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1);
if (roomUnit.getEffectId() > 0)
roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1, true);
return true;
}
@ -164,7 +171,33 @@ public abstract class TagGame extends Game {
public synchronized void removeHabbo(Habbo habbo) {
super.removeHabbo(habbo);
this.taggers.remove(habbo);
habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, 0, -1);
RoomUnit roomUnit = habbo.getRoomUnit();
Room room = roomUnit.getRoom();
if (room == null) return;
HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y);
int nextEffectM = 0;
int nextEffectF = 0;
int nextEffectDuration = -1;
if (topItem != null) {
nextEffectM = topItem.getBaseItem().getEffectM();
nextEffectF = topItem.getBaseItem().getEffectF();
} else if (roomUnit.getPreviousEffectId() > 0) {
nextEffectF = roomUnit.getPreviousEffectId();
nextEffectM = roomUnit.getPreviousEffectId();
nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
}
}
@Override

View File

@ -3,7 +3,10 @@ package com.eu.habbo.habbohotel.games.wired;
import com.eu.habbo.habbohotel.games.*;
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
public class WiredGame extends Game {
public GameState state = GameState.RUNNING;
@ -28,14 +31,42 @@ public class WiredGame extends Game {
@Override
public boolean addHabbo(Habbo habbo, GameTeamColors teamColor) {
this.room.giveEffect(habbo, FreezeGame.effectId + teamColor.type, -1);
RoomUnit roomUnit = habbo.getRoomUnit();
if (roomUnit.getEffectId() > 0)
roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
this.room.giveEffect(habbo, FreezeGame.effectId + teamColor.type, -1, true);
return super.addHabbo(habbo, teamColor);
}
@Override
public void removeHabbo(Habbo habbo) {
super.removeHabbo(habbo);
this.room.giveEffect(habbo, 0, -1);
RoomUnit roomUnit = habbo.getRoomUnit();
Room room = this.room;
if (room == null) return;
HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y);
int nextEffectM = 0;
int nextEffectF = 0;
int nextEffectDuration = -1;
if (topItem != null) {
nextEffectM = topItem.getBaseItem().getEffectM();
nextEffectF = topItem.getBaseItem().getEffectF();
} else if (roomUnit.getPreviousEffectId() > 0) {
nextEffectF = roomUnit.getPreviousEffectId();
nextEffectM = roomUnit.getPreviousEffectId();
nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
}
}
@Override

View File

@ -7,6 +7,8 @@ import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -55,13 +57,40 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
@Override
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
room.giveEffect(roomUnit, 0, -1);
if (this.forceRotation()) {
roomUnit.canRotate = true;
}
if (room == null) return;
this.reset(room);
if (roomUnit != null) {
Habbo habbo = room.getHabbo(roomUnit);
HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y);
int nextEffectM = 0;
int nextEffectF = 0;
int nextEffectDuration = -1;
if (topItem != null) {
nextEffectM = topItem.getBaseItem().getEffectM();
nextEffectF = topItem.getBaseItem().getEffectF();
} else if (roomUnit.getPreviousEffectId() > 0) {
nextEffectF = roomUnit.getPreviousEffectId();
nextEffectM = roomUnit.getPreviousEffectId();
nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
}
if (this.forceRotation()) {
roomUnit.canRotate = true;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
}
}
}
public String achievementName() {

View File

@ -4161,27 +4161,34 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
}
public void giveEffect(Habbo habbo, int effectId, int duration) {
if (this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) {
this.giveEffect(habbo.getRoomUnit(), effectId, duration);
public void giveEffect(Habbo habbo, int effectId, int duration, boolean ignoreChecks) {
if (habbo != null && habbo.getRoomUnit() != null && this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) {
this.giveEffect(habbo.getRoomUnit(), effectId, duration, ignoreChecks);
}
}
public void giveEffect(Habbo habbo, int effectId, int duration) {
if (habbo != null && habbo.getRoomUnit() != null && this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) {
this.giveEffect(habbo.getRoomUnit(), effectId, duration, false);
}
}
public void giveEffect(RoomUnit roomUnit, int effectId, int duration) {
this.giveEffect(roomUnit, effectId, duration, false);
}
public void giveEffect(RoomUnit roomUnit, int effectId, int duration, boolean ignoreChecks) {
if (roomUnit == null || roomUnit.getRoom() == null) return;
Habbo habbo = roomUnit.getRoom().getHabbo(roomUnit);
if (habbo == null) return;
if (!habbo.getHabboInfo().isInGame()) {
if (!habbo.getHabboInfo().isInGame() || ignoreChecks) {
if (duration == -1 || duration == Integer.MAX_VALUE) {
duration = Integer.MAX_VALUE;
} else {
duration += Emulator.getIntUnixTimestamp();
}
if (this.allowEffects && !roomUnit.isSwimming) {
if ((this.allowEffects || ignoreChecks) && !roomUnit.isSwimming) {
roomUnit.setEffectId(effectId, duration);
this.sendComposer(new AvatarEffectMessageComposer(roomUnit).compose());
}