Don't touch them help

I don’t know what to do my code seems fine

def createGenerator(spawnType, x, y, spawnAI):
    generator = game.spawnXY("generator", x, y)
    generator.spawnType = spawnType
    generator.spawnAI = spawnAI

# Scouts are aggressive and munchkins are just walking.
createGenerator("scout", 12, 12, "AttacksNearest")
createGenerator("scout", 68, 56, "AttacksNearest")
createGenerator("munchkin", 12, 56, "Scampers")
createGenerator("munchkin", 68, 12, "Scampers")

player = game.spawnPlayerXY("duelist", 40, 34)
player.maxHealth = 1000
player.attackDamage = 20
player.maxSpeed = 20

# These are our goals. Notice we save them in variables!
spawnMunchkinsGoal = game.addManualGoal("Let 6 munchkins spawn.")
dontTouchGoal = game.addManualGoal("Don't attack munchkins.")
defeatScoutsGoal = game.addManualGoal("Defeat 6 scouts.")
# game properties used to count new and defeated ogres.
game.spawnedMunchkins = 0
game.defeatedScouts = 0
ui.track(game, "spawnedMunchkins")
ui.track(game, "defeatedScouts")

def onSpawn(event):
    game.spawnedMunchkins += 1

def onDefeat(event):
    unit =
    if unit.type == "scout":
        game.defeatedScouts += 1
    if unit.type == "munchkin":
        # dontTouchGoal is failed if a munchkin is defeated.
        game.setGoalState(dontTouchGoal, False)

def checkGoals():
    # If game.defeatedScouts is greater than 5:
    if game.defeatedScouts > 5:
        # Set defeatScoutsGoal state as successful..
        game.setGoalState(defeatScoutsGoal, True)
    # If game.spawnedMunchkins is greater than 5:
    if game.spawnMunchkins > 5:
        game.setGoalState(spawnMunchkinsGoal, True)
        # Set spawnMunchkinsGoal state as successful..
    # If both other goals are completed.
    if spawnMunchkinsGoal.success:
        if defeatScoutsGoal.success:
            # Set dontTouchGoal state as successful..
            game.setGoalState(dontTouchGoal, True)

game.setActionFor("munchkin", "spawn", onSpawn)
game.setActionFor("munchkin", "defeat", onDefeat)
game.setActionFor("scout", "defeat", onDefeat)

while True:

type or paste code here

I defeat 6 scouts but it doesn’t finish the game

are there eror that pop up @kp237218?

No error pops up but the game doesn’t finish

What are the goals of the level

to spawn 6 munchkins and kill 6 scouts

I haven’t played this yet let me check for problems

do you need a link? I can post it if you want

Hey @kp237218 i know which level it is unfortunaley I dont have experience in the level so im going to try to find out how to solve it then help you

Ton code a l’air bon.
Parcontre il ne faut pas tuer les " Munchkin ", seulement les scouts.
Si vous n’y arrivez faite le moi savoir.
:pray: :v: :slight_smile:

you are supposed to put successfulGoal where the spawnMunchkinsGoal and defeatScoutsGoal is.

Thank you for trying to help, but @kp237218 is no longer active and will not see your post. It’s better not to revive topics like this, because you will waste your own time helping them and bump this topic back to the new category.

I tried to put a success goal on the ui.track but it’s still not letting me finish the game. can you or someone else help me?


Hi, welcome to the forum.
Please could you post your code so we can see the problem.