Bits: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 8: Line 8:
  andvar temp 0xF
  andvar temp 0xF
  switch temp
  switch temp
     case 1:
     case 1
         //"1" pressed
         //"1" pressed
         break
         break
     case 2:
     case 2
         //"2" pressed
         //"2" pressed
         break
         break
     //etc.
     //etc.
     case 10:
     case 10
         //"0" pressed
         //"0" pressed
         break
         break
     case 11:
     case 11
         //previous weapon
         //previous weapon
         break
         break
     case 12:
     case 12
         //next weapon
         //next weapon
         break
         break

Revision as of 00:38, 10 January 2012

'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.

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

Bit values for standard keys:

define INPUT_JUMP                      1
define INPUT_CROUCH                    2
define INPUT_FIRE                      4
define INPUT_AIM_UP                    8
define INPUT_AIM_DOWN                 16
define INPUT_RUNNING                  32
define INPUT_LOOK_LEFT                64
define INPUT_LOOK_RIGHT              128
define INPUT_WEAPON_1                256
define INPUT_WEAPON_2                512
define INPUT_WEAPON_3                768
define INPUT_WEAPON_4               1024
define INPUT_WEAPON_5               1280
define INPUT_WEAPON_6               1536
define INPUT_WEAPON_7               1792
define INPUT_WEAPON_8               2048
define INPUT_WEAPON_9               2304
define INPUT_WEAPON_10              2560
define INPUT_WEAPON_PREV            2816
define INPUT_WEAPON_NEXT            3072
define INPUT_STEROIDS               4096
define INPUT_LOOK_UP                8192
define INPUT_LOOK_DOWN             16384
define INPUT_NIGHTVISION           32768
define INPUT_MEDKIT                65536
define INPUT_RESERVED             131072
define INPUT_CENTER_VIEW          262144
define INPUT_HOLSTER_WEAPON       524288
define INPUT_INVENTORY_LEFT      1048576
define INPUT_PAUSE               2097152
define INPUT_QUICK_KICK          4194304
define INPUT_AIM_MODE            8388608
define INPUT_HOLODUKE           16777216
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