How to target enemy/friend/ingore target?


#1

Hello,

Got some trouble in Dugeon Arena playing for Orcs.
I have few questions on gameplay, would be nice if someone could help.

  1. How to target specific friend createures (ex. muchkins)?
    Using this, but it doesn’t work:

     var muchking; //casting grow on muchking
    

    for(var m = 0; m < friends.length; m++) {
    if(friends[m].type === ‘muchking’) {
    muchking = friends[m];
    }
    }
    if(muchking) { // done to ensure it’s not null and that we did find the muchking
    if(this.canCast(‘grow’, muchking)) this.castGrow(muchking);
    }

  2. How to stop targeting enemyHero?
    Got this code for enemy targeting:

  var enemyHero;
    for(var i = 0; i < enemies.length; i++) {
        if(enemies[i].type === 'knight') {
            enemyHero = enemies[i];
        }
    }
    if(enemyHero) { // done to ensure it's not null and that we did find the hero
        if(this.canCast('shrink', enemyHero)) this.castShrink(enemyHero);
    }
    else if (this.canCast('shrink', enemy)) this.castShrink(enemy);

But still tries to target enemy hero, when he died. Would be nice, if someone could tell how to check enemy hero hp and put it to ignore?

3) Can sm1 give an idea how to get position of allied units? Need it to move Yugargen behind the units.

#2
  1. Well, first of all, it is ‘munchkin’ not ‘muchking’

  2. I’m not sure about this one, your code looks ok, though I don’t see you actually defining what ‘enemy’ is, I’m assuming that was done before this code.

  3. Try this code to get the position of the first friend:

    friend = this.getFriends()[0];
     this.moveXY(friend.pos.x+10, friend.pos.y);

#3

Ok, I’m very thankfull for your correction of “muchking”.

Currently i struggle with this:

As you can see munckin is dead, but Yugargen keeps targeting him. How can I reset the ally target?

@dwhittaker, can’t understand what core u wrote:

friend = this.getFriends()[0];
this.moveXY(friend.pos.x+10, friend.pos.y);

mby some dependebles are missing?


#4

Is there code to make Yugargen do something else besides trying to cast spells? Yugargen may not be updating the action to anything, so she stays targeting whatever she was doing last. She’s not still trying to cast grow on the munchkin–she’s just not doing anything.


#5

@nick, how can u explain that Yugargen still targets dead ally, while new are spawn?

Also, can we get status of target? For example, target is shrinked?
Can we get what was cast last time by our hero or enemy hero?

Was testing this code today:


if(this.canCast('shrink', enemy)) {
    // ****************Casting shrink on Hero or Soldiers********************************
    var enemyHero;
    for(var i = 0; i < enemies.length; i++) {
        if(enemies[i].type === 'knight') {
            enemyHero = enemies[i];
        }
    }
    if(enemyHero) { // done to ensure it's not null and that we did find the hero
        if(this.canCast('shrink', enemyHero)) this.castShrink(enemyHero);
    }
    else {
        for(var s = 0; s < enemies.length; s++) {
            if(enemies[s].type === 'soldier') {
                if(this.canCast('shrink', enemies[s])) this.castShrink(enemies[s]);
            }
        }
    }
}
else if(this.canCast('grow', friend)) {
    // ****************Casting Grow on Munckin********************************
    var munchkin; //Casting grow on munchkin
    for(var m = 0; m < friends.length; m++) {
        if(friends[m].type === 'munchkin') {
            munchkin = friends[m];
        }
    } 
    if(munchkin) { // done to ensure it's not null and that we did find the munchkin
        if(this.canCast('grow', munchkin)) this.castGrow(munchkin);
    }
}
else {
    // ****************Attacking Archers********************************
    var archer; //Casting grow on munchkin
    for(var a = 0; a < enemies.length; a++) {
        if(enemies[a].type === 'archer') {
            archer = enemies[a];
        }
    } 
    if(archer) { // done to ensure it's not null and that we did find the munchkin
        this.attack(archer);
    }
}

And got issue with attacking archers when no other target is present.
Also have issue when Yugargen cast grow on munchkin, but doesn’t attack archers after. Where should i look or what to fix?

So new problem is that Yugargen doesn’t attack when she can.

Got same error, when Yugargen targets dead enemy while there is other things to do like cast Grow on muchkin, image:


#6

And here come the quite noob question, where can we get all possible commands? While reading forum saw that many possible commands are not written, so where to look at them?


#7

This gates your outer loops, but probably enemy and friend (the nearest ones) are already shrunk and grown (so you can't cast shrink/grow on them again, so canCast returns false), so it doesn't even get to loop over the other enemies and friends to see if any of them need to be ensorcelled.

Why not have Yugargen say() different things when she's in each if-branch so that you can see which one she's taking each frame?

All the available methods for Dungeon Arena are documented in the spell palette, except for the say() commands (and we'll be moving away from that API soon). Basically you can do `"attack"`, `"move"`, `"defend"`, or `"follow"`. `"move"` and `"defend"` take `targetPos`, whereas `"attack"` takes an optional `target`. Any of them can take `type` to limit which type of ally hears:

`this.say("Attack the wakabayashi!", {type: 'archer', target: enemyHero});`

This gates your outer loops, but probably enemy and friend (the nearest ones) are already shrunk and grown (so you can’t cast shrink/grow on them again, so canCast returns false), so it doesn’t even get to loop over the other enemies and friends to see if any of them need to be ensorcelled.

Why not have Yugargen say() different things when she’s in each if-branch so that you can see which one she’s taking each frame?

All the available methods for Dungeon Arena are documented in the spell palette, except for the say() commands (and we’ll be moving away from that API soon). Basically you can do "attack", "move", "defend", or "follow". "move" and "defend" take targetPos, whereas "attack" takes an optional target. Any of them can take type to limit which type of ally hears:

this.say("Attack the wakabayashi!", {type: 'archer', target: enemyHero});