From Valve Developer Community
< User:Hurricaaane
Revision as of 02:10, 15 January 2006 by Hurricaaane (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A global idea

When you want to do some specific subject which need entities that is not explained by any tutorial, what you have to do is to study the entities. At least remember the global description of the entities. Then you will be able to select in these entities those which you need in the accomplishment of your task. Write down what you need in your task. Then write what constraints inferfeer in the accomplishment of your task. This is particulary linked on the main entity where you will apply effects of other entities on. Only now you can select the entities you need in order to check the objectives and avoid the constraints.

For example, you want to do a Scanner that spawns manhacks when it photograph you. The main entity is Npc_cscanner. Study this entity: You will see that the output OnPhotographPlayer exists. If you study it clearly, even if you are hidden when the Scanner flashes, the output is triggered. This is the constraint.

You will now think about the idea. You want the OnPhotographPlayer to work when it sees the player, but not when it is not seen. There are two outputs that activates when the Scanner finds the player(OnFoundPlayer), and when it loses him from its line of sight (OnLostPlayerLOS). The problem is that you don't want the scanner to send manhacks when it sees it but when it sees AND it makes a flash.

If you have studied the entities, you would know that the Logic_branch is an entity where you can output when the value is 1(True) or 0(False). We can say in another way: If it's true that the Scanner sees the player, trigger the output.

That's all! Now you have all the bases and you can easily connect the entities theorically:

  • When the scanner sees the player(OnFoundPlayer) : Set the branch value to 1(SetValue 1).
  • When the scanner have lost the player LOS(OnLostPlayerLOS) : Set the branch value to 0(SetValue 0).
  • When the scanner photograph the player(OnPhotographPlayer) : Test the branch.
  • When the test is true(OnTrue) : Enable the Manhack spawner (Npc_template_maker) once only.

These are the outputs we should make:

Object outputs: scanner_tscanner - npc_cscanner
My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnFoundPlayer branch_tscanner SetValue 1 0.00 No
Io11.png OnLostPlayerLOS branch_tscanner SetValue 0 0.00 No
Io11.png OnPhotographPlayer branch_tscanner Test <none> 0.00 No

Object outputs: branch_tscanner - logic_branch
My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnTrue maker_tmanhack Enable <none> 1.00 Yes

All you need to do from now is to create it and see if the theory is true. If its not, you have to find why the theory is wrong, or make other decisions.

List of projects

There is the list of my projects; Sound meter - Two different sound-based meters.

Sound meter

In this tutorial, I will teach you how to make 2 different sound meters.

A sound meter is a graphic thing that shows you the level of sound taken from some place.

Getting the sound level

At first, we need to get the level of sound of some place. This part is particulary inspired from Dredfurst's method to make a sound-sensitive trigger.

The entity needed to make that is an env_microphone set to be in Measuring mode. Set these properties:

Classname : env_microphone

  • Name : microphone_micro1
  • Measure target : target_micro1listen
  • Sensitivity : 2 ('Warning' : 'Depends of what kind of sound you need to measure')
  • Radius : 'Choose a radius value'
  • Spawnflags :
  • Hears combat sounds
  • Hears world sounds
  • Hears player sounds
  • Hears bullet impacts
  • Hears explosions

We also need an entity the microphone will take the sound level from. This will be an info_target.

Classname : info_target

  • Name : target_micro1listen

This is the only point both meters need.

A bar as a meter

In the first method, we'll use a bar. The size of the bar increases along with the level of sound.

But what will be the peak value of the bar? To know what to put as a peak value, you need to compile your map, type 'developer 2' and emit sounds near your microphone you like the trigger to consider as a peak. You will read what values were picked up, so round it and set it into the field I will tell you to.

You see, the func_movelinear is an entity that changes position using a value that varies from 0 to 1, 1 is the opened position. Problem is that the peak you need may not be that value.

To convert a value from 0 to <your peak value> into a 0 to 1 value, a special entity was created: math_remap

This entity is rarely used. It consists of getting your sound value, and convert it into another number, based from 4 values globally considered as the input range and the ouput range.

Let's create our entites first, then we'll set the outputs.

>>>>>>>Unfinished tutorial