Fixed bug involving kitten/cat deletion

This commit is contained in:
Player Name 2023-11-05 08:20:06 +00:00 committed by Ryan
parent 978d70ad0c
commit f28076f3a4
4 changed files with 29 additions and 22 deletions

View file

@ -47,7 +47,7 @@ class CatOnArdougneCivilian: InteractionListener {
override fun defineListeners() {
onUseWith(IntType.NPC,cats,*civilians){ player, used, _ ->
sendItemDialogue(player,Items.DEATH_RUNE_560,"You hand over the cat.<br>You are given 100 Death Runes.")
player.familiarManager.removeDetails(used.id)
player.familiarManager.removeDetails(used.idHash)
removeItem(player,used,Container.INVENTORY)
addItem(player,Items.DEATH_RUNE_560,100)
return@onUseWith true

View file

@ -418,14 +418,10 @@ public final class FamiliarManager {
/**
* Removes the details for this pet.
* @param itemId The item id of the pet.
* @param itemIdHash The item id hash of the pet.
*/
public void removeDetails(int itemId) {
Pets pets = Pets.forId(itemId);
if (pets == null) {
return;
}
petDetails.remove(pets.getBabyItemId());
public void removeDetails(int itemIdHash) {
petDetails.remove(itemIdHash);
}
/**

View file

@ -1,5 +1,8 @@
package content.region.misthalin.varrock.dialogue;
import content.global.skill.summoning.pet.Pet;
import content.global.skill.summoning.pet.PetDetails;
import core.game.container.Container;
import core.game.dialogue.DialoguePlugin;
import core.game.dialogue.FacialExpression;
import core.game.node.entity.npc.NPC;
@ -9,6 +12,8 @@ import core.game.node.item.Item;
import core.plugin.Initializable;
import core.tools.RandomFunction;
import java.util.Map;
/**
* Represents the gertrude dialogue plugin.
* @author 'Vexia
@ -326,20 +331,18 @@ public final class GertrudeDialogue extends DialoguePlugin {
case 503:
boolean has = false;
int[] kittens = new int[] { 1555, 1556, 1557, 1558, 1559, 1560, 7583 };
for (int i : kittens) {
// if (player.getFamiliarManager().hasFamiliar()) {TODO:Pet
// if
// (player.getFamiliarManager().getFamiliar().getDetails()
// instanceof PetDetails) {
// final PetDetails details = ((PetDetails)
// player.getFamiliarManager().getFamiliar().getDetails());
// if (details.getPet().getBabyItemId() == i) {
// has = true;
// break;
// }
// }
// }
if (player.getInventory().contains(i, 1) || player.getBank().contains(i, 1)) {
if (player.getFamiliarManager().hasFamiliar()) {
Pet pet = (Pet) player.getFamiliarManager().getFamiliar();
for (int i : kittens) {
if (pet.getItemId() == i) {
has = true;
break;
}
}
}
Container[] searchSpace = {player.getInventory(), player.getBankPrimary(), player.getBankSecondary()};
for (Container container : searchSpace) {
if (container.containsAtLeastOneItem(kittens)) {
has = true;
break;
}

View file

@ -112,6 +112,14 @@ public abstract class Node {
return this instanceof NPC ? ((NPC) this).getId() : this instanceof Scenery ? ((Scenery) this).getId() : this instanceof Item ? ((Item) this).getId() : -1;
}
/**
* Gets the node id hash (only relevant if the node is an item).
* @return the id hash.
*/
public int getIdHash() {
return this instanceof Item ? ((Item) this).getIdHash() : -1;
}
/**
* Gets the center location.
* @return The center location.