Dual Chaingun

- By ShadowWolf
This tutorial was submited on Dec 18, 2005.

[This tutorial was originally posted here. That forum is long gone, but it's actually a useful tutorial; I have preserved it here, unedited except for resized images. See also Tutorial: Mounted Guns, as the union of that tutorial and this one can create a very nice effect. --Rae]

In this tutorial we will create a defensive turret with 2 chainguns wich can be used for both ground and air units. It was inspired by the Chaingun Turret in Command & Conquer: Generals. Please note that this turret will not be able to do any damage but that is only because I did not like to fake the whole thing with some trigger that kills the enemies.

So even if the turret does not work this tutorial will teach you how to make a turret that you can control using the Game_ui entity (rotating, tilting and shooting). Oh and as a warning to users with a low-end computer, this turret will fire 20 shots/second and throw out the shells for each bullet wich makes a total of 40 entities per second.


1. The base

Lets start from creating the base for our toy here. Make it a 128(x)x128(y)x8(z) cylinder with 32 faces. In some cases this will immediately fail and if you want to avoid trouble when you try the map, texture the whole cylinder with a texture. If there is even one face wich is not correctly textured (often a solid color instead of the texture) delete the cylinder and create a 256x256x16 cylinder with 32 faces and if it works then scale it down to 128x128x8. If it keeps failing, then try with 24 faces.

We will also need some brush to keep the chainguns in place, visually only ofcourse, so I created a brush in the center that is 48(x),16(y),48(z) and pulled the top vertices a little closer to eachother as seen on the picture below (grid size is 4):



Now group the 2 brushes in our base and tie them to func_rotating with the following properties:

Name: turret01_base
Max Rotation Speed: 10 (20 or 30 for a fast turret)
Rotating Sound: vehicles/tank_turret_loop1.wav


2. Chainguns

Now it gets a little more complicated. We need to create 2 brushes on each side of the center brush on our base (see the image below), my boxes are both 56(x), 20(y), 24(z). Group them and tie them to func_rotating and give them the following settings:

Name: turret01_barrels
Parent: turret01_base
Max Rotation Speed: 10 (20 or 30 for a fast turret)
Rotating Sound: vehicles/tank_turret_loop1.wav





And now for the flags, took me some time before I learned how Hammer sees the X Axis and Y Axis checkboxes. Here is how to figure this one out: Find the view where (if the rotating brushes would rotate) it would rotate around the origin in the way you want it to. We want it to tilt up and down, so on my screen it is the Side view that is correct. Hard to see how this would work in your head? Try to imagine how it would rotate if you would put a pole straight trough the origin seen from your view and you will figure it out. Anyways, when you have found your view look at the name of the view where it in my case says “side (x/z)”. From this we can see what flags need to be checked: if there is a x in the name (wich there is in my case) the X Axis checkbox must not be checked. Same thing if there is a y in the name. Do you see now why we did not check the X Axis and Y Axis boxes on the base? It rotates correctly seen from the Top View and it has both X and Y in the name: “Top (x/y)”.

Now we will work with cylinders again and if you do not remember what needs to be done to check and repair the broken cylinders please read it again from the first chapter. Create one cylinder with the size: 32x32x64 and give it 8 faces. Resize it to 4x4x64 after you have tested it for texture bugs. Rotate it so that you can attach it to the turret the correct way. Before we do attach it we need 2 more cylinders, again, create a cylinder 32x32x4 with 8 faces and resize it to 16x16x4 and rotate it in the same way you rotated the long cylinder. Now copy the cylinders we just made and create what you can see on the pictures below (grid size is 2):





Group both of the chainguns separatedly and tie them to 2 func_rotating with the following properties:

Names: Chaingun01 and Chaingun02
Parent: turret_barrels
Max Rotation Speed:1800 (5 rounds per second)
Rotating Sound: ambient/machines/engine1.wav

Once again you need to figure out the X Axis and Y Axis checkboxes, on my example it is: the Front View so we need to check X Axis since there is a y in the name. Also, check Acc/Dcc.

3. Effects

Add 2 env_sprite entities at the end of the top most barrel in our chainguns, that will be where the flame comes out when you fire.

Give them both the settings:
Name: turret01_sprites
Parent: turret01_barrels (not the chainguns)
Sprite Name: materials/sprites/ar2_muzzle1.vmt

You can add env_shooter entities where the shells and bullets should befired from. But no matter what you shoot it seems to do no damage to anything so I wont include that in this tutorial. All the shells and bullets can be found under the Weapons folder.

As for the sounds, add a ambient_generic entity somewhere near the turret and fill in this information:
name: turret01_sound
sound name: weapons/ar2/fire1.wav
source entity name: turret01_base


4. Control The Beast

Now here comes the most complicated part, the controls. Create the following entities somewhere in the map (near thet turret would be good): Game_ui, Logic_Case, Logic_Case, Logic_Case and Logic_Timer. And here is the list of the settings for the entities:


Logic_Case #1:
name: turret01_rotate
case 01: -1
case 02: 0
case 03: 1

outputs:
OnCase01, turret01_base, StartForward
OnCase02, turret01_base, Stop
OnCase03, turret01_base, StartBackward

Logic_Case #2:
name: turret01_tilt
case 01: -1
case 02: 0
case 03: 1

outputs:
OnCase01, turret01_barrels, StartForward
OnCase02, turret01_barrels, Stop
OnCase03, turret01_barrels, StartBackward

Logic_Timer:
name: turret_timer

outputs:
OnTimer, turret01_sprites, ShowSprite
OnTimer, turret01_sprites, HideSprite, ,0.05
OnTimer, turret01_sound, PlaySound

Logic_Case #3:
name: turret01_fire
case 01: 1
case 02: 0

outputs:
OnCase01, turret01_timer, Enable
OnCase02, turret01_timer, Disable

Game_UI:
name: turret01_ui

outputs:
PlayerOn, chaingun01, StartForward
PlayerOn, chaingun02, StartForward
PlayerOff, chaingun01, Stop
PlayerOff, chaingun02, Stop
Xaxis, turret01_rotate, InValue
Yaxis, turret01_tilt, InValue
AttackAxis, turret01_fire, InValue

Add a trigger brush or a button or whatever you like to activate the turret and give it the outputs:
OnEndTouch, turret01_ui, Deactivate
OnStartTouch, turret01_ui, Activate



That would be all, thanks for reading. And enjoy experimenting with your new knowledge!

Download the .VMF:

http://www.editlife.net/files/maps/example/chaingunvmf



Still need help? Ask your questions in one of our HELP FORUMS
Post A Comment
Name:
Email: Links Not Allowed In Comments
Comment:
What is the capital of France? Need Help?
Comments
Nick - Dec 1, 2007
how can i make this kill people?
Fletch - Aug 8, 2007
Wait don't worry about the last comment. I figured out that if you deactivate the
game_ui to start with then activate it by pressing a button, it works perfectly. Thanks again for the great tutorial!
Fletch - Aug 6, 2007
Very nice. I downloaded and compiled for CS:S, after making a few changes (fires lasers to kill people :D). The problem i am having is when i try to, for example, add a bot in to test it out on. As soon as i add the bot, CS:S crashes. Any ideas? Thanks
Shifteh - Mar 31, 2007
Hello by know you have wonderd back here wondering why the hell it crashes each time you exit the gun.. well Some idiot didant relise Game_iu crashes on deactivation, so in the trigger_multiple change the output that makes the game_ui deactivate to deactivating the timer instead that way it does not crash YAH :D BTW Nice
firemarshal - Dec 7, 2006
ok it works good for me, the only problem is when i try to get out the whole game freezes and exits? how mai sposed to get out form the gun?
MBD - Nov 10, 2006
Not exactly the best format written in, but take it one at a time. And relax, it's only a map :)~
[6 extra comments]
All original content ©2006 EditLife.net. All Rights reserved. All files property of their rightful owners.
Get Firefox! Get Thunderbird! Get Notepad++!