Topic for Sunfire Blitz!

can anybody help with my throw code?

def throwthings():
    opponent = hero.opponent
    if hero.isReady("shockThrow") and hero.opponent.direction == "left":
        hero.ability("shockThrow", hero.opponent.x - 10, hero.opponent.y)
    if hero.isReady("shockThrow") and hero.opponent.direction == "right":
        hero.ability("shockThrow", hero.opponent.x + 10, hero.opponent.y)
    if hero.isReady("shockThrow") and hero.opponent.direction == "up":
        hero.ability("shockThrow", hero.opponent.x, hero.opponent.y + 10)
    if hero.isReady("shockThrow") and hero.opponent.direction == "down":
        hero.ability("shockThrow", hero.opponent.x, hero.opponent.y - 10)

no copying plz

Use more math
Trust me, it will work out
+10 isn’t that accurate as if you are far, it will always miss

Oh so i should do like > and <

1 Like

idk if this is better but

def throwthings():
    opponent = hero.opponent
    if hero.isReady("shockThrow") and hero.opponent.direction == "left":
        hero.ability("shockThrow", hero.opponent.x - 10, hero.opponent.y)
    if hero.isReady("shockThrow") and hero.opponent.direction == "right" and hero.opponent.x < 39:
        hero.ability("shockThrow", hero.opponent.x, hero.opponent.y + 5)     
    if hero.isReady("shockThrow") and hero.opponent.direction == "right" and hero.opponent.x > 39:
        hero.ability("shockThrow", hero.opponent.x, hero.opponent.y + 10) 
    if hero.isReady("shockThrow") and hero.opponent.direction == "up" and hero.opponent.y > 53:
        hero.ability("shockThrow", hero.opponent.x, hero.opponent.y + 10)    
    if hero.isReady("shockThrow") and hero.opponent.direction == "up" and hero.opponent.y < 53:
        hero.ability("shockThrow", hero.opponent.x, hero.opponent.y + 5)
    if hero.isReady("shockThrow") and hero.opponent.direction == "down" and hero.opponent.y < 19:
        hero.ability("shockThrow", hero.opponent.x, hero.opponent.y - 5)
    if hero.isReady("shockThrow") and hero.opponent.direction == "down" and hero.opponent.y > 19:
        hero.ability("shockThrow", hero.opponent.x, hero.opponent.y - 10)      


no copying plxzzzzzzzzzz```the up and down code works wayy better but the right and left code is not better

Use.more.maths
Use distance and calculate off of that

Thanks for the tips!! except that i am not good at math lol :laughing: :laughing:

I have an idea. Why not make the robot crab remote control. Then you would have to program what it would do.

You could make it dogde things and change direction.

Here. This is the hardest part of the function. The distance is really important. All you have to figure out is how to get the time and the target positions.

dis = ((TargetX-hero.x)** 2 +(TargetY-hero.y)** 2)** 0.5
if ((shockThrowtime - dis/15)**2)**0.5 <= 0.5:
   hero.ability('shockThrow', TargetX, TargetY)

Ok thanks!! but i relly dont understand it. :face_with_raised_eyebrow: :face_with_raised_eyebrow: :laughing: :laughing:

Neither did I at first. Also, you have to do that same equation twice for whatever reason. I don’t understand why but, you do.

1 Like

so i like copy and paste it and replace targetx and targety to thing im using but i have rlly bad moments when i have code from others and it has a bug and i dont know what to do.

this is the math im using

    if hero.isReady("shockThrow") and hero.opponent.direction == "left" and hero.distanceTo(hero.opponent) < 6:
        hero.ability("shockThrow", hero.opponent.x + 5, hero.opponent.y) 

Target x and target y are going to change based on direction. That is why I use a condition with elifs and define them differently for each direction.

Oh. (20 charsssssss)

Don’t use the plus 5. Use enemy speed multiplied by the time. My shockthrow time. You have to figure that one out by yourself unless you really need my help.

Oh. i think i can figure it out. ty for your help!

1 Like

image
is that the speed per sec?

I think so.

k! (200000000000 chars)