Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Every frame, if the flame is moving horizontally, then the flame will call the Arcade RNG cycle function. Depending on the difficulty of Arcade, the flame will have a certain % chance of making a decision each frame:
- - Level 1: 0.96%
- - Level 2: 1.15%
- - Level n = (100 * (((256 * 60n)-1)/32767))
- For that decision, it will set a byte to either 0 or 1. The formula for this is as follows:
- byte = 0x5F70 < (RNG & 0x7FFF) + (((flame->x < jumpman->x) + byte) * 0xFB8))
- So this can be broken down into a few scenarios:
- - If the byte was 1, and the flame is more left than you, then there is a 50% chance the byte will be set to 1
- - If the byte was 0, and the flame is more left than you, then there is a 37% change the byte will be set to 1
- - If the byte was 1 and the flame is more right than you, then there is a 37% chance the byte will be set to 1
- - If the byte was 0 and the flame is more right than you, then there is a 25% chance the byte will be set to 1
- In short, the flame being more left than you yields a higher chance of setting the byte to 1
- The fun and games here don't end, irrespective of the first RNG chance succeeding, if the difference between a value of another variable and the y value of the flame is higher than 5, then this will essentially swap the byte state (if it was 1, it gets set to 0. if it was 0, then it gets set to 1). The value of the variable is decided by the below:
- - If first RNG check failed: minimum value between the level index and 5
- - If otherwise: (a new RNG value & 0x7FFF)
- The flame velocity (which essentially determines whether it goes left or right) is determined by the following:
- flame->x_velocity = ((min(level,5) / 15) + 1) + (byte - 0.5)
- In other words, the value of the byte determines whether the flame goes left (byte = 0) or right (byte = 1), with the level index determining how fast it is doing so. Additionally, every time the flame climbs a ladder, this byte is flipped.
- Here's a rough code extract if you find that easier to understand:
- c = min(level,5);
- if ((oldRNG & 0x7FFF) < (256 + (60 * level))) {
- flame->0x1A = 0x5F70 < rng&0x7FFF + ((((flame->x < jumpman->x) + ((flame->0x1A & 2) * 3) >> 1) * 4024);
- c = rng&0x7FFF;
- }
- if (5 < c - flame->y) {
- flame->0x1A = flame->0x1A == 0;
- } else {
- flame->x = flame->x + flame->x_velocity;
- }
- flame->x_velocity = ((min(level,5) / 15) + 1) + (flame->0x1A - 0.5);
Add Comment
Please, Sign In to add comment