mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Trampoline interaction
This commit is contained in:
parent
c8d3308523
commit
7fef24fa85
@ -134,6 +134,7 @@ public class ItemManager {
|
||||
this.interactionsList.add(new ItemInteraction("pet_food", InteractionPetFood.class));
|
||||
this.interactionsList.add(new ItemInteraction("pet_toy", InteractionPetToy.class));
|
||||
this.interactionsList.add(new ItemInteraction("pet_tree", InteractionPetTree.class));
|
||||
this.interactionsList.add(new ItemInteraction("pet_trampoline", InteractionPetTrampoline.class));
|
||||
this.interactionsList.add(new ItemInteraction("breeding_nest", InteractionPetBreedingNest.class));
|
||||
this.interactionsList.add(new ItemInteraction("obstacle", InteractionObstacle.class));
|
||||
this.interactionsList.add(new ItemInteraction("monsterplant_seed", InteractionMonsterPlantSeed.class));
|
||||
|
@ -0,0 +1,102 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.pets;
|
||||
|
||||
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.InteractionDefault;
|
||||
import com.eu.habbo.habbohotel.pets.Pet;
|
||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.threading.runnables.PetClearPosture;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionPetTrampoline extends InteractionDefault {
|
||||
public InteractionPetTrampoline(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.setExtradata("0");
|
||||
}
|
||||
|
||||
public InteractionPetTrampoline(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
this.setExtradata("0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) {}
|
||||
|
||||
@Override
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||
this.setExtradata("0");
|
||||
room.updateItem(this);
|
||||
|
||||
for (Pet pet : room.getPetsAt(oldLocation)) {
|
||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP);
|
||||
pet.packetUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp(Room room) {
|
||||
this.setExtradata("0");
|
||||
|
||||
for (Pet pet : room.getPetsOnItem(this)) {
|
||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP);
|
||||
pet.packetUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
|
||||
Pet pet = room.getPet(roomUnit);
|
||||
|
||||
if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoal())) {
|
||||
if (pet.getEnergy() <= 35) {
|
||||
return;
|
||||
}
|
||||
|
||||
pet.clearPosture();
|
||||
pet.setTask(PetTasks.JUMP);
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.JUMP, "");
|
||||
Emulator.getThreading().run(() -> {
|
||||
new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false);
|
||||
pet.getRoomUnit().setGoalLocation(room.getRandomWalkableTile());
|
||||
this.setExtradata("0");
|
||||
room.updateItemState(this);
|
||||
}, 4000);
|
||||
pet.addHappyness(25);
|
||||
|
||||
this.setExtradata("1");
|
||||
room.updateItemState(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOff(roomUnit, room, objects);
|
||||
|
||||
Pet pet = room.getPet(roomUnit);
|
||||
|
||||
if (pet != null) {
|
||||
this.setExtradata("0");
|
||||
room.updateItem(this);
|
||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP);
|
||||
pet.packetUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
Pet pet = room.getPet(roomUnit);
|
||||
return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowWiredResetState() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -389,9 +389,7 @@ public class Pet implements ISerialize, Runnable {
|
||||
keys.put(RoomUnitStatus.GESTURE, this.roomUnit.getStatus(RoomUnitStatus.GESTURE));
|
||||
|
||||
if (this.task == null) {
|
||||
boolean isDead = false;
|
||||
if (this.roomUnit.hasStatus(RoomUnitStatus.RIP))
|
||||
isDead = true;
|
||||
boolean isDead = this.roomUnit.hasStatus(RoomUnitStatus.RIP);
|
||||
|
||||
this.roomUnit.clearStatus();
|
||||
|
||||
@ -505,8 +503,8 @@ public class Pet implements ISerialize, Runnable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean findTree(PetTasks task) {
|
||||
HabboItem item = this.petData.randomTreeItem(this.room.getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class));
|
||||
public boolean findPetItem(PetTasks task, Class<? extends HabboItem> type) {
|
||||
HabboItem item = this.petData.randomToyHabboItem(this.room.getRoomSpecialTypes().getItemsOfType(type));
|
||||
|
||||
if (item != null) {
|
||||
this.roomUnit.setCanWalk(true);
|
||||
|
@ -230,18 +230,18 @@ public class PetData implements Comparable<PetData> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public HabboItem randomTreeItem(THashSet<HabboItem> trees) {
|
||||
List<HabboItem> treeList = new ArrayList<>();
|
||||
public HabboItem randomToyHabboItem(THashSet<HabboItem> items) {
|
||||
List<HabboItem> itemList = new ArrayList<>();
|
||||
|
||||
for (HabboItem tree : trees) {
|
||||
if (this.haveToyItem(tree)) {
|
||||
treeList.add(tree);
|
||||
for (HabboItem item : items) {
|
||||
if (this.haveToyItem(item)) {
|
||||
itemList.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (!treeList.isEmpty()) {
|
||||
Collections.shuffle(treeList);
|
||||
return treeList.get(0);
|
||||
if (!itemList.isEmpty()) {
|
||||
Collections.shuffle(itemList);
|
||||
return itemList.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -208,7 +208,7 @@ public class PetManager {
|
||||
PetData.generalFoodItems.add(baseItem);
|
||||
else if (baseItem.getInteractionType().getType() == InteractionPetDrink.class)
|
||||
PetData.generalDrinkItems.add(baseItem);
|
||||
else if (baseItem.getInteractionType().getType() == InteractionPetToy.class || baseItem.getInteractionType().getType() == InteractionPetTree.class)
|
||||
else if (baseItem.getInteractionType().getType() == InteractionPetToy.class || baseItem.getInteractionType().getType() == InteractionPetTree.class || baseItem.getInteractionType().getType() == InteractionPetTrampoline.class)
|
||||
PetData.generalToyItems.add(baseItem);
|
||||
} else {
|
||||
PetData data = this.getPetData(set.getInt("pet_id"));
|
||||
@ -220,7 +220,7 @@ public class PetManager {
|
||||
data.addFoodItem(baseItem);
|
||||
else if (baseItem.getInteractionType().getType() == InteractionPetDrink.class)
|
||||
data.addDrinkItem(baseItem);
|
||||
else if (baseItem.getInteractionType().getType() == InteractionPetToy.class || baseItem.getInteractionType().getType() == InteractionPetTree.class)
|
||||
else if (baseItem.getInteractionType().getType() == InteractionPetToy.class || baseItem.getInteractionType().getType() == InteractionPetTree.class || baseItem.getInteractionType().getType() == InteractionPetTrampoline.class)
|
||||
data.addToyItem(baseItem);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class ActionHang extends PetAction {
|
||||
@Override
|
||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||
|
||||
boolean findTree = pet.findTree(PetTasks.HANG);
|
||||
boolean findTree = pet.findPetItem(PetTasks.HANG, InteractionPetTree.class);
|
||||
if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) {
|
||||
pet.getRoomUnit().setCanWalk(false);
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
|
@ -1,25 +1,29 @@
|
||||
package com.eu.habbo.habbohotel.pets.actions;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTrampoline;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree;
|
||||
import com.eu.habbo.habbohotel.pets.Pet;
|
||||
import com.eu.habbo.habbohotel.pets.PetAction;
|
||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.threading.runnables.PetClearPosture;
|
||||
|
||||
public class ActionJump extends PetAction {
|
||||
public ActionJump() {
|
||||
super(PetTasks.JUMP, true);
|
||||
super(null, false);
|
||||
this.minimumActionDuration = 2000;
|
||||
this.statusToSet.add(RoomUnitStatus.JUMP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||
pet.clearPosture();
|
||||
if(pet.findPetItem(PetTasks.JUMP, InteractionPetTrampoline.class)) return true;
|
||||
|
||||
pet.clearPosture();
|
||||
pet.setTask(PetTasks.JUMP);
|
||||
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false), this.minimumActionDuration);
|
||||
|
||||
if (pet.getHappyness() > 60)
|
||||
|
@ -18,7 +18,7 @@ public class ActionRingOfFire extends PetAction {
|
||||
@Override
|
||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||
|
||||
boolean findTree = pet.findTree(PetTasks.RING_OF_FIRE);
|
||||
boolean findTree = pet.findPetItem(PetTasks.RING_OF_FIRE, InteractionPetTree.class);
|
||||
if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) {
|
||||
pet.getRoomUnit().setCanWalk(false);
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.RINGOFFIRE, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
|
@ -18,7 +18,7 @@ public class ActionRoll extends PetAction {
|
||||
@Override
|
||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||
|
||||
boolean findTree = pet.findTree(PetTasks.ROLL);
|
||||
boolean findTree = pet.findPetItem(PetTasks.ROLL, InteractionPetTree.class);
|
||||
if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) {
|
||||
pet.getRoomUnit().setCanWalk(false);
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.ROLL, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
|
@ -18,7 +18,7 @@ public class ActionSwing extends PetAction {
|
||||
@Override
|
||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||
|
||||
boolean findTree = pet.findTree(PetTasks.SWING);
|
||||
boolean findTree = pet.findPetItem(PetTasks.SWING, InteractionPetTree.class);
|
||||
if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) {
|
||||
pet.getRoomUnit().setCanWalk(false);
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.SWING, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
|
@ -2394,6 +2394,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.roomSpecialTypes.addPetToy((InteractionPetToy) item);
|
||||
} else if (item instanceof InteractionPetTree) {
|
||||
this.roomSpecialTypes.addUndefined(item);
|
||||
} else if (item instanceof InteractionPetTrampoline) {
|
||||
this.roomSpecialTypes.addUndefined(item);
|
||||
} else if (item instanceof InteractionMoodLight) {
|
||||
this.roomSpecialTypes.addUndefined(item);
|
||||
} else if (item instanceof InteractionPyramid) {
|
||||
@ -2548,6 +2550,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.roomSpecialTypes.removePetToy((InteractionPetToy) item);
|
||||
} else if (item instanceof InteractionPetTree) {
|
||||
this.roomSpecialTypes.removeUndefined(item);
|
||||
} else if (item instanceof InteractionPetTrampoline) {
|
||||
this.roomSpecialTypes.removeUndefined(item);
|
||||
} else if (item instanceof InteractionMoodLight) {
|
||||
this.roomSpecialTypes.removeUndefined(item);
|
||||
} else if (item instanceof InteractionPyramid) {
|
||||
|
Loading…
Reference in New Issue
Block a user