Player weaponstrip (GoldSrc)

From Valve Developer Community
Revision as of 01:05, 21 November 2018 by Speedvoltage (talk | contribs)
Jump to navigation Jump to search

Template:Hl1 series point It will take away(strip) all of the player's weapons. The only times the player_weaponstrip entity is used in Half-Life is in the chapter Apprehension, and at the end of the chapter Nihilanth; in Opposing Force, at the very end after killing the final boss, and in Blue Shift, after entering the final teleporter to escape Black Mesa. The player_weaponstrip, as its name implies, only strips the player's weapons, any other items, primarily the player's HEV Suit, will not be removed.

Icon-Bug.pngBug:A small bug is that the ammo information on your HUD does not get removed, only changing the ammo pool to 0 and leaving you with the number of bullets that were in your magazine before the strip. The following fix can be applied if you work on a GoldSrc modification.  [todo tested in ?]

Ammo HUD Fix

Open Ammo.cpp and find the following:

if ( iId < 1 )
	{
		SetCrosshair(0, nullrc, 0, 0, 0);
		return 0;
}

Add the following line of code:

if ( iId < 1 )
	{
		SetCrosshair(0, nullrc, 0, 0, 0);
		m_pWeapon = NULL; //Remove Ammo HUD if weapons are removed
		return 0;
}

Scroll a little lower and find this block of code:

if ( gHUD.m_iFOV >= 90 )
	{ // normal crosshairs
		if (fOnTarget && m_pWeapon->hAutoaim)
			SetCrosshair(m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255);
		else
			SetCrosshair(m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255);
	}
	else
	{ // zoomed crosshairs
		if (fOnTarget && m_pWeapon->hZoomedAutoaim)
			SetCrosshair(m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255);
		else
			SetCrosshair(m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255);

}

Replace that with the following:

if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_CUSTOMCROSSHAIR ))
    {
        WEAPON *ccWeapon = gWR.GetWeapon(7);
        SetCrosshair(ccWeapon->hCrosshair, ccWeapon->rcCrosshair, 255, 255, 255);
    }
    else if ( !(gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
    {
        if ( gHUD.m_iFOV >= 90 )
        { // normal crosshairs
            if (fOnTarget && m_pWeapon->hAutoaim)
                SetCrosshair(m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255);
            else
                SetCrosshair(m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255);
        }
        else
        { // zoomed crosshairs
            if (fOnTarget && m_pWeapon->hZoomedAutoaim)
                SetCrosshair(m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255);
            else
                SetCrosshair(m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255);
 
        }
    }

If you try to compile your code at this point, you will only see an error. That's because we added a new identifier calledHIDEHUD_CUSTOMCROSSHAIR, but this is undefined! Opencdll_dll.h and add the following under#define HIDEHUD_HEALTH ( 1<<3 ):

#define HIDEHUD_CUSTOMCROSSHAIR ( 1<<4 )

Now compile and you are ready to go!

Flags