Metrocop

Tutorial collection, comprehensive listings on main site.

Metrocop

Postby Tutorial on Tue Mar 08, 2005 12:16 am

category
General Half-Life 2/Scripting

description
Looks at setting up our favourite cop. Explains how to make him shove the player also.

keywords
npc, metro, cop, npc_metrocop, ai_goal_police, goal, police, combine.

Ah, the lovely npc_metrocop, oppressing people and kicking dogs, and his lovely ai_goal_police.

You'd think the two would go hand in hand, that you could just give the npc_metrocop an ai_goal_police to police, and all would be well. He'd be standing there, happily pushing you away and occasionally beating you with a stunstick.

You'd be wrong. They're awkward little buggers. In fact, if you want your npc_metrocop to push the player, as they do in the initial levels of HL2, he doesn't even need an ai_goal_police.

I'll explain.

ai_goal_police gives an npc_metrocop a certain area to guard. When the target enters this area, the npc_metrocop will issue up to three warnings, telling the target to halt. Then, they'll commence the beatings, chasing the target if possible.

I have not found any way, however, to allow the npc_metrocop to still push the player away from himself whilst still within the confines of an ai_goal_police.

To set up your ai_goal_police:

name is whatever you wish to call your ai_goal_police. This is needed.

parent can be left blank.

pitch yaw roll (Y Z X) should be set to the direction you wish the npc_metrocop to face.

radius can either be set here, or dragged out using the helpers. This is the area the npc_metrocop will police.

target is the target you wish to police. If you want to police the player, as you most likely will, set it to !player.

To get your ai_goal_police working, you need a few more entities. Obviously, you need an npc_metrocop with a suitable name. You can set the flags on this npc_metrocop however you wish; I'd advise only arming him with a stunstick, however.

You also need a trigger_once of some description. To create this, make a brush through which the player or target can walk. I'd suggest using the trigger texture for this, so you can easily see it when editing. Tie the brush to trigger_once, and set an OnTrigger output to target the npc_metrocop, with the TargetInput of SetPoliceGoal with the Parameter of the ai_goal_police's name.

I'd recommend also sending DisableKnockOut to the npc_metrocop.

Finally, you'llll need an env_global or two. You'll need to set at least one to have the Global State to Set of Gordon Pre-Criminal, with Initial State equalling On and the flag Set Initial State also on.

If you wish, you can also add an env_global set to Gordon is Invulnerable, depending on whether you actually want him to be beaten to death or not.

Compile and run; when the target moves through the trigger_once, the npc_metrocop will walk to the ai_goal_police and face the direction specified. When the target moves within the radius, the npc_metrocop will threaten it. When the target gets close enough, the npc_metrocop will hit it, and follow if you have allowed it

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

Postby HeadCrab on Tue Jul 05, 2005 9:56 pm

Do you mean that you can't get the metrocop to push the player at all?Because if it is,then I found a way to get him to. I set the target of an ai_goal_police to citizen (not player) and found that the cops would push you away with their hands before smacking you...Just thought it might help :)
User avatar
HeadCrab
Regular
Regular
 
Joined: Tue Jul 05, 2005 8:00 pm
Location: To your left. No, your other left!

Postby Generalvivi on Mon Aug 29, 2005 1:00 am

nice find
Generalvivi
Irrational Games
 
Joined: Fri Feb 18, 2005 1:41 am
Location: Boston

Postby ShoGun on Sat Oct 29, 2005 11:17 pm

Doesen't work at all for me :S

Tie the brush to trigger_once, and set an OnTrigger output to target the npc_metrocop, with the TargetInput of SetPoliceGoal with the Parameter of the ai_goal_police's name. <- wtf does all of that mean?

Set that to Ontrigger and what TargetInput to the who?? :?
ShoGun
Member
Member
 
Joined: Sat Oct 29, 2005 10:53 pm
Location: Sweden

Postby The-fox on Sun Oct 30, 2005 12:04 am

ok im gonna try and explain this as good as i can its late night and im tired as hell so it might come out abit....strange with loads of spelling errors anyways what that is that you should first make a trigger_once and have it so that once teh player walks into the trigger_once it targets the npc_metrocop with the output SetPoliceGoal the parameter of ai_goal_polices name is the name the npc_metrocop has i hope i explained this reasonable ....
Sig goes here.
The-fox
Been Here A While
Been Here A While
 
Joined: Wed Mar 09, 2005 7:44 pm

Postby ShoGun on Sun Oct 30, 2005 11:01 am

Thx :P I'll try it again ;)
ShoGun
Member
Member
 
Joined: Sat Oct 29, 2005 10:53 pm
Location: Sweden

Postby Beck on Sat Dec 29, 2007 3:05 pm

Thanks! Worked just how I wanted it too :D
Wheee!
User avatar
Beck
Member
Member
 
Joined: Fri Dec 28, 2007 4:02 pm
Location: Birmingham, UK

Re: Metrocop

Postby chargers5583 on Wed Jul 08, 2009 10:24 pm

Coolio
User avatar
chargers5583
Member
Member
 
Joined: Thu Mar 12, 2009 3:22 am
Location: Home of the CHARGERS

Re: Metrocop

Postby neoviper on Tue Dec 07, 2010 1:41 pm

I got so ridiculously happy when I was able to get my metrocop working right, one of the things I really wanted in my map. Thank you very much good sir.
neoviper
Member
Member
 
Joined: Thu Jan 04, 2007 5:58 am

Return to Tutorials

Who is online

Users browsing this forum: No registered users