Page 1 of 1

Units move to (0,0) regardless of using Move, Rightclick or Attack

Posted: Sun Apr 17, 2016 11:20 am
by Leckofunny
Hello everybody,

I'm using this C# wrapper
https://github.com/Lamarth/BWAPI-CLI

On a map with only 10 vs 10 marines,
marines.png
marines.png (169.03 KiB) Viewed 728 times

I'm just telling each unit to attack some place behind
(determined by startLocation) the army.

Code: Select all

        public void ForceAttack(TilePosition targetPosition)
        {
            foreach(AiCombatUnitBehavior unit in combatUnits)
            {
                Position pos = new Position(targetPosition.X, targetPosition.Y);
                unit.GetUnit().Attack(pos, false);
            }
        }


For some reason all units move to (0,0) regardless of using Move, Attack or Rightclick. Hard coding the coordinates doesn't make a difference.


I fear that this is an issue of the C# wrapper.

edit:

Using that position for PingMiniMap pings in the top left corner.

Re: Units move to (0,0) regardless of using Move, Rightclick or Attack

Posted: Sun Apr 17, 2016 5:41 pm
by warwolf30
I don't have any experience with C#, but I would print targetPosition to a filelog to see if you are giving the proper positions.
Also, you don't need to compute the Position every time, you can do something like:

Code: Select all

public void ForceAttack(TilePosition targetPosition)
{
    Position pos = new Position(targetPosition);  // in BWAPI there is a constructor for TilePosition to Position
    foreach(AiCombatUnitBehavior unit in combatUnits)
    {
        unit.GetUnit().Attack(pos);
    }
}

Re: Units move to (0,0) regardless of using Move, Rightclick or Attack

Posted: Sun Apr 17, 2016 5:50 pm
by Leckofunny
This wrapper doesn't provide a constructor using TilePosition as parameter.

It looks like that I'm dealing with some conversion issue. I have to multiply the TilePosition by 32 in order to get the proper Position.


edit: I hard coded targetPosition, so its always on (28,13) or on (29,45) depending on the startLocation.