mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 07:20:50 +01:00
Totems
This commit is contained in:
parent
45e52f165b
commit
ab6d1ccac6
@ -38,6 +38,9 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.bunnyrun.Interaction
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagField;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagPole;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.rollerskate.InteractionRollerskateField;
|
||||
import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemHead;
|
||||
import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemLegs;
|
||||
import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemPlanet;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.conditions.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.effects.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
|
||||
@ -357,6 +360,10 @@ public class ItemManager {
|
||||
this.interactionsList.add(new ItemInteraction("snowstorm_pile", null));
|
||||
|
||||
this.interactionsList.add(new ItemInteraction("vote_counter", InteractionVoteCounter.class));
|
||||
|
||||
this.interactionsList.add(new ItemInteraction("totem_leg", InteractionTotemLegs.class));
|
||||
this.interactionsList.add(new ItemInteraction("totem_head", InteractionTotemHead.class));
|
||||
this.interactionsList.add(new ItemInteraction("totem_planet", InteractionTotemPlanet.class));
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,85 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.totems;
|
||||
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionTotemHead extends InteractionDefault {
|
||||
|
||||
public InteractionTotemHead(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
|
||||
public InteractionTotemHead(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
public TotemType getTotemType() {
|
||||
int extraData = Integer.parseInt(this.getExtradata());
|
||||
if(extraData < 3) {
|
||||
return TotemType.fromInt(extraData + 1);
|
||||
}
|
||||
return TotemType.fromInt((int)Math.ceil((extraData - 2) / 4.0f));
|
||||
}
|
||||
|
||||
public TotemColor getTotemColor() {
|
||||
int extraData = Integer.parseInt(this.getExtradata());
|
||||
if(extraData < 3) {
|
||||
return TotemColor.NONE;
|
||||
}
|
||||
return TotemColor.fromInt(extraData - 3 - (4 * (getTotemType().type - 1)));
|
||||
}
|
||||
|
||||
private void update(Room room, RoomTile tile) {
|
||||
InteractionTotemLegs legs = null;
|
||||
|
||||
for(HabboItem item : room.getItemsAt(tile)) {
|
||||
if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ())
|
||||
legs = (InteractionTotemLegs)item;
|
||||
}
|
||||
|
||||
if(legs == null)
|
||||
return;
|
||||
|
||||
this.setExtradata(((4 * this.getTotemType().type) + legs.getTotemColor().color) - 1 + "");
|
||||
}
|
||||
|
||||
public void updateTotemState(Room room) {
|
||||
updateTotemState(room, room.getLayout().getTile(this.getX(), this.getY()));
|
||||
}
|
||||
|
||||
public void updateTotemState(Room room, RoomTile tile) {
|
||||
this.setExtradata(getTotemType().type - 1 + "");
|
||||
update(room, tile);
|
||||
this.needsUpdate(true);
|
||||
room.updateItem(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
|
||||
return;
|
||||
|
||||
TotemType newType = TotemType.fromInt(getTotemType().type + 1);
|
||||
if(newType == TotemType.NONE) {
|
||||
newType = TotemType.TROLL;
|
||||
}
|
||||
|
||||
this.setExtradata(newType.type - 1 + "");
|
||||
|
||||
updateTotemState(room);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||
super.onMove(room, oldLocation, newLocation);
|
||||
updateTotemState(room, newLocation);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.totems;
|
||||
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionTotemLegs extends InteractionDefault {
|
||||
public InteractionTotemLegs(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
|
||||
public InteractionTotemLegs(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
public TotemType getTotemType() {
|
||||
int extraData = Integer.parseInt(this.getExtradata());
|
||||
return TotemType.fromInt((int)Math.ceil((extraData + 1) / 4.0f));
|
||||
}
|
||||
|
||||
public TotemColor getTotemColor() {
|
||||
int extraData = Integer.parseInt(this.getExtradata());
|
||||
return TotemColor.fromInt(extraData - (4 * (getTotemType().type - 1)));
|
||||
}
|
||||
|
||||
private void updateHead(Room room, RoomTile tile) {
|
||||
for(HabboItem item : room.getItemsAt(tile)) {
|
||||
if(item instanceof InteractionTotemHead && item.getZ() > this.getZ())
|
||||
((InteractionTotemHead)item).updateTotemState(room);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
|
||||
return;
|
||||
|
||||
updateHead(room, room.getLayout().getTile(this.getX(), this.getY()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||
super.onMove(room, oldLocation, newLocation);
|
||||
|
||||
updateHead(room, oldLocation);
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.totems;
|
||||
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.users.inventory.EffectsComponent;
|
||||
import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionTotemPlanet extends InteractionDefault {
|
||||
public InteractionTotemPlanet(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
|
||||
public InteractionTotemPlanet(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
public TotemPlanetType getPlanetType() {
|
||||
int extraData = Integer.parseInt(this.getExtradata());
|
||||
return TotemPlanetType.fromInt(extraData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
InteractionTotemLegs legs = null;
|
||||
InteractionTotemHead head = null;
|
||||
|
||||
THashSet<HabboItem> items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY()));
|
||||
|
||||
for(HabboItem item : items) {
|
||||
if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ())
|
||||
legs = (InteractionTotemLegs)item;
|
||||
}
|
||||
|
||||
if(legs == null) {
|
||||
super.onClick(client, room, objects);
|
||||
return;
|
||||
}
|
||||
|
||||
for(HabboItem item : items) {
|
||||
if(item instanceof InteractionTotemHead && item.getZ() > legs.getZ())
|
||||
head = (InteractionTotemHead)item;
|
||||
}
|
||||
|
||||
if(head == null) {
|
||||
super.onClick(client, room, objects);
|
||||
return;
|
||||
}
|
||||
|
||||
int effectId = 0;
|
||||
|
||||
if(getPlanetType() == TotemPlanetType.SUN && head.getTotemType() == TotemType.BIRD && legs.getTotemType() == TotemType.BIRD && legs.getTotemColor() == TotemColor.RED) {
|
||||
effectId = 25;
|
||||
}
|
||||
else if(getPlanetType() == TotemPlanetType.EARTH && head.getTotemType() == TotemType.TROLL && legs.getTotemType() == TotemType.TROLL && legs.getTotemColor() == TotemColor.YELLOW) {
|
||||
effectId = 23;
|
||||
}
|
||||
else if(getPlanetType() == TotemPlanetType.EARTH && head.getTotemType() == TotemType.SNAKE && legs.getTotemType() == TotemType.BIRD && legs.getTotemColor() == TotemColor.YELLOW) {
|
||||
effectId = 26;
|
||||
}
|
||||
else if(getPlanetType() == TotemPlanetType.MOON && head.getTotemType() == TotemType.SNAKE && legs.getTotemType() == TotemType.SNAKE && legs.getTotemColor() == TotemColor.BLUE) {
|
||||
effectId = 24;
|
||||
}
|
||||
|
||||
if(effectId > 0) {
|
||||
if(client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) {
|
||||
client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId);
|
||||
return;
|
||||
}
|
||||
|
||||
client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId);
|
||||
client.sendResponse(new UserEffectsListComposer(client.getHabbo()));
|
||||
client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId);
|
||||
return;
|
||||
}
|
||||
|
||||
super.onClick(client, room, objects);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.totems;
|
||||
|
||||
public enum TotemColor {
|
||||
|
||||
NONE(0),
|
||||
RED(1),
|
||||
YELLOW(2),
|
||||
BLUE(3);
|
||||
|
||||
public final int color;
|
||||
|
||||
TotemColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public static TotemColor fromInt(int color) {
|
||||
for(TotemColor totemColor : TotemColor.values()) {
|
||||
if(totemColor.color == color)
|
||||
return totemColor;
|
||||
}
|
||||
|
||||
return NONE;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.totems;
|
||||
|
||||
public enum TotemPlanetType {
|
||||
MOON(0),
|
||||
SUN(1),
|
||||
EARTH(2);
|
||||
|
||||
public final int type;
|
||||
|
||||
TotemPlanetType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static TotemPlanetType fromInt(int type) {
|
||||
for(TotemPlanetType planetType : TotemPlanetType.values()) {
|
||||
if(planetType.type == type)
|
||||
return planetType;
|
||||
}
|
||||
|
||||
return MOON;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.totems;
|
||||
|
||||
public enum TotemType {
|
||||
|
||||
NONE(0),
|
||||
TROLL(1),
|
||||
SNAKE(2),
|
||||
BIRD(3);
|
||||
|
||||
public final int type;
|
||||
|
||||
TotemType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static TotemType fromInt(int type) {
|
||||
for(TotemType totemType : TotemType.values()) {
|
||||
if(totemType.type == type)
|
||||
return totemType;
|
||||
}
|
||||
|
||||
return NONE;
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ public class ToggleFloorItemEvent extends MessageHandler {
|
||||
if (item == null || item instanceof InteractionDice)
|
||||
return;
|
||||
|
||||
/*
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("totem_planet")) {
|
||||
THashSet<HabboItem> items = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
HabboItem totemLeg = null;
|
||||
@ -75,7 +76,7 @@ public class ToggleFloorItemEvent extends MessageHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//Do not move to onClick(). Wired could trigger it.
|
||||
if (item instanceof InteractionMonsterPlantSeed) {
|
||||
|
Loading…
Reference in New Issue
Block a user