Hit and Freeze Python


#21

Let’s just say there was a troller bully and he’s taking advantage over new users and insulting them, so yeah, I banned him. Then another guy came in and started getting triggered that I banned him, and spamming swear words in my PM’s so I had to ban him too ;( But for this forum, I only had to tell a mod to ban only one person, during my time in this forum, in discord, I probably banned over 20 in a year! I wish I can have some chill time. :dark_sunglasses:


#22

What other discourses do you moderate?


#23

If I was a mod on a board like that, it would be empty because I would just ban everyone. LOL.


#24

I quit some, because they were too overwhelming. And seriously those people don’t even listen to you.


#25

But what other boards do you moderate?


#26

Please, help me show me how this does not work.

def inAttackRange(enemy):
    distance = hero.distanceTo(enemy)
    if distance <= 3:
        return True
    else:
        return False
while True:
    enemy = hero.findNearestEnemy()
    canAttack = inAttackRange
    hero.attack(enemy)
    pass


#27

you never called canAttack anywhere

the variable has no use if you don’t use it


#28

use if enemy: and then use if canAttack


#29

Still no hero live but not kill any ogres.


#31

Can you post your updated code please? Thanks!


#32

Here it is.

def inAttackRange(enemy):
    distance = hero.distanceTo(enemy)
    if distance <= 3:
        return True
    else:
        return False
while True:
    if enemy:
        enemy = hero.findNearestEnemy()
        inAttackRange(enemy)
        hero.attack(enemy)
        pass


#33

I tried to just cleave and it worked.


#34

you have to define a variable before you can call it. Place the enemy definition before the if conditional in the while True loop. You need to utilize the true or false return from the function. No where in your code are you doing that.