Friday, November 4, 2011

Entity system in goldsrc

In this tutorial, I will show you how do entities in cs 1.6 , namely how do entities in the goldsrc engine entities work and communicate with each other. The reason I have chose to place goldsrc rather cs 1.6 in the tutorial name is because this tutorial is common for all mods and games based on the goldsrc engine.

You have already dabbled in entities before. Now we will go a bit further with the most basic and very useful trigger_multiple entity.
Make two rooms and connect them. Place a brush between the room and texture it with the aaa texture. Now, right click on it and turn it into an entity. This will turn it into a brush based entity. Select trigger_multiple in the drop down box.
What this entity does is that it triggers another entity whenever it is triggered. Any player passing through this entity will trigger it. For example, we want an ambient_generic entity to play a sound whenever a player passes through this entity. Place an ambient_generic entity and give any name to it. For example, we name it as gg. Now, click on the target box in the trigger_multiple entity and type gg. So whenever any player passes through this entity, it will trigger any entity named gg. Because gg is the name of our ambient generic entity, a sound of your choice will be played.
This entity system is commonly called the name and target system. Look at the following screenshot:
Look carefully at the 2d view on the right. There is a line running from trigger_multiple to ambient_generic. While making complex entity systems, it is useful to turn on the show connections option. This option is available in view tab.

Name and target system
This is what really happens when the trigger_multiple fires at the ambient generic entity thereby triggering it. When a player goes through the entity, it gives a 1 signal to the ambient generic entity. Some entities are like light switches which must be turned on or off. Some are like a bell when, when pressed on, activate for a certain number of seconds. To simplify this, I will be using 1s and 0s because it is easier to explain.

Entity system
Lots of entities and special brushes are used when making scripted sequences, trains, vehicles, elevators, etc. When all these entities work together, they are known as an entity system. Our goal as a level designer is to make these entity systems as compact as possible. Later on, you will learn how to make such complex systems. Remember to give proper names to the entities to avoid confusion. Also group these entities and make them in such a way that they can be easily replicated.

Some entities such as light, light_spot, func_door, game_counter etc retain their state ie: their state which can be either 1 or 0; even when the next round starts. You can easily make these entities change their state back to 1 or 0 at the start of the round by using trigger_auto or this technique.

No comments:

Post a Comment

Post your views here