Jump to content

Home

How does g_weapondisable work ingame?


Lathain Valtiel

Recommended Posts

As Cohsty said, the g_weapondisable cvar contains a number which tells the game which weapons to disable. I haven't got JKA code in front of me so the numbers might not be right. If say, g_weapondisable = 24, in binary this is 11000. If the game wanted to check if the saber was enabled (for this example, the bitflag for saber can be 8, or 01000 in binary), you would do:

if ( g_weapondisable.integer & WP_SABER )......

The & is a bitwise AND operator like this:

 

110000

010000 &

010000

 

When there are two 1s in the same column, the answer is 1, otherwise its 0. The if statement checks the result in between the brackets if it's true/false. False = 0, true = anything else.

 

Hope that helps, and that you understood it :)

Link to comment
Share on other sites

Power of 2 is the correct way, not binary :p.

 

WP_NONE = 0

WP_STUN_BATON = 1

WP_MELEE = 2

WP_SABER = 3

WP_BRYAR_PISTOL = 4

WP_BLASTER = 5

WP_DISRUPTOR = 6

WP_BOWCASTER = 7

WP_REPEATER = 8

WP_DEMP2 = 9

WP_FLECHETTE = 10

WP_ROCKET_LAUNCHER = 11

WP_THERMAL = 12

WP_TRIP_MINE = 13

WP_DET_PACK = 14

WP_CONCUSSION = 15

WP_BRYAR_OLD = 16

WP_EMPLACED_GUN = 17

WP_TURRET = 18

WP_NUM_WEAPONS = 19

 

2^0 = 1

2^1 = 2

2^2 = 4

2^3 = 8

2^4 = 16

2^5 = 32

2^6 = 64

2^7 = 128

2^8 = 256

2^9 = 512

2^10 = 1024

2^11 = 2048

2^12 = 4096

2^13 = 8192

2^14 = 16384

2^15 = 32768

2^16 = 65536

2^17 = 131072

2^18 = 262144

2^19 = 524288

 

Also, checking is done by & (1 << WP_) not just & WP_

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...