lfnetwork.com mark read register faq members calendar

Thread: How does g_weapondisable work ingame?
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 11-17-2007, 11:58 PM   #1
Lathain Valtiel
Ex-Angel
 
Lathain Valtiel's Avatar
 
Join Date: Jul 2002
Posts: 929
LFN Staff Member 
How does g_weapondisable work ingame?

I know how it is calculated, it's a power of two for each weapon... but how does the game check the result? Keep diving by 2 until there's no more weapons to disable, starting with the highest weapon on the list?


Kurgan's Meatgrinder (JA Server: 72.5.248.212:29070)

Player tested, Valtiel approved.

Valtiel approved downloads for Meatgrinder: http://strategy.jediknight.net/jka/downloads.shtml
Lathain Valtiel is offline   you may: quote & reply,
Old 11-18-2007, 01:11 AM   #2
Cohsty243
Rookie
 
Cohsty243's Avatar
 
Join Date: Apr 2007
Posts: 67
if im right lol..
Each weapon has its own bitflag.
i think it checks that if the g_weapondisable integer contains a bitflag assigned to a weapon then disable it/cannot be spawned.

ensi or razor can probably explain it better lol.
Cohsty243 is offline   you may: quote & reply,
Old 11-18-2007, 05:12 AM   #3
XycaleTh
Rookie
 
XycaleTh's Avatar
 
Join Date: Apr 2006
Location: UK
Posts: 67
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:
Code:
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
XycaleTh is offline   you may: quote & reply,
Old 11-18-2007, 02:27 PM   #4
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
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_


iojamp project lead / coder
ensiform is offline   you may: quote & reply,
Old 11-18-2007, 03:19 PM   #5
XycaleTh
Rookie
 
XycaleTh's Avatar
 
Join Date: Apr 2006
Location: UK
Posts: 67
It's pretty much the same thing :P
XycaleTh is offline   you may: quote & reply,
Old 11-18-2007, 11:28 PM   #6
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
Quote:
Originally Posted by XycaleTh
It's pretty much the same thing :P
No its not when the r-value of the & isn't already a 1 <<.


iojamp project lead / coder
ensiform is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > How does g_weapondisable work ingame?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:03 PM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.