liyonghelpme / bwapi

Automatically exported from code.google.com/p/bwapi
0 stars 0 forks source link

Problem with onUnitMorph #194

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When a unit is destroyed and a new one created on the same frame Starcraft 
issues them the same ID.

BWAPI then instead of calling onUnitDestory() and onUnitCreate(), calls 
onUnitMorph() even if it is owned by a different player or a Command Centre 
turning into a lurker.. etc

Original issue reported on code.google.com by quaver.smith on 3 Feb 2010 at 9:21

GoogleCodeExporter commented 9 years ago
I might be wrong about onUnitDestroy() not being called but onUnitMorph() and 
onUnitCreate() are still wrong, this is the code I used to test it: 

std::map<int, std::pair<BWAPI::Player*, BWAPI::UnitType>> theMap;

void BasicAIModule::onUnitCreate( BWAPI::Unit* unit )
{
    theMap[unit->getID()] = std::make_pair(unit->getPlayer(), unit->getType());
}

void BasicAIModule::onUnitMorph(BWAPI::Unit* unit)
{
    if(theMap.find(unit->getID()) != theMap.end())
    {
        BWAPI::Broodwar->printf("Unit was: %s", theMap[unit-
>getID()].second.getName().c_str());
        BWAPI::Broodwar->printf("Unit is now: %s", unit-
>getType().getName().c_str());
    }
}

And this is one result of it: http://i.imgur.com/b7azH.jpg

Siege tank morphing into an SCV :D

Original comment by quaver.smith on 4 Feb 2010 at 6:00

GoogleCodeExporter commented 9 years ago

Original comment by AHeinerm on 6 Feb 2010 at 3:34

GoogleCodeExporter commented 9 years ago

Original comment by AHeinerm on 7 Mar 2010 at 5:00

GoogleCodeExporter commented 9 years ago
Please verify if this issue still exists in r2126.

Original comment by AHeinerm on 7 Mar 2010 at 10:32

GoogleCodeExporter commented 9 years ago
Looks like it's fixed now, haven't seen it happen since changing to 2.7.1

Original comment by quaver.smith on 21 May 2010 at 1:37

GoogleCodeExporter commented 9 years ago
Cool

Original comment by lowerlo...@gmail.com on 21 May 2010 at 5:05