WiseNPCWeapons: NPC Weapon effects

From Valve Developer Community
Jump to: navigation, search

This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.



The sample file for this project, at the page bottom, illustrates:

  1. Disabled APC burning in the distance
  2. Attacks watermelon with Rockets and gunfire.
  3. Melons continue to spawn as broken.

The env_gunfire and npc_launcher entities used in this tutorial can add some very nice effects to your projects. Experiment with the settings on each of these to achieve your own effects. The settings I’ve used in this project are examples only.

One thing I believe helps the rocket effect is a crooked path. An arched path would look just as nice, but not a straight line. The path for the npc_launcher is created with path_corner entities. In this project the only one I created was the first one, gave it a name then cloned the rest by using the Shift+mouse drag method to create the entire path.

The 9 path_corner entities for this project are shown in the image below.


The name of the first path_corner is specified in the properties for the npc_launcher.

  • Name: launcher1
  • Target Path Corner: corner1
  • Start On: Off
  • Missile Model: models/Weapons/W_missile.mdl
  • Launch Sound: PropAPC.FireRocket
  • Fly Sound: eli_lab.attack_battleloop_1
  • Smoke Trail: On
  • Launch Smoke: On
  • Launch Delay: 7
  • Launch Speed: 400
  • Path Corner Name: corner1
  • Homing Speed: 400
  • Homing Strength: 10
  • Gravity: 1.0
  • Min Range: 100
  • Max Range: 2048
  • Spin Magnitude: 10
  • Spin Speed: 10
  • Damage: 50
  • Damage Radius: 256
  • Flags: Check LOS

Notice the sound I used for the Fly Sound. Experiment with this. The default fly sound will generate an error. Battle sounds probably work best for this as the sound can still be heard after the rocket finds the target.

These are the properties for the two env_gunfire entities.

  • Name: gunfire1 and gunfire2
  • Start Disabled: Yes
  • Target: bullseye1
  • Min Burst Size: 10 and 7
  • Max Burst Size: 40 and 15
  • Min Delay Between Bursts: 2 and 1
  • Max Delay Between Bursts: 7 and 2
  • Rate of Fire: 10
  • Bullet spread: 15 Degrees and 5 Degrees
  • Bullet distribution: Evenly distributed
  • Collision detection: None. Cheap for performance.
  • Shoot sound: AR2 and SMG1
  • Tracer: AR2

The target for each of these entities in this project is an npc_bullseye.

  • Name: bullseye1
  • Flags: Not Solid, Take No Damage, Perfect Accuracy

The npc_bullseye will be assigned as an enemy of the Rocket launcher via an Output from the trigger_once.

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnTrigger launcher1 SetEnemyEntity bullseye1 0.00 Yes

Outputs for our trigger_once:


For nothing more than an added effect I’m spawning Watermelons over the target.

See Also