[SOLVED] Medical-Attention

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

i read the the FAQ alreadyn over 71 times

1 Like

i know there is 4 space in a loop

1 Like

Okay, so why haven’t you formatted your code properly?

1 Like

atuly i finished it just now 100% finished

1 Like

uh huh??? ( I needed more characters)

1 Like

sorry i dont know how to space out the code while replying…

1 Like

Hello, Gatorion, and welcome. For future reference, the way to post your code properly is inside the FAQ.

Please do not post correct code, for it provides people an easy answer without their learning a whit.

1 Like

ok :grinning: can i have a link to the FAQ;s?

1 Like

The FAQ is pinned by default so it should be pretty easy for you to find. You can also reach it from the menu in the upper right corner.

1 Like

I try that and it doesnt work for me.

1 Like

can you please tell me how i can format it? I wasnt quite sure because i cant change anything on the preview. I tried to tell him how I formated it but i think that would be even more “tiresome”

1 Like

You can either surround your code in three of these characters: `

Or, you can paste your code, highlight it, and click the button that looks like this: </>

2 Likes

My code made me always heal and I won for some reason

1 Like

Hi, please could you post your code (formatted: [Essentials] How To Post/Format Your Code Correctly).
Danny

1 Like