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: 2003
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 15:46:34
works, not great, needs more. but thanks none the less :)

Posted By: EucalyptuZ on Feb 23 2005 at 10: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 10 2005 at 19: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 04 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
Spinning Corpses Simple Fix
Half-Life | Coding | Snippets
By: darkPhoenix | Sep 05 2008
 
Where do we go from here
General | News
By: MIFUNE | Jun 09 2008
 
The Input/Output system
Half-Life 2 | Level Design
By: nazitaco | Dec 23 2007
 
Where do we go from here
General | News
By: Rob_F | Nov 22 2007
 
Rescaling Half-Life
Half-Life | Coding | Shared Tutorials
By: christoph | Nov 12 2007
 
GameUI
Half-Life 2 | Coding | Client Side Tutorials
By: Evil_j | Oct 29 2007
 
3 State Zoom For Any Weapon
Half-Life 2 | Coding | Server Side Tutorials
By: Ennuified | Oct 18 2007
 
Storing weapons on ladder
Half-Life 2 | Coding | Snippets
By: cct | Sep 07 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: DarkNight | Aug 28 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: deedok | Aug 20 2007
 

Site Info
296 Approved Articless
5 Pending Articles
3940 Registered Members
0 People Online (14 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!