mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
code cleanup
This commit is contained in:
parent
90fec0f18a
commit
0cc5b5cb73
@ -28,7 +28,6 @@ public class InteractionPetTree extends InteractionDefault {
|
|||||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||||
for (Pet pet : room.getPetsAt(oldLocation)) {
|
for (Pet pet : room.getPetsAt(oldLocation)) {
|
||||||
pet.getRoomUnit().clearStatus();
|
pet.getRoomUnit().clearStatus();
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
|
||||||
pet.packetUpdate = true;
|
pet.packetUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,7 +35,6 @@ public class InteractionPetTree extends InteractionDefault {
|
|||||||
public void onPickUp(Room room) {
|
public void onPickUp(Room room) {
|
||||||
for (Pet pet : room.getPetsOnItem(this)) {
|
for (Pet pet : room.getPetsOnItem(this)) {
|
||||||
pet.getRoomUnit().clearStatus();
|
pet.getRoomUnit().clearStatus();
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
|
||||||
pet.packetUpdate = true;
|
pet.packetUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,10 +63,10 @@ public class InteractionPetTree extends InteractionDefault {
|
|||||||
pet.addHappyness(25);
|
pet.addHappyness(25);
|
||||||
pet.getRoomUnit().clearStatus();
|
pet.getRoomUnit().clearStatus();
|
||||||
new PetClearPosture(pet, finalTask, null, true);
|
new PetClearPosture(pet, finalTask, null, true);
|
||||||
if (this.getRoomId() == room.getId() && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentLocation())) {
|
if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentLocation())) {
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
} else {
|
} else {
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
pet.clearPosture();
|
||||||
}
|
}
|
||||||
pet.getRoomUnit().setCanWalk(true);
|
pet.getRoomUnit().setCanWalk(true);
|
||||||
pet.packetUpdate = true;
|
pet.packetUpdate = true;
|
||||||
@ -90,7 +88,6 @@ public class InteractionPetTree extends InteractionDefault {
|
|||||||
|
|
||||||
if (pet != null) {
|
if (pet != null) {
|
||||||
pet.getRoomUnit().clearStatus();
|
pet.getRoomUnit().clearStatus();
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
|
||||||
pet.packetUpdate = true;
|
pet.packetUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.pets;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree;
|
||||||
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.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
@ -18,9 +19,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Calendar;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class Pet implements ISerialize, Runnable {
|
public class Pet implements ISerialize, Runnable {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Pet.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Pet.class);
|
||||||
@ -481,16 +480,41 @@ public class Pet implements ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void findToy() {
|
public boolean findToy() {
|
||||||
HabboItem item = this.petData.randomToyItem(this.room.getRoomSpecialTypes().getPetToys());
|
HabboItem item = this.petData.randomToyItem(this.room.getRoomSpecialTypes().getPetToys());
|
||||||
{
|
{
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
this.roomUnit.setCanWalk(true);
|
this.roomUnit.setCanWalk(true);
|
||||||
|
if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) {
|
||||||
|
try {
|
||||||
|
item.onWalkOn(this.getRoomUnit(), this.getRoom(), null);
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
|
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean findTree(PetTasks task) {
|
||||||
|
HabboItem item = this.petData.randomTreeItem(this.room.getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class));
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.roomUnit.setCanWalk(true);
|
||||||
|
this.setTask(task);
|
||||||
|
if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) {
|
||||||
|
try {
|
||||||
|
item.onWalkOn(this.getRoomUnit(), this.getRoom(), null);
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void randomHappyAction() {
|
public void randomHappyAction() {
|
||||||
if (this.petData.actionsHappy.length > 0) {
|
if (this.petData.actionsHappy.length > 0) {
|
||||||
|
@ -2,10 +2,7 @@ package com.eu.habbo.habbohotel.pets;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest;
|
import com.eu.habbo.habbohotel.items.interactions.pets.*;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink;
|
|
||||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood;
|
|
||||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy;
|
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
@ -233,6 +230,22 @@ public class PetData implements Comparable<PetData> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HabboItem randomTreeItem(THashSet<HabboItem> trees) {
|
||||||
|
List<HabboItem> treeList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (HabboItem tree : trees) {
|
||||||
|
if (this.haveToyItem(tree)) {
|
||||||
|
treeList.add(tree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!treeList.isEmpty()) {
|
||||||
|
Collections.shuffle(treeList);
|
||||||
|
return treeList.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public PetVocal randomVocal(PetVocalsType type) {
|
public PetVocal randomVocal(PetVocalsType type) {
|
||||||
//TODO: Remove this useless copying.
|
//TODO: Remove this useless copying.
|
||||||
|
@ -17,9 +17,9 @@ public class ActionCroak extends PetAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.CROAK, "0");
|
pet.getRoomUnit().setStatus(RoomUnitStatus.CROAK, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
|
||||||
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.CROAK, null, false), 2000);
|
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.CROAK, null, false), this.minimumActionDuration);
|
||||||
|
|
||||||
if (pet.getHappyness() > 80)
|
if (pet.getHappyness() > 80)
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
||||||
|
@ -14,6 +14,7 @@ public class ActionDown extends PetAction {
|
|||||||
this.statusToRemove.add(RoomUnitStatus.BEG);
|
this.statusToRemove.add(RoomUnitStatus.BEG);
|
||||||
this.statusToRemove.add(RoomUnitStatus.MOVE);
|
this.statusToRemove.add(RoomUnitStatus.MOVE);
|
||||||
this.statusToRemove.add(RoomUnitStatus.DEAD);
|
this.statusToRemove.add(RoomUnitStatus.DEAD);
|
||||||
|
this.minimumActionDuration = 4000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -25,7 +26,7 @@ public class ActionDown extends PetAction {
|
|||||||
Emulator.getThreading().run(() -> {
|
Emulator.getThreading().run(() -> {
|
||||||
pet.getRoomUnit().cmdLay = false;
|
pet.getRoomUnit().cmdLay = false;
|
||||||
pet.clearPosture();
|
pet.clearPosture();
|
||||||
}, 4000);
|
}, this.minimumActionDuration);
|
||||||
|
|
||||||
if (pet.getHappyness() > 50)
|
if (pet.getHappyness() > 50)
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
||||||
|
@ -20,7 +20,7 @@ public class ActionEat extends PetAction {
|
|||||||
//Eat
|
//Eat
|
||||||
if (pet.getLevelHunger() > 40) {
|
if (pet.getLevelHunger() > 40) {
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.HUNGRY));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.HUNGRY));
|
||||||
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.EAT, null, false), 500);
|
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.EAT, null, false), this.minimumActionDuration);
|
||||||
pet.eat();
|
pet.eat();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.pets.Pet;
|
|||||||
import com.eu.habbo.habbohotel.pets.PetAction;
|
import com.eu.habbo.habbohotel.pets.PetAction;
|
||||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
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.Habbo;
|
||||||
import com.eu.habbo.threading.runnables.PetFollowHabbo;
|
import com.eu.habbo.threading.runnables.PetFollowHabbo;
|
||||||
|
|
||||||
|
@ -1,70 +1,38 @@
|
|||||||
package com.eu.habbo.habbohotel.pets.actions;
|
package com.eu.habbo.habbohotel.pets.actions;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree;
|
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree;
|
||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
import com.eu.habbo.habbohotel.pets.PetAction;
|
import com.eu.habbo.habbohotel.pets.PetAction;
|
||||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ActionHang extends PetAction {
|
public class ActionHang extends PetAction {
|
||||||
public ActionHang() {
|
public ActionHang() {
|
||||||
super(null, true);
|
super(null, true);
|
||||||
|
this.minimumActionDuration = 4000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
if (pet.getHappyness() < 50) {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Set<HabboItem> petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class);
|
boolean findTree = pet.findTree(PetTasks.HANG);
|
||||||
|
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() + "");
|
||||||
|
|
||||||
if (petTrees == null || petTrees.isEmpty()) {
|
Emulator.getThreading().run(() -> {
|
||||||
|
pet.getRoomUnit().setCanWalk(true);
|
||||||
|
pet.clearPosture();
|
||||||
|
}, minimumActionDuration);
|
||||||
|
} else if (!findTree) {
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<RoomTile> tileList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (HabboItem petTree : petTrees) {
|
|
||||||
if (petTree == null || petTree.getRoomId() != pet.getRoom().getId()) continue;
|
|
||||||
tileList.addAll(petTree.getOccupyingTiles(pet.getRoom().getLayout()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tileList.isEmpty()) {
|
|
||||||
Collections.shuffle(tileList);
|
|
||||||
RoomTile goal = tileList.get(0);
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||||
|
|
||||||
if (goal == null || goal.state == RoomTileState.BLOCKED) {
|
|
||||||
goal = pet.getRoomUnit().getClosestTile(tileList);
|
|
||||||
}
|
|
||||||
pet.setTask(PetTasks.HANG);
|
|
||||||
if (goal.distance(pet.getRoomUnit().getCurrentLocation()) == 0) {
|
|
||||||
HabboItem tree = pet.getRoom().getItemsAt(goal).stream().filter(habboItem -> habboItem instanceof InteractionPetTree).findAny().orElse(null);
|
|
||||||
if (tree != null) {
|
|
||||||
try {
|
|
||||||
tree.onWalkOn(pet.getRoomUnit(), pet.getRoom(), null);
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
} else {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else pet.getRoomUnit().setGoalLocation(goal);
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ public class ActionJump extends PetAction {
|
|||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
pet.clearPosture();
|
pet.clearPosture();
|
||||||
|
|
||||||
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false), 2000);
|
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false), this.minimumActionDuration);
|
||||||
|
|
||||||
if (pet.getHappyness() > 60)
|
if (pet.getHappyness() > 60)
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
||||||
|
@ -14,7 +14,6 @@ public class ActionNest extends PetAction {
|
|||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
if (pet.getEnergy() < 65) {
|
if (pet.getEnergy() < 65) {
|
||||||
pet.findNest();
|
pet.findNest();
|
||||||
|
|
||||||
if (pet.getEnergy() < 30)
|
if (pet.getEnergy() < 30)
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.TIRED));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.TIRED));
|
||||||
|
|
||||||
|
@ -7,19 +7,19 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
|||||||
|
|
||||||
public class ActionPlay extends PetAction {
|
public class ActionPlay extends PetAction {
|
||||||
public ActionPlay() {
|
public ActionPlay() {
|
||||||
super(null, false);
|
super(null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
//Play
|
|
||||||
//TODO Implement playing for pets. For example; go to ball, toy etc.
|
boolean findToy = pet.findToy();
|
||||||
if (pet.getHappyness() > 75)
|
if (!findToy) {
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
|
||||||
else {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,7 +18,7 @@ public class ActionPlayDead extends PetAction {
|
|||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
pet.clearPosture();
|
pet.clearPosture();
|
||||||
|
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.DEAD, pet.getRoom().getStackHeight(pet.getRoomUnit().getX(), pet.getRoomUnit().getY(), false) + "");
|
pet.getRoomUnit().setStatus(RoomUnitStatus.DEAD, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
|
||||||
if (pet.getHappyness() > 50)
|
if (pet.getHappyness() > 50)
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
||||||
|
@ -21,7 +21,7 @@ public class ActionRelax extends PetAction {
|
|||||||
else
|
else
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||||
|
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, "0");
|
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,70 +1,38 @@
|
|||||||
package com.eu.habbo.habbohotel.pets.actions;
|
package com.eu.habbo.habbohotel.pets.actions;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree;
|
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree;
|
||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
import com.eu.habbo.habbohotel.pets.PetAction;
|
import com.eu.habbo.habbohotel.pets.PetAction;
|
||||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ActionRingOfFire extends PetAction {
|
public class ActionRingOfFire extends PetAction {
|
||||||
public ActionRingOfFire() {
|
public ActionRingOfFire() {
|
||||||
super(null, true);
|
super(null, true);
|
||||||
|
this.minimumActionDuration = 4000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
if (pet.getHappyness() < 50) {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Set<HabboItem> petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class);
|
boolean findTree = pet.findTree(PetTasks.RING_OF_FIRE);
|
||||||
|
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() + "");
|
||||||
|
|
||||||
if (petTrees == null || petTrees.isEmpty()) {
|
Emulator.getThreading().run(() -> {
|
||||||
|
pet.getRoomUnit().setCanWalk(true);
|
||||||
|
pet.clearPosture();
|
||||||
|
}, minimumActionDuration);
|
||||||
|
} else if (!findTree) {
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<RoomTile> tileList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (HabboItem petTree : petTrees) {
|
|
||||||
if (petTree == null || petTree.getRoomId() != pet.getRoom().getId()) continue;
|
|
||||||
tileList.addAll(petTree.getOccupyingTiles(pet.getRoom().getLayout()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tileList.isEmpty()) {
|
|
||||||
Collections.shuffle(tileList);
|
|
||||||
RoomTile goal = tileList.get(0);
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||||
|
|
||||||
if (goal == null || goal.state == RoomTileState.BLOCKED) {
|
|
||||||
goal = pet.getRoomUnit().getClosestTile(tileList);
|
|
||||||
}
|
|
||||||
pet.setTask(PetTasks.RING_OF_FIRE);
|
|
||||||
if (goal.distance(pet.getRoomUnit().getCurrentLocation()) == 0) {
|
|
||||||
HabboItem tree = pet.getRoom().getItemsAt(goal).stream().filter(habboItem -> habboItem instanceof InteractionPetTree).findAny().orElse(null);
|
|
||||||
if (tree != null) {
|
|
||||||
try {
|
|
||||||
tree.onWalkOn(pet.getRoomUnit(), pet.getRoom(), null);
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
} else {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else pet.getRoomUnit().setGoalLocation(goal);
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,78 +6,33 @@ import com.eu.habbo.habbohotel.pets.Pet;
|
|||||||
import com.eu.habbo.habbohotel.pets.PetAction;
|
import com.eu.habbo.habbohotel.pets.PetAction;
|
||||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ActionRoll extends PetAction {
|
public class ActionRoll extends PetAction {
|
||||||
public ActionRoll() {
|
public ActionRoll() {
|
||||||
super(null, true);
|
super(null, true);
|
||||||
|
this.minimumActionDuration = 4000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
if (pet.getHappyness() < 50) {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Set<HabboItem> petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class);
|
boolean findTree = pet.findTree(PetTasks.ROLL);
|
||||||
|
if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) {
|
||||||
if (petTrees == null || petTrees.isEmpty()) {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<RoomTile> tileList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (HabboItem petTree : petTrees) {
|
|
||||||
if (petTree == null || !pet.getPetData().haveToyItem(petTree.getBaseItem())) continue;
|
|
||||||
tileList.addAll(petTree.getOccupyingTiles(pet.getRoom().getLayout()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tileList.isEmpty()) {
|
|
||||||
Collections.shuffle(tileList);
|
|
||||||
RoomTile goal = tileList.get(0);
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
|
||||||
|
|
||||||
if (goal == null || goal.state == RoomTileState.BLOCKED) {
|
|
||||||
goal = pet.getRoomUnit().getClosestTile(tileList);
|
|
||||||
}
|
|
||||||
pet.setTask(PetTasks.ROLL);
|
|
||||||
if (goal.distance(pet.getRoomUnit().getCurrentLocation()) == 0) {
|
|
||||||
HabboItem tree = pet.getRoom().getItemsAt(goal).stream().filter(habboItem -> habboItem instanceof InteractionPetTree).findAny().orElse(null);
|
|
||||||
if (tree != null) {
|
|
||||||
try {
|
|
||||||
tree.onWalkOn(pet.getRoomUnit(), pet.getRoom(), null);
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
} else {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else pet.getRoomUnit().setGoalLocation(goal);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) {
|
|
||||||
pet.getRoomUnit().setCanWalk(false);
|
pet.getRoomUnit().setCanWalk(false);
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.ROLL, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
pet.getRoomUnit().setStatus(RoomUnitStatus.ROLL, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
|
||||||
Emulator.getThreading().run(() -> {
|
Emulator.getThreading().run(() -> {
|
||||||
pet.getRoomUnit().setCanWalk(true);
|
pet.getRoomUnit().setCanWalk(true);
|
||||||
pet.clearPosture();
|
pet.clearPosture();
|
||||||
}, 4000);
|
}, minimumActionDuration);
|
||||||
return true;
|
} else if (!findTree) {
|
||||||
}
|
|
||||||
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,8 +15,8 @@ public class ActionSilent extends PetAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
pet.setMuted(true);
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.MUTED));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.MUTED));
|
||||||
|
pet.setMuted(true);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ public class ActionSit extends PetAction {
|
|||||||
this.statusToRemove.add(RoomUnitStatus.MOVE);
|
this.statusToRemove.add(RoomUnitStatus.MOVE);
|
||||||
this.statusToRemove.add(RoomUnitStatus.LAY);
|
this.statusToRemove.add(RoomUnitStatus.LAY);
|
||||||
this.statusToRemove.add(RoomUnitStatus.DEAD);
|
this.statusToRemove.add(RoomUnitStatus.DEAD);
|
||||||
|
this.minimumActionDuration = 4000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -26,7 +27,7 @@ public class ActionSit extends PetAction {
|
|||||||
Emulator.getThreading().run(() -> {
|
Emulator.getThreading().run(() -> {
|
||||||
pet.getRoomUnit().cmdSit = false;
|
pet.getRoomUnit().cmdSit = false;
|
||||||
pet.clearPosture();
|
pet.clearPosture();
|
||||||
}, 4000);
|
}, this.minimumActionDuration);
|
||||||
|
|
||||||
if (pet.getHappyness() > 75)
|
if (pet.getHappyness() > 75)
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
||||||
|
@ -1,70 +1,38 @@
|
|||||||
package com.eu.habbo.habbohotel.pets.actions;
|
package com.eu.habbo.habbohotel.pets.actions;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree;
|
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree;
|
||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
import com.eu.habbo.habbohotel.pets.PetAction;
|
import com.eu.habbo.habbohotel.pets.PetAction;
|
||||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ActionSwing extends PetAction {
|
public class ActionSwing extends PetAction {
|
||||||
public ActionSwing() {
|
public ActionSwing() {
|
||||||
super(null, true);
|
super(null, true);
|
||||||
|
this.minimumActionDuration = 4000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
if (pet.getHappyness() < 50) {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Set<HabboItem> petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class);
|
boolean findTree = pet.findTree(PetTasks.SWING);
|
||||||
|
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() + "");
|
||||||
|
|
||||||
if (petTrees == null || petTrees.isEmpty()) {
|
Emulator.getThreading().run(() -> {
|
||||||
|
pet.getRoomUnit().setCanWalk(true);
|
||||||
|
pet.clearPosture();
|
||||||
|
}, minimumActionDuration);
|
||||||
|
} else if (!findTree) {
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<RoomTile> tileList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (HabboItem petTree : petTrees) {
|
|
||||||
if (petTree == null || petTree.getRoomId() != pet.getRoom().getId()) continue;
|
|
||||||
tileList.addAll(petTree.getOccupyingTiles(pet.getRoom().getLayout()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tileList.isEmpty()) {
|
|
||||||
Collections.shuffle(tileList);
|
|
||||||
RoomTile goal = tileList.get(0);
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||||
|
|
||||||
if (goal == null || goal.state == RoomTileState.BLOCKED) {
|
|
||||||
goal = pet.getRoomUnit().getClosestTile(tileList);
|
|
||||||
}
|
|
||||||
pet.setTask(PetTasks.SWING);
|
|
||||||
if (goal.distance(pet.getRoomUnit().getCurrentLocation()) == 0) {
|
|
||||||
HabboItem tree = pet.getRoom().getItemsAt(goal).stream().filter(habboItem -> habboItem instanceof InteractionPetTree).findAny().orElse(null);
|
|
||||||
if (tree != null) {
|
|
||||||
try {
|
|
||||||
tree.onWalkOn(pet.getRoomUnit(), pet.getRoom(), null);
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
} else {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else pet.getRoomUnit().setGoalLocation(goal);
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,10 +18,6 @@ public class ActionTorch extends PetAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
if (pet.getHappyness() < 30) {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.EAT, null, false), this.minimumActionDuration);
|
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.EAT, null, false), this.minimumActionDuration);
|
||||||
return true;
|
return true;
|
||||||
|
@ -21,14 +21,9 @@ public class ActionWagTail extends PetAction {
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
pet.clearPosture();
|
pet.clearPosture();
|
||||||
|
|
||||||
if (pet.getHappyness() > 40) {
|
|
||||||
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAG_TAIL, null, false), this.minimumActionDuration);
|
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAG_TAIL, null, false), this.minimumActionDuration);
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,18 +13,14 @@ public class ActionWave extends PetAction {
|
|||||||
super(PetTasks.WAVE, false);
|
super(PetTasks.WAVE, false);
|
||||||
|
|
||||||
this.statusToSet.add(RoomUnitStatus.WAVE);
|
this.statusToSet.add(RoomUnitStatus.WAVE);
|
||||||
|
this.minimumActionDuration = 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
//WAV
|
pet.getRoomUnit().setStatus(RoomUnitStatus.WAVE, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
if (pet.getHappyness() > 65) {
|
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.WAVE, "0");
|
|
||||||
|
|
||||||
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAVE, null, false), 2000);
|
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAVE, null, false), this.minimumActionDuration);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user