ADnD: Dragons of Flame/Game Mechanics and Techniques
From SDA Knowledge Base
Contents
RNG
The RNG only matters for the overworld. The dungeon levels only depend on the player actions.
The RNG-addresses are $83 and $84. They're updated with a recursive formula, taking the global timer in $79 as entropy. The sub-routine starts at instruction $D016. The formula produces a sequence that doesn't appear to be possible to manipulate in real-time. Since the global timer in $79 starts running from power-on, it's essentially impossible to manipulate something even at the very start of the game.
Pressing the d-pad from a standstill position will move the player 16 pixels in the corresponding direction. The overworld can therefore be thought of as a grid of 16x16 pixel squares. Several of the events described below occur when the player occupy these corners. Below, these will be referred to as "intersections".
Enemy spawning (overworld)
If there are less than 3 enemies in the memory, the game does a random check every time the player reaches an intersection. The random check has a 25% chance of producing an enemy (the check starts at instruction $8DCD).
- Note 1: If the player is standing still, the check will be done every frame!
- Note 2: If there are no enemies or only one enemy, a check will be done for every missing enemy. So up to 3 enemies can spawn in a single frame.
The player actions determine to a certain extent where the new enemy will spawn:
- - If the player is moving to the right, the enemies will spawn at the bottom of the screen
- - If the player is moving to the left, the enemies will spawn at the left of the screen
- - If the player is moving up, the enemies will spawn at the top of the screen
- - If the player is moving down, the enemies will spawn at the bottom of the screen
- - If the player is standing still, the enemies will spawn in any of the 4 sides of the screen with equal probability
Once the side of the screen has been determined, the game randomly calculates the other coordinate. If the calculated spawning position coincides with an object, the spawn is cancelled.
- Note: The only possibility for an enemy to spawn on the right side of the screen is if the player is standing still (and then it's a 25% probability).
Enemy movement (overworld)
The general movement of enemies is "2 steps towards the player, 1 random step, 2 steps towards the player, 1 random step, etc". This pattern results from the check that starts at instruction $8EBA. The movement direction is updated every time both the player and the enemy are at intersections. A few observations:
- - When the enemy is running into an obstacle, the movement direction is recalculated every frame until a direction moving away from the object is found.
- - If you make small pauses and thereby get out of sync with the enemy movements, you will notice they will also make brief stops, waiting for the positions to sync (same thing happens if they run into obstacles).
- - When the x- and y-distance to the player is equal, the x-movement is preferred. This means it's relatively safe to try and run past an enemy above or below, but risky to do it a square to the left or right of the enemy.