.tact22 \ If we get here then the enemy can't see the tile \ containing the enemy's target, but it can see the \ target object, so now we consider turning a tree into \ a meanie JSR ScanForMeanieTree \ Scan through the objects in the landscape to see if \ any of them are trees that are suitable for turning \ into a meanie to attack the target LDY enemyObject \ Set Y to the object number of the enemy to which we \ are applying tactics (so this is now object #Y) BCC tact24 \ If the call to ScanForMeanieTree cleared the C flag \ then we have successfully turned a tree into a meanie, \ so jump to tact24 to set up the enemy's tactics timer \ and redraw the transformed tree on-screen LDA enemyFailCounter,Y \ If enemyFailCounter for this enemy is two or more then CMP #2 \ the enemy has failed to find a suitable tree to turn BCS tact23 \ into a meanie on more than one occasion, so jump to \ tact23 to have a fairly long pause before applying \ tactics to this enemy again LDA #%10000000 \ Otherwise set bit 7 of enemyDrainScan so the next time STA enemyDrainScan,Y \ we apply tactics to the enemy it will immediately scan \ for an object to drain BNE tact27 \ 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 (this BNE is effectively a JMP as A is \ always non-zero) .tact23 LDA #0 \ Set enemyDrainTimer = 0 to disable the drain timer for STA enemyDrainTimer,Y \ the enemy BEQ tact27 \ 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 (this BNE is effectively a JMP as A is \ always zero) .tact24 \ If we get here then we have just turned a tree into a \ meanie and the enemy number is in Y LDA #50 \ Set enemyTacticTimer for the enemy to 50 so we wait STA enemyTacticTimer,Y \ for 50 * 0.06 = 3.0 seconds before applying tactics to \ the enemy again LDX enemyMeanieTree,Y \ Set X to the object number of the tree that we just \ turned into a meanie, and fall through into part 10 to \ redraw the transformed object on the screen with a \ dithered effectName: ApplyTactics (Part 9 of 10) [Show more] Type: Subroutine Category: Gameplay Summary: Try scanning for a tree to turn into a meanie when the target's tile is obscured 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 ScanForMeanieTree (category: Gameplay)
Scan through the objects in the landscape to see if any of them are trees that are suitable for turning into a meanie
[X]
Variable enemyDrainScan in workspace Main variable workspace
Enemy will perform a scan for a drainable object (one
[X]
Variable enemyDrainTimer in workspace Main variable workspace
A timer for each enemy that counts down every 0.06
[X]
Variable enemyFailCounter in workspace Main variable workspace
Enemy failed to find meanie: counter (one byte per
[X]
Variable enemyMeanieTree in workspace Main variable workspace
Enemy has turned a tree into a meanie (one byte per
[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]
Label tact23 is local to this routine
[X]
Label tact24 is local to this routine
[X]
Label tact27 in subroutine ApplyTactics (Part 10 of 10)