ff3:ff3us:tutorial:events:branch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ff3:ff3us:tutorial:events:branch [2018/05/06 17:24]
lockirby2 [Reading the Event Script Dump]
ff3:ff3us:tutorial:events:branch [2019/02/12 12:44] (current)
Line 8: Line 8:
   * To repeat part of an event many times (perhaps an infinite number of times).   * To repeat part of an event many times (perhaps an infinite number of times).
  
-===== Jumping to a Subroutine =====+==== Jumping to a Subroutine ====
  
 The simplest way to jump to another address is to use the B2 command.  Let's say that we want to jump to CA/4020.  Following the instructions in the Event Commands Document, we know to start by subtracting CA0000 from CA4020, giving us 00 40 20.  Then we need to reverse the order of the bytes.  The full command is B2 20 40 00.  You will need to follow this process many times when jumping or branching. The simplest way to jump to another address is to use the B2 command.  Let's say that we want to jump to CA/4020.  Following the instructions in the Event Commands Document, we know to start by subtracting CA0000 from CA4020, giving us 00 40 20.  Then we need to reverse the order of the bytes.  The full command is B2 20 40 00.  You will need to follow this process many times when jumping or branching.
Line 16: Line 16:
 By itself, this command allows us to reuse parts of the event script, as in the innkeeper example above.  It also lets us make use of extra space from expanding the ROM.  Do not use this command to infinitely repeat part of an event; if you jump to subroutines 255 times without returning, the game will crash. By itself, this command allows us to reuse parts of the event script, as in the innkeeper example above.  It also lets us make use of extra space from expanding the ROM.  Do not use this command to infinitely repeat part of an event; if you jump to subroutines 255 times without returning, the game will crash.
  
-===== Event Bits =====+==== Event Bits ====
  
 A way to branch based on certain conditions would also be very helpful.  For example, after the first set of guards (in vanilla) in Narshe is defeated, the player should not be able to encounter them again.  To accomplish this, the developers used an "event bit" Every event bit consists of a single value that is either 1 or 0.  At the beginning of the game, the event bits are all set to 0.  After you fight the first set of guards in Narshe, an event bit is changed to 1.  This is how the game remembers that you have fought this set of guards. A way to branch based on certain conditions would also be very helpful.  For example, after the first set of guards (in vanilla) in Narshe is defeated, the player should not be able to encounter them again.  To accomplish this, the developers used an "event bit" Every event bit consists of a single value that is either 1 or 0.  At the beginning of the game, the event bits are all set to 0.  After you fight the first set of guards in Narshe, an event bit is changed to 1.  This is how the game remembers that you have fought this set of guards.
Line 24: Line 24:
 If we use event bits correctly, the game can answer questions like "Has the party met Shadow yet?" or "Has the party defeated my optional superboss?" We have a lot more power than simply preventing a cutscene from repeating itself. If we use event bits correctly, the game can answer questions like "Has the party met Shadow yet?" or "Has the party defeated my optional superboss?" We have a lot more power than simply preventing a cutscene from repeating itself.
  
-===== Example =====+==== Example ====
  
 Right now, players can trigger our new Narshe guard cutscene infinitely many times, summoning as many guards as they please.  It's strange that Narshe has an endless supply of guards, and I think that players would be encouraged to grind guards early in the game.  Let's change the cutscene so that activating it a second time will not spawn more guards. Right now, players can trigger our new Narshe guard cutscene infinitely many times, summoning as many guards as they please.  It's strange that Narshe has an endless supply of guards, and I think that players would be encouraged to grind guards early in the game.  Let's change the cutscene so that activating it a second time will not spawn more guards.
Line 44: Line 44:
 Conveniently, the entire cutscene fits in the same space as the vanilla cutscene (the next cutscene start at CC/9B71, as shown by the Event Script Dump), so we don't have to jump to extra space to make everything fit.  If this was necessary, it could have been accomplished with the $B2 command. Conveniently, the entire cutscene fits in the same space as the vanilla cutscene (the next cutscene start at CC/9B71, as shown by the Event Script Dump), so we don't have to jump to extra space to make everything fit.  If this was necessary, it could have been accomplished with the $B2 command.
  
-===== Reading the Event Script Dump =====+==== Reading the Event Script Dump ====
 Event bits are represented in different ways depending on which document or tool you are using to view them.  In the Event Bits Document, each Event Bit is represented by a number between $000 and $2FF, as you have seen.  However, if you look in the Event Script Dump, you may see a line like the following (emphasis mine): Event bits are represented in different ways depending on which document or tool you are using to view them.  In the Event Bits Document, each Event Bit is represented by a number between $000 and $2FF, as you have seen.  However, if you look in the Event Script Dump, you may see a line like the following (emphasis mine):
  
Line 54: Line 54:
 You may have noticed that event bits higher than $2FF are not listed in the Event Bits Document, yet they are often set or cleared in the Event Script Dump.  These event bits are used to determine whether NPCs are immediately shown when you load a map.  For example, bit $31C controls whether Vargas appears on Mt. Kolts.  This bit is cleared after you fight him so that he is not shown if you return to the map.  You can view and modify which bit corresponds to a particular NPC in the LE.  Just select any NPC and look at the "SHOW IF MEM SET" field. You may have noticed that event bits higher than $2FF are not listed in the Event Bits Document, yet they are often set or cleared in the Event Script Dump.  These event bits are used to determine whether NPCs are immediately shown when you load a map.  For example, bit $31C controls whether Vargas appears on Mt. Kolts.  This bit is cleared after you fight him so that he is not shown if you return to the map.  You can view and modify which bit corresponds to a particular NPC in the LE.  Just select any NPC and look at the "SHOW IF MEM SET" field.
  
-{{:ff3:ff3us:tutorial:events:npc_show_if_mem_set.png|}}+{{ :ff3:ff3us:tutorial:events:npc_show_if_mem_set.png |}}
  
-You can cross reference this with the event dump by looking at the following part of the line:+You can cross reference this with the event dump by looking at the following part of lines like this:
  
 ''Set event bit $1E80($31C) [**__$1EE3, bit 4__**]'' ''Set event bit $1E80($31C) [**__$1EE3, bit 4__**]''
  
 In this way, you can tell that "$1EE3, bit 4" corresponds to event bit "$31C". In this way, you can tell that "$1EE3, bit 4" corresponds to event bit "$31C".
  • ff3/ff3us/tutorial/events/branch.1525627472.txt.gz
  • Last modified: 5 years ago
  • (external edit)