This article's documentation is for the "GoldSrc" engine. Click here for more information.

player_weaponstrip

From Valve Developer Community
Jump to navigation Jump to search

player_weaponstrip is a point entity available in Half-Life Half-Life, Half-Life: Opposing Force Half-Life: Opposing Force, Half-Life: Blue Shift Half-Life: Blue Shift, and Cry of Fear Cry of Fear. 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.

Ammo HUD Bug Fix

A small bug that occurs in the official game, as well as the expansions and many mods, 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 using the Half-Life SDK provided by Valve on Github.

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!

Keyvalues

Targetname:

Name (targetname) <string>
The targetname that other entities refer to this entity by.