Wired and Game Related Fixes.

Fixed Counters and timers, can now be triggered by any user walking on a furniture.
Fixed Wired Effect Move Furniture Towards
Fixed Game Wired
This commit is contained in:
KrewsOrg 2019-05-01 02:02:51 +01:00
parent 6f24103528
commit 8839edff47
4 changed files with 32 additions and 17 deletions

View File

@ -47,6 +47,8 @@ public abstract class Game implements Runnable
protected int endTime;
public boolean isRunning;
public GameState state = GameState.IDLE;
@ -149,6 +151,7 @@ public abstract class Game implements Runnable
public void start()
{
this.isRunning = false;
this.state = GameState.RUNNING;
this.startTime = Emulator.getIntUnixTimestamp();

View File

@ -31,11 +31,13 @@ public class GamePlayer
public synchronized void addScore(int amount)
{
this.score += amount;
WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, null, this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});
if (habbo.getHabboInfo().getGamePlayer() != null || this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null){
if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) {
this.score += amount;
WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});}
}
}
public Habbo getHabbo()
{
return this.habbo;

View File

@ -16,7 +16,7 @@ import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionGameTimer extends HabboItem
public abstract class InteractionGameTimer extends HabboItem
{
private int baseTime = 0;
private int lastToggle = 0;
@ -103,8 +103,10 @@ public class InteractionGameTimer extends HabboItem
if ((objects.length >= 2 && objects[1] instanceof WiredEffectType))
{
if (game.state.equals(GameState.RUNNING))
return;
if (game == null || !game.isRunning)
startGame(room);
else if (game.isRunning)
stopGame(room);
}
if(objects.length >= 1 && objects[0] instanceof Integer && client != null)
@ -210,7 +212,9 @@ public class InteractionGameTimer extends HabboItem
if(game != null && game.state != GameState.IDLE)
{
this.setExtradata(this.baseTime + "");
game.stop();
stopGame(room);
}
room.updateItem(this);
@ -254,10 +258,7 @@ public class InteractionGameTimer extends HabboItem
return this.getExtradata() + "\t" + this.baseTime;
}
public Class<? extends Game> getGameType()
{
return WiredGame.class;
}
public abstract Class<? extends Game> getGameType();
@Override
public boolean allowWiredResetState()

View File

@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTile;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -159,14 +161,21 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect
}
}
boolean validMove = true;
RoomTile newTile = room.getLayout().getTile((short) (item.getX() + x), (short) (item.getY() + y));
if (newTile != null && ((newTile.state == RoomTileState.OPEN && newTile.isWalkable()) || newTile.state == RoomTileState.BLOCKED && room.getTopItemAt(newTile.x, newTile.y) == item) && room.furnitureFitsAt(newTile, item, item.getRotation()) == FurnitureMovementError.NONE)
{
if (room.getLayout().tileExists(newTile.x, newTile.y))
{
room.slideFurniTo(item, newTile, item.getRotation());
if(room.getLayout().getTilesAt(newTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()) == null) {
validMove = false;
}
for(RoomTile t : room.getLayout().getTilesAt(newTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())) {
if ((item instanceof InteractionFreezeTile || item instanceof InteractionBattleBanzaiTile) && room.hasItemsAt(t.x, t.y)) {
validMove = false;
}
if (t == null || (t.state == RoomTileState.OPEN && !t.isWalkable()) || t.state == RoomTileState.BLOCKED || t.state == RoomTileState.INVALID || !room.furnitureFitsAt(t, item, item.getRotation()).equals(FurnitureMovementError.NONE) || !room.getLayout().tileExists(t.x, t.y)) {
validMove = false;
}
}
if(validMove) {
room.slideFurniTo(item, newTile, item.getRotation());
}
}
@ -283,4 +292,4 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect
{
return 495;
}
}
}