Skip to content

Commit

Permalink
units: don't update energy, shields or hp for cloaked and undetected …
Browse files Browse the repository at this point in the history
…units, since bwapi returns 0 for them
  • Loading branch information
tscmoo committed Feb 8, 2015
1 parent feb3d1e commit 21f6124
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/units.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,11 @@ void update_unit_stuff(unit*u) {
u->detected = u->game_unit->isDetected();
u->invincible = u->game_unit->isInvincible();

u->energy = u->game_unit->getEnergy();
u->shields = u->game_unit->getShields();
u->hp = u->game_unit->getHitPoints();
if (!u->cloaked || u->detected) {
u->energy = u->game_unit->getEnergy();
u->shields = u->game_unit->getShields();
u->hp = u->game_unit->getHitPoints();
}
u->prev_weapon_cooldown = u->weapon_cooldown;
u->weapon_cooldown = std::max(u->game_unit->getGroundWeaponCooldown(), u->game_unit->getAirWeaponCooldown());

Expand Down Expand Up @@ -768,6 +770,9 @@ unit*new_unit(BWAPI_Unit game_unit) {
update_unit_owner(u);
update_unit_type(u);

u->energy = u->stats->energy;
u->shields = u->stats->shields;
u->hp = u->stats->hp;
u->visible = game_unit->isVisible();
update_unit_stuff(u);

Expand Down

0 comments on commit 21f6124

Please sign in to comment.