# Pet Fetch Bug, not passing potion to moving hero

**URL:** <https://discourse.codecombat.com/t/pet-fetch-bug-not-passing-potion-to-moving-hero/9517>\
**Category:** Bugs\
**Created:** [November 3, 2016, 3:22am UTC](https://discourse.codecombat.com/t/pet-fetch-bug-not-passing-potion-to-moving-hero/9517 "2016-11-03T03:22:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwhittaker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dwhittaker/32/2114_2.png) [@dwhittaker](https://discourse.codecombat.com/u/dwhittaker)\
**Post date:** [November 3, 2016, 3:22am UTC](https://discourse.codecombat.com/t/pet-fetch-bug-not-passing-potion-to-moving-hero/9517/1 "2016-11-03T03:22:17Z")

</div>

When playing Medic School I decided to add a goldstorm so I had something to do while waiting for mushrooms to spawn. But, at times the pet.fetch doesn’t actually bring the item to me. The pet runs to me, but I move away and he doesn’t actually give me the potion. Not sure what exactly is happening in the fetch code.

My pet did come near me, but before I took the potion I moved away and he returned to his spot. I’m guessing:

1. he got in range to say “I’m here”
2. I moved out of range to take the item
3. an attempt was made to pass the item, but I was too far away.
4. he assumed the potion had been passed

I was using pender with ring of speed.

---

<div class="post-metadata">

**Author:** ![Bryukh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bryukh/32/19597_2.png) [@Bryukh](https://discourse.codecombat.com/u/Bryukh)\
**Post date:** [November 3, 2016, 5:24am UTC](https://discourse.codecombat.com/t/pet-fetch-bug-not-passing-potion-to-moving-hero/9517/2 "2016-11-03T05:24:07Z")

</div>

Maybe it’s related with changes in `fetch`. @Catsync could you look this please?

---

<div class="post-metadata">

**Author:** ![Catsync](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/catsync/32/6431_2.png) [@Catsync](https://discourse.codecombat.com/u/Catsync)\
**Post date:** [November 3, 2016, 5:12pm UTC](https://discourse.codecombat.com/t/pet-fetch-bug-not-passing-potion-to-moving-hero/9517/3 "2016-11-03T17:12:32Z")

</div>

I fixed a few oddities in the fetch code, and also because of those fixes, was able to make the level’s default `onHear()` code better. See if any of that helps?

I tried having a fast hero outrun the pet, but it still seemed to drop off the potions okay. The change in `onHear()` should fix one issue where the Hero says “Aaarg” and the pet’s returning with the potion would get interrupted by that hear event.

---

<div class="post-metadata">

**Author:** ![dwhittaker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dwhittaker/32/2114_2.png) [@dwhittaker](https://discourse.codecombat.com/u/dwhittaker)\
**Post date:** [November 4, 2016, 3:09am UTC](https://discourse.codecombat.com/t/pet-fetch-bug-not-passing-potion-to-moving-hero/9517/4 "2016-11-04T03:09:45Z")

</div>

Still having issues:

 ![](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/9/9e71d4829217f8ee96180b5caaa696b9d3364468.jpg)

In this case, he delivered the potion to me, but I didn’t regain health. He doesn’t appear to be carrying it anymore, but he thinks he is carrying something.

Here is my sessionID:

Generated random seed 3016092072 of type submissionCount from sessionIDs 581a74e037e4502400215d3c submissionCount 4

---

<div class="post-metadata">

**Author:** ![Catsync](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/catsync/32/6431_2.png) [@Catsync](https://discourse.codecombat.com/u/Catsync)\
**Post date:** [November 4, 2016, 7:09pm UTC](https://discourse.codecombat.com/t/pet-fetch-bug-not-passing-potion-to-moving-hero/9517/5 "2016-11-04T19:09:24Z")

</div>

Ok, there was a problem where the Wolf would drink the potion instead of fetch it when moving fast 🙂 That should be fixed now. Might need to clear cache to get the fix.

The other issue seems to be fixed if you make the change to `onHear()`:

```python
    if startsWith(event.speaker.id, "Exp"):
        potion = pet.findNearestByType("potion")
        if potion:
            pet.fetch(potion)
            pet.moveXY(28, 34)

```
