WiseNPC02: NPC targets
This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.
Getting NPC’s to shoot at an area without a live target can be done with the npc_bullseye entity. In this project I’ve created three Combine Soldier NPC’s:
- Shooting at a target from a window position.
- Shooting at a wide area from a roof position.
- Shooting at a wall that is bleeding.
Compile the vmf for this project, below, so you can see these three positions in action. The project file compiles in seconds.
We need two entities to make this work, the npc_bullseye
for our NPC to shoot at and a ai_relationship to make it happen.
For the NPC in the window the npc_bullseye is on the ground. Our NPC on the roof is shooting at a moving npc_bullseye
, which is Parented to an invisible func_tracktrain. Notice for each ai_relationship
the Subject is a Combine Soldier and the Target is an npc_bullseye
.
For each of these the Disposition property is set to Hate. The Radius is set to a wide area, 1200 for each of them. Disposition Priority is set very high, 999. Start Active is Yes for each. Reciprocal is No, the target does not hate the NPC.
The npc_bullseye
can take damage but for all three of the ones in this project the Flag Take No Damage is checked. For the target on the wall the Bleed flag is checked, and as the Combine shoots at it the target will bleed on the wall.
Don’t worry about getting shot at, I’ve set a point_clientcommand and used a logic_auto to enable notarget when the map spawns.
Compile the project vmf below, it’s an interesting show.