damage
Function
This inflicts the amount of damage specified in the command argument to the brush face. Inflicting damage to a brush face can make it trigger events if its "group" name is set to certain special characters. These events include things like changing the surface's lightstyle, switching to the next animated texture frame, triggering an entity or calling a thread. The inflicted damage is cumulative.
Syntax
|
@<group_name> damage <value>
|
Notes & examples
|
In order for a brush face to respond to damage, you first have to set the damage surface flag. Second, you have to set either the weak or normal surface flag. This is the minimum requirement. Afterwards, you can set other surface flags and fields to set what events will occur when the brush face is damaged.
What follows is a suite of 3 mini-tutorials. Each one describes with a practical example the 3 kinds of thing a brush face can do when damaged. In order of complexity, these are:
- Make the brush face switch to the texture specified in the brush face's Next Animation field.
- Make a brush face previously set to emit light change the amount or style of light it emits.
- Make a brush face trigger an entity OR call a script thread (but not both at the same time).
- Any combination of the above 3 effects.
|
Damage induced texture change mini-tutorial:
|
First, make a small rectangular room any size you want (256 x 256 x 256 is good). Load the biomech texture folder and select the texture 0wl_techwall1cpu. Draw a 128 wide by 128 high by 8 thick brush anywhere in the room. Align the texture if necessary.
Select one of the tall faces of the brush in the Camera view and do a Middle-Click on that face to grab it (this makes sure all the alignment values are stored in surf inspector). Open the surf inspector window and move it so it doesn't hide your texture selection window as seen in Figure 1 below:
|
|
Figure 1: SinEd: Setting the parameters in surf inspector
|
Set the damage and weak surface flags and do a Ctrl-LeftClick on the texture named 0wl_techwall1cpu_brk in the texture selection window as show in steps 2 and 3 of Figure 1. Hit Apply or OK. That's it. That's all you need to do to make a brush face change to the next texture when damaged.
Save your map and compile it. Launch the game and load the map. Walk up to the brush face and shoot it. The texture will change from 0wl_techwall1cpu to 0wl_techwall1cpu_brk. Also, the brush face will tesselate (shed fragments of itself) so it looks like it shattered as can be seen in Figures 2 and 3 below:
|
|
|
Figure 2: The original texture
|
Figure 3: Shoot! - Next texture
|
So as you can see, it's not complicated at all to make a brush face switch to the next texture when damaged. So now you know what the damage surface flag is for. But what about the weak and normal surface flags? What are those for?
Very simple: they set the amount of damage required to make the brush face trigger the texture change (and all the other possible events as we will see later). The values are:
- weak : 11 points of damage or more must be inflicted to trigger events
- normal : 91 points of damage or more must be inflicted to trigger events
- both weak & normal set : 201 points of damage or more must be inflicted to trigger events
Well that's all good and fine but what does the damage script command have to do with all this? Here again, very simple: you can use the command to inflict damage to the brush face and make it trigger the events instead of requiring that the player shoots the brush face to inflict the required damage. This would be most useful in the case where you want the brush face to change textures as above but without player intervention. Here's an example:
In the same room as the above example, you want the "computer panel" brush face to switch to the "broken panel" texture at some point in the game without player intervention (when a scripted explosion goes off in the room for example). The damage command then comes in handy. But to be able to use it, you first have to name your brush face so you can refer to it in the script. This is what the group field in surf inspector is for.
Select the brush face and bring up surf inspector. Type the name panel1 in the group field as shown in Figure 4 below and click the Apply or OK button.
|
|
Figure 4: SinEd: Setting the group field in surf inspector
|
Save your map and compile it. Now, all you need to do is write this simple script:
waitForPlayer
wait 5
@panel1 damage 11
end
Launch the game and load the map. Don't shoot the brush face, just wait for 5 seconds and the brush face's "computer panel" texture will change to the "broken panel" automatically.
Note: A brush face does not tesselate when damaged by the script.
A few things to keep in mind when using this effect:
- For best results, the "Next Animation" texture should be the same size as the original texture. If it isn't, it will be scaled to fit the brush face size.
- If the "Next Animation" texture is the same size as the original texture, the alignment, scale and rotation values of the original texture are preserved in the next texture.
- Do not make the "Next Animation" field of the original texture point to a texture which has its own "Next Animation" field set by default otherwise QBSP3 will refuse to compile.
With what you learned above about damage and group names, you should be ready to learn how to make a brush face produce other cool effects in the following mini-tutorials.
|
|
Damage induced light change mini-tutorial:
|
What's in a name right?... Well for group names, it can make a difference. In the previous tutorial, you learned that group names are used to give a brush face a name you can refer to in a script. But there's more to group names than just that.
By using certain special letters at the beginning of the group name followed by a number, you can make a light emitting brush face blink and change its amount of emitted light when damaged.
First, here's the list of the special letters and the effect they produce:
|
Special Letter
|
Effect
|
O
|
turn emitted light Off
|
Q
|
reduce emitted light to a Quarter of its original value
|
H
|
reduce emitted light to Half of its original value
|
S
|
make emitted light blink Slowly
|
F
|
make emitted light blink Fast
|
Info courtesy of Mark Dochterman, Ritual Entertainment.
|
|
Then, the letter or combination of letters must be followed by a number*. This number has no particular meaning other than to signify the end of light control character string and give the brush face a unique group name. Please note that I used upper-case letters in the table above only to make them stand out visually: case doesn't matter at all for special letters in the group name.
*Note: You can also use any letter other than O, Q, H, S or H to terminate the control string but using numbers is simpler, more convenient and avoids confusion. So I recommend sticking with numbers to terminate these special letters in group names.
So an actual example of a group name using this naming convention could be something like:
qo1
qo : are the light control letters portion of the group name (quarter light, then light off).
1 : is the unique ID number in the group name for that particular brush face.
The most current and obvious use for this feature is, of course, a wall or ceiling light fixture that goes out when shot. This, combined with a texture change on the brush face makes for an interesting effect, not to mention fun for the player. So let's make one.
First, make a small rectangular room any size you want (256 x 256 x 256 is good). Load the chemical texture folder and select the texture li_chem01. Draw a 32 wide by 64 long by 8 high brush and move it so it's flush with the ceiling. Align the texture if necessary.
Open the surf inspector window and move it so it doesn't hide your texture selection window as seen in Figure 5 below:
|
|
Figure 5: SinEd: Setting the parameters in surf inspector
|
Do the following steps as illutrated in Figure 5 above:
- Select the bottom face of the brush in the Camera view and do a Middle-Click on that face to grab it (this makes sure all the alignment values are stored in surf inspector).
- Ctrl-LeftClick on the texture named li_chem01_brk in the texture selection window.
- Set the damage, weak and light surface flags.
- Set the Radiosity field (or the Direct Value field if you prefer) to 5000.
- Set the Group name to sq1 (slow blink, quarter light, unique ID no: 1).
Hit Apply or OK. Those are the flags and fields that must be set to make a brush face change to the next texture and change its emitted light when damaged.
Note: You don't have to set a "Next Animation" to make a brush face change its light level or style. I chose to combine both effects for this tutorial because it looks more realistic for a light fixture to "break" with a light level change.
Save your map and compile it. Launch the game and load the map. Walk up to the light fixture, look up and shoot it once. Then shoot it a second time.
|
|
|
Figure 6: First shot - texture change & slow blink
|
Figure 7: Second shot - quarter light level
|
The first time you shoot the fixture, the texture will change from li_chem01 to li_chem01_brk and the light will blink slowly as represented in Figure 6 above.
The second time you shoot the fixture, the light will stop blinking and the emitted light level will step down to a quarter or its original value (thus 1250) as represented in Figure 7 above.
So even though these special letters might seem complicated at first, once you understand the basic principle, they are really easy and fun to use. There's a few things you should keep in mind though:
- Brush faces with the same group name are all tied together. If you shoot one of them, they will all change states.
- The unique ID number after the control letters is not required as such for the effect to work: if I had given the brush face the group name sq instead of sq1, it would have worked just the same. It is simply a safety measure to keep your lights separate.
- Keep track of all the light fixtures that use the same control letters which you want to keep separate. Name them in sequence as you create them (for example: fo1, fo2, fo3, etc.).
Now there's another important thing to mention here. The damage inflicted to a brush face is cumulative. Why is this important? Because in principle, you can use as many control letters as you want in any possible combination. BUT... remember, the weak surface flag sets the required amount of damage to inflict 11 points of damage for each event. AND... The Magnum pistol inflicts more than 11 points of damage per shot. I'm not sure exactly how much but let's say it's 20.
The consequence of this is that the second and third pistol shots will trigger 2 events at once if the weak flag is used:
- First pistol shot: 20 points damage. 11 points are used to trigger the first event, 9 points cumulated.
- Second pistol shot: 20 points damage + 9 cumulated = 29. 22 points are taken to trigger 2 events at the same time, 7 points cumulated.
- So on and so forth...
This is why using more than 2 control letters for light fixtures doesn't work well with player induced damage. Using the normal flag might seem like the solution but having a light fixture that needs 5 or 6 pistol shots to break is rather silly.
So for light fixtures, the solution is to limit yourself to group names with 2 control letters maximum which should cover most of your needs anyway. For more sophisticated needs, you would have to make the light fixture brush a func_scriptobject, make it respond to damage with the ondamage command and include a "@groupname damage 11" command in the scriptobject's thread after the pause command. But this is way beyond the scope of this tutorial.
|
|
Damage induced triggering and thread calling mini-tutorial:
|
In the previous tutorial, you learned that using special letters in the group name enables a brush face to trigger any number of lightstyle changes to its own surface. But, as if that weren't enough, there's even more to to the naming scheme than special letters.
By adding an underscore at the end of the [control letters - unique ID no.] combination, you signify to the group name that what follows the underscore is either the targetname of an entity or the name of a script thread.
Ironically enough, of all 3 possible brush face damage features, this one is the simplest to use but knowledge of how to use the previous features was necessary to get to this one. Why? Because in order for this feature to work, the light* surface flag must be set (in addition to the mandatory damage and weak or normal surface flags) and the group name must begin with a special letter.
*Note: In the case where you want the brush face to trigger an entity or call a thread when damaged but you don't want a lightstyle change, just don't set any Radiosity or Direct Value for that face in surface inspector.
The most typical and simplest use of this feature is a ceiling light fixture that throws sparks after it goes out when shot. This, combined with a texture change on the brush face and a lightstyle change as illustrated in the previous tutorials makes for an really cool effect. Just keep in mind that this is only one example of this feature and that the possibilities are really endless.
So for this, let's start from the map we made in the previous example and add a few things to create this effect. First, add a trigger_randomparticles entity and place it right underneath the light fixture's bottom face as shown in Figure 8 below:
|
|
Figure 8: SinEd: Inserting and placing the sparks generator entity
|
To optimize the realism of the effect, move the trigger_randomparticles entity 4 map units into the light fixture brush. This will locate the actual origin of the sparks so they look like they're really coming from the surface of the fixture. Then, set the entity's key/value pairs and spawnflags to the same values as seen in Figure 8 above:
- angles = 180 0 0 : Orients the particles to be thrown downward.
- count = 50 : Sets the amount of thrown particles to 50. Not essential but looks better.
- targetname = sparks1 : This is essential to be able to trigger the entity.
- BRIGHT spawnflag set : Makes sparks brighter. Not essential but looks better.
Now we have to change the group name of the light fixture's brush face so it will trigger the trigger_randomparticles entity when shot. Select the brush face and bring up surf inspector:
|
|
Figure 9: SinEd: Setting the group name to target the sparks generator entity
|
All you have to do now is change the group name to s1_sparks1 as seen in Figure 9 above. Don't change anything else! Hit Apply or OK. Everything is now ready for the effect to work. But did we just do here? Let's take it step by step:
- First, we changed the special control string from its previous value sq1 to s1. As we've seen before, the letters sq would cause 2 events to be triggered. The first pistol shot triggers the first event (slow blink) and the second shot triggers the second event (quarter light). Here, we don't want this because the second event would re-trigger the trigger_randomparticles entity thereby turning it off. So the control string was reduced to only one event: s for slow blink).
- Second, we added a "_" (underscore) character right after the control string s1. This is essential: it signifies that what comes next is either the targetname of an entity to trigger or the name of a script thread to call.
- Third, we added sparks1 after the underscore which is the targetname of the trigger_randomparticles entity.
Note: Here again, assigning a unique ID number in the control string is not essential to make this work. If I had used the group name s_sparks1, this would have worked just the same. But not assigning ID numbers is an extremely bad habit to get into because chances are you'll want more than one fixture of the same type in a map. Remember: if they all have the same group name, they will all go out and make sparks when you shoot one. So always add an ID number to your group name's control characters.
Save your map and compile it. Launch the game and load the map. Walk up to the light fixture and shoot it.
|
|
|
Figure 10: Sparks thrown from light
|
Figure 11: Sparks expanding
|
When you shoot the light fixture, the texture will change to li_chem01_brk, the brush face will blink slowly and sparks will be thrown from it at random time intervals as you can see in the actual game screenshots in Figure 10 and 11 above. One of the nice things about the trigger_randomparticles entity is that it produces a matching electrical spark sound by default.
Now you can also make the brush face call a thread instead of triggering an entity. The syntax of the naming scheme for the group name is exactly the same for this. So, for the next example, all you need to do is change the sparks1 part of the group name to the name of the thread to call.
Select the brush face of the light fixture once again, bring up the surf inspector and change the group name from s1_sparks1 to s1_sparkthread1. Hit Apply or OK. Save your map and compile it. Write the following script:
waitForPlayer
end
sparkthread1:
trigger $sparks1
end
Launch the game and load the map again. Shoot the light fixture. You will get exactly the same result as in the previous example. I just used another method to do the same thing simply to demonstrate the ability for the brush face to call a thread when damaged.
So that's about it for this feature. Just a few things you should keep in mind though:
- You can make a brush face trigger an entity or call a script thread when damaged but not both at the same time.
- If you have an entity and a script thread which both have the same name and the group name is set so it points to that name, the entity will take precedence and will be triggered when the brush face is damaged but the thread will not be called.
- If you have several tasks to have accomplished when the brush face is damaged (such as triggering several different entities), make the group name point to a script thread and trigger those entities from within the thread like in the above example. You'll save yourself a lot of headaches that way. Let the script work for you.
Hopefully by now, "damageable" brush faces hold no secret for you anymore. Have fun making those fixtures and don't forget that experimentation is the road to know-how. If you like, you can download an example map which contains samples of all the things I covered in the tutorials.
|
|
|