I’m going for a high score on the Kithgard Brawl stage, and I’m attempting to use my good boi, the pet wolf, to fetch me those health potions while I hold the center field and shoot everything. However, my wolf will not fetch the potions at all. I’ve gotten my pets to fetch items before, so why isn’t he doing his job? Code below:
function potionFetch(){
var needsHealing = hero.maxHealth / 2;
if(hero.health < needsHealing){
var item = hero.findByType("potion");
if(item){
pet.fetch(item);
}
}
}
pet.on("spawn", potionFetch);
hero.findByType returns a list, not a single item try:
hero.findNearest( hero.findByType("potion") )
I changed to what you suggested, but my wolf just runs in a circle around me, then runs up into me, as if he’s stuck, despite the potion being far off to the right.
Thanks for the welcome! I’m a bit dense at times so I’m sure I’ll be swinging by here often. I’ve already looked at how to post code correctly (not that specific document, but hopefully I got it close enough) and I’ll be sure to read the other one.
As for changing the function name, it didn’t do anything. He ran a lap around my character then pushed up into her.
the potion isn’t there when the pet spawns, maybe try a “while true” loop to make the pet always try to get a potion, because at the beginning the requirements in the " if " aren’t fulfilled.
That did the trick! My good boi is now doing his job! Thanks a lot!