# \[SOLVED\] Medical-Attention

**URL:** <https://discourse.codecombat.com/t/solved-medical-attention/2127>\
**Category:** Level Help\
**Created:** [December 29, 2014, 4:22pm UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127 "2014-12-29T16:22:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wolftein](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wolftein/32/1835_2.png) [@Wolftein](https://discourse.codecombat.com/u/Wolftein)\
**Post date:** [December 29, 2014, 4:22pm UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/1 "2014-12-29T16:22:23Z")

</div>

It seems to always fail; my code is:

```
// Ask the healer for help when you're under half health.
// Buy the Polished Sense Stone for health documentation.
loop {
    currentHealth = this.health;
    healingThreshold = this.maxHealth / 2;
    // If your current health is less than the threshold,
    // move to the healing point and say, "heal me".
    // Otherwise, just attack enemies.
    if (currentHealth < healingThreshold)
    {
        this.moveXY(65, 46);
        this.say("heal me");
    }
    else
    {
        var x = this.findNearestEnemy();
        if (x !== null)
            this.attack(x);
    }
}
```

---

<div class="post-metadata">

**Author:** ![Wolftein](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wolftein/32/1835_2.png) [@Wolftein](https://discourse.codecombat.com/u/Wolftein)\
**Post date:** [December 29, 2014, 4:24pm UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/2 "2014-12-29T16:24:10Z")

</div>

Enemies are being kill from one hit; and i’m not be able to complete the mission due to my humans die before killing the last ogre.

---

<div class="post-metadata">

**Author:** ![juan](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@juan](https://discourse.codecombat.com/u/juan)\
**Post date:** [December 29, 2014, 4:46pm UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/3 "2014-12-29T16:46:56Z")

</div>

Hi Wolftein,

What level was?

edit:

I tested you code, and it works. So I do not know the cause of the problem.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [December 30, 2014, 2:17am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/4 "2014-12-30T02:17:09Z")

</div>

I have it on my list to adjust this level to make it easier. Until then, you might want to try tanking more of the damage by waiting until maxHealth / 3, or trying a few random seeds to see if your soldiers can survive better.

---

<div class="post-metadata">

**Author:** ![ashwinranade99](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@ashwinranade99](https://discourse.codecombat.com/u/ashwinranade99)\
**Post date:** [December 30, 2014, 7:26am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/5 "2014-12-30T07:26:12Z")

</div>

I just kept slightly tweaking the amount of when i got healed (2.1, 2.2,1.9), and eventually it worked. I guess it would help if you bought additional health with gems (they don’t cost that much).

---

<div class="post-metadata">

**Author:** ![dora](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@dora](https://discourse.codecombat.com/u/dora)\
**Post date:** [December 30, 2014, 2:03pm UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/6 "2014-12-30T14:03:33Z")

</div>

when you kill the first wave of enemy, your hero would stay idle for sometime. because findNearestEnemy=null. You need to move you hero to a better place to fight the second wave of enemy. So your chance of success will increase.

---

<div class="post-metadata">

**Author:** ![dora](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@dora](https://discourse.codecombat.com/u/dora)\
**Post date:** [December 30, 2014, 2:04pm UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/7 "2014-12-30T14:04:30Z")

</div>

and health/3 is also needed, if you health is around 400.

---

<div class="post-metadata">

**Author:** ![maxyi2013](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@maxyi2013](https://discourse.codecombat.com/u/maxyi2013)\
**Post date:** [January 1, 2015, 2:37pm UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/8 "2015-01-01T14:37:25Z")

</div>

instead of this.moveXY(65, 46), try (63,47) to avoid hero and humans collision.

---

<div class="post-metadata">

**Author:** ![Feinty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/feinty/32/1869_2.png) [@Feinty](https://discourse.codecombat.com/u/Feinty)\
**Post date:** [January 9, 2015, 12:37am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/9 "2015-01-09T00:37:45Z")

</div>

Hello I would like help on this level also my code is not working here it is

```python
// Ask the healer for help when you're under half health.
loop {
    this.warcry();
    
    var currentHealth = this.health;
    var healingThreshold = this.maxHealth / 2;
    if(currentHealth < healingThreshold){
        this.moveXY(65, 46);
        this.say("heal me");
    }
    else if (enemy){
    var enemy = this.findNearestEnemy();
    this.attack(enemy);
        
    }
    // If your current health is less than the threshold,
    // move to the healing point and say, "heal me".
    // Otherwise, attack. You'll need to fight hard!
    
}

```

All my code does is war cry and then nothing

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [January 9, 2015, 2:03am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/10 "2015-01-09T02:03:26Z")

</div>

You need to assign `enemy` before you check `enemy`, ideally at the start of your loop. Also you only want to `warcry` if `this.isReady("warcry")`.

---

<div class="post-metadata">

**Author:** ![lovezq85](https://avatars.discourse-cdn.com/v4/letter/l/9e8a1a/32.png) [@lovezq85](https://discourse.codecombat.com/u/lovezq85)\
**Post date:** [January 24, 2015, 3:55am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/11 "2015-01-24T03:55:48Z")

</div>

why? health 722  
Sometimes succeed and sometimes fail!!!

```
  # Ask the healer for help when you're under half health.
    loop:
        currentHealth = self.health
        healingThreshold = self.maxHealth / 4
        # If your current health is less than the threshold,
        # move to the healing point and say, "heal me".
        # Otherwise, attack. You'll need to fight hard!
        enemy = self.findNearestEnemy()
        if currentHealth < healingThreshold:
            self.moveXY(65, 45) and self.say("heal me")
        else:
            if enemy:
                self.isReady("cleave") and self.cleave(enemy)
                self.attack(enemy)
```

---

<div class="post-metadata">

**Author:** ![lovezq85](https://avatars.discourse-cdn.com/v4/letter/l/9e8a1a/32.png) [@lovezq85](https://discourse.codecombat.com/u/lovezq85)\
**Post date:** [January 24, 2015, 4:00am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/12 "2015-01-24T04:00:11Z")

</div>

楼上是我的代码，我的最大健康值是722  
楼上的代码有时候成功，有时候会失败，一直没搞懂，

---

<div class="post-metadata">

**Author:** ![juraj\_pechac](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/juraj_pechac/32/4987_2.png) [@juraj\_pechac](https://discourse.codecombat.com/u/juraj_pechac)\
**Post date:** [January 24, 2015, 1:13pm UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/13 "2015-01-24T13:13:59Z")

</div>

```
else:
      if enemy:
             if self.isReady("cleave"):
                   self.cleave(enemy)
             else:
                  self.attack(enemy)
```

---

<div class="post-metadata">

**Author:** ![Feinty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/feinty/32/1869_2.png) [@Feinty](https://discourse.codecombat.com/u/Feinty)\
**Post date:** [January 26, 2015, 2:32am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/14 "2015-01-26T02:32:35Z")

</div>

The reason it is only working some times is because it was designed that way and I dont think anyone has found a strat that works all the time

---

<div class="post-metadata">

**Author:** ![lovezq85](https://avatars.discourse-cdn.com/v4/letter/l/9e8a1a/32.png) [@lovezq85](https://discourse.codecombat.com/u/lovezq85)\
**Post date:** [January 26, 2015, 2:37am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/15 "2015-01-26T02:37:19Z")

</div>

thank you,Or a failure

---

<div class="post-metadata">

**Author:** ![lovezq85](https://avatars.discourse-cdn.com/v4/letter/l/9e8a1a/32.png) [@lovezq85](https://discourse.codecombat.com/u/lovezq85)\
**Post date:** [January 26, 2015, 2:38am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/16 "2015-01-26T02:38:20Z")

</div>

设计成这样？  
Designed to be like this?

---

<div class="post-metadata">

**Author:** ![Feinty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/feinty/32/1869_2.png) [@Feinty](https://discourse.codecombat.com/u/Feinty)\
**Post date:** [January 26, 2015, 2:39am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/17 "2015-01-26T02:39:44Z")

</div>

kinda Im just guessing that because ive never seen anyone who finishes it 100% of the time

---

<div class="post-metadata">

**Author:** ![lovezq85](https://avatars.discourse-cdn.com/v4/letter/l/9e8a1a/32.png) [@lovezq85](https://discourse.codecombat.com/u/lovezq85)\
**Post date:** [January 26, 2015, 4:40am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/18 "2015-01-26T04:40:45Z")

</div>

ok.thank you，原来如此！！！！

---

<div class="post-metadata">

**Author:** ![Rytrik](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@Rytrik](https://discourse.codecombat.com/u/Rytrik)\
**Post date:** [January 26, 2015, 8:43pm UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/19 "2015-01-26T20:43:17Z")

</div>

for the healer, I’ve found that saying “Heal me” 2 or 3 times helps to pop my hero back up to full health. Otherwise it only seems to heal a certain portion.

Also, I’ve found that a winning strat is to move your character to a mid-point between all 3 spawn spots when enemies are dead. And to make that spot be a point where your hero won’t have collisions with the ally NPC’s.

I think i’ll toss my current strat against the Submit button a number of times, and see what my win% is after about 10 mins.  
_edit_ fascinating. I have quite the skewed ratio! Some wins, and a bunch of losses. Peculliar!

---

<div class="post-metadata">

**Author:** ![Feinty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/feinty/32/1869_2.png) [@Feinty](https://discourse.codecombat.com/u/Feinty)\
**Post date:** [January 27, 2015, 3:32am UTC](https://discourse.codecombat.com/t/solved-medical-attention/2127/20 "2015-01-27T03:32:06Z")

</div>

As I said I have not found anyone who has finished it 100% of the time

[Next page](https://discourse.codecombat.com/t/solved-medical-attention/2127.md?page=2)
