Outpost Universe Forums

Projects & Development => Outpost 2 Programming & Development => Topic started by: Sirbomber on July 15, 2010, 12:07:15 PM

Title: Finding Units On A Tile
Post by: Sirbomber on July 15, 2010, 12:07:15 PM
Hey, does anyone know if there's a way to check what type of unit is on a specific tile?

Note that I'm not talking about simply detecting any unit on a tile using a trigger.  I want to check a specific location and grab the mapID of the unit on that tile (or return mapNone if no unit is there).
Title: Finding Units On A Tile
Post by: Hidiot on July 15, 2010, 02:14:46 PM
I don't know of any good way either.

I currently do it by running a RectEnum on one tile (the centre tile for buildings) and using GetNext(<unit>) to get the handle.
Title: Finding Units On A Tile
Post by: Flashy on July 15, 2010, 02:35:21 PM
What militates against using a LocationEnumerator ? Im using it and it works for me.

What im using is something like

Code: [Select]
LocationEnumerator SpaceportEnum(LOCATION(tr.Location().x-2, tr.Location().y-1));
if(SpaceportEnum.GetNext(unitontile))
{
[Stuff, in my code i checked if its a spaceport with unitontileGetType()]
}
Title: Finding Units On A Tile
Post by: Arklon on July 25, 2010, 06:58:33 PM
Quote
Hey, does anyone know if there's a way to check what type of unit is on a specific tile?

Note that I'm not talking about simply detecting any unit on a tile using a trigger.  I want to check a specific location and grab the mapID of the unit on that tile (or return mapNone if no unit is there).
HFL, or the old GetTile hack. If you go HFL, use GameMapEx::GetTileEx, and check the tile.unitIndex field. I dunno how that works for structures (if at all), though, but it works for vehicles. A LocationEnumerator would probably work as well.

Oh, I should probably commit my HFL fixes (which includes a fix for the aforementioned function, which was horribly broken) to the SVN...