mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 07:20:50 +01:00
Wired fixes
This commit is contained in:
parent
abc1c6905f
commit
01d1fefdff
@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.games.Game;
|
import com.eu.habbo.habbohotel.games.Game;
|
||||||
import com.eu.habbo.habbohotel.games.GameState;
|
import com.eu.habbo.habbohotel.games.GameState;
|
||||||
|
import com.eu.habbo.habbohotel.games.wired.WiredGame;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
@ -98,11 +99,15 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void endGame(Room room) {
|
public void endGame(Room room) {
|
||||||
|
endGame(room, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endGame(Room room, boolean isStart) {
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
this.isPaused = false;
|
this.isPaused = false;
|
||||||
|
|
||||||
for (Game game : room.getGames()) {
|
for (Game game : room.getGames()) {
|
||||||
if (!game.getState().equals(GameState.IDLE)) {
|
if (!game.getState().equals(GameState.IDLE) && !(isStart && game instanceof WiredGame)) {
|
||||||
game.onEnd();
|
game.onEnd();
|
||||||
game.stop();
|
game.stop();
|
||||||
}
|
}
|
||||||
@ -226,7 +231,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
boolean wasPaused = this.isPaused;
|
boolean wasPaused = this.isPaused;
|
||||||
this.endGame(room);
|
this.endGame(room, true);
|
||||||
|
|
||||||
if(wasPaused) {
|
if(wasPaused) {
|
||||||
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
|
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
|
||||||
|
@ -50,8 +50,8 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
boolean positionMatches = !this.position || (setting.x == item.getX() && setting.y == item.getY());
|
boolean positionMatches = !this.position || (setting.x == item.getX() && setting.y == item.getY());
|
||||||
boolean directionMatches = !this.rotation || setting.rotation == item.getRotation();
|
boolean directionMatches = !this.rotation || setting.rotation == item.getRotation();
|
||||||
|
|
||||||
if (stateMatches && positionMatches && directionMatches)
|
if (!stateMatches || !positionMatches || !directionMatches)
|
||||||
return false;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
s.add(setting);
|
s.add(setting);
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,7 +86,6 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
|||||||
room.moveFurniTo(entry.getKey(), targetTile, entry.getValue().rotation, null, true);
|
room.moveFurniTo(entry.getKey(), targetTile, entry.getValue().rotation, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetTile != null && targetTile.state != RoomTileState.INVALID && room.furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) {
|
|
||||||
boolean hasRoomUnits = false;
|
boolean hasRoomUnits = false;
|
||||||
THashSet<RoomTile> newOccupiedTiles = room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
THashSet<RoomTile> newOccupiedTiles = room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||||
for(RoomTile tile : newOccupiedTiles) {
|
for(RoomTile tile : newOccupiedTiles) {
|
||||||
@ -99,6 +98,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (targetTile != null && targetTile.state != RoomTileState.INVALID && room.furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) {
|
||||||
if (!hasRoomUnits) {
|
if (!hasRoomUnits) {
|
||||||
RoomTile oldLocation = room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY());
|
RoomTile oldLocation = room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY());
|
||||||
double oldZ = entry.getKey().getZ();
|
double oldZ = entry.getKey().getZ();
|
||||||
@ -243,7 +243,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
|||||||
private RoomUserRotation nextRotation(RoomUserRotation currentRotation) {
|
private RoomUserRotation nextRotation(RoomUserRotation currentRotation) {
|
||||||
switch (this.blockedAction) {
|
switch (this.blockedAction) {
|
||||||
case ACTION_TURN_BACK:
|
case ACTION_TURN_BACK:
|
||||||
return RoomUserRotation.fromValue(currentRotation.getValue() + 4);
|
return RoomUserRotation.fromValue(currentRotation.getValue()).getOpposite();
|
||||||
case ACTION_TURN_LEFT_45:
|
case ACTION_TURN_LEFT_45:
|
||||||
return RoomUserRotation.counterClockwise(currentRotation);
|
return RoomUserRotation.counterClockwise(currentRotation);
|
||||||
case ACTION_TURN_LEFT_90:
|
case ACTION_TURN_LEFT_90:
|
||||||
|
@ -2,32 +2,25 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
|
import com.eu.habbo.habbohotel.items.ICycleable;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionRoller;
|
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||||
import com.eu.habbo.habbohotel.rooms.*;
|
import com.eu.habbo.habbohotel.rooms.*;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
|
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
import org.apache.commons.math3.util.Pair;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implements ICycleable {
|
||||||
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMoveRotateFurni.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMoveRotateFurni.class);
|
||||||
|
|
||||||
@ -35,13 +28,16 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
|||||||
private final THashSet<HabboItem> items = new THashSet<>(WiredHandler.MAXIMUM_FURNI_SELECTION / 2);
|
private final THashSet<HabboItem> items = new THashSet<>(WiredHandler.MAXIMUM_FURNI_SELECTION / 2);
|
||||||
private int direction;
|
private int direction;
|
||||||
private int rotation;
|
private int rotation;
|
||||||
|
private THashSet<HabboItem> itemCooldowns;
|
||||||
|
|
||||||
public WiredEffectMoveRotateFurni(ResultSet set, Item baseItem) throws SQLException {
|
public WiredEffectMoveRotateFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
|
this.itemCooldowns = new THashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WiredEffectMoveRotateFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
public WiredEffectMoveRotateFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
|
this.itemCooldowns = new THashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,6 +46,9 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
|||||||
this.items.removeIf(item -> Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null);
|
this.items.removeIf(item -> Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null);
|
||||||
|
|
||||||
for (HabboItem item : this.items) {
|
for (HabboItem item : this.items) {
|
||||||
|
if(this.itemCooldowns.contains(item))
|
||||||
|
continue;
|
||||||
|
|
||||||
int newRotation = this.rotation > 0 ? this.getNewRotation(item) : item.getRotation();
|
int newRotation = this.rotation > 0 ? this.getNewRotation(item) : item.getRotation();
|
||||||
RoomTile newLocation = room.getLayout().getTile(item.getX(), item.getY());
|
RoomTile newLocation = room.getLayout().getTile(item.getX(), item.getY());
|
||||||
RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY());
|
RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY());
|
||||||
@ -68,6 +67,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
|||||||
FurnitureMovementError furniMoveTest = room.furnitureFitsAt(newLocation, item, newRotation, true);
|
FurnitureMovementError furniMoveTest = room.furnitureFitsAt(newLocation, item, newRotation, true);
|
||||||
if(newLocation != null && newLocation.state != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && (furniMoveTest == FurnitureMovementError.NONE || ((furniMoveTest == FurnitureMovementError.TILE_HAS_BOTS || furniMoveTest == FurnitureMovementError.TILE_HAS_HABBOS || furniMoveTest == FurnitureMovementError.TILE_HAS_PETS) && newLocation == oldLocation))) {
|
if(newLocation != null && newLocation.state != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && (furniMoveTest == FurnitureMovementError.NONE || ((furniMoveTest == FurnitureMovementError.TILE_HAS_BOTS || furniMoveTest == FurnitureMovementError.TILE_HAS_HABBOS || furniMoveTest == FurnitureMovementError.TILE_HAS_PETS) && newLocation == oldLocation))) {
|
||||||
if(room.furnitureFitsAt(newLocation, item, newRotation, false) == FurnitureMovementError.NONE && room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) {
|
if(room.furnitureFitsAt(newLocation, item, newRotation, false) == FurnitureMovementError.NONE && room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) {
|
||||||
|
this.itemCooldowns.add(item);
|
||||||
if(slideAnimation) {
|
if(slideAnimation) {
|
||||||
room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose());
|
room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose());
|
||||||
}
|
}
|
||||||
@ -298,4 +298,9 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
return movemementDirection;
|
return movemementDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cycle(Room room) {
|
||||||
|
this.itemCooldowns.clear();
|
||||||
|
}
|
||||||
}
|
}
|
@ -68,6 +68,9 @@ public class WiredHandler {
|
|||||||
if (triggers == null || triggers.isEmpty())
|
if (triggers == null || triggers.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
long millis = System.currentTimeMillis();
|
||||||
|
THashSet<InteractionWiredEffect> effectsToExecute = new THashSet<InteractionWiredEffect>();
|
||||||
|
|
||||||
List<RoomTile> triggeredTiles = new ArrayList<>();
|
List<RoomTile> triggeredTiles = new ArrayList<>();
|
||||||
for (InteractionWiredTrigger trigger : triggers) {
|
for (InteractionWiredTrigger trigger : triggers) {
|
||||||
RoomTile tile = room.getLayout().getTile(trigger.getX(), trigger.getY());
|
RoomTile tile = room.getLayout().getTile(trigger.getX(), trigger.getY());
|
||||||
@ -75,7 +78,11 @@ public class WiredHandler {
|
|||||||
if (triggeredTiles.contains(tile))
|
if (triggeredTiles.contains(tile))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (handle(trigger, roomUnit, room, stuff)) {
|
THashSet<InteractionWiredEffect> tEffectsToExecute = new THashSet<InteractionWiredEffect>();
|
||||||
|
|
||||||
|
if (handle(trigger, roomUnit, room, stuff, tEffectsToExecute)) {
|
||||||
|
effectsToExecute.addAll(tEffectsToExecute);
|
||||||
|
|
||||||
if (triggerType.equals(WiredTriggerType.SAY_SOMETHING))
|
if (triggerType.equals(WiredTriggerType.SAY_SOMETHING))
|
||||||
talked = true;
|
talked = true;
|
||||||
|
|
||||||
@ -83,12 +90,14 @@ public class WiredHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (InteractionWiredEffect effect : effectsToExecute) {
|
||||||
|
triggerEffect(effect, roomUnit, room, stuff, millis);
|
||||||
|
}
|
||||||
|
|
||||||
return talked;
|
return talked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleCustomTrigger(Class<? extends InteractionWiredTrigger> triggerType, RoomUnit roomUnit, Room room, Object[] stuff) {
|
public static boolean handleCustomTrigger(Class<? extends InteractionWiredTrigger> triggerType, RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||||
boolean talked = false;
|
|
||||||
|
|
||||||
if (!Emulator.isReady)
|
if (!Emulator.isReady)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -106,6 +115,9 @@ public class WiredHandler {
|
|||||||
if (triggers == null || triggers.isEmpty())
|
if (triggers == null || triggers.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
long millis = System.currentTimeMillis();
|
||||||
|
THashSet<InteractionWiredEffect> effectsToExecute = new THashSet<InteractionWiredEffect>();
|
||||||
|
|
||||||
List<RoomTile> triggeredTiles = new ArrayList<>();
|
List<RoomTile> triggeredTiles = new ArrayList<>();
|
||||||
for (InteractionWiredTrigger trigger : triggers) {
|
for (InteractionWiredTrigger trigger : triggers) {
|
||||||
if (trigger.getClass() != triggerType) continue;
|
if (trigger.getClass() != triggerType) continue;
|
||||||
@ -115,15 +127,35 @@ public class WiredHandler {
|
|||||||
if (triggeredTiles.contains(tile))
|
if (triggeredTiles.contains(tile))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (handle(trigger, roomUnit, room, stuff)) {
|
THashSet<InteractionWiredEffect> tEffectsToExecute = new THashSet<InteractionWiredEffect>();
|
||||||
|
|
||||||
|
if (handle(trigger, roomUnit, room, stuff, tEffectsToExecute)) {
|
||||||
|
effectsToExecute.addAll(tEffectsToExecute);
|
||||||
triggeredTiles.add(tile);
|
triggeredTiles.add(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return talked;
|
for (InteractionWiredEffect effect : effectsToExecute) {
|
||||||
|
triggerEffect(effect, roomUnit, room, stuff, millis);
|
||||||
|
}
|
||||||
|
|
||||||
|
return effectsToExecute.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handle(InteractionWiredTrigger trigger, final RoomUnit roomUnit, final Room room, final Object[] stuff) {
|
public static boolean handle(InteractionWiredTrigger trigger, final RoomUnit roomUnit, final Room room, final Object[] stuff) {
|
||||||
|
long millis = System.currentTimeMillis();
|
||||||
|
THashSet<InteractionWiredEffect> effectsToExecute = new THashSet<InteractionWiredEffect>();
|
||||||
|
|
||||||
|
if(handle(trigger, roomUnit, room, stuff, effectsToExecute)) {
|
||||||
|
for (InteractionWiredEffect effect : effectsToExecute) {
|
||||||
|
triggerEffect(effect, roomUnit, room, stuff, millis);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean handle(InteractionWiredTrigger trigger, final RoomUnit roomUnit, final Room room, final Object[] stuff, final THashSet<InteractionWiredEffect> effectsToExecute) {
|
||||||
long millis = System.currentTimeMillis();
|
long millis = System.currentTimeMillis();
|
||||||
if (Emulator.isReady && trigger.canExecute(millis) && trigger.execute(roomUnit, room, stuff)) {
|
if (Emulator.isReady && trigger.canExecute(millis) && trigger.execute(roomUnit, room, stuff)) {
|
||||||
trigger.activateBox(room);
|
trigger.activateBox(room);
|
||||||
@ -173,13 +205,13 @@ public class WiredHandler {
|
|||||||
if (extra instanceof WiredExtraUnseen) {
|
if (extra instanceof WiredExtraUnseen) {
|
||||||
extra.setExtradata(extra.getExtradata().equals("1") ? "0" : "1");
|
extra.setExtradata(extra.getExtradata().equals("1") ? "0" : "1");
|
||||||
InteractionWiredEffect effect = ((WiredExtraUnseen) extra).getUnseenEffect(effectList);
|
InteractionWiredEffect effect = ((WiredExtraUnseen) extra).getUnseenEffect(effectList);
|
||||||
triggerEffect(effect, roomUnit, room, stuff, millis);
|
effectsToExecute.add(effect); // triggerEffect(effect, roomUnit, room, stuff, millis);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (final InteractionWiredEffect effect : effectList) {
|
for (final InteractionWiredEffect effect : effectList) {
|
||||||
boolean executed = triggerEffect(effect, roomUnit, room, stuff, millis);
|
boolean executed = effectsToExecute.add(effect); //triggerEffect(effect, roomUnit, room, stuff, millis);
|
||||||
if (hasExtraRandom && executed) {
|
if (hasExtraRandom && executed) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user