Npc turret ceiling/fixes

From Valve Developer Community
Jump to: navigation, search

npc_turret_ceiling contains various bugs. This is a list of many of these bugs and how to fix them.

Looping engine sound lingering after death/removal

Confirm:Should be stopped directly with StopSound() by overriding StopLoopingSounds(). Haven't fully looked into this yet.

No shooting sound

This is caused by a missing soundscript called NPC_CeilingTurret.ShotSounds. Just place the following text in a soundscript file (e.g. "npc_sounds_turret.txt") to make ceiling turrets use the shooting sounds used by all other turrets:

	"channel"		"CHAN_WEAPON"
	"volume"		"VOL_NORM"
	"pitch"			"PITCH_NORM"

	"soundlevel"	"SNDLVL_GUNFIRE"

		"wave"	"^npc/turret_floor/shoot1.wav"
		"wave"	"^npc/turret_floor/shoot2.wav"
		"wave"	"^npc/turret_floor/shoot3.wav"

Muzzle flash only plays once / no shot recoil

This is caused by the fact ceiling turrets don't reset their activity after playing their "shoot" animation. This means the turret is stuck at the end of its shooting activity while it's firing, which is also why the muzzle flash plays only once. To fix this, navigate to where the shooting activities are set in this part of CNPC_CeilingTurret::ActiveThink():

if ( m_spawnflags & SF_CEILING_TURRET_OUT_OF_AMMO )
	SetActivity( (Activity) ACT_CEILING_TURRET_DRYFIRE );
	SetActivity( (Activity) ACT_CEILING_TURRET_FIRE );

Place ResetActivity() right above the spawnflag check and the reset should allow the activity to play for each shot, therefore firing the muzzle flashes on each shot. The turret's barrel will also recoil when firing.

Not firing at enemies directly underneath turret

This is caused by the ceiling turret's m_flFieldOfView being set to 0.0f, equivalent to 90 degrees. Actually, the turret's model is fully capable of rotating 360 degrees and lowering m_flFieldOfView, or at least making it mapper-modifiable through DEFINE_KEYFIELD, should expand the turret's vision to the point in which it could shoot downwards. Keep in mind this expands its horizontal FOV as well.

Health is too high

In CNPC_CeilingTurret::Spawn(), you can find this:

m_iHealth		= 1000;

You can either adjust it to your own liking or change it to this to make the health modifiable by the "health" keyvalue in Hammer:

if (m_iHealth == 0)
	m_iHealth = 1000;