What is the jump table? Jump table is analogue arrays.
The jumptable manages a selection for jump commands to one of much labels
the first entry is the variable to select a jump command.
The jump table starts with 0871: the max entry's for that is 7,
if more entry's are needed you can expand the limit of the table using 0872: max for that is 9, if you need even more, then you can expand it again with that opcode.
If you do not even wanna use 7, say you wanna use 4, you mark the other 3 using(0xFFFFFFFF) or -1 before the label, do this for ones which you do not wanna use.
Here is an example of that:
Here is an example of expanding a jump table:
The jump after each table bit, makes it so the script does not just go on to the next. There is a limit for the labels of a jump table, that limit is 75
A jump table is mostly used for random spawn places, and things like this, however, they can be used for different things.
The default jump:
You can set this to the first jump table entry label, it's more easy to understand if you do it that way.
Some find the jump table hard to understand, they find this method more easy, for example:
The jumptable manages a selection for jump commands to one of much labels
the first entry is the variable to select a jump command.
The jump table starts with 0871: the max entry's for that is 7,
if more entry's are needed you can expand the limit of the table using 0872: max for that is 9, if you need even more, then you can expand it again with that opcode.
If you do not even wanna use 7, say you wanna use 4, you mark the other 3 using(0xFFFFFFFF) or -1 before the label, do this for ones which you do not wanna use.
Here is an example of that:
- Code:
0209: 3@ = random_int_in_ranges 0 4
0871: init_jump_table 3@ total_jumps 4 default_jump 0 @T_01 jumps 0 @T_01 1 @T_02 2 @T_03 3 @T_04 0xFFFFFFFF @T_04 0xFFFFFFFF @T_04 0xFFFFFFFF @T_04
:T_01
// Do something
0002: jump @End_jump_table
:T_02
// Do something
0002: jump @End_jump_table
:T_03
// Do something
0002: jump @End_jump_table
:T_04
// Do something
:End_jump_table
// Something
Here is an example of expanding a jump table:
- Code:
0209: 3@ = random_int_in_ranges 0 16
0871: init_jump_table 3@ total_jumps 16 default_jump 0 @T_01 jumps 0 @T_01 1 @T_02 2 @T_03 3 @T_04 4 @T_05 5 @T_06 6 @T_07
0872: jump_table_jumps 7 @T_08 8 @T_09 9 @T_10 10 @T_11 11 @T_12 12 @T_13 13 @T_14 14 @T_15 15 @T_16
:T_01
// Do something
0002: jump @End_jump_table
:T_02
// Do something
0002: jump @End_jump_table
:T_03
// Do something
0002: jump @End_jump_table
:T_04
// Do something
0002: jump @End_jump_table
:T_05
// Do something
0002: jump @End_jump_table
:T_06
// Do something
0002: jump @End_jump_table
:T_07
// Do something
0002: jump @End_jump_table
:T_08
// Do something
0002: jump @End_jump_table
:T_09
// Do something
0002: jump @End_jump_table
:T_10
// Do something
0002: jump @End_jump_table
:T_11
// Do something
0002: jump @End_jump_table
:T_12
// Do something
0002: jump @End_jump_table
:T_13
// Do something
0002: jump @End_jump_table
:T_14
// Do something
0002: jump @End_jump_table
:T_15
// Do something
0002: jump @End_jump_table
:T_16
// Do something
:End_jump_table
// Something
The jump after each table bit, makes it so the script does not just go on to the next. There is a limit for the labels of a jump table, that limit is 75
A jump table is mostly used for random spawn places, and things like this, however, they can be used for different things.
The default jump:
- Code:
default_jump 0 @T_01
You can set this to the first jump table entry label, it's more easy to understand if you do it that way.
Some find the jump table hard to understand, they find this method more easy, for example:
- Code:
0209: 1@ = random_int_in_ranges 0 4
00d6: if
0039: 1@ == 0
004d: jump_if_false @_1_
// Do something
0002: jump @End
:_1_
00d6: if
0039: 1@ == 1
004d: jump_if_false @_2_
// Do something
0002: jump @End
:_2_
00d6: if
0039: 1@ == 2
004d: jump_if_false @_3_
// Do something
0002: jump @End
:_3_
//..etc
:End
//..........................