[SOLVED] Medical-Attention

Ok, I edited my coding but still doesn’t work:

It only got me 58.7s into the battle until my teammates die. Is there something that I have to buy?

1 Like

No, not at all. Keep submitting. Each submission gives you a random seed, so sooner or later you should win.

1 Like

Now I got it! Thanks for the help! :smile:

1 Like

So it seems like Frandar keeps killing Augustus. I need some suggestions on my code please. It’s Python by the way.

Code:

loop:
# If your current health is less than the threshold,
currentHealth = self.health
healingThreshold = self.maxHealth / 3
enemy=self.findNearestEnemy()
# move to the healing point and say, “heal me”.
if currentHealth<healingThreshold:
self.shield()
self.moveXY(65, 46)
self.say(“Heal me”)
# Otherwise, attack. You’ll need to fight hard!
else
self.findNearestEnemy()
if enemy:
self.attack(enemy)
self.attack(enemy)
if self.isReady(“cleave”):
if enemy:
distance=self.distanceTo(enemy)
if distance<5:
self.cleave(enemy)
else
self.findNearestEnemy()
if enemy:
self.attack(enemy)
self.attack(enemy)

1 Like

nvm i just kep submitting

1 Like

Please read the FAQ on how to format your code properly

1 Like

yo it is not impossible i just beat it litterally just now i am so supper suppper happy

1 Like

if you want to know how to beat it

http://discourse.codecombat.com/t/if-you-want-to-know-how-to-beat-medical-attention/4003

1 Like

Never mind, I just used your tip that you gave nub-soldier and it worked. Thanks!

1 Like

Please do not give correct code, as it gives the solution to people without the effort that we wish them to put in to the level.

2 Likes

what is wrong with my code

Ask the healer for help when you’re under one-third health.

loop:
currentHealth = self.health
healingThreshold = self.maxHealth / 4
enemy = self.findNearestEnemy()
if currentHealth < healingThreshold:
self.moveXY(65, 45) and self.say(“heal me”)
else:
if self.isReady(“cleave”):self.cleave(enemy)
if enemy:
self.attack(enemy)
self.attack(enemy)
if self.isReady(“cleave”):
self.cleave(enemy)

1 Like

Draz21x welcome the forum and please read the FAQ oh how to format your code properly

If you want help with your code please give us the following information

  1. Correctly formatted code
  2. What is happening when this code is run
  3. What the coding language is.

Now on the actual code

This code looks like python I cannon help you but I will put one of @J_F_B_M 's quotes

Indentations save lives, but more indentation don't!

So check your code to see if the indentations are out of order
but since python is not the language I use I cannot provide advanced coding help

1 Like

it’s python
how do i go to the wizard and tell the wizard to heal me the i am done

1 Like

thats my new code
loop:
currentHealth = self.health
healingThreshold = self.maxHealth / 3
enemy = self.findNearestEnemy()
if self.isReady(“cleave”):self.cleave(enemy)
if enemy:
enemy = self.findNearestEnemy()
self.attack(enemy)
if self.isReady(“cleave”):self.cleave(enemy)
if enemy:
enemy = self.findNearestEnemy()

1 Like

it says that there is a problem but i checked many times and its all perfect

1 Like

Please use the correct code formating when posting (see FAQ for how to use ` to do this.)

There are several things “wrong” with the code so it is definitely not “perfect”, but it is hard to tell without the proper formatting if there are more problems.

assuming that your code looks like this (if not then there are more problems than I discuss):

loop:
    currentHealth = self.health
    healingThreshold = self.maxHealth / 3        # 1
    enemy = self.findNearestEnemy()
    if self.isReady("cleave"):
        self.cleave(enemy)                       # 2
    if enemy:                                    # 2.1
        enemy = self.findNearestEnemy()          # 3
        self.attack(enemy)
    if self.isReady("cleave"):                   # 4
        self.cleave(enemy)                       # 5
    if enemy:
        enemy = self.findNearestEnemy()          # 6
  1. This (maxHealth) “never” changes so doesn’t need to be in the loop.
  2. Why are you checking for enemy at “2.1” but not checking here?? You either need to check with ALL uses of enemy or none.
  3. You just checked to see if “enemy” existed, why are you changing it to something else . . . (it is now possible that it doesn’t exist)
  4. Why are you repeating part of your code (that is the loops job).
  5. See 2
  6. See 4

#2 & 5 will cause errors.

#3 could cause an error (if your buddies kill the last enemy on the screen, such that you reset enemy and it is now empty.

As to your question about being healed . . . that was in your original code but you took it out…

1 Like

this still does not work# Ask the healer for help when you’re under one-third health.
loop:
currentHealth = self.health
healingThreshold = self.maxHealth / 3
# 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!
if currentHealth < healingThreshold:
self.moveXY(65, 45) and self.say(“heal me”)
enemy = self.findNearestEnemy()
if self.isReady(“cleave”):
self.cleave(enemy)
if enemy:
enemy = self.findNearestEnemy()
self.attack(enemy)
self.attack(enemy)
if enemy:
enemy = self.findNearestEnemy()

1 Like

my new code what is wrong with it

Ask the healer for help when you’re under one-third health.

loop:
currentHealth = self.health
healingThreshold = self.maxHealth / 3
# 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!
if self.health < healingThreshold:
self.moveXY(65, 46)
self.say(“Heal Me”)
else:
enemy = self.findNearestEnemy()
if enemy:
self.attack(enemy)
self.attack(enemy)
if enemy:
self.shield(3)
self.isReady(“cleave”)
self.cleave(enemy)

1 Like

Dude! (Dudette?) Please read the FAQ and PROPERLY FORMAT YOUR CODE, so we can read it…
This is the third time it has been “suggested” to you…
DO IT
It is hard/tiresome enough to try to read peoples code who “don’t know any better”, but you no longer have that reason/excuse.

2 Likes

Heres how to properly format your code.

#3 of these: ``` go before and after the code and comments

loop:
self.moveRight()
self.moveDown()
self.moveRight()

1 Like