Npc turret ceiling/fixes
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

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 this in a soundscript file (e.g. "npc_sounds_turret.txt") to make ceiling turrets use the shooting sounds used by all other turrets:
"NPC_CeilingTurret.ShotSounds" { "channel" "CHAN_WEAPON" "volume" "VOL_NORM" "pitch" "PITCH_NORM" "soundlevel" "SNDLVL_GUNFIRE" "rndwave" { "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 using their "shoot" animation. This means the turret is stuck at the end of its shooting animation, 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 );
}
else
{
SetActivity( (Activity) ACT_CEILING_TURRET_FIRE );
}
Place ResetActivity()
right above the spawnflag check and the activity 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 FOV. Its m_flFieldOfView
is 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.
Lowering health
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;