Zero-Sum "can't command x" bug

Hi all,

In zero-sum, I am seeing a message like the following in some games:

Hero Placeholder 1 (team ogres) can't command Bonnie (team humans).

This crashes my hero and then I usually lose the match.

I would expect this to mean that I am attempting to call this.command() on a unit I do not control, however I do not believe this to be the case — I only use units retrieved via this.findFriends(). Something unexpected must be happening.

In the game I am currently viewing it seems to happen immediately upon the death of some resurrected zombies. Perhaps this is related, since it seems that enemy units will fight for you if resurrected. Perhaps, upon death, there is an instant where they are included in the return value of this.findFriends(), but it is not valid to command them.

The above is largely speculation. I haven’t been able to debug this at all because there does not seem to be any practical logging functionality (this.say() is not very useful) or inspection tools. I have a high confidence that this is not a problem in my code, but I’m not willing to share it at this time.

Anyway, if a dev sees this (@nick) perhaps you can have a look?

1 Like

I had the same problem. I think the issue is that you have something like:

friends = this.findFriends()
this.summon('soldier')
for friend in friends:
    this.command(friend, 'attack', enemy)

Basically you have some action between when you created the findFriends array and when you actually commanded, and in that time a dude that you were controlling died and switched teams (I also have had the error appear because the dude was dead)

If you make sure you are only getting the array directly before using it with no game actions in between, it should remove the error.

2 Likes

Damn, I think you’re right @dwhittaker, your explanation fits my problem very well. Well done for figuring that out and thanks for telling me!

It had not occurred to me that the summoning action takes time (I guess just one “frame”) and therefore the state of the world would change before I got to issuing orders. I was doing exactly as you described: fetching the data, then summoning, then giving orders.

So, not a CodeCombat bug after all, just a clueless player bug. Though it would be nice if the hero AI didn’t die completely when this happens. :slight_smile:

1 Like

I just realized who I was helping… I shoulda kept my mouth shut til after the tournament! :slight_smile: Actually at least this way I can take a smidgeon of glory by saying I helped Wizard Dude!

My guy finds something interesting in the wall and spends about 20 seconds studying it before getting back to the task at hand.

1 Like

:smiley: Your generosity did seem rather unfounded! Looks like I’m finally down from first though so I have some more work to do. :wink:

I also had this problem with the wall… sometimes a coin appears in the rocks at the top-right which is not reachable in a straight line and my hero would spend a good while furiously charging the wall to get to it. Now I check the coin with this.isPathClear() before chasing it and the problem is largely gone. Either that or you can specifically ignore coins in this section of the map.

1 Like

I believe Nick has gotten it fixed so that coins don’t spawn out of bounds anymore.

Good luck getting back on top! I’m just hoping to be in the top ten, too busy teaching and getting ready to move to spend much time playing.

1 Like

Maybe we need a warning for commanding enemies that isn’t an error?

I did try to add this.debug to the method list for this one, but it appears not to have worked. Let me try again.

If you still see a coin stuck in the wall, press Ctrl+\ and send me a screenshot so I can debug it further.

1 Like

@nick

Here is one. I’m not sure if there is a coin hidden there or not, but I stand there running into the wall for a while before moving on.

1 Like

Hello, the question has arealdy been answered, but maybe my solution could help others.

    Hero Placeholder 1 (team ogres) can't command Bonnie (team humans).

I added a condition checking the team of the unit before commanding it.

Somewhere in the initialization, I have

myTeam=this.team;

And instead of

this.command(friend, 'attack', enemy);

I use

if(friend.team==myTeam){
  this.command(friend, 'attack', enemy);
}

I think this is a more robust solution than “do it quickly so your units can’t die or change team before you command them”.

2 Likes

Hmm, I can’t tell where the coins was, though–I need to be able to see how far into the obstacle the coin spawned in order to figure out whether there’s a bug in the don’t-spawn-coins-in-obstacles logic or whether the tolerances are just slightly off.

1 Like

Yeah, I realized later that I had 2 self.move(item.pos) lines separated by spell casting and friend summoning. Apparently somewhere between the two lines I reached the coin, then didn’t have anything to move toward for the second one so Pender got confused.

1 Like

I finished the level, but it never showed the red flag on the map. Any ideas why?
:confused:

Did you “finish” it for both ogres and humans? It’s possible it’s loading one or the other session and seeing it as incomplete.