Modding => Event Editing => Topic started by: Xifanie on May 10, 2017, 03:06:01 pm
Title: Event Branching Tutorial
Post by: Xifanie on May 10, 2017, 03:06:01 pm
Today we'll tackle branches and jumps, but we will not really use those names as while they correctly describe what the instructions do, we'll look at each individual instruction one by one.
All of these instructions have one single parameter, which is a ForwardTarget ID or a BackTarget ID. Jumping Forward [indent=2] JumpForwardIfNot(xJF) (http://ffhacktics.com/wiki/Event_Instruction_D0) [indent=2] Jumps to ForwardTarget if Variable 0x0000 is equal to 0. Otherwise simply keeps advancing. Must be placed before ForwardTarget! [/indent] JumpForward(xJF) (http://ffhacktics.com/wiki/Event_Instruction_D1) [indent=2] Jumps to ForwardTarget. Must be placed before ForwardTarget! [/indent] ForwardTarget(xJF) (http://ffhacktics.com/wiki/Event_Instruction_D2) [indent=2] Target Destination of JumpForwardIfNot/JumpForward. Must be placed after JumpForwardIfNot/JumpForward! [/indent] [/indent] Jumping Backward [indent=2] JumpBack(xJB) (http://ffhacktics.com/wiki/Event_Instruction_D3) [indent=2] Jumps back to BackTarget. Must be placed after BackTarget! [/indent] BackTarget(xJB) (http://ffhacktics.com/wiki/Event_Instruction_D5) [indent=2] Target Destination of JumpBack. Must be placed before JumpBack! [/indent] [/indent]
Targets Forward Targets and Back Targets are essentially the same thing, but they are limited to their current subset of event instructions. Thus ForwardTarget 0x00 and BackTarget 0x00 use different memory allocations and are separate. Only a Forward Instruction can use a Forward Target, and only a Back Instruction can use a Back Target
A ForwardTarget may only be placed after a Forward Instruction, and can be reused. This means that you may use ForwardTarget 0x00 as often as you want with simple instructions.
A BackTarget may only be placed before a Back Instruction and cannot be reused.
Conditions [indent=2] EQ() (http://ffhacktics.com/wiki/Event_Instruction_A2) Equal [indent=2]Variable 0x0000 = If ( Variable 0x0000 == Variable 0x0001 ) [/indent] NEQ() (http://ffhacktics.com/wiki/Event_Instruction_A3) Not Equal [indent=2]Variable 0x0000 = If ( Variable 0x0000 != Variable 0x0001 ) [/indent] LT() (http://ffhacktics.com/wiki/Event_Instruction_A4) Less Than [indent=2]Variable 0x0000 = If ( Variable 0x0000 < Variable 0x0001 ) [/indent] GT() (http://ffhacktics.com/wiki/Event_Instruction_A5) Greater Than [indent=2]Variable 0x0000 = If ( Variable 0x0000 > Variable 0x0001 )[/indent] LTE() (http://ffhacktics.com/wiki/Event_Instruction_A0) Less Than or Equal [indent=2]Variable 0x0000 = If ( Variable 0x0000 <= Variable 0x0001 )[/indent] GTE() (http://ffhacktics.com/wiki/Event_Instruction_A1) Greater Than or Equal [indent=2]Variable 0x0000 = If ( Variable 0x0000 >= Variable 0x0001 ) [/indent] [/indent]
Examples: Note that in each of these examples, I used Target 0xFF to make it easier to remember where the end of the conditions section is. [indent=2] Player has at least 1 gold. (Aeris Flower Event)
//Set Variable 0x0000 to War Funds (Variable 0x002C) ZERO(x0000) ADDVar(x0000,x002C)
//Set Comparison Value to 0x0001 ZERO(x0001) ADD(x0001,x0001)
//Greater Than or Equal Comparison GTE() JumpForwardIfNot(x00)
//What Happens if the player has at least 1 gil
JumpForward(xFF) ForwardTarget(x00)
//ELSE (i.e. What happens if the player has 0 gil)
ForwardTarget(xFF)
//Resume the rest of the event
Dialogue Selection (3 options)
//Set Variable 0x0001 to the Selected Option in Dialog (0x0018) ZERO(x0001) ADDVar(x0001,x0018)
//Set Variable 0x0000 to Option #1 (0x0000) ZERO(x0000)
//Equal Comparison EQ() JumpForwardIfNot(x00)
//What happens if the first option was selected
JumpForward(xFF) ForwardTarget(x00) //Set Variable x0000 to Option #2 //Note that 0x0000 will be 0x0000 anyway because of EQ() returning false, so we don't have to ZERO the variable ADD(x0000,x0001)
//Equal Comparison EQ() JumpForwardIfNot(x01)
//What happens if the second option was selected
JumpForward(xFF) ForwardTarget(x01)
//ELSE (i.e. What happens if the third option was selected)
ForwardTarget(xFF)
//Resume the rest of the event
Page Selection (8 options)
//Set Variable 0x0001 to the Selected Option in Dialog (0x0018) ZERO(x0001) ADDVar(x0001,x0018)
//Set Variable 0x0000 to Option #1 (0x0000) ZERO(x0000)
//Equal Comparison EQ() JumpForwardIfNot(x00)
//What happens if the first option was selected
JumpForward(xFF) ForwardTarget(x00) //Set Variable x0000 to Option #2 //Note that 0x0000 will be 0x0000 anyway because of EQ() returning false, so we don't have to ZERO the variable ADD(x0000,x0001)
//Equal Comparison EQ() JumpForwardIfNot(x01)
//What happens if the second option was selected
JumpForward(xFF) ForwardTarget(x01) //Set Variable x0000 to Option #3 ADD(x0000,x0002)
//Equal Comparison EQ() JumpForwardIfNot(x02)
//What happens if the third option was selected
JumpForward(xFF) ForwardTarget(x02) //Set Variable x0000 to Option #4 ADD(x0000,x0003)