Flying under bridges and over main street
Probably the most recognisable image of Aviator is the screenshot on the front of the box, showing the view as we approach the iconic suspension bridge. Flying under the bridge or along the main street of the town is a real test of flying skill, so much so that the following points are awarded for these audacious acts of derring-do:
- 50 points for flying under the bridge the right way up
- 100 points for flying under the bridge upside down
- 100 points for flying down the main street of Acornsville the right way up
- 200 points for flying down the main street of Acornsville upside down
The CheckFlyingSkills is responsible for detecting these flying skills and awarding the correct points, so let's take a look at how it's done.
Skill zones
-----------
The first part of CheckFlyingSkills simply checks to see if the plane is close enough to the bridge or town for a test of skill to be possible. Specifically, we check whether the plane is within a distance of &0500 from the location of the bridge or the town's object anchor point, and if not, we stop checking as the plane is too far away.
If we are close enough, then we move on to part 2 of CheckFlyingSkills, which checks the relevant skill zones by calling the CheckBridgeAndTown routine for each zone. This routine checks whether the plane is within a certain distance of a specific coordinate from the (skillZoneHi skillZoneLo) table. If it is within the correct distance, which is given in the skillZoneSize table, then it is within the skill zone.
The plane is said to be within a coordinate's skill zone if the following checks are all true. They start with larger checks and whittle it down to more fine-grained checks, as follows:
- The vector from the skill zone coordinate to the plane is in a positive direction along each axis, i.e. the plane is somewhere inside a cuboid that has the skill zone coordinate at its bottom-left corner, nearest the origin (the origin being at ground level in the bottom-left corner of the map).
- The length of this vector along each axis is < 1024, so the plane is close enough to the skill zone coordinate for the next check to be done, i.e. within the rectangular cuboid described above, so the plane is within a cube of size 1024 in the skill zone coordinate's corner.
- The length of the vector along each axis divided by 4 is within the margin for this skill zone (as defined in the skillZoneSize table), i.e. the plane is within an even smaller rectangular cuboid, again in the skill zone coordinate's corner, with dimensions given in the skillZoneSize table.
In short, the plane is in the skill zone if it's inside a box whose dimensions are given in the skillZoneSize table, and whose corner nearest the origin is at the skill zone coordinate given in the skillZone table - in other words, the cuboid at the skill zone coordinate, with the dimensions in skillZoneSize.
Or, even shorter, the plane is in a skill zone if this is true for all three axes:
skill zone <= plane < skill zone + skill zone coordinate coordinate coordinate size * 4
Given this, let's see how the skill zones are constructed for the bridge and town.
Size and location of skill zones
--------------------------------
The skill zones are defined as follows. For the bridge we have these three skill zones:
- Skill zone 0 is at (&4CA8, &0000, &8656) with size (&A8, &10, &18) * 4
- Skill zone 3 is at (&4CA8, &0060, &8656) with size (&A8, &16, &18) * 4
- Skill zone 6 is at (&4C88, &0000, &8656) with size (&B8, &2C, &18) * 4
And we have these four for the town:
- Skill zone 9 is at (&0430, &0000, &0330) with size (&A8, &44, &28) * 4
- Skill zone 12 is at (&04D0, &0000, &0470) with size (&28, &84, &48) * 4
- Skill zone 15 is at (&0610, &0000, &0470) with size (&60, &24, &38) * 4
- Skill zone 18 is at (&04E0, &0000, &03C0) with size (&78, &20, &60) * 4
I hope to visualise these skill zones in a future update, but for now these descriptions will have to do:
- Skill zone 0 is the safe zone under the bridge's suspended deck
- Skill zone 3 is the safe zone above the bridge's suspended deck
- Skill zone 6 is a long, tall zone covering the bounds of the entire bridge structure, from the ground to the top of the towers
The bridge's suspended deck (i.e. where the road runs across the bridge) is sandwiched between zones 0 and 3, so if we find ourselves inside zone 6, but not in zone 0 or 3, then we have hit the bridge.
The zones for the town are as follows:
- Skill zone 9 is one of the town's buildings
- Skill zone 12 is another of the town's buildings
- Skill zone 15 is another of the town's buildings
- Skill zone 18 is the safe zone above the main street
If we're inside the safe zone then all is well; if we're inside one of the buildings, then we probably don't need to discuss that further.
Awarding points
---------------
Points are banked when they are earned, but they are only awarded when the plane exits the area safely, at which point the ScorePoints routine is called to make a beep and add the points to the score. There are no posthumous points in Aviator.
Starting with the bridge, points are banked when the plane passes the following three tests in sequence:
- Inside skill zone 6 (we are inside the bounds of the bridge)
- Outside skill zone 3 (we are not above the bridge's suspended deck)
- Inside skill zone 0 (we are below the bridge's suspended deck)
The points are awarded when the plane exits skill zone 6 (i.e. leaves the bridge zone) or enters skill zone 3 (i.e. pulls up from the dive under the bridge and clips zone 3, maybe as part of a loop-the-loop). However, if the plane passes the following three tests in sequence:
- Inside skill zone 6 (we are inside the bounds of the bridge)
- Outside skill zone 3 (we are not above the bridge's suspended deck)
- Outside skill zone 0 (we are not below the bridge's suspended deck)
then the plane crashes into the bridge.
For the town, points are banked when the plane passes the following four tests in sequence:
- Outside skill zone 12 (we are not inside the first building)
- Outside skill zone 15 (we are not inside the second building)
- Outside skill zone 9 (we are not inside the third building)
- Inside skill zone 18 (we are above the main street)
The points are awarded when the plane exits skill zone 18, i.e. when we fly away without hitting any buildings. However, if the plane passes any of the following tests:
- Inside skill zone 12
- Inside skill zone 15
- Inside skill zone 9
then the plane has hit one of the buildings and crashes.
Finally, the points awarded are doubled if there is a line at the bottom of the artificial horizon indicator, which indicates that the plane is upside down. Screen memory is checked directly, so the on-screen bar effectively doubles as a flag variable.
Unfortunately, knowing the above doesn't make it any easier to earn those points. This is a difficult game where you really earn your stripes, but that's all part of the point. This is a simulator, after all...