Phobos icon indicating copy to clipboard operation
Phobos copied to clipboard

Conditional Jumps for changing the current Team script flow

Open FS-21 opened this issue 3 years ago • 5 comments

New script actions 134 to 146. They are capable to change the current script Action flow.

More information in the documentation.

FS-21 avatar Apr 17 '22 15:04 FS-21

Nightly build for this pull request:

github-actions[bot] avatar Apr 17 '22 15:04 github-actions[bot]

Default values for conditional jumps are:

- Disabled kills counter
- Disabled Action abortion after killing the Team targets.
- Index used for Houses, etc: An invalid ingeter
- Comparator value: 1
- Comparator mode: 3 (translated as ">=" )

If you want to use different values you have to use the right script actions for modifying the values.

Some possible test examples:

[AITargetTypes] ; this for the first example
0=ZEP,DISK,MIND,APOC,BFRT,TELE

; Each 100 in-game seconds checks if there are ">= 5" objects listed in the first line of [AITargetTypes]
[B9999999-G]
0=138,0  ; Point to the first list in [AITargetTypes]
1=137,5  ; Set comparator value to 5
2=71,100 ; Put the Task force in Area Guard for 100 seconds
3=146,0  ; Check if there are "5" (or more) objects from the selected list
4=141,7  ; If the Conditional Jump evaluation ( in line "3=146,0" ) was true go to line 7 ( is the line "6=74,1" )
5=6,3    ; (else case) jump to line 3 ( is the line "2=71,100" )
6=74,1   ; Attack anything (only executed if the conditional jump was "true")
; Change script flow if the Team killed 2 or more targets
[B9999999-G]
0=142,0  ; Enable Kills counter
1=137,2  ; Set comparator value to 2
2=134,1  ; Interrumpt current Action and jump to next Action if Team registered a kill
3=74,5   ; Attack vehicles
4=145,0  ; Check if the team killed "2" (or more) targets
5=141,7  ; If the Conditional Jump evaluation ( in line "4=145,0" ) was true go to line 8 ( is the line "7=74,2" )
6=6,3    ; (else case) jump to line 3 ( is the line "2=134,1" )
7=74,2   ; Attack structures (only executed if the conditional jump was "true")
; Change sript flow if the most rich House has more than 20000 credits
[B9999999-G]
0=136,4      ; Set the comparator ">"
1=137,20000  ; Set comparator value to 20000
2=138,-3     ; Set the option: search the richest House
3=71,100     ; Put the Task force in Area Guard for 100 seconds
4=146,0      ; Check if selected house has more than "20000" credits
5=141,7      ; If the Conditional Jump evaluation ( in line "4=146,0" ) was true go to line 8 ( is the line "7=74,1" )
6=6,4        ; (else case) jump to line 4 ( is the line "3=71,100" )
7=74,2       ; Attack structures (only executed if the conditional jump was "true")
; Change sript flow if the enemy House with less energy has more than 500 of energy
[B9999999-G]
0=136,4      ; Set the comparator ">"
1=137,500    ; Set comparator value to 500
2=138,-6     ; Set the option: search the enemy House with less energy
3=71,100     ; Put the Task force in Area Guard for 100 seconds
4=144,0      ; Check if selected house has more than "20000" credits
5=141,7      ; If the Conditional Jump evaluation ( in line "4=144,0" ) was true go to line 8 ( is the line "7=74,1" )
6=6,4        ; (else case) jump to line 4 ( is the line "3=71,100" )
7=74,2       ; Attack structures (only executed if the conditional jump was "true")

FS-21 avatar Apr 18 '22 14:04 FS-21

I don't want to make this PR as big as the old Attack/Move PRs but I consider this new Action "basic" of you want limit script loops.

Conditional Jump Action 147: Check Simple Count

  • Increases or decreases the Conditional Jump counter with the specified value by the Action argument and saves the comparison result for the Conditional Jump evaluation.
  • The Count can be reseted using the Script Action 135.

FS-21 avatar Apr 20 '22 15:04 FS-21

Added Action 148: "Manage Variables Reset If The Jump Is Successful"

By default the Conditional Jump variables are cleaned after a successful jump. This Action 148 enables the ability to retain variables values after the jump. This Action behavior isn't modified by the Action 139 "Reset Variables" or by the successful jump, only by this Action 148.

FS-21 avatar Apr 21 '22 21:04 FS-21

I removed the old (and complex) script actions for checking Economy and House energy and replaced it by other 2 actions and I believe that are more useful for a first Conditional jump pack of script actions.

Those removed actions will come later in a future PR.

FS-21 avatar May 17 '22 17:05 FS-21

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

github-actions[bot] avatar Jul 22 '23 12:07 github-actions[bot]

Closing because I start again in PR #1172 and made some fixes.

FS-21 avatar Oct 12 '23 12:10 FS-21