[Adventurer] Accounts Department

The new level is here: Accounts Department

In this level, you’ll learn how track (and process) any collected item. Use an event handler and become the true owner of King treasury! Oh, sorry, it’s another story :wink:

P.S.: Play Stick Shift level first if you haven’t completed it yet.

6 Likes

@Bryukh, I didn’t receive any gems. :crying_cat_face:

5 Likes

Incorrect Intro body:

def onCollect(event):
    who = event.target
    what = event.other
    game.score += what.value
    who.say("I found " + item)

somebody.on("collect", onCollect)

item = event.other is correct

2 Likes

Thanks. Fixed. 20chars

1 Like

pls help i have been stuck for a lmost a month

1 Like
# Now you can create a custom goal for your game
# using the game.addManualGoal(description) method!

# Spawn a few scouts, a boss, and a maze.
game.spawnMaze(5)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
ogref = game.spawnXY("ogre-f", 60, 12)
game.spawnXY("ogre-f", 60, 12)
# Spawn and configure the hero.
hero = game.spawnPlayerXY("captain", 12, 56)
hero.maxHealth = 5500
hero.maxSpeed = 1000000000
hero.attackDamage = 500
# Spawn a munchkin generator.
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 5
generator.spawnType = "munchkin"

# Survive goal.
game.addSurviveGoal()
game.spawnXY("potion-medium", 28, 12)

# addManualGoal adds an incomplete goal with a description
# The description will be shown to players.
# NOTE that we save it in a variable called scoutGoal
scoutGoal = game.addManualGoal("Defeat all scouts")

# Use addManualGoal to add a goal to defeat the boss
# Save it in a variable called bossGoal
game.addManualGoal("Thegoal")

# Enemy Behavior
def onSpawn(event):
    unit = event.target
    while True:
        enemy = unit.findNearestEnemy()
        if enemy:
            unit.attack(enemy)

game.setActionFor("scout", "spawn", onSpawn)
game.setActionFor("ogre", "spawn", onSpawn)

# Count how many scouts are defeated.
scoutsDefeated = 0

# Update our manual goals whenever an enemy is defeated.
# This is an example of an algorithm using if-statements.
def onDefeat(event):
    unit = event.target
    if unit.type == "scout":
        scoutsDefeated += 1
        hero.say("Scout down!")
    if scoutsDefeated >= 3:
        # Use setGoalState to mark scoutGoal complete.
        game.setGoalState(scoutGoal, True)
        hero.say("All Scouts down!")
    if unit.type == "ogre":
        # Use game.setGoalState to mark bossGoal complete.
        # Don't forget about the second parameter.
        game.setGoalState(1234, True)
        hero.say("Defeated the big boss!")
# Assign the onDefeat handler to the ogres" "defeat"
# NOTE that munchkins don't count toward success!
game.setActionFor("scout", "defeat", onDefeat)
game.setActionFor("ogre", "defeat", onDefeat)
1 Like

Annotation 2020-08-25 013606

regarde bien l’exemple un peu plus haut:

Annotation 2020-08-25 013812

sinon pour ici:
Annotation 2020-08-25 013449

Ce que j’ai surligné n’est pas bon. Quand tu aura repéré ton erreur dans le 1er, tu aura la réponse pour la 2ieme erreur.

Si cela ne fonctionne pas, n’hésite pas a demander.
:v: :pray:

1 Like

can you translate to english?

There’s a very nifty thing called “google translate”. I would recommend using that. It works very well :grin:
Danny

2 Likes

Or use Yandex Translate if you don’t know language. (this language is French)

1 Like

me:
._.???
you guys:
its obvious