How Do I Get enemy health?

I need help getting my enemy’s health. I want to create simple logic that can launch a IU and, if the enemy health doesn’t go down, try another area. But I can’t seem to figure out how to call enemy health

If you’re using Python, the enemy’s health can be accessed at game_state.enemy_health. There are a bunch of other useful things in the game_state, which you can read up on in the documentation, viewable either by opening the HTML files in the documentation folder of the starterkit, or by browsing through here.

Would i say something like: if game_state.enemy_health == 30:
and then do whatever i want here? cause i tried that and it passed an error

Yes, that should work. You can also use class member variables (the code is all wrapped in a class) to store that info from the previous turn for your comparison.

1 Like

Thank you so much Ryan! You’re amazing.

One more question, sorry lol ik im prob annoying but how do i get a random friendly position?
i tried random.choice(ListOfPositions) but naturally, it passed an error in the debug console that it didn’t identify as an x, y coordinate

You’re fine, questions are encouraged here! Just referencing the attack implementation from the starterkit (line 197-220), you could do this by picking a random number from 0 to the length of your list, then indexing into the list with that number.

Something else must be going on here since random.choice() should work fine.

I ran the following and there were no problems:

import random
ListOfPositions = [[0, 0], [0, 1], [0, 2]]
print (random.choice(ListOfPositions)

Output (obviously will be different for you, since its random):


I would check what you are passing and getting back from random.choice().