.tact19 \ If we get here then there is a suitable target for the \ enemy to drain, and the target's object number is in Y TYA \ Store the target number in enemyTarget in the enemy's STA enemyTarget,X \ data, so it is set as the enemy's target going forward LDA targetVisibility \ Store the target's visibility in enemyVisibility for STA enemyVisibility,X \ this enemy LDA enemyDrainTimer,X \ If enemyDrainTimer for this enemy is non-zero then it CMP #1 \ is either counting down or has counted down, so jump BCS tact21 \ to tact21 to process this \ If we get here then enemyDrainTimer is zero, so we \ restart the timer from 120 LDA #120 \ Set enemyDrainTimer for this enemy to 120 so the enemy STA enemyDrainTimer,X \ doesn't drain energy for another 120 timer ticks \ (120 * 0.06 = 7.2 seconds) .tact20 JMP MoveOnToNextEnemy \ Jump to MoveOnToNextEnemy to stop applying tactics to \ this enemy and set things up so we move on to the next \ enemy in the next iteration of the gameplay loop .tact21 BNE tact20 \ We jump knowing that the enemyDrainTimer for the enemy \ is 1 or greater, so this jumps to tact20 to move on to \ the next enemy when enemyDrainTimer is greater than 1 \ and is still counting down \ If we get here then enemyDrainTimer for the enemy has \ counted down to 1, so we need to process that LDA targetVisibility \ If bit 7 of targetVisibility is clear then the enemy BPL tact22 \ can't see the tile containing the enemy's target (but \ we know it can see the enemy object as otherwise we \ wouldn't have reached this point), so jump to part 9 \ to consider turning a tree into a meanie \ If we get here then the enemy can see the tile \ containing the target, so it can drain its target of \ energy JSR DrainObjectEnergy \ Drain energy from the target object into the enemy, \ transforming it into an object with an energy level \ of one unit less (if applicable) \ \ This updates enemyEnergy with the drained energy, so \ it can be expended back onto the landscape later on \ \ It also sets X to the object number of the target that \ has been drained of energy (and which has therefore \ been transformed into a different object type) LDY enemyObject \ Set enemyTacticTimer for the enemy to 30 so we wait LDA #30 \ for 30 * 0.06 = 1.8 seconds before applying tactics STA enemyTacticTimer,Y \ to the enemy again BCS tact27 \ If DrainObjectEnergy set the C flag then the enemy \ just drained the player object, so jump to \ MoveOnToNextEnemy via tact27 to stop applying tactics \ to this enemy and set things up so we move on to the \ next enemy in the next iteration of the gameplay loop JMP tact25 \ Otherwise it wasn't the player object being drained, \ so jump to tact25 in part 10 with X set to the number \ of the object that was drained so we update it \ on-screen with a dithered effect (as it has now been \ transformed into a different type of object) and \ return from the subroutineName: ApplyTactics (Part 8 of 10) [Show more] Type: Subroutine Category: Gameplay Summary: If the drain timer has run down, either drain the target's energy or jump to part 9 to create a meanie; or start the drain timer Deep dive: Enemy timers and state variablesContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Subroutine DrainObjectEnergy (category: Gameplay)
Drain energy from an object into an enemy, transforming it into an object with an energy level of one unit less (if applicable)
[X]
Subroutine MoveOnToNextEnemy (category: Gameplay)
Update enemyObject so the next time we consider applying enemy tactics, we apply them to the next enemy, looping from 7 to 0
[X]
Variable enemyDrainTimer in workspace Main variable workspace
A timer for each enemy that counts down every 0.06
[X]
Variable enemyObject in workspace Zero page
The object number of the enemy to which we are applying tactics in this iteration around the main loop (0-7)
[X]
Variable enemyTacticTimer in workspace Main variable workspace
A timer for each enemy that counts down every 0.06
[X]
Variable enemyTarget in workspace Main variable workspace
The object number of the enemy's target (one byte per
[X]
Variable enemyVisibility in workspace Main variable workspace
Visibility of the enemy's target (one byte per enemy)
[X]
Label tact20 is local to this routine
[X]
Label tact21 is local to this routine
[X]
Label tact22 in subroutine ApplyTactics (Part 9 of 10)
[X]
Entry point tact25 in subroutine ApplyTactics (Part 10 of 10) (category: Gameplay)
Dither the updated object #X onto the screen, with bit 7 of drawLandscape determining whether the object is drawn on its own (bit 7 set) or with the surrounding landscape (bit 7 clear)
[X]
Label tact27 in subroutine ApplyTactics (Part 10 of 10)
[X]
Variable targetVisibility in workspace Zero page
Reports whether a target object is visible from an enemy in the CheckEnemyGaze routine