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() { override fun defineListeners() {
onUseWith(IntType.NPC,cats,*civilians){ player, used, _ -> 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.") 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) removeItem(player,used,Container.INVENTORY)
addItem(player,Items.DEATH_RUNE_560,100) addItem(player,Items.DEATH_RUNE_560,100)
return@onUseWith true return@onUseWith true

View file

@ -418,14 +418,10 @@ public final class FamiliarManager {
/** /**
* Removes the details for this pet. * 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) { public void removeDetails(int itemIdHash) {
Pets pets = Pets.forId(itemId); petDetails.remove(itemIdHash);
if (pets == null) {
return;
}
petDetails.remove(pets.getBabyItemId());
} }
/** /**

View file

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