this.statusCheck = function () {
if (!this.cloakedTarget) {
if (this.cloakingTimer) {
this.cloakingTimer.stop();
delete this.cloakingTimer;
}
} else {
if (!this.cloakedTarget.isCloaked) {
this.ship.target = this.cloakedTarget;
this.ship.reactToAIMessage("TARGET_DECLOAKED");
if (this.cloakingTimer) {
this.cloakingTimer.stop();
delete this.cloakingTimer;
}
}
}
};
Notice that the timer is being stopped in two different places.
If we chart the two conditions, cloakedTarget and isCloaked, we will see that the timer is allowed to continue only when there is a currently cloaked target.
Likewise, the decloaked message occurs only when the ship is not cloaked.