Dungeon Arena Help


#1

Hey Guys

I run through the tutorial and i decided to do some Dungeon Arena battle. Now i do not really have programing experience so i decided to do the tutorials. I am fighting the Ogres. I clicked on the Human base building ready to build my strategy. Now for some reason i am unable to bring the hero into battle and i cannot figure out what i am doing wrong. For EG

at the bottom of the file i made an if statement which says

If(hero < = 0)
{
this.build(‘tharin’);
} else
{
this.build(type);
}

Now all this does is build solders, it does not build the hero.

Then i saw the array so i decided him to add him there. Everything appeared to be working well, until he had to spawn for a second time. At that point no more troops come out. I also tried to call him from inside the function where he is defined with no avail. I tried to make 2 this.build functions one under the other and it still didn’t work. I kind of hit a road block. If someone could give me some suggestions on how to spawn him it will be much appreciated.

thanks


#2

The problem is this line:

if(hero <= 0)

What is the hero variable? This would only trigger if it’s a number, either 0 or a negative number. Otherwise, that condition will always be false and it’ll trigger the else clause.

The default code has an example of how to just build Tharin once:

// CHOOSE YOUR HERO! You can only build one hero.
var hero;
//hero = 'tharin';  // A fierce knight with battlecry abilities.
//hero = 'hushbaum';  // A fiery spellcaster hero.

if(hero && !this.builtHero) {
    this.builtHero = this.build(hero);
    return;
}

Here it saves the builtHero property to this, so that the next time chooseAction is called, it can check whether it has already built the hero. If it hasn’t, it builds the hero and returns early. If it has, it continues to build the other units. Does that make sense?

Dungeon Arena is intended to be pretty hard, and we don’t yet have enough educational levels to get you there without starting with some programming experience, so don’t worry if it’s a big jump–we intended it as a tournament level for experienced developers.


#3

Thanks for your help i finaly figured out what to do and how to fix it your a legend thanks. I will eventually learn and maybe i can participate to the community