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

https://github.com/bwapi/bwapi
User avatar
Leckofunny
Posts: 27
Joined: Mon Apr 04, 2016 7:41 pm

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

Postby Leckofunny » Sun Apr 17, 2016 11:20 am

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 625 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.
User avatar
warwolf30
Site Admin
Posts: 7
Joined: Mon Apr 04, 2016 12:33 am

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

Postby warwolf30 » Sun Apr 17, 2016 5:41 pm

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);
    }
}
User avatar
Leckofunny
Posts: 27
Joined: Mon Apr 04, 2016 7:41 pm

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

Postby Leckofunny » Sun Apr 17, 2016 5:50 pm

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.

Return to “BWAPI (wrappers in other languages / questions and announcements related to BWAPI itself)”

Who is online

Users browsing this forum: No registered users and 1 guest