Hit and Freeze Python

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:

1 Like

What other discourses do you moderate?

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

1 Like

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

1 Like

But what other boards do you moderate?

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

you never called canAttack anywhere

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

use if enemy: and then use if canAttack

Still no hero live but not kill any ogres.

Can you post your updated code please? Thanks!

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

I tried to just cleave and it worked.

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.

// You are trapped. Don't move, it'll be painful.

// This function checks if the enemy is in your attack range.
function inAttackRange(enemy) {
    var distance = hero.distanceTo(enemy);
    // Almost all swords have attack range of 3.
    if (distance <= 3) {
        return true;
    } else {
        return false;
    }
}

// Attack ogres only when they're within reach.
while (true) {
    // Find the nearest enemy and store it in a variable.
    var canAttack = inAttackRange(enemy);
    // Call inAttackRange(enemy), with the enemy as the argument
    // and save the result in the variable canAttack.
    inAttackRange(enemy)}
    // If the result stored in canAttack is true, then attack!
    hero.attack(enemy);

please help i need some serious help

Looks like you missed the second comment in:

    // Call inAttackRange(enemy), with the enemy as the argument
    // and save the result in the variable canAttack.

You’ve called the function, but haven’t assigned the results to a variable. Once you have that part, you will need to make your hero.attack statement part of an if statement.

Hi I am new here so plz help me mr or miss Deadpool198 Leader

le me introduce myself
name: wazi age:7

plz someone help me!!!

Welcome to the forum!
Can you format your code correctly? (using `)

2 Likes