# Interception glitch level is impossible? (javascript)

**URL:** <https://discourse.codecombat.com/t/interception-glitch-level-is-impossible-javascript/35848>\
**Category:** Level Help\
**Created:** [July 25, 2023, 1:37pm UTC](https://discourse.codecombat.com/t/interception-glitch-level-is-impossible-javascript/35848 "2023-07-25T13:37:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![herokolbert](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/herokolbert/32/34618_2.png) [@herokolbert](https://discourse.codecombat.com/u/herokolbert)\
**Post date:** [July 25, 2023, 1:37pm UTC](https://discourse.codecombat.com/t/interception-glitch-level-is-impossible-javascript/35848/1 "2023-07-25T13:37:29Z")

</div>

hey guys my peasant gets too far from the hero and my hero then defines the soldier athe nearest friend help!  
here is my code:

```python
// Stand between the peasant and the tower.

while(true) {
    var enemy = hero.findNearestEnemy();
    var friend = hero.findNearestFriend();
    
    // Calculate x by adding friend.pos.x to enemy.pos.x
    // Then divide by 2.
    // Check the guide if you need more help!
    var x = (friend.pos.x + enemy.pos.x) / 2
    var y = (friend.pos.y + enemy.pos.x) / 2
    // Now do the same for y
    
    hero.moveXY(x, y);
    
    // Move to the x and y coordinates you calculated.
    
}

```

---

<div class="post-metadata">

**Author:** ![JustALuke](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/justaluke/32/43608_2.png) [@JustALuke](https://discourse.codecombat.com/u/JustALuke)\
**Post date:** [July 25, 2023, 8:40pm UTC](https://discourse.codecombat.com/t/interception-glitch-level-is-impossible-javascript/35848/2 "2023-07-25T20:40:13Z")

</div>

If you have the method hero.findByType() unlocked, use that to find the nearest peasant, otherwise it’s probably the hero.moveXY() being too slow; if you can, use hero.move().

---

<div class="post-metadata">

**Author:** ![herokolbert](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/herokolbert/32/34618_2.png) [@herokolbert](https://discourse.codecombat.com/u/herokolbert)\
**Post date:** [July 26, 2023, 12:45pm UTC](https://discourse.codecombat.com/t/interception-glitch-level-is-impossible-javascript/35848/3 "2023-07-26T12:45:35Z")

</div>

ok thank you @JustALuke I will try hero.findByType

---

<div class="post-metadata">

**Author:** ![herokolbert](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/herokolbert/32/34618_2.png) [@herokolbert](https://discourse.codecombat.com/u/herokolbert)\
**Post date:** [July 26, 2023, 12:50pm UTC](https://discourse.codecombat.com/t/interception-glitch-level-is-impossible-javascript/35848/4 "2023-07-26T12:50:47Z")

</div>

how do i mark this as solved I solved it

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [July 26, 2023, 7:06pm UTC](https://discourse.codecombat.com/t/interception-glitch-level-is-impossible-javascript/35848/5 "2023-07-26T19:06:02Z")

</div>

There is a mark near every post in a level-help topic, you click on it and the topic closes.

---

<div class="post-metadata">

**Author:** ![herokolbert](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/herokolbert/32/34618_2.png) [@herokolbert](https://discourse.codecombat.com/u/herokolbert)\
**Post date:** [July 27, 2023, 4:13pm UTC](https://discourse.codecombat.com/t/interception-glitch-level-is-impossible-javascript/35848/6 "2023-07-27T16:13:08Z")

</div>

i cant see it 😕@Chaboi_3000 can u close this

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [July 27, 2023, 4:49pm UTC](https://discourse.codecombat.com/t/interception-glitch-level-is-impossible-javascript/35848/7 "2023-07-27T16:49:52Z")

</div>

Try now. I changed the category of the topic to #Level Help.

---

<div class="post-metadata">

**Author:** ![herokolbert](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/herokolbert/32/34618_2.png) [@herokolbert](https://discourse.codecombat.com/u/herokolbert)\
**Post date:** [July 29, 2023, 2:25pm UTC](https://discourse.codecombat.com/t/interception-glitch-level-is-impossible-javascript/35848/8 "2023-07-29T14:25:43Z")

</div>

thank you peter 20chars

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [July 30, 2023, 2:25am UTC](https://discourse.codecombat.com/t/interception-glitch-level-is-impossible-javascript/35848/9 "2023-07-30T02:25:58Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
