Skip to navigation

Gameplay: ApplyTactics (Part 4 of 8)

Name: ApplyTactics (Part 4 of 8) [Show more] Type: Subroutine Category: Gameplay Summary: If configured, search the landscape for a suitable target for the enemy to drain of energy
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.tact7 LDX enemyObject \ Set X to the object number of the enemy to which we \ are applying tactics (so this is now object #X) LDA enemyDrainScan,X \ If bit 7 of enemyDrainScan is clear, jump to part 5 to BPL tact9 \ skip the search for a drainable object JSR FindObjectToDrain \ Find a suitable target object for the enemy to drain \ (i.e. a tree that is stacked on top of another object, \ or a boulder, which is exposed to the enemy and on a \ tile that can be seen by the enemy) \ \ If successful, the object number is in targetObject \ and the C flag is clear, otherwise the C flag is set LDX enemyObject \ Set X to the object number of the enemy to which we \ are applying tactics (so this is now object #X) BCS tact8 \ If FindObjectToDrain set the C flag, then no suitable \ object was found for the enemy to drain, so jump to \ tact8 to stop the enemy from searching again and keep \ applying tactics LDA #64 \ Set enemyMeanieCheck = 64 for the enemy so if we start STA enemyMeanieScan,X \ scanning objects for trees to potentially turn into a \ meanie, we start from the last object and work down BNE tact15 \ Jump to tact15 to drain energy from the target object \ (this BNE is effectively a JMP as A is never zero) .tact8 LSR enemyDrainScan,X \ Clear bit 7 of enemyDrainScan for this enemy to stop \ it searching for a drainable target for now \ Fall through into part 5 to keep applying tactics to \ this enemy