You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If elseif support is added first, then switch support could be derived from that.
Otherwise switch support could be added using opcodes 0871 and 0872 (only support integers, though). GTA3Script already has nested switch support using opcodes 0871 and 0872.
switch 0@
case 1
[...]
end
case "2"
[...]
end
case Actor.IsDead()
[...]
case 0x4
[...]
end
default
[...]
end
end
TO COMPILE AND DECOMPILE ⬇
:LABEL_1X // begin SWITH
XXXX: if
XXXX: 0@ == 1 // CASE 1
XXXX: jf @LABEL_2X
[...]
XXXX: goto @LABEL_7 // exit SWITH
:LABEL_2X
XXXX: if
XXXX: 0@ == "2" // CASE 2
XXXX: jf @LABEL_3X
[...]
XXXX: goto @LABEL_7 // exit SWITH
:LABEL_3X
XXXX: if
XXXX: actor 0@ is_dead // CASE 3
XXXX: jf @LABEL_5X
[...]
:LABEL_4X
XXXX: if
XXXX: 0@ == 0x4 // CASE 4
XXXX: jf @LABEL_5X
[...]
XXXX: goto @LABEL_7X // exit SWITH
:LABEL_5X
[...] // DEFAULT
XXXX: goto @LABEL_7X
:LABEL_7X // end SWITH
It is best for SA to give priority to 0871 and 0872.
Conditional opcodes need to be distinguished,
But the latter is more suitable for VC and 3. Because VC and 3 do not have these commands
0871 & 0872 could be used in the case that the SWITCH only contains INTERGERS and if it is also the same as the one with which it is compared.
You couldn't tell if one number is greater than another or something else :(
0871 & 0872 could be used in the case that the SWITCH only contains INTERGERS and if it is also the same as the one with which it is compared.
You couldn't tell if one number is greater than another or something else :(
It looks more like "expressions (mapping)" than a classic "switch". However, design compatibility across all games would be a priority for me over a limited case jump table.
Two examples of the switch construct as used in the original source file, Girls.sc - the 2nd example includes a default_jump [true] for when no cases match the key variable:
/********************************************
GET CURRENT GIRLFRIEND ORIGIN XYZ & HEADING
********************************************/
GF_Dating_Agent_GetOrigin_X_Y_Z_H:
SWITCH iGFidx
CASE COOCHIE
fOriginX = 2401.9646
fOriginY = -1723.2197
fOriginZ = 12.6005
fOriginH = 180.0
BREAK
CASE MICHELLE
fOriginX = -1799.5
fOriginY = 1195.5
fOriginZ = 24.1094
fOriginH = 180.0
BREAK
CASE KYLIE
fOriginX = -377.3978 //-398.5166 89.8377
fOriginY = -1438.6919 //-1426.4675
fOriginZ = 24.7209 //24.7110
fOriginH = 270.0 //90.0
BREAK
CASE BARBARA
fOriginX = -1398.1010
fOriginY = 2636.8730
fOriginZ = 54.7031
fOriginH = 75.0
BREAK
CASE KATIE
fOriginX = -2576.8079
fOriginY = 1144.7438
fOriginZ = 54.7422
fOriginH = 164.0
BREAK
CASE MILLIE
fOriginX = 2035.3619
fOriginY = 2732.4106
fOriginZ = 9.8203
fOriginH = 0.0
BREAK
ENDSWITCH
RETURN
/********************************************
GET GF MEETING ORIGIN XYZ & HEADING
********************************************/
GF_Dating_Agent_GetMeetingOrigin_X_Y_Z_H:
SWITCH iGFidx
CASE MICHELLE
fOriginX = -2027.5835
fOriginY = -118.7022
fOriginZ = 1034.0
fOriginH = 3.4
BREAK
CASE KYLIE
fOriginX = 257.6682
fOriginY = -154.7475
fOriginZ = 4.0786
fOriginH = 268.7731
BREAK
CASE BARBARA
fOriginX = -1410.0997
fOriginY = 2648.7307
fOriginZ = 54.6875
fOriginH = 130.0
BREAK
CASE KATIE // commented the co-ords inside the gym, temporarily set her in a park nearby
fOriginX = -2291.7075 //762.9347
fOriginY = -233.0215 //-23.3127
fOriginZ = 41.7185 //999.5938
fOriginH = 360.0 //360.0
BREAK
DEFAULT
fOriginX = 0.0
fOriginY = 0.0
fOriginZ = 0.0
fOriginH = 0.0
BREAK
ENDSWITCH
RETURN
// switch on int value
switch 0@
case 1, 2, 3
// do something if 0@ == 1 or 2 or 3
case 5
// do something if 0@ == 5
default // optional
// do something otherwise
end
// switch on string value
switch 0@v
case "foo"
// do something if 0@s == "foo"
case "bar"
// do something if 0@s == "bar"
end
Activity
MatiDragon-YT commentedon Jul 26, 2021
Maybe it is better with conditional jump opcodes
TO COMPILE AND DECOMPILE ⬇
MatiDragon-YT commentedon Jul 26, 2021
The same I think could be applied to ELSE-IF
TO COMPILE AND DECOMPILE ⬇
XMDS commentedon Jul 27, 2021
It is best for SA to give priority to 0871 and 0872.
Conditional opcodes need to be distinguished,
But the latter is more suitable for VC and 3. Because VC and 3 do not have these commands
MatiDragon-YT commentedon Jul 27, 2021
0871 & 0872 could be used in the case that the SWITCH only contains INTERGERS and if it is also the same as the one with which it is compared.
You couldn't tell if one number is greater than another or something else :(
wmysterio commentedon Jul 28, 2021
@MatiDragon-YT
It looks more like "expressions (mapping)" than a classic "switch". However, design compatibility across all games would be a priority for me over a limited case jump table.
MatiDragon-YT commentedon Jul 29, 2021
Exactly @wmysterio
OrionSR commentedon Sep 6, 2023
Two examples of the switch construct as used in the original source file, Girls.sc - the 2nd example includes a default_jump [true] for when no cases match the key variable:
x87 commentedon Nov 21, 2023
MiranDMC commentedon Jul 23, 2024
Switch is implemented. Any chance for
elif?