Bits: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
New page: ''''''bits'''''' returns a bit-field indicating which buttons the player is pressing. A particular button press can be checked by using ifvarand with the following values: <pre> define...
 
Fox (talk | contribs)
No edit summary
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
''''''bits'''''' returns a bit-field indicating which buttons the player is pressing. A particular button press can be checked by using [[ifvarand]] with the following values:
''''''bits'''''' is a [[bitfield]] indicating which buttons the player is pressing. A particular button press can be checked by using [[ifvarand]] with the values listed at the end of this article.
<pre>
 
define INPUT_JUMP 1
INPUT_RESERVED will only display "!!! INCORRECT VERSION !!!" message.
define INPUT_CROUCH 2
 
define INPUT_FIRE 4
== Weapons ==
define INPUT_AIM_UP 8
 
define INPUT_AIM_DOWN 16
'''This technique does not work properly with the weapon selection keys''', however. They share four bits in the second-to-lowest byte, which represent the number of the corresponding weapon. They can be decoded as follows:
define INPUT_RUNNING 32
getinput[THISACTOR].bits temp
define INPUT_LOOK_LEFT 64
shiftvarr temp 8
define INPUT_LOOK_RIGHT 128
andvar temp 0xF
define INPUT_WEAPON_1 256
switch temp
define INPUT_WEAPON_2 512
    case 1
define INPUT_WEAPON_3 768
        //"1" pressed
define INPUT_WEAPON_4 1024
        break
define INPUT_WEAPON_5 1280
    case 2
define INPUT_WEAPON_6 1536
        //"2" pressed
define INPUT_WEAPON_7 1792
        break
define INPUT_WEAPON_8 2048
    //etc.
define INPUT_WEAPON_9 2304
    case 10
define INPUT_WEAPON_10 2560
        //"0" pressed
define INPUT_WEAPON_PREV 2816
        break
define INPUT_WEAPON_NEXT 3072
    case 11
define INPUT_STEROIDS 4096
        //previous weapon
define INPUT_LOOK_UP 8192
        break
define INPUT_LOOK_DOWN 16384
    case 12
define INPUT_NIGHTVISION 32768
        //next weapon
define INPUT_MEDKIT 65536
        break
define INPUT_RESERVED 131072
endswitch
define INPUT_CENTER_VIEW 262144
 
define INPUT_HOLSTER_WEAPON 524288
== Flags ==
define INPUT_INVENTORY_LEFT 1048576
 
define INPUT_PAUSE 2097152
{{Bits}}
define INPUT_QUICK_KICK 4194304
 
define INPUT_AIM_MODE 8388608
[[Category:Bitfields]]
define INPUT_HOLODUKE 16777216
[[Category:Input structure members]]
define INPUT_JETPACK 33554432
define INPUT_QUIT 67108864
define INPUT_INVENTORY_RIGHT 134217728
define INPUT_TURN_AROUND 268435456
define INPUT_OPEN 536870912
define INPUT_INVENTORY 1073741824
define INPUT_ESC 2147483648
</pre>

Latest revision as of 16:44, 20 February 2020

'bits' is a bitfield indicating which buttons the player is pressing. A particular button press can be checked by using ifvarand with the values listed at the end of this article.

INPUT_RESERVED will only display "!!! INCORRECT VERSION !!!" message.

Weapons

This technique does not work properly with the weapon selection keys, however. They share four bits in the second-to-lowest byte, which represent the number of the corresponding weapon. They can be decoded as follows:

getinput[THISACTOR].bits temp
shiftvarr temp 8
andvar temp 0xF
switch temp
    case 1
        //"1" pressed
        break
    case 2
        //"2" pressed
        break
    //etc.
    case 10
        //"0" pressed
        break
    case 11
        //previous weapon
        break
    case 12
        //next weapon
        break
endswitch

Flags

The following values are used with bits.

WARNING: All weapon bits operate on non-power-of-two!

Exposed Value Label Description
No 1 INPUT_JUMP
No 2 INPUT_CROUCH
No 4 INPUT_FIRE
No 8 INPUT_AIM_UP
No 16 INPUT_AIM_DOWN
No 32 INPUT_RUNNING
No 64 INPUT_LOOK_LEFT
No 128 INPUT_LOOK_RIGHT
No 256 INPUT_WEAPON_1
No 512 INPUT_WEAPON_2
No 768 INPUT_WEAPON_3 NPOT
No 1024 INPUT_WEAPON_4
No 1280 INPUT_WEAPON_5 NPOT
No 1536 INPUT_WEAPON_6 NPOT
No 1792 INPUT_WEAPON_7 NPOT
No 2048 INPUT_WEAPON_8
No 2304 INPUT_WEAPON_9 NPOT
No 2560 INPUT_WEAPON_10 NPOT
No 2816 INPUT_WEAPON_PREV NPOT
No 3072 INPUT_WEAPON_NEXT NPOT
No 3328 INPUT_ALT_WEAPON Note: NPOT. Not defined as a macro in the source.
No 3584 INPUT_LAST_WEAPON Note: NPOT. Not defined as a macro in the source.
No 4096 INPUT_STEROIDS
No 8192 INPUT_LOOK_UP
No 16384 INPUT_LOOK_DOWN
No 32768 INPUT_NIGHTVISION
No 65536 INPUT_MEDKIT
No 131072 INPUT_RESERVED
No 262144 INPUT_CENTER_VIEW
No 524288 INPUT_HOLSTER_WEAPON
No 1048576 INPUT_INVENTORY_LEFT
No 2097152 INPUT_PAUSE
No 4194304 INPUT_QUICK_KICK
No 8388608 INPUT_AIM_MODE
No 16777216 INPUT_HOLODUKE
No 33554432 INPUT_JETPACK
No 67108864 INPUT_QUIT
No 134217728 INPUT_INVENTORY_RIGHT
No 268435456 INPUT_TURN_AROUND
No 536870912 INPUT_OPEN
No 1073741824 INPUT_INVENTORY
No 2147483648 INPUT_ESC


Defines
define INPUT_JUMP                       0x00000001
define INPUT_CROUCH                     0x00000002
define INPUT_FIRE                       0x00000004
define INPUT_AIM_UP                     0x00000008
define INPUT_AIM_DOWN                   0x00000010
define INPUT_RUNNING                    0x00000020
define INPUT_LOOK_LEFT                  0x00000040
define INPUT_LOOK_RIGHT                 0x00000080
define INPUT_WEAPON_1                   0x00000100
define INPUT_WEAPON_2                   0x00000200
define INPUT_WEAPON_3                   0x00000300
define INPUT_WEAPON_4                   0x00000400
define INPUT_WEAPON_5                   0x00000500
define INPUT_WEAPON_6                   0x00000600
define INPUT_WEAPON_7                   0x00000700
define INPUT_WEAPON_8                   0x00000800
define INPUT_WEAPON_9                   0x00000900
define INPUT_WEAPON_10                  0x00000A00
define INPUT_WEAPON_PREV                0x00000B00
define INPUT_WEAPON_NEXT                0x00000C00
define INPUT_ALT_WEAPON                 0x00000D00
define INPUT_LAST_WEAPON                0x00000E00
define INPUT_STEROIDS                   0x00001000
define INPUT_LOOK_UP                    0x00002000
define INPUT_LOOK_DOWN                  0x00004000
define INPUT_NIGHTVISION                0x00008000
define INPUT_MEDKIT                     0x00010000
define INPUT_RESERVED                   0x00020000
define INPUT_CENTER_VIEW                0x00040000
define INPUT_HOLSTER_WEAPON             0x00080000
define INPUT_INVENTORY_LEFT             0x00100000
define INPUT_PAUSE                      0x00200000
define INPUT_QUICK_KICK                 0x00400000
define INPUT_AIM_MODE                   0x00800000
define INPUT_HOLODUKE                   0x01000000
define INPUT_JETPACK                    0x02000000
define INPUT_QUIT                       0x04000000
define INPUT_INVENTORY_RIGHT            0x08000000
define INPUT_TURN_AROUND                0x10000000
define INPUT_OPEN                       0x20000000
define INPUT_INVENTORY                  0x40000000
define INPUT_ESC                        0x80000000