🍬 Added the cannon in the Emu
This commit is contained in:
parent
1016e6e68d
commit
36c26f72e8
@ -46,37 +46,42 @@ public class InteractionCannon extends HabboItem {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||||
if (client != null) {
|
|
||||||
super.onClick(client, room, objects);
|
super.onClick(client, room, objects);
|
||||||
}
|
|
||||||
|
|
||||||
if (room == null)
|
if (room == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
RoomTile tile = room.getLayout().getTile(this.getX(), this.getY());
|
RoomTile tile = room.getLayout().getTile(this.getX(), this.getY());
|
||||||
RoomTile fuseTile = this.getRotation() >= 4 ? tile : room.getLayout().getTileInFront(tile, ((this.getRotation() % 2) + 2) % 8);
|
RoomTile fuseTile = room.getLayout().getTileInFront(tile, this.getRotation());
|
||||||
List<RoomTile> tiles = room.getLayout().getTilesAround(fuseTile);
|
List<RoomTile> tiles = room.getLayout().getTilesAround(fuseTile);
|
||||||
tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + (this.getRotation() >= 4 ? -1 : 0)) % 8));
|
|
||||||
tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + (this.getRotation() >= 4 ? 5 : 4)) % 8));
|
|
||||||
|
|
||||||
if ((client == null || (tiles.contains(client.getHabbo().getRoomUnit().getCurrentLocation())) && client.getHabbo().getRoomUnit().canWalk()) && !this.cooldown) {
|
tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + 7) % 8));
|
||||||
if (client != null) {
|
tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + 5) % 8));
|
||||||
|
|
||||||
|
boolean conditionClient = (client != null);
|
||||||
|
boolean conditionTile = (tiles.contains(client != null ? client.getHabbo().getRoomUnit().getCurrentLocation() : null));
|
||||||
|
boolean conditionWalk = (client != null && client.getHabbo().getRoomUnit().canWalk());
|
||||||
|
|
||||||
|
if (!this.cooldown && conditionClient && conditionTile && conditionWalk) {
|
||||||
|
|
||||||
client.getHabbo().getRoomUnit().setCanWalk(false);
|
client.getHabbo().getRoomUnit().setCanWalk(false);
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(client.getHabbo().getRoomUnit().getCurrentLocation());
|
client.getHabbo().getRoomUnit().setGoalLocation(client.getHabbo().getRoomUnit().getCurrentLocation());
|
||||||
client.getHabbo().getRoomUnit().lookAtPoint(fuseTile);
|
client.getHabbo().getRoomUnit().lookAtPoint(fuseTile);
|
||||||
client.getHabbo().getRoomUnit().statusUpdate(true);
|
client.getHabbo().getRoomUnit().statusUpdate(true);
|
||||||
}
|
|
||||||
|
|
||||||
this.cooldown = true;
|
this.cooldown = true;
|
||||||
this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
|
this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
|
||||||
room.updateItemState(this);
|
room.updateItemState(this);
|
||||||
|
|
||||||
Emulator.getThreading().run(new CannonKickAction(this, room, client), 750);
|
Emulator.getThreading().run(new CannonKickAction(this, room, client), 750);
|
||||||
Emulator.getThreading().run(new CannonResetCooldownAction(this), 2000);
|
Emulator.getThreading().run(new CannonResetCooldownAction(this), 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.eu.habbo.messages.incoming.rooms.items;
|
package com.eu.habbo.messages.incoming.rooms.items;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.InteractionCannon;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionDice;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionDice;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionMonsterPlantSeed;
|
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionMonsterPlantSeed;
|
||||||
@ -34,7 +35,7 @@ public class ToggleFloorItemEvent extends MessageHandler {
|
|||||||
|
|
||||||
HabboItem item = room.getHabboItem(itemId);
|
HabboItem item = room.getHabboItem(itemId);
|
||||||
|
|
||||||
if (item == null || item instanceof InteractionDice)
|
if (item == null || (item instanceof InteractionDice && !(item instanceof InteractionCannon)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Event furnitureToggleEvent = new FurnitureToggleEvent(item, this.client.getHabbo(), state);
|
Event furnitureToggleEvent = new FurnitureToggleEvent(item, this.client.getHabbo(), state);
|
||||||
|
@ -26,15 +26,16 @@ public class CannonKickAction implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (this.client != null) {
|
if (this.client != null)
|
||||||
this.client.getHabbo().getRoomUnit().setCanWalk(true);
|
this.client.getHabbo().getRoomUnit().setCanWalk(true);
|
||||||
}
|
|
||||||
THashMap<String, String> dater = new THashMap<>();
|
THashMap<String, String> dater = new THashMap<>();
|
||||||
dater.put("title", "${notification.room.kick.cannonball.title}");
|
dater.put("title", "${notification.room.kick.cannonball.title}");
|
||||||
dater.put("message", "${notification.room.kick.cannonball.message}");
|
dater.put("message", "${notification.room.kick.cannonball.message}");
|
||||||
|
|
||||||
int rotation = this.cannon.getRotation();
|
int rotation = ((this.cannon.getRotation() - 2) + 8) % 8;
|
||||||
List<RoomTile> tiles = this.room.getLayout().getTilesInFront(this.room.getLayout().getTile(this.cannon.getX(), this.cannon.getY()), rotation + 6, 3);
|
int amount = (rotation == 2 || rotation == 4) ? 4 : 3;
|
||||||
|
List<RoomTile> tiles = this.room.getLayout().getTilesInFront(this.room.getLayout().getTile(this.cannon.getX(), this.cannon.getY()), rotation, amount);
|
||||||
|
|
||||||
ServerMessage message = new BubbleAlertComposer("cannon.png", dater).compose();
|
ServerMessage message = new BubbleAlertComposer("cannon.png", dater).compose();
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ public class CannonKickAction implements Runnable {
|
|||||||
for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) {
|
for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) {
|
||||||
if (!habbo.hasPermission(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) {
|
if (!habbo.hasPermission(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) {
|
||||||
Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room);
|
Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room);
|
||||||
habbo.getClient().sendResponse(message); //kicked composer
|
habbo.getClient().sendResponse(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user