Welcome, Guest! Login | Register

Fix MP Grenade Auto-Switching [Print this Article]
Posted by: trepid_jon
Date posted: Jan 19 2005
User Rating: 3 out of 5.0
Number of views: 4332
Number of comments: 3
Description: A basic fix for stopping the grenade from auto-switching to the next best weapon after you throw one. Also allows more than one grenade to be thrown.
I've never written an article here on Wavelength, so I figured I'd start with something very basic. I noticed some people here and there have been asking how to fix this "bug" with the grenade, so I figured I'd give a little snippet on how I fixed it for my test mod a week or so ago.

Open weapon_basesdkgrenade.cpp, and go to void CBaseSDKGrenade::ItemPostFrame().

Look for this...
 CODE  
            else
            {
                pPlayer->SwitchToNextBestWeapon( this );
            }


And change that to this...
 CODE  
            else
            {
                //pPlayer->SwitchToNextBestWeapon( this );
                m_bRedraw = false;
            }


That's pretty much all there is to it. Like I said, it's very simple. I feel dirty or something for making my first article something that's so incredibly simple, but I guess that's why it's in the snippets section.

Now just change the grenade so it isn't the CS grenade, and you'll earn bonus points for the contest. Wait, what?

Rate This Article
This article is currently rated: 3 out of 5.0 (1 Votes)

You have to register to rate this article.
User Comments Showing comments 1-3

Posted By: the_hat on Feb 03 2005 at 21:46:34
works, not great, needs more. but thanks none the less :)

Posted By: EucalyptuZ on Feb 23 2005 at 16:27:52
thats right the_hat...
and here is how i fixed it:

replase this:

CODE

else
{
//pPlayer->SwitchToNextBestWeapon( this );
m_bRedraw = false;
}

with this...

CODE

else
{
//pPlayer->SwitchToNextBestWeapon( this );
m_bRedraw = false;
m_flNextPrimaryAttack = gpGlobals->curtime + 0.5;
SendWeaponAnim( ACT_VM_DRAW );
}

And if your 2nd granade dosent trow then replase this:

CODE

void CBaseSDKGrenade::StartGrenadeThrow()
{
m_fThrowTime = gpGlobals->curtime + 0.0f;
}

with this:

CODE

void CBaseSDKGrenade::StartGrenadeThrow()
{
m_fThrowTime = gpGlobals->curtime + 0.5f; // Modifyed AND fixed from 0.0f
}

That should do it :)

btw thx for the idea trepid_jon ;)

Posted By: trepid_jon on Mar 11 2005 at 01:00:30
Oh, very cool additions. That way your grenade draw animation will play, like you pull another grenade out, right? Cool, man.


You must register to post a comment. If you have already registered, you must login.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 05 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
knock knock
General | News
By: omega | Dec 22 2016
 
knock knock
General | News
By: MIFUNE | Oct 10 2015
 
New HL HUD Message System
Half-Life | Coding | Shared Tutorials
By: chbrules | Dec 31 2011
 
knock knock
General | News
By: Whistler | Nov 05 2011
 
Particle Engine tutorial part 4
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 18 2010
 
Particle Engine tutorial part 2
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Particle Engine tutorial part 3
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Game Movement Series #2: Analog Jumping and Floating
Half-Life 2 | Coding | Shared Tutorials
By: mars3554 | Oct 26 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Deadpool | Aug 02 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Persuter | Aug 02 2009
 

Site Info
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (3 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!