Metrocop Shooting Flare

Tutorial collection, comprehensive listings on main site.

Metrocop Shooting Flare

Postby Tutorial on Wed Nov 22, 2006 10:32 pm

category
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)

Image

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!

Image

Broodrooster
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Postby Willy2k on Sun Apr 22, 2007 10:52 am

Ohh, thank you for this wonderful tutorial, it really helped me alot! You are my new god dude!
Image
User avatar
Willy2k
Regular
Regular
 
Joined: Wed May 24, 2006 3:00 pm

Postby Sauce on Sun Apr 22, 2007 2:03 pm

haha, cool :D
Image
Blink wrote:Do you watch porn and decide you don't need to have sex because you've seen the ending? :-D

zombie@computer wrote:what retarded countries measure in stones anyway?
or feet? or inches? Your dick is a lot longer in cms
User avatar
Sauce
Senior Member
Senior Member
 
Joined: Sat Nov 26, 2005 4:36 am
Location: Australia

Re: Metrocop Shooting Flare

Postby joe_rogers_11155 on Fri Dec 11, 2009 8:07 am

hey I'm having a problem with this tutorial. As soon as the red flare spawns from the shooter, I see it appearing right above the cop...then the Ep2 engine crashes. So is there an issue in Ep2 that prevents cops from shooting flares?

All my I/O is set up correctly.

At first I did not add the ai_relationship because i DID want the cop to attack the player. The crash happened. So I added the ai_relationship to see if that fixed the problem. This time, the cop did not attack the player...that's because the cop did not "find" the player since the player was an ally to the cop. So with the ai_relationship still on, I used the console command,

ent_fire flare_cop_1 fireuser1

The cop's OnUser1 triggered the sequence to begin. As soon as the flare spawned from the shooter, the engine crashed.

So can you guys figure this one out for me please? Thanks.
"Day breaks, but decay soon follows." - Ava Winona
Currently developing in radio silence... 99 Bolts
Here's another project of mine... Assault on Overwatch
Are you new to Source SDK? VDC
joe_rogers_11155
Veteran
Veteran
 
Joined: Wed Oct 08, 2008 11:11 pm
Location: United States

Re: Metrocop Shooting Flare

Postby joe_rogers_11155 on Sat Dec 19, 2009 5:55 am

Hey guys I worked with stoopdapoop and came up with a workaround. For some reason in Ep2, the setup does not work correctly. It is mainly due to the "effects/redflare.vmt" inside the env_shooter.

Instead of using "effects/redflare.vmt", do this...inside the env_shooter properties:

Model: "sprites/orangeflare1.vmt"
Render Mode: "World Space Glow"
FX Color: "255 100 100"

That will make a sprite that is colored a pinkish red. Until a better solution can be found for Ep2 users, this will work for you.

As an added special effect, create a very bright light_spot over the area where the flare will be fired. Color it as though it was the same color as the flare and set it to Flicker B, then name it. Make sure the light is off initially. Turn it on when the metro cop fires the flare and it will look like the cop is lighting the area with the flare.
"Day breaks, but decay soon follows." - Ava Winona
Currently developing in radio silence... 99 Bolts
Here's another project of mine... Assault on Overwatch
Are you new to Source SDK? VDC
joe_rogers_11155
Veteran
Veteran
 
Joined: Wed Oct 08, 2008 11:11 pm
Location: United States

Re: Metrocop Shooting Flare

Postby MMmaster on Sat Dec 19, 2009 8:34 am

Use an env_flare instead of an env_shooter shooting an effect.
http://developer.valvesoftware.com/wiki/Env_flare

parent the env_flare to a func_tracktrain and move it along a shoot trajectory like path or simply,
parent the env_flare to a func_physox and use a trigger_push to send if flying in the desired direction.

I use the second method and it works perfectly, although I think it is more resource consuming then the first one as it involves a physics entity flying, falling, ...

I am sure you can put this together.
MMmaster
MMmaster
Member
Member
 
Joined: Fri Apr 17, 2009 2:17 pm

Re: Metrocop Shooting Flare

Postby joe_rogers_11155 on Sat Dec 19, 2009 8:31 pm

MMmaster, that's a good alternative. Make sure these elements are parented to the metro cop that will be firing the flare so the flare appears to emanate from the cop's gun.
"Day breaks, but decay soon follows." - Ava Winona
Currently developing in radio silence... 99 Bolts
Here's another project of mine... Assault on Overwatch
Are you new to Source SDK? VDC
joe_rogers_11155
Veteran
Veteran
 
Joined: Wed Oct 08, 2008 11:11 pm
Location: United States

Return to Tutorials

Who is online

Users browsing this forum: No registered users