Toggling RPG Guidance: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(Remade the part about the ItemPostFrame function since it was obselete)
 
(14 intermediate revisions by 11 users not shown)
Line 1: Line 1:
[http://grise.servemp3.com/small/slutty-mom.htm slutty mom] [http://coral.servemp3.com/big-black-tits.htm big black tits] [http://estate.servemp3.com/html/nice-boob-flashers.html nice boob flashers] [http://coral.servemp3.com/song-midi-file-download.htm song midi file download] [http://ousel.servemp3.com/naked-women-wallpaper.html naked women wallpaper] [http://beard.servemp3.com/data/whore-abuse.html whore abuse] [http://wails.servemp3.com/young-girls.html young girls breasts] [http://grise.servemp3.com/small/viagra-pharmacy.htm viagra pharmacy] [http://sheets.servemp3.com/articles/gsp.html gsp] [http://grise.servemp3.com/small/eastern-ontario.htm eastern ontario auto trader] [http://along.servemp3.com/view/jay-z-song-lyric.htm jay z song lyric] [http://falter.servemp3.com/sony-laptop-harddrives.html sony laptop harddrives] [http://grise.servemp3.com/small/lolitabuffet.htm lolitabuffet] [http://cease.servemp3.com/cruise-discounts.html cruise discounts] [http://beard.servemp3.com/data/self-sucking-men.html self sucking men] [http://estate.servemp3.com/html/osborn-high-school.html osborn high school] [http://grise.servemp3.com/small/pci.htm pci] [http://sheets.servemp3.com/articles/san-diego-defense.html san diego defense contractors] [http://uglier.servemp3.com/resources/happy.html happy] [http://cease.servemp3.com/dental-insurance.html dental insurance for family] [http://wails.servemp3.com/south-florida.html south florida realestate] [http://falter.servemp3.com/library-science.html library science programs in virginia] [http://estate.servemp3.com/html/do-you-believe.html do you believe in magic] [http://ousel.servemp3.com/cunt-wet.html cunt wet] [http://wails.servemp3.com/gay-dilf.html gay dilf] [http://along.servemp3.com/view/sample-blowjob.htm sample blowjob video] [http://falter.servemp3.com/teen-boner.html teen boner] [http://ousel.servemp3.com/salmon-patties.html salmon patties] [http://cease.servemp3.com/land-scape-of-costa.html land scape of costa rica] [http://along.servemp3.com/view/folding-american.htm folding american flag] [http://uglier.servemp3.com/resources/anal-traffic.html anal traffic] [http://coral.servemp3.com/lloyd-alexander.htm lloyd alexander born] [http://allies.servemp3.com/resources/disney-porno.html disney porno] [http://uglier.servemp3.com/resources/michigan-department.html michigan department of natural resources] [http://along.servemp3.com/view/cost-of-living.htm cost of living comparisons] [http://wails.servemp3.com/types-of-designers.html types of designers] [http://grise.servemp3.com/small/chondroitin-sulfate.htm chondroitin sulfate] [http://grise.servemp3.com/small/rottweiler.htm rottweiler] [http://along.servemp3.com/view/stp.htm stp] [http://cease.servemp3.com/buy-provigil-online.html buy provigil online] [http://uglier.servemp3.com/resources/free-telus-ringtones.html free telus ringtones] [http://coral.servemp3.com/cum-hentai.htm cum hentai] [http://coral.servemp3.com/miriam.htm miriam] [http://ousel.servemp3.com/orange-county-ca.html orange county ca real esate] [http://estate.servemp3.com/html/sporty-spice.html sporty spice] [http://beard.servemp3.com/data/little-girl-pics.html little girl pics] [http://wails.servemp3.com/tuyen.html tuyen] [http://grise.servemp3.com/small/fuck-of-the-month.htm fuck of the month] [http://coral.servemp3.com/online-image-mapping.htm online image mapping] [http://beard.servemp3.com/data/canberra-real.html canberra real estate] [http://beard.servemp3.com/data/kerri.html kerri] [http://estate.servemp3.com/html/onboys.html onboys] [http://uglier.servemp3.com/resources/shed.html shed] [http://grise.servemp3.com/small/plant-cell-lessons.htm plant cell lessons] [http://beard.servemp3.com/data/beautiful-plumpers.html beautiful plumpers] [http://sheets.servemp3.com/articles/male-to-female-hormones.html male to female hormones] [http://cease.servemp3.com/alprazolam-xanax.html alprazolam xanax] [http://grise.servemp3.com/small/used-air-conditioning.htm used air conditioning equipment] [http://uglier.servemp3.com/resources/japan-grill.html japan grill] [http://beard.servemp3.com/data/xl-girls.html xl girls] [http://falter.servemp3.com/ass-reaming.html ass reaming] [http://falter.servemp3.com/ro-download.html ro download] [http://allies.servemp3.com/resources/www-budget-rental.html www budget rental cars] [http://cease.servemp3.com/oiled-pussy.html oiled pussy] [http://beard.servemp3.com/data/type.html type] [http://ousel.servemp3.com/beastiality-cum.html beastiality cum] [http://sheets.servemp3.com/articles/spirit-of-the.html spirit of the enlightenment] [http://coral.servemp3.com/online-sex-video.htm online sex video] [http://allies.servemp3.com/resources/hollister-clothing.html hollister clothing] [http://estate.servemp3.com/html/hillary-duff-naked.html hillary duff naked] [http://grise.servemp3.com/small/travis-county.htm travis county] [http://grise.servemp3.com/small/eatting-pussy.htm eatting pussy] [http://wails.servemp3.com/sexy-kiss.html sexy kiss] [http://uglier.servemp3.com/resources/latina-facial.html latina facial] [http://beard.servemp3.com/data/psp-downloads.html psp downloads] [http://ousel.servemp3.com/rebirthing.html rebirthing] [http://coral.servemp3.com/online-medical-billing.htm online medical billing training programs] [http://ousel.servemp3.com/kia-sorento-accessory.html kia sorento accessory] [http://sheets.servemp3.com/articles/naked-trish-stratus.html naked trish stratus] [http://estate.servemp3.com/html/custom-furniture.html custom furniture] [http://falter.servemp3.com/linkin-park.html linkin park wallpaper] [http://sheets.servemp3.com/articles/telephone-numbers.html telephone numbers] [http://cease.servemp3.com/lesbian-twister.html lesbian twister] [http://coral.servemp3.com/jet-pumps.htm jet pumps] [http://coral.servemp3.com/dreamqueens.htm dreamqueens] [http://cease.servemp3.com/costa-rica-tours.html costa rica tours] [http://cease.servemp3.com/import-car-canada.html import car canada us] [http://coral.servemp3.com/art-deviant-pgirls.htm art deviant pgirls] [http://grise.servemp3.com/small/the-guitar-man-bread.htm the guitar man bread] [http://estate.servemp3.com/html/gay-child-porn.html gay child porn] [http://beard.servemp3.com/data/car-dirt-modified.html car dirt modified race sale] [http://sheets.servemp3.com/articles/male-dog-knot.html male dog knot] [http://estate.servemp3.com/html/spanish-fly.html spanish fly] [http://coral.servemp3.com/couples-fucking.htm couples fucking] [http://along.servemp3.com/view/cash-strapped-teens.htm cash strapped teens] [http://uglier.servemp3.com/resources/naturist-pageant.html naturist pageant] [http://falter.servemp3.com/homo.html homo] [http://estate.servemp3.com/html/christening-gowns.html christening gowns] [http://wails.servemp3.com/teen-couples-sex.html teen couples sex videos] [http://sheets.servemp3.com/articles/lets-get-to.html lets get to the point lets roll]
{{Dead end|date=January 2024}}
[[Category:Tutorials]][[Category:Programming]]
''Based on tutorial found [http://www.hl2world.com/wiki/index.php/Toggle_RPG_Laser here].''


Basically what we're going to be doing is allowing a player to switch the RPG's guiding laser on and off using the weapon's secondary fire. Along with this, we will allow a player who has fired a dumb (non-guided) rocket that hasn't yet exploded to change weapons.
NOTE: This tutorial may not work for Source SDK 2013 Multiplayer, the last element Identifier StopLaserEffects() is nonexistent in the server.dll, causing the errors E0020 undefined and C3861 Identifier not found in V.S. 2022 and fails to compile the server.dll. This tutorial should be capable i believe on the SDKs 2006 and 2007. This is not an issue for the current version of the 2013 SDK.


''Based on tutorial found [https://web.archive.org/web/20061105023442/https://www.hl2world.com/wiki/index.php/Toggle_RPG_Laser here].''
Basically what we're going to be doing is allowing a [[player]] to switch the [[weapon_rpg]]'s guiding laser on and off using the weapon's secondary fire. Along with this, we will allow a player who has fired a dumb (non-guided) rocket that hasn't yet exploded to change weapons.


'''Files affected:'''
'''Files affected:'''
* ''weapon_rpg.cpp''
* ''weapon_rpg.cpp''


In CWeaponRPG::ItemPostFrame() find the following code:


In CWeaponRPG::ItemPostFrame() (about line 1539), add the following code:
<source lang=cpp>
 
if ( g_pGameRules->IsMultiplayer() == true )
<pre>
if ( pPlayer->m_afButtonPressed & IN_ATTACK2 )
{
{
ToggleGuiding();
if ( pPlayer->m_afButtonPressed & IN_ATTACK2 )
{
ToggleGuiding();
}
}
}
</pre>
</source>


at the end of the method, after:
And comment out the following like that (or delete them):


<pre>
<source lang=cpp>
if ( pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0 && m_hMissile == NULL )
//if ( g_pGameRules->IsMultiplayer() == true )
{
//{
StopGuiding();
if ( pPlayer->m_afButtonPressed & IN_ATTACK2 )
}
{
</pre>
ToggleGuiding();
}
//}
</source>


This says, in effect, "If the player hits the secondary attack, toggle rocket guidance on or off."
This removes the gamerule that only allows you to toggle RPG guidance in multiplayer.


Then in CWeaponRPG::SuppressGuiding() (about line 1497), find the following code:
Then in CWeaponRPG::SuppressGuiding() (about line 1497), find the following code:


<pre>
<source lang=cpp>
if ( m_hLaserDot == NULL )
if ( m_hLaserDot == NULL )
{
{
Line 41: Line 47:
return;
return;
}
}
</pre>
</source>


and comment "StartGuiding();" out, so that it looks like this:
and comment "StartGuiding();" out, so that it looks like this:


<pre>
<source lang=cpp>
if ( m_hLaserDot == NULL )
if ( m_hLaserDot == NULL )
{
{
Line 54: Line 60:
return;
return;
}
}
</pre>
</source>


This stops the code from automatically starting up rocket guidance again.
This stops the code from automatically starting up rocket guidance again.
Line 62: Line 68:
In CWeaponRPG::Lower() (about line 1528), find the following code:
In CWeaponRPG::Lower() (about line 1528), find the following code:


<pre>
<source lang=cpp>
if ( m_hMissile != NULL )
if ( m_hMissile != NULL )
return false;
return false;
</pre>
</source>


and change it to read:
and change it to read:


<pre>
<source lang=cpp>
if ( m_hMissile != NULL && IsGuiding() )
if ( m_hMissile != NULL && IsGuiding() )
return false;
return false;
</pre>
</source>


This prevents the code from automatically telling us that we can't lower the RPG if we're not guiding. You will then need to make the same change in CWeaponRPG::CanHolster() (about line 1641).
This prevents the code from automatically telling us that we can't lower the RPG if we're not guiding. You will then need to make the same change in CWeaponRPG::Holster() (about line 1641).


Then in CWeaponRPG::Reload() (about line 1827), add this code:
Then in CWeaponRPG::Reload() (about line 1827), add this code:


<pre>
<source lang=cpp>
if ( pOwner->GetActiveWeapon() != this )
if ( pOwner->GetActiveWeapon() != this )
return false;
return false;
</pre>
</source>


after:
after:


<pre>
<source lang=cpp>
if ( pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
if ( pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
return false;
return false;
</pre>
</source>


If we changed weapons after firing, this will prevent the RPG from getting kicked back up to us for a reload after the dumb rocket explodes.
If we changed weapons after firing, this will prevent the RPG from getting kicked back up to us for a reload after the dumb rocket explodes.


And that's it! You're done.
As soon as we run out of rockets, the RPG is forced to lower, causing a constant toggle sound to play forever, we clearly don't want that, and there is a very simple fix for this sort of issue, in ''void CWeaponRPG::StopGuiding()'' change this code :
<source lang=cpp>
m_bGuiding = false;
 
WeaponSound( SPECIAL2 );
 
StopLaserEffects();
 
// Kill the dot completely
if (m_hLaserDot != NULL)
{
m_hLaserDot->TurnOff();
UTIL_Remove(m_hLaserDot);
m_hLaserDot = NULL;
}
</source>
 
To this :
<source lang=cpp>
m_bGuiding = false;
 
StopLaserEffects();
 
// Kill the dot completely
if (m_hLaserDot != NULL)
{
m_hLaserDot->TurnOff();
UTIL_Remove(m_hLaserDot);
m_hLaserDot = NULL;
 
WeaponSound(SPECIAL2);
}
</source>
 
What we did here, was simply change the position of the ''WeaponSound(SPECIAL2);'', putting it inside of the if statement of which is designated to kill the guidance dot.
{{note|This still retains the Toggling sound when you Disable or Enable guidance, so there is nothing to worry about :)}}
 
And that's it! You're done!
 
'''If any issues arise, ensure that you've done the steps above correctly, and that you didn't misplace (or create a typo within) the code.'''
 
==See also==
*  {{ent|npc_missiledefense}}
*  {{ent|item_rpg_round}}
*  {{ent|trigger_rpgfire}}
 
[[Category:Tutorials]]
[[Category:Weapons programming]]
[[Category:Programming]]

Latest revision as of 13:13, 3 August 2025

Dead End - Icon.png
This article has no Wikipedia icon links to other VDC articles. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024

NOTE: This tutorial may not work for Source SDK 2013 Multiplayer, the last element Identifier StopLaserEffects() is nonexistent in the server.dll, causing the errors E0020 undefined and C3861 Identifier not found in V.S. 2022 and fails to compile the server.dll. This tutorial should be capable i believe on the SDKs 2006 and 2007. This is not an issue for the current version of the 2013 SDK.

Based on tutorial found here.

Basically what we're going to be doing is allowing a player to switch the weapon_rpg's guiding laser on and off using the weapon's secondary fire. Along with this, we will allow a player who has fired a dumb (non-guided) rocket that hasn't yet exploded to change weapons.

Files affected:

  • weapon_rpg.cpp

In CWeaponRPG::ItemPostFrame() find the following code:

if ( g_pGameRules->IsMultiplayer() == true )
{
	if ( pPlayer->m_afButtonPressed & IN_ATTACK2 )
	{
		ToggleGuiding();
	}
}

And comment out the following like that (or delete them):

//if ( g_pGameRules->IsMultiplayer() == true )
//{
	if ( pPlayer->m_afButtonPressed & IN_ATTACK2 )
	{
		ToggleGuiding();
	}
//}

This removes the gamerule that only allows you to toggle RPG guidance in multiplayer.

Then in CWeaponRPG::SuppressGuiding() (about line 1497), find the following code:

if ( m_hLaserDot == NULL )
{
	StartGuiding();

	//STILL!?
	if ( m_hLaserDot == NULL )
		return;
}

and comment "StartGuiding();" out, so that it looks like this:

if ( m_hLaserDot == NULL )
{
	//StartGuiding();

	//STILL!?
	if ( m_hLaserDot == NULL )
		return;
}

This stops the code from automatically starting up rocket guidance again.

That's it for the guidance toggling code. Now to allow the player to lower the RPG after firing a dumb rocket but before it explodes.

In CWeaponRPG::Lower() (about line 1528), find the following code:

if ( m_hMissile != NULL )
	return false;

and change it to read:

if ( m_hMissile != NULL && IsGuiding() )
	return false;

This prevents the code from automatically telling us that we can't lower the RPG if we're not guiding. You will then need to make the same change in CWeaponRPG::Holster() (about line 1641).

Then in CWeaponRPG::Reload() (about line 1827), add this code:

if ( pOwner->GetActiveWeapon() != this )
	return false;

after:

if ( pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
	return false;

If we changed weapons after firing, this will prevent the RPG from getting kicked back up to us for a reload after the dumb rocket explodes.

As soon as we run out of rockets, the RPG is forced to lower, causing a constant toggle sound to play forever, we clearly don't want that, and there is a very simple fix for this sort of issue, in void CWeaponRPG::StopGuiding() change this code :

m_bGuiding = false;

WeaponSound( SPECIAL2 );

StopLaserEffects();

// Kill the dot completely
if (m_hLaserDot != NULL)
{
	m_hLaserDot->TurnOff();
	UTIL_Remove(m_hLaserDot);
	m_hLaserDot = NULL;
}

To this :

m_bGuiding = false;

StopLaserEffects();

// Kill the dot completely
if (m_hLaserDot != NULL)
{
	m_hLaserDot->TurnOff();
	UTIL_Remove(m_hLaserDot);
	m_hLaserDot = NULL;

	WeaponSound(SPECIAL2);
}

What we did here, was simply change the position of the WeaponSound(SPECIAL2);, putting it inside of the if statement of which is designated to kill the guidance dot.

Note.pngNote:This still retains the Toggling sound when you Disable or Enable guidance, so there is nothing to worry about :)

And that's it! You're done!

If any issues arise, ensure that you've done the steps above correctly, and that you didn't misplace (or create a typo within) the code.

See also