Tutorial: Grunts and Guns Last edited 1 year ago2022-10-10 22:55:32 UTC

Download attachment

Remember that rocket launcher in On a Rail? Yeah, you know, the one that was at the end of the tunnel. You had to kill the grunt to get it to stop firing.
Something tells me this is a rather unfair fightSomething tells me this is a rather unfair fight
First thing you need to do is to read Atom's tutorial on Tankrockets. Build a turret using the tutorial and place it in your map. In this example I have used the func_tank entity because you can set the Bullets to None and this saves you having to go into God Mode to test it.

The turret I have used was built from scratch (Using Vertex Manipulation) as I had a particular field gun theme in mind, but you don't have to limit yourself to the func_tank. This tutorial will work with the func_tanklaser, tankmortar or rocket.

Place your func_tank in the map and give it a name. I have used Gun1. The only other thing you have to do is set Active on in its flag properties. Don't set the Controllable flag. I will talk about that later.

Place a monster_grunt behind it and set the grunt properties:
Trigger Target: Gun1 (the name of the func_tank)
Trigger Condition: Death (the reason I haven't set it to 50% is that I had trouble with the tank stopping if the grunt was killed outright on the first shot - sometimes the gun would continue to function). In the grunt's Flag properties check Prisoner as this will stop the grunt from leaving the gun and attacking. you can also check Gag if you want the grunt to stay silent.

Ok, run the map and you should have a functioning gun with a grunt behind it. Shoot the grunt, the gun stops!

If the gun doesn't stop when you kill the grunt, then go over the settings again. If it still doesn't work you can add a trigger_relay and get the grunt to Trigger Target the relay's name, and the relay to target the func_tank, with the Trigger State set to Off. Either way you now have a gun that will target the player.

But now...

What if you want to kill the grunt and then let the player use the gun?

Taking what you have achieved above, copy your tank.
Give it a name of Gun2.
Change the Render Mode attribute to Texture.
Leave the FX Amount set at 0. Set the Controllable flag on, and make sure Active is not checked.
Place gun 2 in the exact same place as gun 1, so that they look like one in all views.
Create a brush and tie it to a func_tankcontrols entity, Set the Tank Entity Name to Gun2 and place the brush so Gun2 will be controllable. Check out the example: The func_tankcontrols is placed at the player end of the gun, but to make it useable a clip brush is added so the player won't get caught on the gun. Also in the initial trial the corpse of the grunt got in the way; Check Fade Corpse in the grunt's properties to fix this.

Note that placing objects on top of each other can create problems if you want to make changes, because it's hard to select the individual guns. A tip is to go to Map -> Entity Report and select the properties of the func_tank you want to modify. The tank will then be highlighted.

Add two env_render entities to your map. For ease of use I put them above and to the right of the gun.

The first env_render:
Name it unrend1.
Target is Gun1.
Set the Render Mode to Texture.

The second env_render:
Name it rend2.
Target is Gun2.
Leave the rest of the settings at their defaults.

Add a multi_manager to your map.
Name it rendermm. With Smart Edit off, add the following keys and values:
unrend1 0.2
rend2 0.2
gun1 0

You will see with Smart Edit off that the Name you gave the multimanager will already be there as targetname rendermm (Smart Edit properties correspond to non-Smart Edit properties).

Click on your grunt, and change his Trigger Target property to rendermm.

So what's happening?

The gun will commence firing when it has the player in range. Shooting the grunt triggers rendermm which instantly switches off Gun1, then triggers unrend1 and rend2. Unrend1 makes Gun1 disappear. Rend2 makes Gun2 appear and Gun2 is flagged as Controllable. The player can now use the gun!
An overview of the entity setup in Hammer. Keeping it neat like this ensures things don't get too confusing.An overview of the entity setup in Hammer. Keeping it neat like this ensures things don't get too confusing.
Just a few things added to this map to make it more realistic: I have added another multimanager, an env_shake and an ambient_generic because the func_tank is set to No Bullets. There is no need to add the ambient_generic if you set the gun to fire something (the func_tank is the only entity that can be set not to fire anything) as it is already included as part of the entity.

Name set to mm2.
Smart edit off and keys and values added for bang, 0 and shake, 0.
Name set to shake.
Name set to bang. WAV File Name set to weapons/explode3.wav.

To get this part of it to work, you need to set Gun1 and Gun2 to Target mm2. That way mm2 will turn the sound and shake on for Gun1 when it fires, and turn it on again when Gun2 is fired by the player.

Thanks to SlayerA, The Handy Vandal and Ramon Talavera for information used in this tutorial.


Commented 16 years ago2008-05-19 22:04:11 UTC Comment #100545
Very interesting
Commented 14 years ago2009-07-06 09:42:07 UTC Comment #100546
I'd recommend that instead of disappearing Gun1 with an env_render and disabling it with the multi_manager, simply use a trigger_relay's "kill target" field to permanently delete Gun1 from the map. You use less entities and then you don't have an invisible func_tank to run into.

But what really bothers me about this process is that you can literally walk right up beside the grunt and begin firing your own invisible gun, all while the grunt is still in control of its own func_tank. I haven't found a way around this, since func_tankcontrols apparently cannot be targeted (they have no name field), and thus cannot be switched on and off with a relay.

I rate it four stars because the method is sound, but it's a bit messy for my tastes, and it leaves something to be desired.
Commented 14 years ago2009-07-22 21:01:45 UTC Comment #100547
I found a much easier way under the turrets flags I checked active and Controllable, so you just place a prisoner grunt(or any other bot) and it will automatically use the turret you don't even have to put the turret name in under target. If you place a node by it other bots that walk up and use it.
I have only tested this in Sven-Coop and Opposing Force.
Commented 14 years ago2009-08-20 05:49:47 UTC Comment #100548
SomeNoob, I don't think that works in Half-Life at least, because I think when I tried that the gun just acted infinitely active, and wouldn't shut off when the grunt was killed. I think what you're describing is just a regular turret with a grunt standing beside it.
Commented 13 years ago2011-03-09 21:54:24 UTC Comment #100549
ok but how can i make it like a security system that i can un render the grunt or something when i want the turret to not shoot
Commented 13 years ago2011-03-09 22:03:27 UTC Comment #100550
maybe try killing it using a trigger_changetarget and the KillTarget attribute?
Commented 13 years ago2011-03-09 22:26:00 UTC Comment #100551
and when i want to turn it back on ?
Commented 3 years ago2020-08-23 11:46:17 UTC Comment #102869
The gun works but it spins around all the time. PLZ help

You must log in to post a comment. You can login or register a new account.