npc_combine_cannon

From Valve Developer Community
Jump to navigation Jump to search
Not to be confused with func_tankmortar (The Suppression Device from d3_c17_10a in Half-Life 2 Half-Life 2).
Class hierarchy
CNPC_Combine_Cannon
CAI_BaseNPC
CBaseCombatCharacter
CBaseFlex
CBaseAnimatingOverlay
CBaseAnimating
CBaseEntity
npc_combine_cannon.cpp

npc_combine_cannon is a model entity available in Half-Life 2 Half-Life 2.

A npc_combine_cannon in the midst of acquiring an antlion guard as target.
The model is merely a visual set piece. The actual npc_combine_canon is just the blue lasers and the bullets it spawns.

It is a fully automatic machinegun cannon with perfect accuracy. Possibly an early forerunner to the Combine Autogun in Episode Two.
It is unsure why this entity has not been used, as for all intent and purposes, it does work. Perhaps because it was too powerful. But if that were true, they could have lowered the damage of it.

When a target is spotted, multiple blue lasers emit from its location, converging on the enemy. It then fires five bursts which deal 20 points of damage each. Then it reacquires a new -or the same- target.
If it targets the player however, it does not do bursts, and instead goes fully automatic. Even if the player is at full health and armor, the player will die in three seconds.

It is basically a cousin of npc_sniper, but with a fully automatic cannon and anger issues.
Just like the sniper as well, it aims fully on its own. It does not need to be pointed a specific spot like a func_tank would.
It appears to have a 45° cone of vision to either side. It stays wherever you put it, even if it's mid air, and it can be parented to other things. The console will complain about it, but still parent it.
This would allow you to make an extra deadly gunship, or whatever you want to attach it to.

It can only be killed through the I/O system. You could use a npc_bullseye or a func_breakable to have something to damage.
Alternatively, do the same as the "Combine Autogun" by having the player interact with something to kill the npc_combine_cannon. Or just fire the "DisableSniper" input to not remove it entirely.

Note.pngNote:During testing, having numerous npc_citizen attack it directly seems to overwhelm it. The cannon stops its "target acquiring" phase and tries it again.
Either that, or it can't make up its mind with who to shoot at.
Note.pngNote:Despite the entity being displayed as a combine soldier, it does not use a model in game. It is merely a point from which lasers and tracers spawn, unlike npc_sniper that spawns with a visible model.

Making it work

As this is an unfinished npc, the FGD is also unfinished. it behaves pretty much like npc_sniper, even sharing two flags and the inputs to wake the "sniper".
To make this thing work pretty well, swap your FGD entry with the following:

@NPCClass base(Angles, Targetname, Parentname) sphere(sightdist) studio("models/editor/cone_helper.mdl") = npc_combine_cannon : "A very lethal cannon that takes aim and fires endlessly until the enemy dies. ONLY THE TRACERS ARE VISIBLE"
[
	sightdist(float) 					: "Sight radius" 	: 1024	: "Radius distance at which the cannon is able to aquire enemies."
	
	input EnableSniper(void) 			: "Turn the cannon ON."
	input DisableSniper(void) 			: "Turn the cannon OFF."
	
	//tested, works	
    input ForgetEntity(string) 			: "Clears out the NPC's knowledge of a named entity. Causes gun to stop firing, and reacquire target. "
	input SetRelationship(string) 		: "Changes this entity's relationship with another entity or class. Format: <entityname/classname> <D_HT/D_FR/D_LI/D_NU> <priority>"

	//taken from npc_sniper. probably the only ones that work. and the only ones you'll need.
	spawnflags(Flags) = 
	[
		65536 :  "Hidden (never draws combine that the wake input spawns)" : 1
		524288 : "Start Disabled - enable via EnableSniper input. " : 0
	]
]

As you can see, the "BaseNpc" has been entirely removed as a base for this npc, as there's no real need to have it use all the keyvalues and I/O when it never moves.

Icon-Bug.pngBug:Spawning this entity asleep causes the blue lasers to point at the map center at all times. Waking this npc renders it useless. It gets swapped out for a braindead combnine soldier.
Use the flag "Start Disabled" instead, and fire the "EnableSniper" input when you want it to shoot.  (tested in: Half-Life 2: Episode Two Half-Life 2: Episode Two)
Note.pngNote:When trying to get this to work, I did not test all keyvalues and I/O options that BaseNPC has. I merely picked and tested some that I thought would be useful at all for this entity.
It works if it is used just like npc_sniper, but way more deadly. As this was my goal. --MrFunreal (talk)

Keyvalues

Name (targetname) <string> [ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Sight radius ([todo internal name (i)]) <float>
Radius distance at which the cannon is able to acquire enemies.
BaseNPC keyvalues

CBaseCombatCharacter:

Relationship (Relationship) <string> !FGD
<string|targetname or classname> <string|disposition> <int|rank>
Changes whether this entity likes or dislikes certain other things. Used like the ai_relationship entity, with this entity as the subject.
Values for disposition are:
  • D_HT: Hate
  • D_FR: Fear
  • D_LI: Like
  • D_NU: Neutral
Physics Impact Damage Scale (physdamagescale) <float>
Multiplier for damage amount when this entity is hit by a physics object. With a value of 0 the entity will take no damage from physics.

CAI_BaseNPC:

Target Path Corner (target) <targetname>
The path_corner that this NPC will move to after spawning.
Squad Name (squadname) <string>
NPCs that are in the same squad (i.e., have matching squad names) will share information about enemies and will take turns attacking and covering each other.
Hint Group (hintgroup) <string>
Hint groups are used by NPCs to restrict their hint-node searching to a subset of the map's hint nodes. Only hint nodes with matching hint group names will be considered by this NPC.
Hint Limit Nav (hintlimiting) <boolean>
Limits NPC to using specified hint group for navigation requests. Does not limit local navigation.
Sleep State (sleepstate) <choices>
Holds the NPC in stasis until specified condition. See also Wake Radius and Wake Squad.
  • 0: None
  • 1: Waiting for threat
  • 2: Waiting for PVS
  • 3: Waiting for input, ignore PVS
  • 4: Auto PVS
  • 5: Auto PVS after PVS
Wake Radius (wakeradius) <float>
Auto-wake if player comes within this distance.
Wake Squad (wakesquad) <boolean>
Wake all of the NPCs squadmates if the NPC is woken.
Enemy Filter (enemyfilter) <targetname>
Filter entity to test targets against.
Ignore unseen enemies (ignoreunseenenemies) <boolean>
Prefers visible enemies, regardless of distance or relationship priority.

DamageFilter:

Damage Filter (damagefilter) <targetname>
Name of the filter_damage_type entity that controls which entities can damage us.

Flags

BaseNPC flags 

Inputs

EnableSniper  !FGD
Turns the cannon on, causing it to start shooting if it spots an enemy.
DisableSniper  !FGD
Turns the cannon off.
BaseNPC inputs 

Outputs

BaseNPC Outputs
OnDamaged
Fired when this NPC takes damage (!activator is the damage inflictor).
OnDamagedByPlayer
Fired when this NPC is hurt by a player (!activator is the attacker or vehicle driver [if friendly fire]).
OnDamagedByPlayerSquad
Fired when this NPC is hurt by a player OR by one of the player's squadmates (!activator is the attacker or vehicle driver [if friendly fire]).
OnDeath
Fired when this NPC is killed (!activator is the killer).
OnDenyCommanderUse
Fired when this NPC has refused to join the player's squad.
OnForcedInteractionAborted
Fired when the NPC aborts a forced interaction for some reason (target NPC died, couldn't be pathed to, etc.).
OnForcedInteractionStarted
Fired when the NPC starts a forced interaction.
OnForcedInteractionFinished
"NPCs in actbusies can no longer perform dynamic interactions."
Todo: What does this mean?
OnHalfHealth
Fired when this NPC reaches half of its maximum health.
OnHearCombat
Fired when this NPC hears combat sounds.
OnHearPlayer
Fired when this NPC hears the player.
OnHearWorld
Fired when this NPC hears a sound (other than combat or the player).
OnFoundEnemy <targetname*RedirectOutput/ehandle>
Fired when this NPC establishes line of sight to its enemy.
OnLostEnemy
Fired when this NPC loses its enemy. Usually due to the enemy being killed/removed, or because this NPC has selected a newer, more dangerous enemy.
OnLostEnemyLOS
Fired when this NPC loses line of sight to its enemy.
OnFoundPlayer <targetname*RedirectOutput/ehandle>
Fired when this NPC establishes line of sight to its enemy, and that enemy is a player.
OnLostPlayer
Fired when this NPC loses its enemy, and that enemy was a player. Usually due to the enemy being killed/removed, or because this NPC has selected a newer, more dangerous enemy.
OnLostPlayerLOS
Fired when this NPC loses line of sight to its enemy, and that enemy is a player.
OnSleep
Fired when this NPC enters a sleep state.
OnWake
Fired when this NPC comes out of a sleep state.