Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java

870 lines
24 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.pets;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
2018-09-12 18:45:00 +02:00
import com.eu.habbo.habbohotel.rooms.*;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
2018-09-12 18:45:00 +02:00
import com.eu.habbo.messages.ISerialize;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.messages.ServerMessage;
2018-12-22 11:39:00 +01:00
import com.eu.habbo.messages.outgoing.rooms.pets.PetLevelUpdatedComposer;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetExperienceComposer;
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetRespectComposer;
2018-09-12 18:45:00 +02:00
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer;
import com.eu.habbo.plugin.events.pets.PetTalkEvent;
2018-07-06 15:30:00 +02:00
import gnu.trove.map.hash.THashMap;
import java.sql.*;
2018-09-28 21:25:00 +02:00
import java.util.Calendar;
import java.util.Map;
import java.util.TimeZone;
2018-07-06 15:30:00 +02:00
2018-09-12 18:45:00 +02:00
public class Pet implements ISerialize, Runnable
2018-07-06 15:30:00 +02:00
{
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected int id;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected int userId;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected Room room;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected String name;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected PetData petData;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected int race;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected String color;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected int happyness;
2018-12-22 11:39:00 +01:00
public int levelThirst;
public int levelHunger;
2018-09-12 18:45:00 +02:00
protected int experience;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected int energy;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected int respect;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected int created;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
protected int level;
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
public boolean needsUpdate = false;
private int chatTimeout;
RoomUnit roomUnit;
2018-07-06 15:30:00 +02:00
public boolean packetUpdate = false;
private int tickTimeout = Emulator.getIntUnixTimestamp();
private int happynessDelay = Emulator.getIntUnixTimestamp();
private int gestureTickTimeout = Emulator.getIntUnixTimestamp();
private int randomActionTickTimeout = Emulator.getIntUnixTimestamp();
private int postureTimeout = Emulator.getIntUnixTimestamp();
private int idleCommandTicks = 0;
private int freeCommandTicks = -1;
private PetTasks task = PetTasks.FREE;
private boolean muted = false;
public Pet(ResultSet set) throws SQLException
{
super();
this.id = set.getInt("id");
this.userId = set.getInt("user_id");
this.room = null;
this.name = set.getString("name");
this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(set.getInt("type"));
2018-09-28 21:25:00 +02:00
if (this.petData == null)
{
Emulator.getLogging().logErrorLine("WARNING! Missing pet data for type: " + set.getInt("type") + "! Insert a new entry into the pet_actions table for this type!");
this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(0);
}
2018-07-06 15:30:00 +02:00
this.race = set.getInt("race");
this.experience = set.getInt("experience");
this.happyness = set.getInt("happyness");
this.energy = set.getInt("energy");
this.respect = set.getInt("respect");
this.created = set.getInt("created");
this.color = set.getString("color");
this.levelThirst = set.getInt("thirst");
this.levelHunger = set.getInt("hunger");
this.level = PetManager.getLevel(this.experience);
}
public Pet(int type, int race, String color, String name, int userId)
{
this.id = 0;
this.userId = userId;
this.room = null;
this.name = name;
this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(type);
if(this.petData == null)
{
2018-09-28 21:25:00 +02:00
Emulator.getLogging().logErrorLine(new Exception("WARNING! Missing pet data for type: " + type + "! Insert a new entry into the pet_actions table for this type!"));
2018-07-06 15:30:00 +02:00
}
this.race = race;
this.color = color;
this.experience = 0;
this.happyness = 100;
this.energy = 100;
this.respect = 0;
this.levelThirst = 0;
this.levelHunger = 0;
this.created = Emulator.getIntUnixTimestamp();
this.level = 1;
}
2018-12-22 11:39:00 +01:00
protected void say(String message)
2018-09-12 18:45:00 +02:00
{
if(this.roomUnit != null && this.room != null && !message.isEmpty())
{
RoomChatMessage chatMessage = new RoomChatMessage(message, this.roomUnit, RoomChatMessageBubbles.NORMAL);
PetTalkEvent talkEvent = new PetTalkEvent(this, chatMessage);
if (!Emulator.getPluginManager().fireEvent(talkEvent).isCancelled())
{
this.room.petChat(new RoomUserTalkComposer(chatMessage).compose());
}
}
}
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
public void say(PetVocal vocal)
{
if(vocal != null)
this.say(vocal.message);
}
2018-12-22 11:39:00 +01:00
public void addEnergy(int amount)
2018-09-12 18:45:00 +02:00
{
this.energy += amount;
if(this.energy > PetManager.maxEnergy(this.level))
this.energy = PetManager.maxEnergy(this.level);
if(this.energy < 0)
this.energy = 0;
}
2018-12-22 11:39:00 +01:00
public void addHappyness(int amount)
2018-09-12 18:45:00 +02:00
{
this.happyness += amount;
if(this.happyness > 100)
this.happyness = 100;
if(this.happyness < 0)
this.happyness = 0;
}
public int getRespect()
{
return respect;
}
public void addRespect()
{
this.respect++;
}
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
public int daysAlive()
{
return (Emulator.getIntUnixTimestamp() - this.created) / 86400;
}
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
public String bornDate()
{
Calendar cal = Calendar.getInstance(TimeZone.getDefault());
cal.setTime(new java.util.Date(this.created));
return cal.get(Calendar.DAY_OF_MONTH) + "/" + cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.YEAR);
}
2018-07-06 15:30:00 +02:00
@Override
public void run()
{
if(this.needsUpdate)
{
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
{
if (this.id > 0)
{
2018-09-12 18:45:00 +02:00
try (PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET room_id = ?, experience = ?, energy = ?, respect = ?, x = ?, y = ?, z = ?, rot = ?, hunger = ?, thirst = ?, happyness = ?, created = ? WHERE id = ?"))
2018-07-06 15:30:00 +02:00
{
statement.setInt(1, (this.room == null ? 0 : this.room.getId()));
statement.setInt(2, this.experience);
statement.setInt(3, this.energy);
statement.setInt(4, this.respect);
2018-09-12 18:45:00 +02:00
statement.setInt(5, this.roomUnit != null ? this.roomUnit.getX() : 0);
statement.setInt(6, this.roomUnit != null ? this.roomUnit.getY() : 0);
statement.setDouble(7, this.roomUnit != null ? this.roomUnit.getZ() : 0.0);
statement.setInt(8, this.roomUnit != null ? this.roomUnit.getBodyRotation().getValue() : 0);
2018-07-06 15:30:00 +02:00
statement.setInt(9, this.levelHunger);
statement.setInt(10, this.levelThirst);
statement.setInt(11, this.happyness);
2018-09-12 18:45:00 +02:00
statement.setInt(12, this.created);
statement.setInt(13, this.id);
2018-07-06 15:30:00 +02:00
statement.execute();
}
}
else if (this.id == 0)
{
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_pets (user_id, room_id, name, race, type, color, experience, energy, respect, created) VALUES (?, 0, ?, ?, ?, ?, 0, 0, 0, ?)", Statement.RETURN_GENERATED_KEYS))
{
statement.setInt(1, this.userId);
statement.setString(2, this.name);
statement.setInt(3, this.race);
statement.setInt(4, 0);
if (this.petData != null)
{
statement.setInt(4, this.petData.getType());
}
statement.setString(5, this.color);
statement.setInt(6, this.created);
statement.execute();
try (ResultSet set = statement.getGeneratedKeys())
{
if (set.next())
{
this.id = set.getInt(1);
}
}
}
}
}
catch (SQLException e)
{
Emulator.getLogging().logSQLException(e);
}
this.needsUpdate = false;
}
}
public void cycle()
{
this.idleCommandTicks++;
int time = Emulator.getIntUnixTimestamp();
if(this.roomUnit != null && this.task != PetTasks.RIDE)
{
if(time - this.gestureTickTimeout > 5)
{
2018-09-12 18:45:00 +02:00
this.roomUnit.removeStatus(RoomUnitStatus.GESTURE);
2018-07-06 15:30:00 +02:00
this.packetUpdate = true;
}
if(time - this.postureTimeout > 1 && this.task == null)
{
this.clearPosture();
2018-12-22 11:39:00 +01:00
this.postureTimeout = time + 120;
2018-07-06 15:30:00 +02:00
}
if (this.freeCommandTicks > 0)
{
this.freeCommandTicks--;
if (this.freeCommandTicks == 0)
{
freeCommand();
}
}
if(!this.roomUnit.isWalking())
{
2018-09-12 18:45:00 +02:00
this.roomUnit.removeStatus(RoomUnitStatus.MOVE);
2018-07-06 15:30:00 +02:00
if (this.roomUnit.getWalkTimeOut() < time && this.canWalk())
{
2018-09-28 21:25:00 +02:00
RoomTile tile = this.room.getRandomWalkableTile();
if (tile != null)
{
this.roomUnit.setGoalLocation(tile);
}
2018-07-06 15:30:00 +02:00
}
if (this.task == PetTasks.NEST || this.task == PetTasks.DOWN)
{
if (this.levelHunger > 0)
this.levelHunger--;
if (this.levelThirst > 0)
this.levelThirst--;
this.addEnergy(5);
this.addHappyness(1);
if (this.energy == PetManager.maxEnergy(this.level))
{
2018-09-12 18:45:00 +02:00
this.roomUnit.removeStatus(RoomUnitStatus.LAY);
2018-07-06 15:30:00 +02:00
this.roomUnit.setCanWalk(true);
this.roomUnit.setGoalLocation(this.room.getRandomWalkableTile());
this.task = null;
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.ENERGY.getKey());
2018-07-06 15:30:00 +02:00
this.gestureTickTimeout = time;
}
}
else if(this.tickTimeout >= 5)
{
if(this.levelHunger < 100)
this.levelHunger++;
if(this.levelThirst < 100)
this.levelThirst++;
if(this.energy < PetManager.maxEnergy(this.level))
this.energy++;
this.tickTimeout = time;
}
}
else
{
int timeout = Emulator.getRandom().nextInt(10) * 2;
this.roomUnit.setWalkTimeOut(timeout < 20 ? 20 + time : timeout + time);
if(this.energy >= 2)
this.addEnergy(-1);
if(this.levelHunger < 100)
this.levelHunger++;
if(this.levelThirst < 100)
this.levelThirst++;
if(this.happyness > 0 && time - this.happynessDelay >= 30)
{
this.happyness--;
this.happynessDelay = time;
}
}
if(time - this.gestureTickTimeout > 15)
{
updateGesture(time);
}
else if(time - this.randomActionTickTimeout > 30)
{
this.randomAction();
this.randomActionTickTimeout = time + (10 * Emulator.getRandom().nextInt(60));
}
if(!this.muted)
{
2018-09-12 18:45:00 +02:00
if (this.chatTimeout <= time)
2018-07-06 15:30:00 +02:00
{
if (this.energy <= 30)
{
2018-09-12 18:45:00 +02:00
this.say(this.petData.randomVocal(PetVocalsType.TIRED));
2018-07-06 15:30:00 +02:00
if(this.energy <= 10)
this.findNest();
} else if (this.happyness > 85)
{
2018-09-12 18:45:00 +02:00
this.say(this.petData.randomVocal(PetVocalsType.GENERIC_HAPPY));
2018-07-06 15:30:00 +02:00
} else if (this.happyness < 15)
{
2018-09-12 18:45:00 +02:00
this.say(this.petData.randomVocal(PetVocalsType.GENERIC_SAD));
2018-07-06 15:30:00 +02:00
} else if (this.levelHunger > 50)
{
2018-09-12 18:45:00 +02:00
this.say(this.petData.randomVocal(PetVocalsType.HUNGRY));
2018-07-06 15:30:00 +02:00
this.eat();
} else if (this.levelThirst > 50)
{
2018-09-12 18:45:00 +02:00
this.say(this.petData.randomVocal(PetVocalsType.THIRSTY));
2018-07-06 15:30:00 +02:00
this.drink();
}
int timeOut = Emulator.getRandom().nextInt(30);
2018-09-12 18:45:00 +02:00
this.chatTimeout = time + (timeOut < 3 ? 30 : timeOut);
2018-07-06 15:30:00 +02:00
}
}
}
}
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
public void handleCommand(PetCommand command, Habbo habbo, String[] data)
2018-07-06 15:30:00 +02:00
{
this.idleCommandTicks = 0;
2018-09-12 18:45:00 +02:00
command.handle(this, habbo, data);
2018-07-06 15:30:00 +02:00
}
public boolean canWalk()
{
if(this.task == null)
return true;
switch(this.task)
{
case DOWN:
case FLAT:
case HERE:
case SIT:
case BEG:
case PLAY:
case PLAY_FOOTBALL:
case PLAY_DEAD:
case FOLLOW:
case JUMP:
case STAND:
case NEST:
case RIDE:
return false;
}
return true;
}
2018-09-12 18:45:00 +02:00
public void clearPosture()
2018-07-06 15:30:00 +02:00
{
2018-09-28 21:25:00 +02:00
THashMap<RoomUnitStatus, String> keys = new THashMap<>();
2018-07-06 15:30:00 +02:00
2018-09-12 18:45:00 +02:00
if(this.roomUnit.hasStatus(RoomUnitStatus.MOVE))
keys.put(RoomUnitStatus.MOVE, this.roomUnit.getStatus(RoomUnitStatus.MOVE));
2018-07-06 15:30:00 +02:00
2018-09-12 18:45:00 +02:00
if(this.roomUnit.hasStatus(RoomUnitStatus.SIT))
keys.put(RoomUnitStatus.SIT, this.roomUnit.getStatus(RoomUnitStatus.SIT));
2018-07-06 15:30:00 +02:00
2018-09-12 18:45:00 +02:00
if(this.roomUnit.hasStatus(RoomUnitStatus.LAY))
keys.put(RoomUnitStatus.LAY, this.roomUnit.getStatus(RoomUnitStatus.LAY));
2018-07-06 15:30:00 +02:00
2018-09-12 18:45:00 +02:00
if(this.roomUnit.hasStatus(RoomUnitStatus.GESTURE))
keys.put(RoomUnitStatus.GESTURE, this.roomUnit.getStatus(RoomUnitStatus.GESTURE));
2018-07-06 15:30:00 +02:00
if(this.task == null)
{
2018-12-22 11:39:00 +01:00
boolean isDead = false;
if (this.roomUnit.hasStatus(RoomUnitStatus.RIP))
isDead = true;
2018-09-12 18:45:00 +02:00
this.roomUnit.clearStatus();
2018-12-22 11:39:00 +01:00
if (isDead) this.roomUnit.setStatus(RoomUnitStatus.RIP, "");
2018-09-12 18:45:00 +02:00
for (Map.Entry<RoomUnitStatus, String> entry : keys.entrySet())
{
this.roomUnit.setStatus(entry.getKey(), entry.getValue());
}
2018-07-06 15:30:00 +02:00
}
this.packetUpdate = true;
}
public void updateGesture(int time)
{
this.gestureTickTimeout = time;
2018-09-12 18:45:00 +02:00
if (this.energy < 30)
2018-07-06 15:30:00 +02:00
{
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.TIRED.getKey());
2018-07-06 15:30:00 +02:00
this.findNest();
}
2018-09-12 18:45:00 +02:00
else if(this.happyness == 100)
2018-07-06 15:30:00 +02:00
{
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.LOVE.getKey());
2018-07-06 15:30:00 +02:00
} else if (this.happyness >= 90)
{
this.randomHappyAction();
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.HAPPY.getKey());
2018-07-06 15:30:00 +02:00
} else if (this.happyness <= 5)
{
this.randomSadAction();
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.SAD.getKey());
2018-07-06 15:30:00 +02:00
} else if (this.levelHunger > 80)
{
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.HUNGRY.getKey());
2018-07-06 15:30:00 +02:00
this.eat();
} else if (this.levelThirst > 80)
{
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.THIRSTY.getKey());
2018-07-06 15:30:00 +02:00
this.drink();
}
else if(this.idleCommandTicks > 240)
{
this.idleCommandTicks = 0;
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.QUESTION.getKey());
2018-07-06 15:30:00 +02:00
}
}
@Override
public void serialize(ServerMessage message)
{
2018-09-12 18:45:00 +02:00
message.appendInt(this.id);
message.appendString(this.name);
2018-09-28 21:25:00 +02:00
if (this.petData != null)
{
message.appendInt(this.petData.getType());
}
else
{
message.appendInt(-1);
}
2018-07-06 15:30:00 +02:00
message.appendInt(this.race);
message.appendString(this.color);
message.appendInt(0);
message.appendInt(0);
message.appendInt(0);
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public void findNest()
{
HabboItem item = this.petData.randomNest(this.room.getRoomSpecialTypes().getNests());
this.roomUnit.setCanWalk(true);
if(item != null)
{
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
}
else
{
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.LAY, this.room.getStackHeight(this.roomUnit.getX(), this.roomUnit.getY(), false) + "");
this.say(this.petData.randomVocal(PetVocalsType.SLEEPING));
2018-07-06 15:30:00 +02:00
this.task = PetTasks.DOWN;
}
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public void drink()
{
HabboItem item = this.petData.randomDrinkItem(this.room.getRoomSpecialTypes().getPetDrinks());
if(item != null)
{
this.roomUnit.setCanWalk(true);
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
}
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public void eat()
{
HabboItem item = this.petData.randomFoodItem(this.room.getRoomSpecialTypes().getPetFoods());
{
if(item != null)
{
this.roomUnit.setCanWalk(true);
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
}
}
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public void findToy()
{
HabboItem item = this.petData.randomToyItem(this.room.getRoomSpecialTypes().getPetToys());
{
if(item != null)
{
this.roomUnit.setCanWalk(true);
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
}
}
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public void randomHappyAction()
{
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsHappy[Emulator.getRandom().nextInt(this.petData.actionsHappy.length)]), "");
2018-07-06 15:30:00 +02:00
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public void randomSadAction()
{
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsTired[Emulator.getRandom().nextInt(this.petData.actionsTired.length)]), "");
2018-07-06 15:30:00 +02:00
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public void randomAction()
{
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsRandom[Emulator.getRandom().nextInt(this.petData.actionsRandom.length)]), "");
2018-07-06 15:30:00 +02:00
}
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
public void addExperience(int amount)
2018-07-06 15:30:00 +02:00
{
this.experience += amount;
if(this.room != null)
{
this.room.sendComposer(new RoomPetExperienceComposer(this, amount).compose());
2018-09-28 21:25:00 +02:00
if(this.level < PetManager.experiences.length + 1 && this.experience >= PetManager.experiences[this.level - 1])
2018-07-06 15:30:00 +02:00
{
this.levelUp();
}
}
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
protected void levelUp()
{
2018-12-22 11:39:00 +01:00
if (this.level >= PetManager.experiences.length)
return;
2018-07-06 15:30:00 +02:00
this.level++;
2018-12-22 11:39:00 +01:00
if (this.experience < PetManager.experiences[this.level])
{
this.experience = PetManager.experiences[this.level];
}
2018-09-12 18:45:00 +02:00
this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP));
2018-07-06 15:30:00 +02:00
this.addHappyness(100);
2018-09-12 18:45:00 +02:00
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, "exp");
2018-07-06 15:30:00 +02:00
this.gestureTickTimeout = Emulator.getIntUnixTimestamp();
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp"));
2018-12-22 11:39:00 +01:00
this.room.sendComposer(new PetLevelUpdatedComposer(this).compose());
2018-07-06 15:30:00 +02:00
}
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
public void addThirst(int amount)
2018-07-06 15:30:00 +02:00
{
this.levelThirst += amount;
if(this.levelThirst > 100)
this.levelThirst = 100;
if(this.levelThirst < 0)
this.levelThirst = 0;
}
2018-12-22 11:39:00 +01:00
2018-09-12 18:45:00 +02:00
public void addHunger(int amount)
2018-07-06 15:30:00 +02:00
{
this.levelHunger += amount;
if(this.levelHunger > 100)
this.levelHunger = 100;
if(this.levelHunger < 0)
this.levelHunger = 0;
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public void freeCommand()
{
this.task = null;
2018-09-12 18:45:00 +02:00
this.roomUnit.setGoalLocation(this.getRoomUnit().getCurrentLocation());
this.roomUnit.clearStatus();
2018-07-06 15:30:00 +02:00
this.roomUnit.setCanWalk(true);
2018-09-12 18:45:00 +02:00
this.say(this.petData.randomVocal(PetVocalsType.GENERIC_NEUTRAL));
2018-07-06 15:30:00 +02:00
}
2018-12-22 11:39:00 +01:00
2018-07-06 15:30:00 +02:00
public void scratched(Habbo habbo)
{
this.addExperience(10);
this.addRespect();
if (habbo != null)
{
habbo.getHabboStats().petRespectPointsToGive--;
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomPetRespectComposer(this).compose());
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetRespectGiver"));
}
2018-09-12 18:45:00 +02:00
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetRespectReceiver"));
}
public int getId()
{
return this.id;
}
public int getUserId()
{
return this.userId;
}
public void setUserId(int userId)
{
this.userId = userId;
}
public Room getRoom()
{
return this.room;
}
public void setRoom(Room room)
{
this.room = room;
}
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name = name;
}
public PetData getPetData()
{
return this.petData;
}
public void setPetData(PetData petData)
{
this.petData = petData;
}
public int getRace()
{
return this.race;
}
public void setRace(int race)
{
this.race = race;
}
public String getColor()
{
return this.color;
}
public void setColor(String color)
{
this.color = color;
}
public int getHappyness()
{
return happyness;
}
public void setHappyness(int happyness)
{
this.happyness = happyness;
}
public int getExperience()
{
return experience;
}
public void setExperience(int experience)
{
this.experience = experience;
}
public int getEnergy()
{
return this.energy;
}
public int getMaxEnergy()
{
return this.level * 100;
}
public void setEnergy(int energy)
{
this.energy = energy;
}
public int getCreated()
{
return this.created;
}
public void setCreated(int created)
{
this.created = created;
}
public int getLevel()
{
return this.level;
}
public void setLevel(int level)
{
this.level = level;
}
public RoomUnit getRoomUnit()
{
return this.roomUnit;
}
public void setRoomUnit(RoomUnit roomUnit)
{
this.roomUnit = roomUnit;
}
public PetTasks getTask()
{
return this.task;
}
public void setTask(PetTasks newTask)
{
this.task = newTask;
}
public boolean isMuted()
{
return muted;
}
public void setMuted(boolean muted)
{
this.muted = muted;
}
public int getLevelThirst()
{
return levelThirst;
}
public void setLevelThirst(int levelThirst)
{
this.levelThirst = levelThirst;
}
public int getLevelHunger()
{
return levelHunger;
}
public void setLevelHunger(int levelHunger)
{
this.levelHunger = levelHunger;
2018-07-06 15:30:00 +02:00
}
}