Game dev 2 help needed!

I’m on Game Dev 2 Final Project. My level meets all the requirements, but it won’t let me go to the next level.

Hi @taha1124, welcome to the CodeCombat discourse.
I’m afraid after Game Dev 2 Final project there aren’t any more levels. That’s the end unfortunately.
Or are you saying your code meets the requirements but it’s not saying ‘success’?
Danny

Yeah, it won’t say success.

Ok, please could you post a screenshot of this.
Have you played and won the level you made yet?
Danny

also, please post your code (properly formatted)…since this is a ‘create your own’ level, being able to see what you’ve come up with will help us troubleshoot.

1 Like

def spawnArcher(x, y):
archer = game.spawnXY(“archer”, x, y)
archer.behavior = “Defends”
archer.attackDamage = 20
goliath = game.spawnPlayerXY(“goliath”, 20, 35)
boss = game.spawnXY(“ogre”, 67, 15)
boss.attackDamage = 200
boss.maxSpeed = 1
boss.maxHealth = 200
goliath.maxSpeed = 10
boss.behavior = “AttacksNearest”
bossGoal = game.addManualGoal(“Kill the boss”)
game.addCollectGoal(1)
goliath.maxHealth = 20000
goliath.attackDamage = 20
game.spawnXY(“fence”, 72, 9)
game.spawnXY(“fence”, 68, 9)
game.spawnXY(“fence”, 64, 9)
game.spawnXY(“fence”, 72, 13)
game.spawnXY(“fence”, 72, 17)
game.spawnXY(“fence”, 68, 17)
game.spawnXY(“fence”, 64, 17)
game.spawnXY(“fence”, 72, 13)
fence1 = game.spawnXY(“fence”, 60, 13)
def onDefeat1(event):
unit = event.target
if unit.type == “ogre”:
bossGoal.success == True
game.spawnXY(“chest”, 36, 30)

def spawnMunchkin(x, y):
ogre = game.spawnXY(“munchkin”, x, y)
ogre.behavior = “AttacksNearest”

def spawnArcherWall():
spawnArcher(10, 54)
spawnArcher(10, 44)
spawnArcher(10, 34)
spawnArcher(10, 24)
spawnArcher(10, 14)

def spawnOgreWave():
offset = game.randomInteger(-6, 6)
spawnMunchkin(80, 22 + offset)
spawnMunchkin(80, 28 + offset)
spawnMunchkin(80, 34 + offset)
spawnMunchkin(80, 40 + offset)
spawnMunchkin(80, 46 + offset)
spawnMunchkin(80, 52 + offset)

def onDefeat2(event):
unit = event.target
game.defeated +=1
unit.destroy()

game.setActionFor(“munchkin”, “defeat”, onDefeat2)
game.setActionFor(“ogre”, “defeat”, onDefeat1)

game.defeated = 0
game.spawnTime = 0
goal = game.addManualGoal(“Defeat over 100 ogres.”)
ui.track(game, “defeated”)

def checkSpawnTimer():
if game.time > game.spawnTime:
spawnOgreWave()
game.spawnTime += 5

def checkGoal1():
if game.defeated > 100:
goal.success = True
fence1.destroy()

spawnArcherWall()
while True:
checkSpawnTimer()
checkGoal1()

def spawnArcher(x, y):
    archer = game.spawnXY("archer", x, y)
    archer.behavior = "Defends"
    archer.attackDamage = 20
goliath = game.spawnPlayerXY("goliath", 20, 35)
boss = game.spawnXY("ogre", 67, 15)
boss.attackDamage = 200 
boss.maxSpeed = 1
boss.maxHealth = 200
goliath.maxSpeed = 10
boss.behavior = "AttacksNearest" 
bossGoal = game.addManualGoal("Kill the boss")
game.addCollectGoal(1)
goliath.maxHealth = 20000
goliath.attackDamage = 20
game.spawnXY("fence", 72, 9)
game.spawnXY("fence", 68, 9)
game.spawnXY("fence", 64, 9)
game.spawnXY("fence", 72, 13)
game.spawnXY("fence", 72, 17)
game.spawnXY("fence", 68, 17)
game.spawnXY("fence", 64, 17)
game.spawnXY("fence", 72, 13)
fence1 = game.spawnXY("fence", 60, 13)
def onDefeat1(event):
    unit = event.target
    if unit.type == "ogre":
        bossGoal.success == True
        game.spawnXY("chest", 36, 30)

            
            
            
def spawnMunchkin(x, y):
    ogre = game.spawnXY("munchkin", x, y)
    ogre.behavior = "AttacksNearest"

def spawnArcherWall():
    spawnArcher(10, 54)
    spawnArcher(10, 44)
    spawnArcher(10, 34)
    spawnArcher(10, 24)
    spawnArcher(10, 14)

def spawnOgreWave():
    offset = game.randomInteger(-6, 6)
    spawnMunchkin(80, 22 + offset)
    spawnMunchkin(80, 28 + offset)
    spawnMunchkin(80, 34 + offset)
    spawnMunchkin(80, 40 + offset)
    spawnMunchkin(80, 46 + offset)
    spawnMunchkin(80, 52 + offset)


def onDefeat2(event):
    unit = event.target
    game.defeated +=1
    unit.destroy()
    

game.setActionFor("munchkin", "defeat", onDefeat2)
game.setActionFor("ogre", "defeat", onDefeat1)

game.defeated = 0
game.spawnTime = 0
goal = game.addManualGoal("Defeat over 100 ogres.")
ui.track(game, "defeated")

def checkSpawnTimer():
    if game.time > game.spawnTime:
        spawnOgreWave()
        game.spawnTime += 5

def checkGoal1():
    if game.defeated > 100:
        goal.success = True
        fence1.destroy()

spawnArcherWall()
while True:
    checkSpawnTimer()
    checkGoal1()
1 Like

Thanks for formatting!

It looks like the problem is with bossGoal. If you comment out the ‘bossGoal=’ line and the ‘bossGoal.success’ line in the definition, the game will complete when you collect the chest.

I haven’t found the exact problem (yet), but I see two options…either combine the two manual goals in to one, by making it something like “Defeat over 100 ogres to release the boss…then kill him too!”, or, figure out why defeating him is not being counted as a goal completion. (Personally, I’m going to keep looking for the cause :stuck_out_tongue_winking_eye:)

Found it…line 28, you have ‘==’ where it should be ‘=’. Man, that one was sneaky! :grin: