.TACTICS CPX #MSL \ If this is a missile, jump up to TA18 to implement BEQ TA18 \ missile tactics CPX #ESC \ If this is not an escape pod, skip the following two BNE P%+8 \ instructions JSR SPS1 \ This is an escape pod, so call SPS1 to calculate the \ vector to the planet and store it in XX15 JMP TA15 \ Jump down to TA15 CPX #SST \ If this is not the space station, jump down to TA13 BNE TA13 \ We only call the tactics routine for the space station \ when it is hostile, so if we get here then this is the \ station, and we already know it's hostile, so we need \ to spawn some cops JSR DORND \ Set A and X to random numbers CMP #140 \ If A < 140 (55% chance) then return from the BCC TA14-1 \ subroutine (as TA14-1 contains an RTS) LDA MANY+COPS \ We only call the tactics routine for the space station CMP #4 \ when it is hostile, so first check the number of cops BCS TA14-1 \ in the vicinity, and if we already have 4 or more, we \ don't need to spawn any more, so return from the \ subroutine (as TA14-1 contains an RTS) LDX #COPS \ Set X to the ship type for a cop LDA #%11110001 \ Set the AI flag to give the ship E.C.M., enable AI and \ make it very aggressive (60 out of 63) JMP SFS1 \ Jump to SFS1 to spawn the ship, returning from the \ subroutine using a tail call .TA13 CPX #TGL \ If this is not a Thargon, jump down to TA14 BNE TA14 LDA MANY+THG \ If there is at least one Thargoid in the vicinity, BNE TA14 \ jump down to TA14 LSR INWK+32 \ This is a Thargon but there is no Thargoid mothership, ASL INWK+32 \ so clear bit 0 of the AI flag to disable its E.C.M. LSR INWK+27 \ And halve the Thargon's speed RTS \ Return from the subroutine .TA14 CPX #CYL \ If A >= #CYL, i.e. this is a Cobra Mk III trader (as BCS TA62 \ asteroids and cargo canisters never have AI), jump \ down to TA62 CPX #COPS \ If this is a cop, jump down to TA62 BEQ TA62 LDA SSPR \ If we aren't within range of the space station, jump BEQ TA62 \ down to TA62 LDA INWK+32 \ This is a pirate or bounty hunter, but we are inside AND #%10000001 \ the space station's safe zone, so clear bits 1-6 of STA INWK+32 \ the AI flag to stop it being hostile, because even \ pirates aren't crazy enough to breach the station's \ no-fire zone .TA62 LDY #14 \ If the ship's energy is greater or equal to the LDA INWK+35 \ maximum value from the ship's blueprint pointed to by CMP (XX0),Y \ XX0, then skip the next instruction BCS TA21 INC INWK+35 \ The ship's energy is not at maximum, so recharge the \ energy banks by 1Name: TACTICS (Part 2 of 7) [Show more] Type: Subroutine Category: Tactics Summary: Apply tactics: Escape pod, station, lone Thargon, safe-zone pirate Deep dive: Program flow of the tactics routineContext: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: This subroutine is called as follows: * MVEIT (Part 2 of 9) calls TACTICS
This section contains the main entry point at TACTICS, which is called from part 2 of MVEIT for ships that have the AI flag set (i.e. bit 7 of byte #32). This part does the following: * If this is a missile, jump up to the missile code in part 1 * If this is an escape pod, point it at the planet and jump to the manoeuvring code in part 7 * If this is the space station and it is hostile, consider spawning a cop (45% chance, up to a maximum of four) and we're done * If this is a lone Thargon without a mothership, set it adrift aimlessly and we're done * If this is a pirate and we are within the space station safe zone, stop the pirate from attacking by removing all its aggression * Recharge the ship's energy banks by 1
Arguments: X The ship type
[X]
Configuration variable COPS = 2
Ship type for a Viper
[X]
Configuration variable CYL = 7
Ship type for a Cobra Mk III (trader)
[X]
Subroutine DORND (category: Maths (Arithmetic))
Generate random numbers
[X]
Configuration variable ESC = 13
Ship type for an escape pod
[X]
Configuration variable MSL = 9
Ship type for a missile
[X]
Subroutine SFS1 (category: Universe)
Spawn a child ship from the current (parent) ship
[X]
Subroutine SPS1 (category: Maths (Geometry))
Calculate the vector to the planet and store it in XX15
[X]
Configuration variable SST = 8
Ship type for the space station
[X]
Label TA13 is local to this routine
[X]
Label TA14 is local to this routine
[X]
[X]
Label TA15 in subroutine TACTICS (Part 7 of 7)
[X]
Label TA18 in subroutine TACTICS (Part 1 of 7)
[X]
Label TA21 in subroutine TACTICS (Part 3 of 7)
[X]
Label TA62 is local to this routine
[X]
Configuration variable TGL = 12
Ship type for a Thargon
[X]
Configuration variable THG = 6
Ship type for a Thargoid
[X]
Temporary storage, used to store the address of a ship blueprint. For example, it is used when we add a new ship to the local bubble in routine NWSHP, and it contains the address of the current ship's blueprint as we loop through all the nearby ships in the main flight loop