/// <summary> /// Tries to load a pet from the database and makes it visible in the room. If the X and Y parameters are not both zero, then the pet will be placed at the new position. /// </summary> /// <param name="nestID">The database ID of the nest item of the pet to load.</param> /// <param name="newX">The new X position of the pet. Supply 0 to set the last saved X position of the pet.</param> /// <param name="newY">The new Y position of the pet. Supply 0 to set the last saved Y position of the pet.</param> public void loadRoomPet(int nestID, byte newX, byte newY) { if (this.roomPets != null) { virtualPetInformation pInfo = ObjectTree.Game.Items.getPetInformation(nestID); if (pInfo != null) { roomPet pPet = new roomPet(pInfo); pPet.ID = this.getFreeRoomUnitIdentifier(); if (newX > 0 || newY > 0) // New placement from user hand { pPet.X = newX; pPet.Y = newY; } else { pPet.X = pPet.Information.lastX; pPet.Y = pPet.Information.lastY; } pPet.Z = this.gridHeight[pPet.X, pPet.Y]; this.gridUnit[pPet.X, pPet.Y] = true; this.roomPets.Add(pPet); if (newX > 0 || newY > 0) // New placement during instance lifetime { castRoomUnit(pPet.ToString()); } } } }
/// <summary> /// Removes a pet with a given nest ID from the room pet collection, updates the pet information in the database, releases it's map spot and makes it disappear for clients. /// </summary> /// <param name="nestID">The database ID of the nest item of the pet.</param> /// <param name="removedFromRoom">Supply true if this pet is removed from the room by someone with flat admin, and it's coordinates should be reset.</param> public void unloadRoomPet(int nestID, bool removedFromRoom) { if (this.roomPets != null) { for (int x = 0; x < this.roomPets.Count; x++) { roomPet pPet = this.roomPets[x]; if (pPet.Information.ID == nestID) { this.releaseRoomUnit(pPet.ID, pPet.X, pPet.Y); if (removedFromRoom) // Removed from room, reset coordinates { pPet.X = 0; pPet.Y = 0; // TODO: less happiness? } pPet.Information.Update(); this.roomPets.RemoveAt(x); return; } } } }
/// <summary> /// Tries to load a pet from the database and makes it visible in the room. If the X and Y parameters are not both zero, then the pet will be placed at the new position. /// </summary> /// <param name="nestID">The database ID of the nest item of the pet to load.</param> /// <param name="newX">The new X position of the pet. Supply 0 to set the last saved X position of the pet.</param> /// <param name="newY">The new Y position of the pet. Supply 0 to set the last saved Y position of the pet.</param> public void loadRoomPet(int nestID, byte newX, byte newY) { if (this.roomPets != null) { virtualPetInformation pInfo = ObjectTree.Game.Items.getPetInformation(nestID); if (pInfo != null) { roomPet pPet = new roomPet(pInfo); pPet.ID = this.getFreeRoomUnitIdentifier(); if (newX > 0 || newY > 0) // New placement from user hand { pPet.X = newX; pPet.Y = newY; } else { pPet.X = pPet.Information.lastX; pPet.Y = pPet.Information.lastY; } pPet.Z = this.gridHeight[pPet.X, pPet.Y]; this.gridUnit[pPet.X, pPet.Y] = true; this.roomPets.Add(pPet); if (newX > 0 || newY > 0) // New placement during instance lifetime castRoomUnit(pPet.ToString()); } } }
/// <summary> /// 128 - "B@" /// </summary> public void GETPETSTAT() { int petID = int.Parse(Request.getParameter(0).Split(Convert.ToChar(4))[0]); roomPet pPet = Session.roomInstance.getRoomPet(petID); if (pPet != null) { Response.Initialize(210); // "CR" Response.appendWired(pPet.ID); Response.appendWired(pPet.Information.Age); Response.appendWired((int)pPet.Information.Hunger); Response.appendWired((int)pPet.Information.Thirst); Response.appendWired((int)pPet.Information.Happiness); Response.appendWired((int)pPet.Information.Energy); Response.appendWired((int)pPet.Information.Friendship); sendResponse(); } }