General Half-Life 2/Scripting
description
Get a Metrocop to shoot a flare into the sky.
keywords
metro, cop, shoot, flare, shooting, metrocop, npc_metrocop, police, combine.
In this tutorial we are going to make a Metrocop that shoots a flare.
1. First we need a room with a high ceiling/sky (my map was 768 Units high)
2. when your room is done, make a metrocop with these settings:
-npc_metropolice-
Name: metrocop_flare
Weapons: Pistol
Pistol starts drawn: Yes
Flags:
-none
Outputs:
-None
3. We now have our metrocop, the second entity we make is a scripted_sequence.
You can randomly place it in the map, the metrocop will not walk to the sequence, the cop will stay where he was and then shoot out the flare
Make the scripted_sequence with these settings:
-scripted_sequence-
Name: metrocop_flare_sequence
Target Npc: metrocop_flare
Action Animation: shootflare
Loop Action animation: No
Sync post idles: No
Move to position: No
Flags:
-no interruptions
-override AI
Outputs:
OnBeginSequence Flare_shooter Shoot 0.75
OnBeginSequence Flare_shooter_sound PlaySound 0.75
4. Our metrocop can now play the animation, what we need to do now is make a flare, we will use a Env_shooter to launch the flare.
make an env_shooter with these settings:
-env_shooter-
Name: flare_shooter
Parent: metrocop_flare
Gib Direction (Pitch Yaw Roll): -90 0 0
Number of Gibs: 1
Gib Velocity: 900
Course Variance: 0.1
Gib Life : 2
Model: effects/redflare.vmt
Material Sound: None
Simulate: Point
Gib Gravity scale 0.25
Flags:
-None
Outputs:
-None
5. Now we must place the env_shooter at the right position, select the cop, go to Properties, click the tab "models" and then select the "shootflare" animation from the list.
the cop will now play the animation, you should place the env_shooter somewhere here: (see picture)
As you can see I placed the env_shooter a little bit above the hand (remember that the cop will have a pistol in his hand!)
6. We almost have everything we need, we only need a cool launch sound for the flare, (you can choose one yourself), i used pistol_fire3.wav
Now create an ambient_generic with these settings:
-Ambient_generic-
Name: Flare_shooter_sound
Sound Name: weapons/pistol/pistol_fire3.wav (or something else!)
Max audible Distance: 2500
SourceEntityname: metrocop_flare
Now we are done with the combine, the last thing we need is triggering the sequence, this can be done with a trigger_once or any other trigger, button etc...
7. Make a brush with trigger_once and add this output to it:
OnTrigger metrocop_flare_sequence Beginsequence 0.00
And the final thing, we must make a ai_relationship because we dont want our combine to shoot at us.
Make an ai_relationship entity with these settings:
Ai_relationship:
Subject: metrocop_flare
Target: !player
Disposition: Like
Start Active: Yes
Now we are ready to compile and test the map!
Broodrooster






