Raiders of the long dark Help


#1

This is my code so far but the peasant is not moving

this.choosePeasantStrategy = function() {
    var enemy = this.findNearest(this.findEnemies());
    if(enemy){
        if(enemy.pos.y > peasant.pos.y){
            return "build-above";    
        }
        else if(enemy.pos.y < peasant.pos.y){
            return "build-below";    
        }
        else {
            return "follow";
        }
    }
    // Return "follow", "build-above", or "build-below"
    // Hint: use isPathClear() to determine where the hallways are
};

#2

The only way to get “follow” is if the enemy exists and is the same y as the peasant…

move the else follow out of the if enemy…


#3

Error
not
arryn = self.findByType(“paladin”)[0]
but
arryn = self.findByType(“raider”)[0]


#4

Error
not
arryn = self.findByType(“paladin”)[0]
but
arryn = self.findByType(“raider”)[0]

This and what Vlevo mentioned where my problems and @nick you need to fix the paladin/raider thing in the default code.

Okay everything is good except my use of parameters
this is my function

this.peasantBuild = function(x,y) {
    xx = x;
    yy = y;
    this.command(peasant, "buildXY","palisade",{x:xx,y:yy});
    // Command the peasant to build a palisade.
};

Shouldn’t this work ?
If not pls tell me how to fix it


#5

Better then

if(enemy){
        if(enemy.pos.y > peasant.pos.y){
            return "build-above";    
        }

is

 if self.isPathClear(peasant.pos, {"x": peasant.pos.x, "y": peasant.pos.y + 10}):
        return "build-above"

#6

The raider / paladin thing should be fixed now. :smile:


#7

Off the top of my head I see:

build XY , what, POS

not

“buildXY”, what, x , y

but it is possible the top of my head is fuzzy, I mean, it does have hair all over it…


#8

Okay let me clarify I need help getting the parameters from the function


#9

what does the fire helmet mean?
without changing my hero:
can I prevent it from happening?
what can I do to minimize the effects?


#10

The “fire helmet”, as you call it, is good. It shows the effect of Warcry, which is one of Arryn’s skills. Given that, why would you want to prevent it from happening?


#11

Interesting. I didn’t know it was good. As you can see from the pic my peasant put the palisade in the wrong place and I assumed that it was because of the ‘fire-helmet’. Also, Arryn goes off by himself way ahead of the pack so I thought the ‘fire-helmet’ was making everyone act crazy so that’s why I wanted to know what I could do to prevent or minimize it.

Thanks for clarifying that it’s from the warcry.


#12

i am stuck
here is the code:

Your goal is to protect the peasant and move to the right.

Arryn Stonewall will defend the front, and command the soldiers.

You need to cover the rear and command t

arryn = self.findByType(“raider”)[0]
peasant = self.findByType(“peasant”)[0]

def chooseHeroStrategy():
# Return either “fight” or “advance”.
# Try to stay 5m behind the peasant when not fighting.
# Don’t get more than 15m away from the peasant.
pass

def heroFight():
# Stop the ogres from rushing past you to get to the peasant!
# Hint: try to slow them down if you can
pass

def heroAdvance():
# Stay behind the peasant
pass

def choosePeasantStrategy():
# Return “follow”, “build-above”, or “build-below”
# Hint: use isPathClear() to determine where the hallways are

def peasantAdvance():
# Keep the peasant behind Arryn and her soldiers.
if arryn:
self.command(peasant, “move”, arryn.pos.x-5,arryn.pos.y)

def peasantBuild(x,y):
# Command the peasant to build a palisade.
self.command(peasant, “BuildXY”, x,y)

loop:
heroStrategy = chooseHeroStrategy()
if heroStrategy == “fight”:
heroFight();
elif heroStrategy == “advance”:
heroAdvance();

peasantStrategy = choosePeasantStrategy()
if peasantStrategy == "build-above":
    peasantBuild(peasant.pos.x, peasant.pos.y + 5)
elif peasantStrategy == "build-below":
    peasantBuild(peasant.pos.x, peasant.pos.y - 5)
elif peasantStrategy == "follow":
    peasantAdvance()

#13
# Your goal is to protect the peasant and move to the right.
# Arryn Stonewall will defend the front, and command the soldiers.
# You need to cover the rear and command t
arryn = self.findByType("raider")[0]
peasant = self.findByType("peasant")[0]

def chooseHeroStrategy():
    # Return either "fight" or "advance".
    # Try to stay 5m behind the peasant when not fighting.
    # Don't get more than 15m away from the peasant.
    pass

def heroFight():
    # Stop the ogres from rushing past you to get to the peasant!
    # Hint: try to slow them down if you can
    pass

def heroAdvance():
    # Stay behind the peasant
    pass

def choosePeasantStrategy():
    # Return "follow", "build-above", or "build-below"
    # Hint: use isPathClear() to determine where the hallways are
    

def peasantAdvance():
    # Keep the peasant behind Arryn and her soldiers.
    if arryn:
        self.command(peasant, "move", arryn.pos.x-5,arryn.pos.y)

def peasantBuild(x,y):
    # Command the peasant to build a palisade.
    self.command(peasant, "BuildXY", x,y)

loop:
    heroStrategy = chooseHeroStrategy()
    if heroStrategy == "fight":
        heroFight();
    elif heroStrategy == "advance":
        heroAdvance();

    peasantStrategy = choosePeasantStrategy()
    if peasantStrategy == "build-above":
        peasantBuild(peasant.pos.x, peasant.pos.y + 5)
    elif peasantStrategy == "build-below":
        peasantBuild(peasant.pos.x, peasant.pos.y - 5)
    elif peasantStrategy == "follow":
        peasantAdvance()

#14

i don’t know how to do the rest