WiseAiSound: NPC sensed sounds

From Valve Developer Community
Jump to: navigation, search


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

Introduction

ai_sound is an entity that makes sounds, or smells, that can be sensed by NPCs. The player can’t smell of course but they also will not hear these sounds. (In this project I've also included a sound the player can hear, to be played at the same time.) This entity is used to cause reactions from nearby NPCs. wiseAiSound02.jpg

Creation

In this project I’m using a logic_timer with random timer settings to alert the NPCs in the area. The two citizens in this project will continue to warn Gordon, move out of the way of danger and even cower.

The Sound and Smell types available are:

  • Combat: Causes most NPCs to become alert.
  • World: Causes most NPCs to become alert.
  • Danger: Causes most NPCs to move away, can also warn Gordon.
  • Bullet Impact: NPC Alert
  • Carcass: Unknown, un-tested.
  • Meat: Unknown, un-tested.
  • Garbage: Unknown, un-tested.
  • Thumper: causes antlions to run away briefly

Three levels of readiness cause NPC Player companions that can sense this to be ready.

  • Readiness: Low
  • Readiness: Medium
  • Readiness: High

This entity has a special property named Location Proxy. You can specify another named entity, or even the !player. This new object will be the proxy location for the AI sound. ai_sound can also be parented, which can come in handy for many map needs. Take for example the moving sound of an incoming missile.

You have to name this entity to use it. The input it receives to alert NPCs is InsertSound, with a parameter for volume (1-100) which influences detection radius.

The Sound Type property I’ve set for the ai_sound in this project is Danger. When the logic_timer triggers the input it will alert the NPCs. This is a handy entity for any project involving NPCs. It’s simple to use and provides the random NPC actions that spice up a level.

wiseAiSound01.jpg

See also