The event sheet is largely the same in overall structure, but we need to make some changes to accommodate the keyboard controls and changes to global variables.
The On Start of Layout event has gained a couple of extra actions along with the function mapping. We now need to also set the CurState variable to "PickAction" to allow for a battle turn to start, and set the text in the BattleText object to a simple opening line.
As we're now using a specific key to control most of the project, everything that relates to the Z key is nested in a single event:
Condition
Keyboard ▶︎ On Z Key pressed
BattleText ▶︎ Typewriter text "Welcome to the test. Use the Z key to start the battle. See if you can beat your opponent." over 2 seconds
Sub-event Condition
System ▶︎ CurState = "PlayerTurn"
OR
System ▶︎ CurState = "OppTurn"
Sub-event Condition
System ▶︎ NextState = "PlayerTurn"
Sub-event Action
Function ▶︎ Call PlayerAttack
Sub-event Condition
System ▶︎ NextState = "OppTurn"
Sub-event Action
Function ▶︎ Call OppAttack
Sub-event Condition
System ▶︎ NextState = "EndTurn"
Sub-event Action
Function ▶︎ Call EndTurn
A second sub-event under the Z key level then handles the text progression events:
Sub-event Condition
System ▶︎ CurState = "PickAction"
Sub-event Action
Function ▶︎ Call TurnStart
The typewriter text is how we control when the player can advance the text and therefore the battle turn. As a part of that, the Continue sprite acts as a visual cue for when they can press the Z key and progress. This is managed by a single event:
Condition
BattleText ▶︎ On typewriter text finished
Action
Continue ▶︎ Set visibility to Visible
The typewriter text is also used as a condition to check when to call the EndTurn function. When NextState is "EndTurn" then the function is only called if the typewriter text has finished:
Condition
System ▶︎ NextState = "EndTurn"
BattleText ▶︎ On typewriter text finished
Action
System ▶︎ CurState = "EndTurn"
Function ▶︎ Call EndTurn