if (DamagePct >= 100.0) { // Don't let damage go above 100% DamagePct = 100.0; // After destruction, the tank becomes inoperative for some period of time (15 seconds is the Tamiya spec - NOT the same as recovery/invulnerability time!) // After that time it will automatically recover itself. During invulnerability time, the tank can fire but is impervious to enemy fire. // Invulnerabilty time is dependent on the weight class. isDestroyed = true; TankTimer->setTimeout(DESTROYED_INOPERATIVE_TIME_mS, ResetBattle); // DESTROYED_INOPERATIVE_TIME_mS is defined in OP_BattleTimes.h // Start the destroyed light effect HitLEDs_CannonHit(); // After the cannon hit effect, because isDestroyed is true, the subsequent HitLEDs_Destroyed effect will start automatically HitRelay(); //After the cannon hit effect the relay disconnect the motors. Tank cannot move ClearHitRelay(); } else { // Flash the hit notification LEDs HitLEDs_CannonHit(); HitRelay(); ClearHitRelay(); // Start a brief invulnerability timer. Each IR signal is sent multiple times, but we only want to count // one hit per shot. For the next second after being hit, we ignore further hits TankTimer->setTimeout(HIT_FILTER_mS, EnableHitReception);
First of all, if we reach the code you have posted, we already know that we have received a cannon hit (not a machine gun hit). [...]This means that we've added up all our damage and it's equal to or over 100%, therefore the tank is "destroyed" and must be disabled. [...]I hope that helps!
if (jumperState == LOW) { WEIGHT_CLASS = WC_HEAVY; } else { WEIGHT_CLASS = WC_MEDIUM; }
#define pin_WeightJumper 7unsigned char WC;pinMode(pin_WeightJumper, INPUT_PULLUP); if (digitalRead(pin_WeightJumper) == LOW) { WC = WC_HEAVY;}else { WC = WC_MEDIUM;}
BattleSettings.WeightClass = WC;
Let me know if it works!