Difference between revisions of "Ikari Warriors (NES)/Fuel drop manipulation"

From SDA Knowledge Base

Jump to: navigation, search
Line 1: Line 1:
[[Ikari_Warriors_(NES)]]<br />
 
 
This page goes more in depth on how to manipulate fuel drops for the helicopters in areas 3 and 4. The RAM-addresses used here are listed in the [[Ikari Warriors/Game Mechanics#Memory addresses|memory address section]].<br /><br />
 
This page goes more in depth on how to manipulate fuel drops for the helicopters in areas 3 and 4. The RAM-addresses used here are listed in the [[Ikari Warriors/Game Mechanics#Memory addresses|memory address section]].<br /><br />
  
 
==Some background about object allocation in the RAM==
 
==Some background about object allocation in the RAM==
All objects that aren't part of the background are allocated to RAM-address $500 and onwards (player 1 is always in $4FE and player 2 is always in $4FF, but they can be disregarded here since they don't interfere with the foreign objects). This includes enemies, destroyable structures, hidden items, mines etc and even bullets). These addresses are referred to as "object addresses". The object address with index 0 corresponds to $500, index 1 corresponds to $501 etc. A new object entering the screen will be allocated to the lowest available index and when an object leaves the screen (regardless of how), the corresponding index will be restored to null. Dropped objects will retain the address of the initial object though. Bullets are also an exception as they will be allocated to an index further down (without interest for the topics of this page).<br /><br />
+
All objects that aren't part of the background are allocated to RAM-address $500 and onwards (player 1 is always in $4FE and player 2 is always in $4FF, but they can be disregarded here since they don't interfere with the foreign objects). This includes enemies, destroyable structures, hidden items, mines etc and even bullets. These addresses are referred to as "object addresses". The object address with index 0 corresponds to $500, index 1 corresponds to $501 etc. A new object entering the screen will be allocated to the lowest available index. If two objects enter the screen at the same frame, the object to the left will first be attributed the object address and will therefore always have the lower index. When an object leaves the screen (regardless of how), the corresponding index will be restored to null. Dropped objects will retain the address of the initial object though. Bullets are also an exception as they will be allocated to an index further down (without interest for the topics of this page).<br /><br />
  
 
Different objects provide different values to the object addresses. Some objects share the same value, so there must be additional addresses that determine the exact type of object. However, these values aren't overly important to know, but are helpful when analyzing emulator movie files. Below are some common values (but the list is nowhere near complete):
 
Different objects provide different values to the object addresses. Some objects share the same value, so there must be additional addresses that determine the exact type of object. However, these values aren't overly important to know, but are helpful when analyzing emulator movie files. Below are some common values (but the list is nowhere near complete):
Line 64: Line 63:
 
This section will explain how to increase the chances of getting a fuel drop from the first tank in the helicopter section.<br /><br />
 
This section will explain how to increase the chances of getting a fuel drop from the first tank in the helicopter section.<br /><br />
  
The tank drops in this game are determined by the index the tank is allocated to. If the tank is in index 0 (= $500), it will drop a tank and if it's in index 2 (= $502), it will drop a fuel. All other index will result in no drop. The goal of this manipulation is therefore to maximize the chances of the tank spawning in index 2. This can be broken down in two parts. One part leading up to fuel drop itself and one part ensuring the helicopter itself isn't blocking the relevant certain index. It's easiest to understand the route by starting with the fuel drop itself and then retracing the steps as far backwards as possible to try and fulfill the drop conditions.<br /><br />
+
The tank drops in this game are determined by the index the tank is allocated to. If the tank is in index 0 (= $500), it will drop a tank and if it's in index 2 (= $502), it will drop a fuel. All other index will result in no drop. The goal of this manipulation is therefore to maximize the chances of the tank spawning in index 2. This can be broken down in two parts. One part leading up to the fuel drop and one part ensuring the helicopter isn't blocking the relevant index. It's easiest to understand the route by starting with the fuel drop itself and then retracing the steps while trying to keep the drop conditions.<br /><br />
  
 
===Part 2 - getting the tank in index 2===
 
===Part 2 - getting the tank in index 2===
Line 72: Line 71:
  
 
[[File:Ikari Warriors (U)-3 fuel manip.zip]]<br />
 
[[File:Ikari Warriors (U)-3 fuel manip.zip]]<br />
The fm2-movie in the file above shows a successful fuel drop. The lua script and the wch-file both contain the object addresses to make it easier to follow the address allocations. Other than illustrating the description above, it's also worth mentioning the role of #8. If the knife gets an index in the range 0 to 2 (which is not feasible to know in real-time) and is not collected, the leftmost gate (#3) will inherit its index, which means the fuel drop will not be possible. If it's collected, one of the enemy soldiers will inherit its index. #8 should therefore always be collected, no matter what.<br /><br />
+
The fm2-movie in the file above shows a successful fuel drop. The lua script (in the format [object value, index], while following the x-position of the object on screen) and the wch-file both contain the object addresses to make it easier to follow the address allocations. Other than illustrating the description above, it's also worth mentioning the role of #8. If the knife gets an index in the range 0 to 2 (which is not feasible to know in real-time) and is not collected, the leftmost gate (#3) will inherit its index, which means the fuel drop will not be possible. If it's collected, one of the enemy soldiers will inherit its index. #8 should therefore always be collected, no matter what.<br /><br />
 +
 
 +
[[File:Ikari Warriors (U)-3 fuel fail.zip]]<br />
 +
This fm2-movie illustrates some of the things that can go wrong and prevent the fuel drop. Assuming the execution was correct, there are three types of occurrences that will cause problems:
 +
#There is a fifth enemy soldier around #6 in the screenshot above.
 +
#The underwater kamikaze that comes from the left side and starts following you.
 +
#An enemy soldier is running on the right and manages to stay on screen until the group in #6 spawns.
 +
The first case is not possible to work around. All you can do is hope that it didn't get one of the lower index (but they often do since they tend to spawn earlier than the group in #6).<br />
 +
The second case is shown in this movie, but the threat is avoided by barely managing to scroll it off screen before the group at #6 spawned. This enemy doesn't always appear because of sprite limitation, which is an advantage. However, if you collect the heart (like shown in this movie), an index will be released, which increases the chances of spawning this enemy. Avoiding the heart will also result in a more direct route and if this enemy still spawns, it will be scrolled off screen faster. For safety, it's therefore better to leave this heart alone.<br />
 +
It's case 3 that was the root cause in this case. Despite being hit, the enemy's dying animation lasted long enough for it to occupy index 0 when the enemies at #6 spawned. This could have been mitigated by pausing before #6 appeared, but that would also have meant that the underwater enemy probably wouldn't have been pushed off screen. Pausing also increases the risk of more spawns in front of you, which is dangerous in this section. Overall, a difficult situation to deal with.<br /><br />
 +
 
 +
By following the route and suggestions above, the tank will drop fuel very roughly three times out of four.<br /><br />
  
 
===Part 1 - index of the helicopter===
 
===Part 1 - index of the helicopter===
 +
In the part 2 above, nothing has been mentioned about the index of the helicopter itself. The helicopter is treated like any other object and will be dealt an object address according to the same rules. This means that if the helicopter has index 0, 1 or 2, it will be virtually impossible to get a fuel drop later on. This section will describe how to manipulate the helicopter into a higher index.<br /><br />
 +
 +
Let's start by looking at the map of the section in question with all items shown:<br />
 +
[[File:Ikari1-3 heli area.jpg]]<br /><br />
 +
 +
The objects down to the topmost barrel will be on screen when the helicopter appears. So there are 5 non-moving objects that can potentially help keeping the helicopter out of index 0-2. However, there are also blue soldiers creating some randomness by spawning between the barrel section and the helicopter. So the threat comes from either a blue soldier or one of the lower barrels leaving the screen right before the helicopter appears. The helicopter will then inherit a potentially low index. The only realistic variation in terms of routing comes in the barrel section. You can either go to the left, which is faster, or to the right (going straight ahead is not a good option on foot). Let's look at both options.<br /><br />
 +
 +
<u>Left side of the barrel section</u><br />
 +
The following fm2-movie shows the route through the left side of the barrel section:<br />
 +
[[File:Ikari Warriors (U)-3 Heli address fail.zip]]<br />
 +
Similar to the movies above, a lua and a wch-file have been included to make it easier to follow the objects' index. As can be seen from  the movie name, it shows a case where the helicopter was allocated to an index in the range 0-2, which will prevent the fuel drop later on. To understand why this happens, let's take a look at the map again, but this time with arrows showing how the index are transferred from one object to the next:<br />
 +
[[File:Ikari1-3 heli address fail.jpg]]<br /><br />
 +
 +
As a first step, we can see that there are roughly three transfer phases. The first phase (green arrows), where unknown index are transferred to the objects around the gate. The second phase (red arrows), where the gate object index are transferred to the barrels. The third and final phase (yellow arrows), where the barrel index are transferred into the objects leading up to the helicopter. Numbers in yellow indicate the number of frames between the two connected objects disappear/appear. If a blue soldier is spawned (rng) in the meantime, it will inherit the index instead. As a general rule, the more arrows and the longer chain leading up to an object, the more likely it is to contain a low index.<br /><br />
 +
 +
In phase one (green arrows), we see that #4 and #5 are likely to inherit low index. Depending on when the red soldier leaves the screen, either #6 or the triple shot will inherit its value.<br /><br />
 +
 +
In phase two (red arrows), it's difficult to imagine a case where the left barrel in #2 will have an index higher than 2. There are a few more barrels that are likely to have a low index, but not to the same extent as #2.<br /><br />
 +
 +
In phase three (yellow arrows), we can see the issue with this route. #2 leaves the screen some 24 or so frames before the helicopter appears. If no blue soldier appears in the meantime, it's more or less guaranteed that the helicopter will have an index in the range 0-2, which is what we wanted to prevent in the first place. I can be confirmed in the fm2-movie above that this is indeed what happened.<br /><br />
 +
 +
<u>Right side of the barrel section</u><br />
  
 
==Area 4 fuel drop==
 
==Area 4 fuel drop==

Revision as of 16:42, 27 March 2017

This page goes more in depth on how to manipulate fuel drops for the helicopters in areas 3 and 4. The RAM-addresses used here are listed in the memory address section.

Some background about object allocation in the RAM

All objects that aren't part of the background are allocated to RAM-address $500 and onwards (player 1 is always in $4FE and player 2 is always in $4FF, but they can be disregarded here since they don't interfere with the foreign objects). This includes enemies, destroyable structures, hidden items, mines etc and even bullets. These addresses are referred to as "object addresses". The object address with index 0 corresponds to $500, index 1 corresponds to $501 etc. A new object entering the screen will be allocated to the lowest available index. If two objects enter the screen at the same frame, the object to the left will first be attributed the object address and will therefore always have the lower index. When an object leaves the screen (regardless of how), the corresponding index will be restored to null. Dropped objects will retain the address of the initial object though. Bullets are also an exception as they will be allocated to an index further down (without interest for the topics of this page).

Different objects provide different values to the object addresses. Some objects share the same value, so there must be additional addresses that determine the exact type of object. However, these values aren't overly important to know, but are helpful when analyzing emulator movie files. Below are some common values (but the list is nowhere near complete):

Object address value Description
(128) Player moving forward
(120) Player in tank/heli
(64) Rail turret, drops, mine
(63) Exploding rail turret
(62) Soldier, heli, blinking object
(61) Dying soldier, exploding barrel
(58) Returning soldier, missile target plate
(54) Guardian soldier
(53) Dying soldier (alternating with 75)
(50) Missile target plate with incoming airstrike
(45) Dying kamikaze (alternating with 83)
2 Helicopter/tank in use
64 Unrevealed mine
66 Object not on screen (includes unrevealed hidden items and destroyable structures with drops)
75 Dying soldier (alternating with -53)
83 Dying kamikaze (alternating with -53)

The type of drop is determined by the value of the object's "drop address". The drop addresses start with $0676. When the object leaves the screen, the drop address isn't reset to null, like the object address. When an object is allocated to an object address, its "drop address" can be overwritten with the object's corresponding drop value. This drop value is overwritten for most objects (including many objects that don't drop anything), but for example blue soldiers don't overwrite the drop values. The only drop value of interest is 20, which means fuel will be dropped.

Area 3 fuel drop

This section will explain how to increase the chances of getting a fuel drop from the first tank in the helicopter section.

The tank drops in this game are determined by the index the tank is allocated to. If the tank is in index 0 (= $500), it will drop a tank and if it's in index 2 (= $502), it will drop a fuel. All other index will result in no drop. The goal of this manipulation is therefore to maximize the chances of the tank spawning in index 2. This can be broken down in two parts. One part leading up to the fuel drop and one part ensuring the helicopter isn't blocking the relevant index. It's easiest to understand the route by starting with the fuel drop itself and then retracing the steps while trying to keep the drop conditions.

Part 2 - getting the tank in index 2

Ikari Warriors (U)-3 fuel manip.JPG

With reference to the numbering in the screenshot above, we can see that the tank will be allocated to index 2 if, and only if, index 0 and 1 are unoccupied when #1 and #2 appear on screen. This is only true if #3-#5 get index >2 and the objects occupying index 0-2 at that point disappear before the mines appear. There are 4 enemies (the three in #6 + one underwater enemy not shown in the screenshot) and #7 that are always present and can help achieve this condition. If index 0-2 are occupied among these 5 objects and they despawn between the gates and the mines, the tank will get index 2. #7 will disappear after #3-#5 have spawned, but before #1 and #2, so that's never an issue. Fortunately, the four enemies can also be taken out so they despawn according to this condition.

File:Ikari Warriors (U)-3 fuel manip.zip
The fm2-movie in the file above shows a successful fuel drop. The lua script (in the format [object value, index], while following the x-position of the object on screen) and the wch-file both contain the object addresses to make it easier to follow the address allocations. Other than illustrating the description above, it's also worth mentioning the role of #8. If the knife gets an index in the range 0 to 2 (which is not feasible to know in real-time) and is not collected, the leftmost gate (#3) will inherit its index, which means the fuel drop will not be possible. If it's collected, one of the enemy soldiers will inherit its index. #8 should therefore always be collected, no matter what.

File:Ikari Warriors (U)-3 fuel fail.zip
This fm2-movie illustrates some of the things that can go wrong and prevent the fuel drop. Assuming the execution was correct, there are three types of occurrences that will cause problems:

  1. There is a fifth enemy soldier around #6 in the screenshot above.
  2. The underwater kamikaze that comes from the left side and starts following you.
  3. An enemy soldier is running on the right and manages to stay on screen until the group in #6 spawns.

The first case is not possible to work around. All you can do is hope that it didn't get one of the lower index (but they often do since they tend to spawn earlier than the group in #6).
The second case is shown in this movie, but the threat is avoided by barely managing to scroll it off screen before the group at #6 spawned. This enemy doesn't always appear because of sprite limitation, which is an advantage. However, if you collect the heart (like shown in this movie), an index will be released, which increases the chances of spawning this enemy. Avoiding the heart will also result in a more direct route and if this enemy still spawns, it will be scrolled off screen faster. For safety, it's therefore better to leave this heart alone.
It's case 3 that was the root cause in this case. Despite being hit, the enemy's dying animation lasted long enough for it to occupy index 0 when the enemies at #6 spawned. This could have been mitigated by pausing before #6 appeared, but that would also have meant that the underwater enemy probably wouldn't have been pushed off screen. Pausing also increases the risk of more spawns in front of you, which is dangerous in this section. Overall, a difficult situation to deal with.

By following the route and suggestions above, the tank will drop fuel very roughly three times out of four.

Part 1 - index of the helicopter

In the part 2 above, nothing has been mentioned about the index of the helicopter itself. The helicopter is treated like any other object and will be dealt an object address according to the same rules. This means that if the helicopter has index 0, 1 or 2, it will be virtually impossible to get a fuel drop later on. This section will describe how to manipulate the helicopter into a higher index.

Let's start by looking at the map of the section in question with all items shown:
Ikari1-3 heli area.jpg

The objects down to the topmost barrel will be on screen when the helicopter appears. So there are 5 non-moving objects that can potentially help keeping the helicopter out of index 0-2. However, there are also blue soldiers creating some randomness by spawning between the barrel section and the helicopter. So the threat comes from either a blue soldier or one of the lower barrels leaving the screen right before the helicopter appears. The helicopter will then inherit a potentially low index. The only realistic variation in terms of routing comes in the barrel section. You can either go to the left, which is faster, or to the right (going straight ahead is not a good option on foot). Let's look at both options.

Left side of the barrel section
The following fm2-movie shows the route through the left side of the barrel section:
File:Ikari Warriors (U)-3 Heli address fail.zip
Similar to the movies above, a lua and a wch-file have been included to make it easier to follow the objects' index. As can be seen from the movie name, it shows a case where the helicopter was allocated to an index in the range 0-2, which will prevent the fuel drop later on. To understand why this happens, let's take a look at the map again, but this time with arrows showing how the index are transferred from one object to the next:
Ikari1-3 heli address fail.jpg

As a first step, we can see that there are roughly three transfer phases. The first phase (green arrows), where unknown index are transferred to the objects around the gate. The second phase (red arrows), where the gate object index are transferred to the barrels. The third and final phase (yellow arrows), where the barrel index are transferred into the objects leading up to the helicopter. Numbers in yellow indicate the number of frames between the two connected objects disappear/appear. If a blue soldier is spawned (rng) in the meantime, it will inherit the index instead. As a general rule, the more arrows and the longer chain leading up to an object, the more likely it is to contain a low index.

In phase one (green arrows), we see that #4 and #5 are likely to inherit low index. Depending on when the red soldier leaves the screen, either #6 or the triple shot will inherit its value.

In phase two (red arrows), it's difficult to imagine a case where the left barrel in #2 will have an index higher than 2. There are a few more barrels that are likely to have a low index, but not to the same extent as #2.

In phase three (yellow arrows), we can see the issue with this route. #2 leaves the screen some 24 or so frames before the helicopter appears. If no blue soldier appears in the meantime, it's more or less guaranteed that the helicopter will have an index in the range 0-2, which is what we wanted to prevent in the first place. I can be confirmed in the fm2-movie above that this is indeed what happened.

Right side of the barrel section

Area 4 fuel drop

Personal tools