I was in need of a code that allowed me to check whether a unit is being rescued or not.
It should be formatted to work with SETVAL conditions, as you can see in this topic:
So, working with memory slots 1 and C, like it was already done in the past for other checks.
_SETVAL 0x1 0x1 // writes 0x1 at memory slot 0x1
ASMC offset // the ASM should do the check and write to slot 0xC
_SETCONDITION 0x1 0xC 0x0 // compares the value stored in 0x1 and 0xC
(insert events that play if the comparison results in a "true")
(insert events that play if the comparison results in a "false")
So the ASM does the check and returns 0 or 1 to memory slot 0xC depending on the result, and then the events compare what is in slot 0x1 and in 0xC.
Paste this somewhere word-aligned and call it with an ASMC. It will search all Player and NPC units for a character of the given ID, and check if that character is being rescued. To use it:
SETVAL 0x1 CharID // Character ID to check is being rescued
IFNOTEQUAL 0x0 0xC 0x0 // Compares the value stored in 0x0 and 0xC
(Events that occur if the unit is being rescued)
(Events that occur if the comparison results in a False)
Since slot 0x0 is always zero, we can just compare with that instead of setting some other slot to a value.