The Storm Siege Topic

what part for i use…

I meant do instead of for

How to cast spells on the strongest enemy rather than having to put in the x,y coordinates cause like when battling they cast lightning whenever I summon catapult…

Optional: Backup code

First, copy and paste your Storm Siege code into a Word Document, Notepad file, Google Doc, or Google Keep note (or a different text editor, if you don’t use any of the above)
(You don’t have to do this, but it’s good to have a backup of your code for if something goes wrong.)

(After this step, you can try to figure it out for yourself instead of using the instructions below if you want to.)


Step 1: Put Mad Maxer code into Storm Siege

Then copy everything from the Mad Maxer code except the while loop at the top, and paste it where you want to use the attack action.


Step 2: Important corrections

if enemies[enemyIndex].health < leastHealth:
Switch the < with a >.
And set the starting value of leastHealth variable to 0, instead of 999999


Optional: Change variable names

Then rename the variables to things like strongest and mostHealth. You’ll also need to find all the places where these were used before, and correct the variable names. (Note: you can just leave the variable names as they are, but it could make the code confusing to debug in future)

Bruh i did not know you can use index

I still have to put in the x,y coordinates?

strongest.pos.x and strongest.pos.y (if you renamed the variables) should suffice

if i remember right i think it is just .x/.y

That is correct. (20chars)

Is this on Python? (20chars)

Yeah, it is.


1 Like

I have a for loop instead of a while loop in Mad Maxer. How do i implement that in my storm siege code?

What’s the points graded on, cause I can beat many people but am same place, bruh I am like 60th place when I can beat 15-59(I mean 14), lol I increased to 37 even though I can beat 14-36

bro I can beat 9th place, I need that code to be 1st.

where do you put those codes? I put this, (you said Mad Maxer code…

farthest = None
maxDistance = 0
enemyIndex = 0
enemies = hero.findEnemies()
while enemyIndex < len(enemies):
target = enemies[enemyIndex]
enemyIndex += 1
distance = hero.distanceTo(target)
if distance > maxDistance:
maxDistance = distance
farthest = target
if farthest:
while farthest.health > 0:
if (hero.isReady(“cleave”)):
hero.cleave(farthest)
elif (hero.isReady(“bash”)):
hero.bash(farthest)
elif (hero.isReady(“power-up”)):
hero.powerUp()
else:
hero.attack(farthest)

Put the code where you whant to cast the spell on the strongest enemy.

it is Mad Maxer right? cause in mad maxer strikes back it has all those weakest and least.

Yes, it’s Mad Maxer strikes back.
Sorry if my instructions were unclear

Ohhh
There’s a level just called “Mad Maxer”
I shortened it to that thinking (for some reason) that Mad Maxer Strikes Back was the first one…
Sorry about that

so do I do all of the variables in to strongest and most health (none blank?)