Tuesday, June 8, 2010

Progress toward bullet support

Over the last couple days I've added the following functions to the Bullet interface, which is now documented on the wiki:
I've implemented all of these functions except for getID using information found in Starcraft's memory, specifically in Starcraft's bullet array, which we define in the BW::Bullet struct. This struct has been updated many times over the last several days and contains everything we currently know about the 112 bytes that each bullet occupies in Starcraft memory.

The process of adding new functions to the BulletImpl class, such as getTargetPosition(), usually consists of searching through the bytes in this struct and looking for bytes that appear to contain information that define the bullet's target position, or where on the map it is heading. Once we're sure the bytes represent what we think it does, we can rename the field for those bytes from some generic name, like unknown_0x18, to something more descriptive, like targetPosition, and use that field in the implementation of the getTargetPosition() function.

The getID() function returns a unique ID for each bullet and is updated whenever a bullet switches from non-existent to existent. Since bullets are created and destroyed much more frequently than units, unlike BWAPI Units, new BWAPI Bullets are not created when a Bullet is destroyed, which means bullets do not have a unique address throughout the course of a match. Only 100 BulletImpl objects are created (1 for each element in Starcraft's bullet array), and the IDs of these are updated when the slots are re-used for new bullets.

Bullet::isVisible() is now implemented correctly and does not depend on the visibility of the source unit.

I've also added a Game::getBullets() function which returns the set of accessible bullets (all existing bullets if Flag::CompleteMapInformation is enabled, otherwise just visible bullets).

Bullet support has also been added to the client and server code, however it has not been tested yet.

No comments:

Post a Comment