Get a Siege Tank's cooldown?

https://github.com/bwapi/bwapi
Nuclear
Posts: 13
Joined: Thu Jan 28, 2010 8:32 pm

Get a Siege Tank's cooldown?

Postby Nuclear » Sat Mar 06, 2010 10:21 am

Hi, I'm "learning" my units to micro - for now against zealots and I need the unit's remaining weapon cooldown, so I know, that the unit is ready to attack.
I use getGroundWeaponCooldown(), but it doesn't work for Siege Tanks. It returns always 0.
I read something, that I must use getChild().
This is part of my code: If unit's countdown is greater than 10 and an enemy is nearby, run away. After that another piece of code orders the unit to attack and after the unit has attacked once, this will be executed again.

Code: Select all

... && u->getGroundWeaponCooldown()>10  &&...


In this case it works for other units (I tried with vultures and marines), but it doesn't work for tanks, because getGroundWeaponCooldown returns always 0.

Code: Select all

... && (u->getGroundWeaponCooldown()>10 || (u->getType()==UnitTypes::Terran_Siege_Tank_Tank_Mode && u->getChild()->getGroundWeaponCooldown()>10)) &&...


this crashes, when 'u' is Siege Tank.

Code: Select all

... && (u->getGroundWeaponCooldown()>10 || (u->getType()==UnitTypes::Terran_Siege_Tank_Tank_Mode && u->/*getChild()*/->getGroundWeaponCooldown()>=0)) &&...


I removed getChild and set the condition for Cooldown >=0. So it will be executed every time
Now it doesn't crash, but it runs every frame for tanks and they move without attacking. I need to get the tank's cooldown (remaining time in frames, before the tank can shoot).
I think, that getChild() causes the crash.
krasi0
Posts: 254
Joined: Thu Dec 18, 2008 12:42 pm

Postby krasi0 » Sat Mar 06, 2010 11:30 am

Hi, just to confirm I've faced the same problem a while ago working on my micro... groundweaponcooldown for sieged tanks is always 0 :((
Where have you read about the getChild() method? I've never heard of it.
Nuclear
Posts: 13
Joined: Thu Jan 28, 2010 8:32 pm

Postby Nuclear » Sat Mar 06, 2010 12:35 pm

http://code.google.com/p/bwapi/issues/deta...=188&q=tank
I'm not sure, that getChild() will do it. They aren't sure too. ("maybe something like getChild").
Nuclear
Posts: 13
Joined: Thu Jan 28, 2010 8:32 pm

Postby Nuclear » Sun Mar 07, 2010 12:53 am

http://code.google.com/p/bwapi/source/detail?r=2109
Good, I tested it and it's fixed now.

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