weapon_headcrab

From Valve Developer Community
Jump to navigation Jump to search
C++ Class hierarchy
CWeapon_Headcrab
CBlackMesaBaseWeapon
CBaseCombatWeapon
CBaseAnimating
CBaseEntity
Weapon's viewmodel.
Weapon's world and player model.
The red overlay texture, dev/hc_blur.

weapon_headcrab is a model entity available in Black Mesa Black Mesa. This weapon is part a of headcrab latching, unused feature in final versions of the game, because it was hated by almost all Black Mesa developers (the conclusion is based on the developer's comment in this post). It was an experimental game mechanic which would have allowed for headcrabs to latch on to the player's head, forcing them to rapidly tap their primary fire to remove it, if the player didn't remove the headcrab - the game triggers game over with message (similar if a player losses important NPCs for instant). All classic headcrabs can latch with certain chance if damaged head. While attached, the headcrab also applies the red texture overlay (dev/hc_blur) and pushes the player's viewing angle randomly. Pressing the main attack button will play one of the headcrab pain sounds and either will drop the headcrab client side ragdoll, or will animation of attempt to detach and require another try, the amount hits needed to detach the headcrab is random. Without using server side modifications, it is not possible to use this feature in Steam versions of the game, it is possible only in Black Mesa (mod) Black Mesa (mod) by using the sv_headcrab_can_latch_on_player 1 console command.

Before it is picked up, this entity also follows all physics rules as if it were a prop_physics.

Icon-Important.pngImportant:Before using it, download the texture overlay fix, unless the missing texture placeholder wanted.
Note.pngNote:
  • The HUD hint about headcrab detach is not used.
  • The player drops this "weapon" when dead, instead of triggering the game over with message.
  • The original viewmodel doesn't have multiplayer hands for other characters except HEV, the model also doesn't have proper scale (causes lighting issues).
  • The damage seems to be hardcoded.
  • The HUD bucket seems to be disabled for this weapon.
  • This weapon will be saved in item_ammo_box.
Icon-Bug.pngBug:
  • The overlay texture doesn't seem to be cached properly in Steam versions of the game. Because of this, even with the texture fix, the placeholder still appears. Precache the texture or (use for something else to trigger precache) before using this weapon.
  • Despite the presence of anim_prefix parameter, players will still use T-pose.
  • If the game didn't recorded the player's "previous weapon", after the headcrab detach, the player will not switch back to weapon previous. Using save load under this conditions will lead to weapon_headcrab's viewmodel reappear. The same will happen if the player has no weapons.
  • Initially, weapons were supposed to either spawn instantly if used mp_weaponstay 1, or 20 seconds delay, but due to a bug in the respawn code where current time is added back to a value that already contains current time, the respawn time accumulates and gets longer each time the weapon is picked up.

Weapon script

Placed in scripts\gameplay\weapons\weapon_headcrab.dmx. Used to load some weapon parameters.

Note.pngNote:Not everything seems to be used, anim_prefix doesn't work for instant.
<!-- dmx encoding keyvalues2 1 format dmx 1 -->
"WEAPON_HEADCRAB"
{
	"id" "elementid" "3a196cb7-7f25-436f-b0af-1453598e2263" //a hardcoded ID element, not being changed or the game will most likely crash
	"paramDef" "string" "WeaponParamDef" //helps server to define, for what kind of class we want to load parameters
	"playermodel" "string" "models/xenians/headcrab.mdl" //world model, used by NPCs and as physics/drop model
	"viewmodel" "string" "models/weapons/v_headcrabbed.mdl" //viewmodel, used for first person
	"printname" "string" "Headcrab" //the friendly name shown to players in the UI, a localization key can be used
	"bucket" "int" "0" //HUD bucket slot
	"bucket_position" "int" "0" //HUD bucket position 

	"bucket_controller" "int" "1" //controller version for HUD bucket slot
	"bucket_position_controller" "int" "3" //controller version for HUD bucket position 

	"anim_prefix" "string" "headcrab" //animation prefix, defines what animations will be used by player models
	"item_flags" "int" "0" //weapon flags
	"weight" "int" "-100" //used to determine the weapon's importance when the game auto-selects one
	"sounds" "sounds" //set of sounds
	{
		"id" "elementid" "e9d0b3a0-dbd6-47fe-b8c3-581d9e5b2902" //a hardcoded ID element, not being changed or the game will most likely crash
		"special1" "string" "weapon_headcrab.Special1" //first special sound, used for one the headcrab's attack sounds
		"special2" "string" "weapon_headcrab.Special2" //second special sound, used for one the headcrab's pain sounds
	}
}

Hint and over message

There is unused hint that tells how to detach the headcrab:

"BMS_HINT_HEACRAB_HEADGRAB"	"TAP %+attack% UNTIL HEADCRAB IS REMOVED"

There is unused "game over" message:

"BMS_GameOver_Headcrab"		"ASSIGNMENT: TERMINATED\nSUBJECT: FREEMAN\nREASON: ZOMBIFIED"

Flags

Start Constrained : [1]
Prevents the model from moving.
Deny player pickup : [2]
Prevents weapon pick up by a player.
Not puntable by Gravity Gun : [4] Obsolete
Deprecated.
FGD leftover from Half-Life 2 Half-Life 2.
Do not play weapon pick up sound : [8] !FGD
Prevents weapon from playing weapon pick up sound (not item pick up sound) and pick up animation.
No respawn : [1073741824] !FGD
Prevents weapon respawn in multiplayer.

Inputs

HideWeapon  !FGD
If this weapon is being held, hide the worldmodel and/or viewmodel via EF_NODRAW. Weapon will still be useable. The weapon will become visible again if the holder is to switch between weapons in their inventory.

Outputs

OnNPCPickup
Fires when an NPC picks up this weapon. (!activator is the NPC.)
Confirm:NPCs can't pick up weapons in Black Mesa Black Mesa, can they pick up weapons forcibly ?
OnPlayerUse
Fires when the player +uses this weapon. (!activator is the player.)
OnPlayerPickup
Fires when a player picks up this weapon. (!activator is the player.)
OnCacheInteraction
Fires when the player 'proves' they've found this weapon. Fires on player touch or use pickup.

Dedicated Console Variables

Cvar/Command Parameters or default value Descriptor Effect
sv_headcrab_can_latch_on_player (only in Black Mesa (mod)) 0 Bool Enable/disable headcrab ability to latch on a player.

See also