Hi @SirStonks and welcome to the forum!
This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Don’t forget to read the guidelines if you haven’t yet. Have a great time!
I think that the problem over here is this: potion = hero.findNearestItem() it should be for the pet instead.