Rename and clean up MaplePet
This commit is contained in:
@@ -104,7 +104,7 @@ function end(mode, type, selection) {
|
|||||||
qm.gainMeso(-10000);
|
qm.gainMeso(-10000);
|
||||||
|
|
||||||
qm.evolvePet(i, after);
|
qm.evolvePet(i, after);
|
||||||
// var petId = MaplePet.createPet(rand + 5000049, level, closeness, fullness);
|
// var petId = Pet.createPet(rand + 5000049, level, closeness, fullness);
|
||||||
// if (petId == -1) return;
|
// if (petId == -1) return;
|
||||||
// MapleInventoryManipulator.addById(qm.getClient(), rand+5000049, 1, "", petId);
|
// MapleInventoryManipulator.addById(qm.getClient(), rand+5000049, 1, "", petId);
|
||||||
qm.dispose();
|
qm.dispose();
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
private MapleRockPaperScissor rps;
|
private MapleRockPaperScissor rps;
|
||||||
private MapleMount maplemount;
|
private MapleMount maplemount;
|
||||||
private MapleParty party;
|
private MapleParty party;
|
||||||
private MaplePet[] pets = new MaplePet[3];
|
private Pet[] pets = new Pet[3];
|
||||||
private MaplePlayerShop playerShop = null;
|
private MaplePlayerShop playerShop = null;
|
||||||
private MapleShop shop = null;
|
private MapleShop shop = null;
|
||||||
private MapleSkinColor skinColor = MapleSkinColor.NORMAL;
|
private MapleSkinColor skinColor = MapleSkinColor.NORMAL;
|
||||||
@@ -616,7 +616,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
this.mesosTraded += gain;
|
this.mesosTraded += gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPet(MaplePet pet) {
|
public void addPet(Pet pet) {
|
||||||
petLock.lock();
|
petLock.lock();
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
@@ -2962,7 +2962,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
deletedCoupon = true;
|
deletedCoupon = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MaplePet pet = item.getPet(); // thanks Lame for noticing pets not getting despawned after expiration time
|
Pet pet = item.getPet(); // thanks Lame for noticing pets not getting despawned after expiration time
|
||||||
if (pet != null) {
|
if (pet != null) {
|
||||||
unequipPet(pet, true);
|
unequipPet(pet, true);
|
||||||
}
|
}
|
||||||
@@ -5614,7 +5614,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
this.setMessengerPosition(4);
|
this.setMessengerPosition(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaplePet[] getPets() {
|
public Pet[] getPets() {
|
||||||
petLock.lock();
|
petLock.lock();
|
||||||
try {
|
try {
|
||||||
return Arrays.copyOf(pets, pets.length);
|
return Arrays.copyOf(pets, pets.length);
|
||||||
@@ -5623,7 +5623,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaplePet getPet(int index) {
|
public Pet getPet(int index) {
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -5652,7 +5652,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getPetIndex(MaplePet pet) {
|
public byte getPetIndex(Pet pet) {
|
||||||
petLock.lock();
|
petLock.lock();
|
||||||
try {
|
try {
|
||||||
for (byte i = 0; i < 3; i++) {
|
for (byte i = 0; i < 3; i++) {
|
||||||
@@ -7042,7 +7042,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
ret.getInventory(item.getRight()).addItemFromDB(item.getLeft());
|
ret.getInventory(item.getRight()).addItemFromDB(item.getLeft());
|
||||||
Item itemz = item.getLeft();
|
Item itemz = item.getLeft();
|
||||||
if (itemz.getPetId() > -1) {
|
if (itemz.getPetId() > -1) {
|
||||||
MaplePet pet = itemz.getPet();
|
Pet pet = itemz.getPet();
|
||||||
if (pet != null && pet.isSummoned()) {
|
if (pet != null && pet.isSummoned()) {
|
||||||
ret.addPet(pet);
|
ret.addPet(pet);
|
||||||
}
|
}
|
||||||
@@ -7973,7 +7973,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePet(MaplePet pet, boolean shift_left) {
|
public void removePet(Pet pet, boolean shift_left) {
|
||||||
petLock.lock();
|
petLock.lock();
|
||||||
try {
|
try {
|
||||||
int slot = -1;
|
int slot = -1;
|
||||||
@@ -8477,7 +8477,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MaplePet> petList = new LinkedList<>();
|
List<Pet> petList = new LinkedList<>();
|
||||||
petLock.lock();
|
petLock.lock();
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
@@ -8489,7 +8489,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
petLock.unlock();
|
petLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MaplePet pet : petList) {
|
for (Pet pet : petList) {
|
||||||
pet.saveToDb();
|
pet.saveToDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9708,7 +9708,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runFullnessSchedule(int petSlot) {
|
public void runFullnessSchedule(int petSlot) {
|
||||||
MaplePet pet = getPet(petSlot);
|
Pet pet = getPet(petSlot);
|
||||||
if (pet == null) {
|
if (pet == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -9762,20 +9762,20 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
|||||||
|
|
||||||
public void unequipAllPets() {
|
public void unequipAllPets() {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MaplePet pet = getPet(i);
|
Pet pet = getPet(i);
|
||||||
if (pet != null) {
|
if (pet != null) {
|
||||||
unequipPet(pet, true);
|
unequipPet(pet, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unequipPet(MaplePet pet, boolean shift_left) {
|
public void unequipPet(Pet pet, boolean shift_left) {
|
||||||
unequipPet(pet, shift_left, false);
|
unequipPet(pet, shift_left, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unequipPet(MaplePet pet, boolean shift_left, boolean hunger) {
|
public void unequipPet(Pet pet, boolean shift_left, boolean hunger) {
|
||||||
byte petIdx = this.getPetIndex(pet);
|
byte petIdx = this.getPetIndex(pet);
|
||||||
MaplePet chrPet = this.getPet(petIdx);
|
Pet chrPet = this.getPet(petIdx);
|
||||||
|
|
||||||
if (chrPet != null) {
|
if (chrPet != null) {
|
||||||
chrPet.setSummoned(false);
|
chrPet.setSummoned(false);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ package client.command.commands.gm2;
|
|||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
import client.MapleClient;
|
import client.MapleClient;
|
||||||
import client.command.Command;
|
import client.command.Command;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||||
import config.YamlConfig;
|
import config.YamlConfig;
|
||||||
import constants.inventory.ItemConstants;
|
import constants.inventory.ItemConstants;
|
||||||
@@ -67,7 +67,7 @@ public class ItemCommand extends Command {
|
|||||||
quantity = 1;
|
quantity = 1;
|
||||||
long days = Math.max(1, Integer.parseInt(params[1]));
|
long days = Math.max(1, Integer.parseInt(params[1]));
|
||||||
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
|
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
|
||||||
int petid = MaplePet.createPet(itemId);
|
int petid = Pet.createPet(itemId);
|
||||||
|
|
||||||
MapleInventoryManipulator.addById(c, itemId, quantity, player.getName(), petid, expiration);
|
MapleInventoryManipulator.addById(c, itemId, quantity, player.getName(), petid, expiration);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import client.MapleClient;
|
|||||||
import client.command.Command;
|
import client.command.Command;
|
||||||
import client.inventory.InventoryType;
|
import client.inventory.InventoryType;
|
||||||
import client.inventory.Item;
|
import client.inventory.Item;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import config.YamlConfig;
|
import config.YamlConfig;
|
||||||
import constants.inventory.ItemConstants;
|
import constants.inventory.ItemConstants;
|
||||||
import server.MapleItemInformationProvider;
|
import server.MapleItemInformationProvider;
|
||||||
@@ -68,7 +68,7 @@ public class ItemDropCommand extends Command {
|
|||||||
quantity = 1;
|
quantity = 1;
|
||||||
long days = Math.max(1, Integer.parseInt(params[1]));
|
long days = Math.max(1, Integer.parseInt(params[1]));
|
||||||
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
|
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
|
||||||
int petid = MaplePet.createPet(itemId);
|
int petid = Pet.createPet(itemId);
|
||||||
|
|
||||||
Item toDrop = new Item(itemId, (short) 0, quantity, petid);
|
Item toDrop = new Item(itemId, (short) 0, quantity, petid);
|
||||||
toDrop.setExpiration(expiration);
|
toDrop.setExpiration(expiration);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ package client.command.commands.gm4;
|
|||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
import client.MapleClient;
|
import client.MapleClient;
|
||||||
import client.command.Command;
|
import client.command.Command;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||||
import server.maps.MapleMapItem;
|
import server.maps.MapleMapItem;
|
||||||
import server.maps.MapleMapObject;
|
import server.maps.MapleMapObject;
|
||||||
@@ -59,7 +59,7 @@ public class ForceVacCommand extends Command {
|
|||||||
// Add NX to account, show effect and make item disappear
|
// Add NX to account, show effect and make item disappear
|
||||||
player.getCashShop().gainCash(1, mapItem.getItemId() == 4031865 ? 100 : 250);
|
player.getCashShop().gainCash(1, mapItem.getItemId() == 4031865 ? 100 : 250);
|
||||||
} else if (mapItem.getItem().getItemId() >= 5000000 && mapItem.getItem().getItemId() <= 5000100) {
|
} else if (mapItem.getItem().getItemId() >= 5000000 && mapItem.getItem().getItemId() <= 5000100) {
|
||||||
int petId = MaplePet.createPet(mapItem.getItem().getItemId());
|
int petId = Pet.createPet(mapItem.getItem().getItemId());
|
||||||
if (petId == -1) {
|
if (petId == -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class Item implements Comparable<Item> {
|
|||||||
private short position;
|
private short position;
|
||||||
private short quantity;
|
private short quantity;
|
||||||
private int petid = -1;
|
private int petid = -1;
|
||||||
private MaplePet pet = null;
|
private Pet pet = null;
|
||||||
private String owner = "";
|
private String owner = "";
|
||||||
protected List<String> log;
|
protected List<String> log;
|
||||||
private short flag;
|
private short flag;
|
||||||
@@ -58,7 +58,7 @@ public class Item implements Comparable<Item> {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
if (petid > -1) { // issue with null "pet" having petid > -1 found thanks to MedicOP
|
if (petid > -1) { // issue with null "pet" having petid > -1 found thanks to MedicOP
|
||||||
this.pet = MaplePet.loadFromDb(id, position, petid);
|
this.pet = Pet.loadFromDb(id, position, petid);
|
||||||
if (this.pet == null) {
|
if (this.pet == null) {
|
||||||
petid = -1;
|
petid = -1;
|
||||||
}
|
}
|
||||||
@@ -184,7 +184,7 @@ public class Item implements Comparable<Item> {
|
|||||||
this.giftFrom = giftFrom;
|
this.giftFrom = giftFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaplePet getPet() {
|
public Pet getPet() {
|
||||||
return pet;
|
return pet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,10 +40,9 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Matze
|
* @author Matze
|
||||||
*/
|
*/
|
||||||
public class MaplePet extends Item {
|
public class Pet extends Item {
|
||||||
private String name;
|
private String name;
|
||||||
private int uniqueid;
|
private int uniqueid;
|
||||||
private int closeness = 0;
|
private int closeness = 0;
|
||||||
@@ -54,13 +53,13 @@ public class MaplePet extends Item {
|
|||||||
private int stance;
|
private int stance;
|
||||||
private boolean summoned;
|
private boolean summoned;
|
||||||
private int petFlag = 0;
|
private int petFlag = 0;
|
||||||
|
|
||||||
public enum PetFlag {
|
public enum PetFlag {
|
||||||
OWNER_SPEED(0x01);
|
OWNER_SPEED(0x01);
|
||||||
|
|
||||||
private int i;
|
|
||||||
|
|
||||||
private PetFlag(int i) {
|
private final int i;
|
||||||
|
|
||||||
|
PetFlag(int i) {
|
||||||
this.i = i;
|
this.i = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,14 +68,14 @@ public class MaplePet extends Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaplePet(int id, short position, int uniqueid) {
|
private Pet(int id, short position, int uniqueid) {
|
||||||
super(id, position, (short) 1);
|
super(id, position, (short) 1);
|
||||||
this.uniqueid = uniqueid;
|
this.uniqueid = uniqueid;
|
||||||
this.pos = new Point(0, 0);
|
this.pos = new Point(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MaplePet loadFromDb(int itemid, short position, int petid) {
|
public static Pet loadFromDb(int itemid, short position, int petid) {
|
||||||
MaplePet ret = new MaplePet(itemid, position, petid);
|
Pet ret = new Pet(itemid, position, petid);
|
||||||
try (Connection con = DatabaseConnection.getConnection();
|
try (Connection con = DatabaseConnection.getConnection();
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT name, level, closeness, fullness, summoned, flag FROM pets WHERE petid = ?")) { // Get the pet details...
|
PreparedStatement ps = con.prepareStatement("SELECT name, level, closeness, fullness, summoned, flag FROM pets WHERE petid = ?")) { // Get the pet details...
|
||||||
ps.setInt(1, petid);
|
ps.setInt(1, petid);
|
||||||
@@ -96,7 +95,7 @@ public class MaplePet extends Item {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteFromDb(MapleCharacter owner, int petid) {
|
public static void deleteFromDb(MapleCharacter owner, int petid) {
|
||||||
try (Connection con = DatabaseConnection.getConnection();
|
try (Connection con = DatabaseConnection.getConnection();
|
||||||
PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE `petid` = ?")) {
|
PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE `petid` = ?")) {
|
||||||
@@ -109,7 +108,7 @@ public class MaplePet extends Item {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveToDb() {
|
public void saveToDb() {
|
||||||
try (Connection con = DatabaseConnection.getConnection();
|
try (Connection con = DatabaseConnection.getConnection();
|
||||||
PreparedStatement ps = con.prepareStatement("UPDATE pets SET name = ?, level = ?, closeness = ?, fullness = ?, summoned = ?, flag = ? WHERE petid = ?")) {
|
PreparedStatement ps = con.prepareStatement("UPDATE pets SET name = ?, level = ?, closeness = ?, fullness = ?, summoned = ?, flag = ? WHERE petid = ?")) {
|
||||||
@@ -184,48 +183,55 @@ public class MaplePet extends Item {
|
|||||||
public byte getLevel() {
|
public byte getLevel() {
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gainClosenessFullness(MapleCharacter owner, int incCloseness, int incFullness, int type) {
|
public void gainClosenessFullness(MapleCharacter owner, int incCloseness, int incFullness, int type) {
|
||||||
byte slot = owner.getPetIndex(this);
|
byte slot = owner.getPetIndex(this);
|
||||||
boolean enjoyed;
|
boolean enjoyed;
|
||||||
|
|
||||||
//will NOT increase pet's closeness if tried to feed pet with 100% fullness
|
//will NOT increase pet's closeness if tried to feed pet with 100% fullness
|
||||||
if (fullness < 100 || incFullness == 0) { //incFullness == 0: command given
|
if (fullness < 100 || incFullness == 0) { //incFullness == 0: command given
|
||||||
int newFullness = fullness + incFullness;
|
int newFullness = fullness + incFullness;
|
||||||
if (newFullness > 100) newFullness = 100;
|
if (newFullness > 100) {
|
||||||
|
newFullness = 100;
|
||||||
|
}
|
||||||
fullness = newFullness;
|
fullness = newFullness;
|
||||||
|
|
||||||
if (incCloseness > 0 && closeness < 30000) {
|
if (incCloseness > 0 && closeness < 30000) {
|
||||||
int newCloseness = closeness + incCloseness;
|
int newCloseness = closeness + incCloseness;
|
||||||
if (newCloseness > 30000) newCloseness = 30000;
|
if (newCloseness > 30000) {
|
||||||
|
newCloseness = 30000;
|
||||||
|
}
|
||||||
|
|
||||||
closeness = newCloseness;
|
closeness = newCloseness;
|
||||||
while(newCloseness >= ExpTable.getClosenessNeededForLevel(level)) {
|
while (newCloseness >= ExpTable.getClosenessNeededForLevel(level)) {
|
||||||
level += 1;
|
level += 1;
|
||||||
owner.sendPacket(PacketCreator.showOwnPetLevelUp(slot));
|
owner.sendPacket(PacketCreator.showOwnPetLevelUp(slot));
|
||||||
owner.getMap().broadcastMessage(PacketCreator.showPetLevelUp(owner, slot));
|
owner.getMap().broadcastMessage(PacketCreator.showPetLevelUp(owner, slot));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enjoyed = true;
|
enjoyed = true;
|
||||||
} else {
|
} else {
|
||||||
int newCloseness = closeness - 1;
|
int newCloseness = closeness - 1;
|
||||||
if (newCloseness < 0) newCloseness = 0;
|
if (newCloseness < 0) {
|
||||||
|
newCloseness = 0;
|
||||||
|
}
|
||||||
|
|
||||||
closeness = newCloseness;
|
closeness = newCloseness;
|
||||||
if (level > 1 && newCloseness < ExpTable.getClosenessNeededForLevel(level - 1)) {
|
if (level > 1 && newCloseness < ExpTable.getClosenessNeededForLevel(level - 1)) {
|
||||||
level -= 1;
|
level -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
enjoyed = false;
|
enjoyed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
owner.getMap().broadcastMessage(PacketCreator.petFoodResponse(owner.getId(), slot, enjoyed, false));
|
owner.getMap().broadcastMessage(PacketCreator.petFoodResponse(owner.getId(), slot, enjoyed, false));
|
||||||
saveToDb();
|
saveToDb();
|
||||||
|
|
||||||
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
||||||
if (petz != null)
|
if (petz != null) {
|
||||||
owner.forceUpdateItem(petz);
|
owner.forceUpdateItem(petz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevel(byte level) {
|
public void setLevel(byte level) {
|
||||||
@@ -271,31 +277,33 @@ public class MaplePet extends Item {
|
|||||||
public void setSummoned(boolean yes) {
|
public void setSummoned(boolean yes) {
|
||||||
this.summoned = yes;
|
this.summoned = yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPetFlag() {
|
public int getPetFlag() {
|
||||||
return this.petFlag;
|
return this.petFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPetFlag(int flag) {
|
private void setPetFlag(int flag) {
|
||||||
this.petFlag = flag;
|
this.petFlag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPetFlag(MapleCharacter owner, PetFlag flag) {
|
public void addPetFlag(MapleCharacter owner, PetFlag flag) {
|
||||||
this.petFlag |= flag.getValue();
|
this.petFlag |= flag.getValue();
|
||||||
saveToDb();
|
saveToDb();
|
||||||
|
|
||||||
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
||||||
if (petz != null)
|
if (petz != null) {
|
||||||
owner.forceUpdateItem(petz);
|
owner.forceUpdateItem(petz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePetFlag(MapleCharacter owner, PetFlag flag) {
|
public void removePetFlag(MapleCharacter owner, PetFlag flag) {
|
||||||
this.petFlag &= 0xFFFFFFFF ^ flag.getValue();
|
this.petFlag &= 0xFFFFFFFF ^ flag.getValue();
|
||||||
saveToDb();
|
saveToDb();
|
||||||
|
|
||||||
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
||||||
if (petz != null)
|
if (petz != null) {
|
||||||
owner.forceUpdateItem(petz);
|
owner.forceUpdateItem(petz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair<Integer, Boolean> canConsume(int itemId) {
|
public Pair<Integer, Boolean> canConsume(int itemId) {
|
||||||
@@ -408,7 +408,7 @@ public class MapleInventoryManipulator {
|
|||||||
if (petid > -1) { // thanks Vcoc for finding a d/c issue with equipped pets and pets remaining on DB here
|
if (petid > -1) { // thanks Vcoc for finding a d/c issue with equipped pets and pets remaining on DB here
|
||||||
int petIdx = chr.getPetIndex(petid);
|
int petIdx = chr.getPetIndex(petid);
|
||||||
if(petIdx > -1) {
|
if(petIdx > -1) {
|
||||||
MaplePet pet = chr.getPet(petIdx);
|
Pet pet = chr.getPet(petIdx);
|
||||||
chr.unequipPet(pet, true);
|
chr.unequipPet(pet, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,7 +702,7 @@ public class MapleInventoryManipulator {
|
|||||||
if (petid > -1) {
|
if (petid > -1) {
|
||||||
int petIdx = chr.getPetIndex(petid);
|
int petIdx = chr.getPetIndex(petid);
|
||||||
if(petIdx > -1) {
|
if(petIdx > -1) {
|
||||||
MaplePet pet = chr.getPet(petIdx);
|
Pet pet = chr.getPet(petIdx);
|
||||||
chr.unequipPet(pet, true);
|
chr.unequipPet(pet, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import client.MapleCharacter;
|
|||||||
import client.MapleClient;
|
import client.MapleClient;
|
||||||
import client.SkillFactory;
|
import client.SkillFactory;
|
||||||
import client.inventory.InventoryType;
|
import client.inventory.InventoryType;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||||
import provider.MapleDataProvider;
|
import provider.MapleDataProvider;
|
||||||
import provider.MapleDataProviderFactory;
|
import provider.MapleDataProviderFactory;
|
||||||
@@ -44,7 +44,7 @@ public class SpawnPetProcessor {
|
|||||||
if (c.tryacquireClient()) {
|
if (c.tryacquireClient()) {
|
||||||
try {
|
try {
|
||||||
MapleCharacter chr = c.getPlayer();
|
MapleCharacter chr = c.getPlayer();
|
||||||
MaplePet pet = chr.getInventory(InventoryType.CASH).getItem(slot).getPet();
|
Pet pet = chr.getInventory(InventoryType.CASH).getItem(slot).getPet();
|
||||||
if (pet == null) return;
|
if (pet == null) return;
|
||||||
|
|
||||||
int petid = pet.getItemId();
|
int petid = pet.getItemId();
|
||||||
@@ -56,7 +56,7 @@ public class SpawnPetProcessor {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
int evolveid = MapleDataTool.getInt("info/evol1", dataRoot.getData("Pet/" + petid + ".img"));
|
int evolveid = MapleDataTool.getInt("info/evol1", dataRoot.getData("Pet/" + petid + ".img"));
|
||||||
int petId = MaplePet.createPet(evolveid);
|
int petId = Pet.createPet(evolveid);
|
||||||
if (petId == -1) {
|
if (petId == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ package net.server.channel.handlers;
|
|||||||
|
|
||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
import client.MapleClient;
|
import client.MapleClient;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import client.inventory.PetCommand;
|
import client.inventory.PetCommand;
|
||||||
import client.inventory.PetDataFactory;
|
import client.inventory.PetDataFactory;
|
||||||
import net.AbstractPacketHandler;
|
import net.AbstractPacketHandler;
|
||||||
@@ -38,7 +38,7 @@ public final class PetCommandHandler extends AbstractPacketHandler {
|
|||||||
MapleCharacter chr = c.getPlayer();
|
MapleCharacter chr = c.getPlayer();
|
||||||
int petId = p.readInt();
|
int petId = p.readInt();
|
||||||
byte petIndex = chr.getPetIndex(petId);
|
byte petIndex = chr.getPetIndex(petId);
|
||||||
MaplePet pet;
|
Pet pet;
|
||||||
if (petIndex == -1) {
|
if (petIndex == -1) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ package net.server.channel.handlers;
|
|||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
import client.MapleClient;
|
import client.MapleClient;
|
||||||
import client.autoban.AutobanFactory;
|
import client.autoban.AutobanFactory;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import net.AbstractPacketHandler;
|
import net.AbstractPacketHandler;
|
||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ public final class PetExcludeItemsHandler extends AbstractPacketHandler {
|
|||||||
byte petIndex = chr.getPetIndex(petId);
|
byte petIndex = chr.getPetIndex(petId);
|
||||||
if (petIndex < 0) return;
|
if (petIndex < 0) return;
|
||||||
|
|
||||||
final MaplePet pet = chr.getPet(petIndex);
|
final Pet pet = chr.getPet(petIndex);
|
||||||
if (pet == null) {
|
if (pet == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import client.autoban.AutobanManager;
|
|||||||
import client.inventory.Inventory;
|
import client.inventory.Inventory;
|
||||||
import client.inventory.InventoryType;
|
import client.inventory.InventoryType;
|
||||||
import client.inventory.Item;
|
import client.inventory.Item;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||||
import net.AbstractPacketHandler;
|
import net.AbstractPacketHandler;
|
||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
@@ -53,7 +53,7 @@ public final class PetFoodHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
int previousFullness = 100;
|
int previousFullness = 100;
|
||||||
byte slot = 0;
|
byte slot = 0;
|
||||||
MaplePet[] pets = chr.getPets();
|
Pet[] pets = chr.getPets();
|
||||||
for (byte i = 0; i < 3; i++) {
|
for (byte i = 0; i < 3; i++) {
|
||||||
if (pets[i] != null) {
|
if (pets[i] != null) {
|
||||||
if (pets[i].getFullness() < previousFullness) {
|
if (pets[i].getFullness() < previousFullness) {
|
||||||
@@ -63,7 +63,7 @@ public final class PetFoodHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MaplePet pet = chr.getPet(slot);
|
Pet pet = chr.getPet(slot);
|
||||||
if(pet == null) return;
|
if(pet == null) return;
|
||||||
|
|
||||||
short pos = p.readShort();
|
short pos = p.readShort();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ package net.server.channel.handlers;
|
|||||||
|
|
||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
import client.MapleClient;
|
import client.MapleClient;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import net.AbstractPacketHandler;
|
import net.AbstractPacketHandler;
|
||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
import server.maps.MapleMapItem;
|
import server.maps.MapleMapItem;
|
||||||
@@ -42,7 +42,7 @@ public final class PetLootHandler extends AbstractPacketHandler {
|
|||||||
MapleCharacter chr = c.getPlayer();
|
MapleCharacter chr = c.getPlayer();
|
||||||
|
|
||||||
int petIndex = chr.getPetIndex(p.readInt());
|
int petIndex = chr.getPetIndex(p.readInt());
|
||||||
MaplePet pet = chr.getPet(petIndex);
|
Pet pet = chr.getPet(petIndex);
|
||||||
if (pet == null || !pet.isSummoned()) {
|
if (pet == null || !pet.isSummoned()) {
|
||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler {
|
|||||||
player.checkBerserk(player.isHidden());
|
player.checkBerserk(player.isHidden());
|
||||||
|
|
||||||
if (newcomer) {
|
if (newcomer) {
|
||||||
for (MaplePet pet : player.getPets()) {
|
for (Pet pet : player.getPets()) {
|
||||||
if (pet != null) {
|
if (pet != null) {
|
||||||
wserv.registerPetHunger(player, player.getPetIndex(pet));
|
wserv.registerPetHunger(player, player.getPetIndex(pet));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
|
|||||||
player.getMap().startMapEffect(ii.getMsg(itemId).replaceFirst("%s", player.getName()).replaceFirst("%s", p.readString()), itemId);
|
player.getMap().startMapEffect(ii.getMsg(itemId).replaceFirst("%s", player.getName()).replaceFirst("%s", p.readString()), itemId);
|
||||||
remove(c, position, itemId);
|
remove(c, position, itemId);
|
||||||
} else if (itemType == 517) {
|
} else if (itemType == 517) {
|
||||||
MaplePet pet = player.getPet(0);
|
Pet pet = player.getPet(0);
|
||||||
if (pet == null) {
|
if (pet == null) {
|
||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
@@ -405,7 +405,7 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
|
|||||||
|
|
||||||
} else if (itemType == 524) {
|
} else if (itemType == 524) {
|
||||||
for (byte i = 0; i < 3; i++) {
|
for (byte i = 0; i < 3; i++) {
|
||||||
MaplePet pet = player.getPet(i);
|
Pet pet = player.getPet(i);
|
||||||
if (pet != null) {
|
if (pet != null) {
|
||||||
Pair<Integer, Boolean> pair = pet.canConsume(itemId);
|
Pair<Integer, Boolean> pair = pet.canConsume(itemId);
|
||||||
|
|
||||||
|
|||||||
@@ -498,8 +498,8 @@ public class AbstractPlayerInteraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Item evolvePet(byte slot, int afterId) {
|
public Item evolvePet(byte slot, int afterId) {
|
||||||
MaplePet evolved = null;
|
Pet evolved = null;
|
||||||
MaplePet target;
|
Pet target;
|
||||||
|
|
||||||
long period = (long) 90 * 24 * 60 * 60 * 1000; //refreshes expiration date: 90 days
|
long period = (long) 90 * 24 * 60 * 60 * 1000; //refreshes expiration date: 90 days
|
||||||
|
|
||||||
@@ -512,7 +512,7 @@ public class AbstractPlayerInteraction {
|
|||||||
Item tmp = gainItem(afterId, (short) 1, false, true, period, target);
|
Item tmp = gainItem(afterId, (short) 1, false, true, period, target);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
evolved = MaplePet.loadFromDb(tmp.getItemId(), tmp.getPosition(), tmp.getPetId());
|
evolved = Pet.loadFromDb(tmp.getItemId(), tmp.getPosition(), tmp.getPetId());
|
||||||
|
|
||||||
evolved = tmp.getPet();
|
evolved = tmp.getPet();
|
||||||
if(evolved == null) {
|
if(evolved == null) {
|
||||||
@@ -561,17 +561,17 @@ public class AbstractPlayerInteraction {
|
|||||||
return gainItem(id, quantity, randomStats, showMessage, expires, null);
|
return gainItem(id, quantity, randomStats, showMessage, expires, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item gainItem(int id, short quantity, boolean randomStats, boolean showMessage, long expires, MaplePet from) {
|
public Item gainItem(int id, short quantity, boolean randomStats, boolean showMessage, long expires, Pet from) {
|
||||||
Item item = null;
|
Item item = null;
|
||||||
MaplePet evolved;
|
Pet evolved;
|
||||||
int petId = -1;
|
int petId = -1;
|
||||||
|
|
||||||
if (quantity >= 0) {
|
if (quantity >= 0) {
|
||||||
if (ItemConstants.isPet(id)) {
|
if (ItemConstants.isPet(id)) {
|
||||||
petId = MaplePet.createPet(id);
|
petId = Pet.createPet(id);
|
||||||
|
|
||||||
if(from != null) {
|
if(from != null) {
|
||||||
evolved = MaplePet.loadFromDb(id, (short) 0, petId);
|
evolved = Pet.loadFromDb(id, (short) 0, petId);
|
||||||
|
|
||||||
Point pos = getPlayer().getPosition();
|
Point pos = getPlayer().getPosition();
|
||||||
pos.y -= 12;
|
pos.y -= 12;
|
||||||
@@ -1113,13 +1113,13 @@ public class AbstractPlayerInteraction {
|
|||||||
return getPlayer().getJailExpirationTimeLeft();
|
return getPlayer().getJailExpirationTimeLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MaplePet> getDriedPets() {
|
public List<Pet> getDriedPets() {
|
||||||
List<MaplePet> list = new LinkedList<>();
|
List<Pet> list = new LinkedList<>();
|
||||||
|
|
||||||
long curTime = System.currentTimeMillis();
|
long curTime = System.currentTimeMillis();
|
||||||
for(Item it : getPlayer().getInventory(InventoryType.CASH).list()) {
|
for(Item it : getPlayer().getInventory(InventoryType.CASH).list()) {
|
||||||
if(ItemConstants.isPet(it.getItemId()) && it.getExpiration() < curTime) {
|
if(ItemConstants.isPet(it.getItemId()) && it.getExpiration() < curTime) {
|
||||||
MaplePet pet = it.getPet();
|
Pet pet = it.getPet();
|
||||||
if (pet != null) {
|
if (pet != null) {
|
||||||
list.add(pet);
|
list.add(pet);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ package scripting.npc;
|
|||||||
import client.*;
|
import client.*;
|
||||||
import client.inventory.Item;
|
import client.inventory.Item;
|
||||||
import client.inventory.ItemFactory;
|
import client.inventory.ItemFactory;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import config.YamlConfig;
|
import config.YamlConfig;
|
||||||
import constants.game.GameConstants;
|
import constants.game.GameConstants;
|
||||||
import constants.inventory.ItemConstants;
|
import constants.inventory.ItemConstants;
|
||||||
@@ -336,7 +336,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void gainCloseness(int closeness) {
|
public void gainCloseness(int closeness) {
|
||||||
for (MaplePet pet : getPlayer().getPets()) {
|
for (Pet pet : getPlayer().getPets()) {
|
||||||
if(pet != null) {
|
if(pet != null) {
|
||||||
pet.gainClosenessFullness(getPlayer(), closeness, 0, 0);
|
pet.gainClosenessFullness(getPlayer(), closeness, 0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class CashShop {
|
|||||||
|
|
||||||
int petid = -1;
|
int petid = -1;
|
||||||
if (ItemConstants.isPet(itemId)) {
|
if (ItemConstants.isPet(itemId)) {
|
||||||
petid = MaplePet.createPet(itemId);
|
petid = Pet.createPet(itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ItemConstants.getInventoryType(itemId).equals(InventoryType.EQUIP)) {
|
if (ItemConstants.getInventoryType(itemId).equals(InventoryType.EQUIP)) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ package server;
|
|||||||
import client.MapleClient;
|
import client.MapleClient;
|
||||||
import client.inventory.InventoryType;
|
import client.inventory.InventoryType;
|
||||||
import client.inventory.Item;
|
import client.inventory.Item;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||||
import constants.inventory.ItemConstants;
|
import constants.inventory.ItemConstants;
|
||||||
import tools.DatabaseConnection;
|
import tools.DatabaseConnection;
|
||||||
@@ -138,7 +138,7 @@ public class MapleShop {
|
|||||||
int diff = cardreduce + c.getPlayer().getMeso();
|
int diff = cardreduce + c.getPlayer().getMeso();
|
||||||
if (MapleInventoryManipulator.checkSpace(c, itemId, quantity, "")) {
|
if (MapleInventoryManipulator.checkSpace(c, itemId, quantity, "")) {
|
||||||
if (ItemConstants.isPet(itemId)) {
|
if (ItemConstants.isPet(itemId)) {
|
||||||
int petid = MaplePet.createPet(itemId);
|
int petid = Pet.createPet(itemId);
|
||||||
MapleInventoryManipulator.addById(c, itemId, quantity, "", petid, -1);
|
MapleInventoryManipulator.addById(c, itemId, quantity, "", petid, -1);
|
||||||
} else {
|
} else {
|
||||||
MapleInventoryManipulator.addById(c, itemId, quantity, "", -1, -1);
|
MapleInventoryManipulator.addById(c, itemId, quantity, "", -1, -1);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import client.autoban.AutobanFactory;
|
|||||||
import client.inventory.Equip;
|
import client.inventory.Equip;
|
||||||
import client.inventory.InventoryType;
|
import client.inventory.InventoryType;
|
||||||
import client.inventory.Item;
|
import client.inventory.Item;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import client.status.MonsterStatus;
|
import client.status.MonsterStatus;
|
||||||
import client.status.MonsterStatusEffect;
|
import client.status.MonsterStatusEffect;
|
||||||
import config.YamlConfig;
|
import config.YamlConfig;
|
||||||
@@ -2452,8 +2452,8 @@ public class MapleMap {
|
|||||||
chr.sendPacket(PacketCreator.getClock(pqTimer / 1000));
|
chr.sendPacket(PacketCreator.getClock(pqTimer / 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
MaplePet[] pets = chr.getPets();
|
Pet[] pets = chr.getPets();
|
||||||
for (MaplePet pet : pets) {
|
for (Pet pet : pets) {
|
||||||
if (pet != null) {
|
if (pet != null) {
|
||||||
pet.setPos(getGroundBelow(chr.getPosition()));
|
pet.setPos(getGroundBelow(chr.getPosition()));
|
||||||
chr.sendPacket(PacketCreator.showPet(chr, pet, false, false));
|
chr.sendPacket(PacketCreator.showPet(chr, pet, false, false));
|
||||||
|
|||||||
@@ -19,11 +19,10 @@
|
|||||||
*/
|
*/
|
||||||
package server.quest.actions;
|
package server.quest.actions;
|
||||||
|
|
||||||
import client.MapleClient;
|
|
||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
import client.inventory.MaplePet;
|
import client.MapleClient;
|
||||||
|
import client.inventory.Pet;
|
||||||
import provider.MapleData;
|
import provider.MapleData;
|
||||||
import provider.MapleDataTool;
|
|
||||||
import server.quest.MapleQuest;
|
import server.quest.MapleQuest;
|
||||||
import server.quest.MapleQuestActionType;
|
import server.quest.MapleQuestActionType;
|
||||||
|
|
||||||
@@ -46,12 +45,12 @@ public class PetSpeedAction extends MapleQuestAction {
|
|||||||
public void run(MapleCharacter chr, Integer extSelection) {
|
public void run(MapleCharacter chr, Integer extSelection) {
|
||||||
MapleClient c = chr.getClient();
|
MapleClient c = chr.getClient();
|
||||||
|
|
||||||
MaplePet pet = chr.getPet(0); // assuming here only the pet leader will gain owner speed
|
Pet pet = chr.getPet(0); // assuming here only the pet leader will gain owner speed
|
||||||
if(pet == null) return;
|
if(pet == null) return;
|
||||||
|
|
||||||
c.lockClient();
|
c.lockClient();
|
||||||
try {
|
try {
|
||||||
pet.addPetFlag(c.getPlayer(), MaplePet.PetFlag.OWNER_SPEED);
|
pet.addPetFlag(c.getPlayer(), Pet.PetFlag.OWNER_SPEED);
|
||||||
} finally {
|
} finally {
|
||||||
c.unlockClient();
|
c.unlockClient();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
*/
|
*/
|
||||||
package server.quest.actions;
|
package server.quest.actions;
|
||||||
|
|
||||||
import client.MapleClient;
|
|
||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
import client.inventory.MaplePet;
|
import client.MapleClient;
|
||||||
|
import client.inventory.Pet;
|
||||||
import provider.MapleData;
|
import provider.MapleData;
|
||||||
import provider.MapleDataTool;
|
import provider.MapleDataTool;
|
||||||
import server.quest.MapleQuest;
|
import server.quest.MapleQuest;
|
||||||
@@ -50,7 +50,7 @@ public class PetTamenessAction extends MapleQuestAction {
|
|||||||
public void run(MapleCharacter chr, Integer extSelection) {
|
public void run(MapleCharacter chr, Integer extSelection) {
|
||||||
MapleClient c = chr.getClient();
|
MapleClient c = chr.getClient();
|
||||||
|
|
||||||
MaplePet pet = chr.getPet(0); // assuming here only the pet leader will gain tameness
|
Pet pet = chr.getPet(0); // assuming here only the pet leader will gain tameness
|
||||||
if(pet == null) return;
|
if(pet == null) return;
|
||||||
|
|
||||||
c.lockClient();
|
c.lockClient();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
package server.quest.requirements;
|
package server.quest.requirements;
|
||||||
|
|
||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import provider.MapleData;
|
import provider.MapleData;
|
||||||
import provider.MapleDataTool;
|
import provider.MapleDataTool;
|
||||||
import server.quest.MapleQuest;
|
import server.quest.MapleQuest;
|
||||||
@@ -55,7 +55,7 @@ public class MinTamenessRequirement extends MapleQuestRequirement {
|
|||||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||||
int curCloseness = 0;
|
int curCloseness = 0;
|
||||||
|
|
||||||
for(MaplePet pet : chr.getPets()) {
|
for(Pet pet : chr.getPets()) {
|
||||||
if(pet == null) continue;
|
if(pet == null) continue;
|
||||||
|
|
||||||
if(pet.getCloseness() > curCloseness)
|
if(pet.getCloseness() > curCloseness)
|
||||||
|
|||||||
@@ -22,14 +22,15 @@
|
|||||||
package server.quest.requirements;
|
package server.quest.requirements;
|
||||||
|
|
||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
import client.inventory.MaplePet;
|
import client.inventory.Pet;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import provider.MapleData;
|
import provider.MapleData;
|
||||||
import provider.MapleDataTool;
|
import provider.MapleDataTool;
|
||||||
import server.quest.MapleQuest;
|
import server.quest.MapleQuest;
|
||||||
import server.quest.MapleQuestRequirementType;
|
import server.quest.MapleQuestRequirementType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Tyler (Twdtwd)
|
* @author Tyler (Twdtwd)
|
||||||
@@ -54,7 +55,7 @@ public class PetRequirement extends MapleQuestRequirement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||||
for(MaplePet pet : chr.getPets()) {
|
for(Pet pet : chr.getPets()) {
|
||||||
if(pet == null) continue; // thanks Arufonsu for showing a NPE occurring here
|
if(pet == null) continue; // thanks Arufonsu for showing a NPE occurring here
|
||||||
|
|
||||||
if(petIDs.contains(pet.getItemId()))
|
if(petIDs.contains(pet.getItemId()))
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public class PacketCreator {
|
|||||||
p.writeInt(chr.getHair()); // hair
|
p.writeInt(chr.getHair()); // hair
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MaplePet pet = chr.getPet(i);
|
Pet pet = chr.getPet(i);
|
||||||
if (pet != null) //Checked GMS.. and your pets stay when going into the cash shop.
|
if (pet != null) //Checked GMS.. and your pets stay when going into the cash shop.
|
||||||
{
|
{
|
||||||
p.writeLong(pet.getUniqueId());
|
p.writeLong(pet.getUniqueId());
|
||||||
@@ -375,7 +375,7 @@ public class PacketCreator {
|
|||||||
}
|
}
|
||||||
addExpirationTime(p, item.getExpiration());
|
addExpirationTime(p, item.getExpiration());
|
||||||
if (isPet) {
|
if (isPet) {
|
||||||
MaplePet pet = item.getPet();
|
Pet pet = item.getPet();
|
||||||
p.writeFixedString(StringUtil.getRightPaddedStr(pet.getName(), '\0', 13));
|
p.writeFixedString(StringUtil.getRightPaddedStr(pet.getName(), '\0', 13));
|
||||||
p.writeByte(pet.getLevel());
|
p.writeByte(pet.getLevel());
|
||||||
p.writeShort(pet.getCloseness());
|
p.writeShort(pet.getCloseness());
|
||||||
@@ -1937,7 +1937,7 @@ public class PacketCreator {
|
|||||||
|
|
||||||
p.writeShort(0);//chr.getFh()
|
p.writeShort(0);//chr.getFh()
|
||||||
p.writeByte(0);
|
p.writeByte(0);
|
||||||
MaplePet[] pet = chr.getPets();
|
Pet[] pet = chr.getPets();
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (pet[i] != null) {
|
if (pet[i] != null) {
|
||||||
addPetInfo(p, pet[i], false);
|
addPetInfo(p, pet[i], false);
|
||||||
@@ -2693,7 +2693,7 @@ public class PacketCreator {
|
|||||||
p.writeString(allianceName); // does not seem to work
|
p.writeString(allianceName); // does not seem to work
|
||||||
p.writeByte(0); // pMedalInfo, thanks to Arnah (Vertisy)
|
p.writeByte(0); // pMedalInfo, thanks to Arnah (Vertisy)
|
||||||
|
|
||||||
MaplePet[] pets = chr.getPets();
|
Pet[] pets = chr.getPets();
|
||||||
Item inv = chr.getInventory(InventoryType.EQUIPPED).getItem((short) -114);
|
Item inv = chr.getInventory(InventoryType.EQUIPPED).getItem((short) -114);
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (pets[i] != null) {
|
if (pets[i] != null) {
|
||||||
@@ -4361,7 +4361,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addPetInfo(final OutPacket p, MaplePet pet, boolean showpet) {
|
private static void addPetInfo(final OutPacket p, Pet pet, boolean showpet) {
|
||||||
p.writeByte(1);
|
p.writeByte(1);
|
||||||
if (showpet) {
|
if (showpet) {
|
||||||
p.writeByte(0);
|
p.writeByte(0);
|
||||||
@@ -4375,7 +4375,7 @@ public class PacketCreator {
|
|||||||
p.writeInt(pet.getFh());
|
p.writeInt(pet.getFh());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet showPet(MapleCharacter chr, MaplePet pet, boolean remove, boolean hunger) {
|
public static Packet showPet(MapleCharacter chr, Pet pet, boolean remove, boolean hunger) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.SPAWN_PET);
|
OutPacket p = OutPacket.create(SendOpcode.SPAWN_PET);
|
||||||
p.writeInt(chr.getId());
|
p.writeInt(chr.getId());
|
||||||
p.writeByte(chr.getPetIndex(pet));
|
p.writeByte(chr.getPetIndex(pet));
|
||||||
@@ -4475,7 +4475,7 @@ public class PacketCreator {
|
|||||||
mask |= MapleStat.PET.getValue();
|
mask |= MapleStat.PET.getValue();
|
||||||
p.writeByte(0);
|
p.writeByte(0);
|
||||||
p.writeInt(mask);
|
p.writeInt(mask);
|
||||||
MaplePet[] pets = chr.getPets();
|
Pet[] pets = chr.getPets();
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (pets[i] != null) {
|
if (pets[i] != null) {
|
||||||
p.writeLong(pets[i].getUniqueId());
|
p.writeLong(pets[i].getUniqueId());
|
||||||
|
|||||||
Reference in New Issue
Block a user