.CheckEnemyGaze STA T \ Store the object type in T so we can refer to it later STX xStoreEnemyGaze \ Store X in xStoreEnemyGaze so it can be preserved \ across calls to the routine STY targetObject \ Store the target object in targetObject, so object #Y \ is the target object LDA #0 \ Clear all bits of targetVisibility so we can set them STA targetVisibility \ later with the results of the analysis LDA objectFlags,Y \ If bit 7 is set for object #Y then this object number BMI egaz3 \ is not allocated to an object, so jump to egaz3 to \ return from the subroutine with the C flag clear to \ indicate that the target object can't be seen by the \ enemy LDA objectTypes,Y \ If object #Y is not an object of type T (which we set CMP T \ to the argument A above), then jump to egaz3 to return BNE egaz3 \ from the subroutine with the C flag clear to indicate \ that the target object is of the wrong type JSR GetObjectAngles \ Calculate the angles and distances of the vector from \ the viewer to object #Y and put them into the \ following variables: \ \ * Set objTypeToAnalyse to the type of object #Y \ \ * Set objectViewYaw(Hi Lo) to the yaw angle of the \ viewer's gaze towards the object, relative to the \ screen \ \ * Set angle(Hi Lo) to the angle of the hypotenuse of \ the triangle formed by the x-axis and z-axis, \ which is the projection of the 3D vector from the \ viewer to the object down onto the ground plane \ (so imagine a light shining down from above, \ casting the vector's shadow onto the y = 0 plane, \ and that's the hypotenuse) \ \ * Set hypotenuse(Hi Lo) to the length of the 3D \ vector from the viewer to the object when \ projected down onto the ground plane \ \ * Set yDelta(Hi Lo) to the difference (the delta) in \ the y-axis between the viewer and the object we are \ analysing, so this gives us the altitude difference \ between the viewer and the object \ We now have a very short interlude to set up some of \ the anti-cracker code before continuing in part 2Name: CheckEnemyGaze (Part 1 of 2) [Show more] Type: Subroutine Category: Gameplay Summary: Check to see whether the current enemy can see a specific target object of a specific typeContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ApplyTactics (Part 2 of 8) calls CheckEnemyGaze * ApplyTactics (Part 5 of 8) calls CheckEnemyGaze * FindObjectToDrain calls CheckEnemyGaze * ScanForMeanieTree calls CheckEnemyGaze
Arguments: A The type of the object to match against the target (this ensures that we only perform the gaze calculations when the target object is of this type; if it isn't, the routine aborts without doing the calculations) Y The number of the target object to analyse viewingObject The viewing object (i.e. the enemy doing the scanning)
Returns: targetVisibility The target visibility result: * If the target object is a robot, then bit 6 will be set if the robot object can be seen, even if the robot's tile can't be seen * Bit 7 will be set if the enemy can see the target object's tile treeVisibility The tree visibility result: * If the target object is a robot, then bit 6 will be set if there is a tree blocking the view of the robot object * Bit 7 will be set if there is a tree blocking the view of the target object's tile C flag Status flag (though note that this is ignored for every call to this routine): * Clear if the target object does not exist, or is not of the specified type, or the object is in the viewing arc * Set if the target object is not within the viewing arc of the enemy X X is preserved Y Y is preserved
[X]
Subroutine GetObjectAngles (category: 3D objects)
Calculate the angles and distances of the vector from the viewer to a specific object
[X]
Label egaz3 in subroutine CheckEnemyGaze (Part 2 of 2)
[X]
Variable objectFlags in workspace Stack variables
Object flags for up to 64 objects
[X]
Variable objectTypes (category: 3D objects)
The object types table for up to 64 objects
[X]
Variable targetObject in workspace Main variable workspace
The number of the object that is being targeted in the DrainObjectEnergy routine
[X]
Variable targetVisibility in workspace Zero page
Reports whether a target object is visible from an enemy in the CheckEnemyGaze routine
[X]
Variable xStoreEnemyGaze (category: Gameplay)
Temporary storage for X so it can be preserved through calls to CheckEnemyGaze