Post tutorial Report RSS [Black Mesa] 50. cal machinegun (Player and NPC controlled)

How to set up a 50 cal. machinegun in Black Mesa (Source).

Posted by on - Intermediate Mapping/Technical

Here is how you make a player controlled and an NPC controlled 50 cal.

Player Controlled 50 Cal. Machinegun
1. Create a prop_dynamic.
Name : 50cal_model
Model: models/props_marines/50cal.mdl
Tag Flags: Start with Collision Disabled

2. Create a platform or prop (like a ammo crate), which is about 32 units high and put the 50 cal on top of it. At this height, the player and enemy grunts can use it standing.

3. Create a brush with the "triggertool" texture. This is the field in which the player has to stand to control the turret, so make it big enough for the player to stand in and put it behind the gun handles. Make it into trigger_multiple.

Name: 50cal_control
Tag Flags: Clients (should be on by default)

4. Create a new brush with the "toolsinvisible" or "nodraw" texture and make it: h: 16, w: 16, l:64 and put it inside the 50 cal model. Make sure it covers the entire length of the gun. Make this into a func_50cal. Now align the origin of the brush to the middle of the model (right above the tripod, there where the turret can turn)

Name: 50cal_gun
Parent 50cal_model (the model will copy the movements of the func_tank this way)
Contol Volume: 50cal_control
Tag Flags: Controllable, Non-Solid

Make sure the brush has the same angles as the model!

5. Then connect the animations of the 50cal model to the yaw and pitch movement of the func_50cal by entering these values:
Gun Base Attachment: aimrotation
Gun Barrel Attachment: muzzle
Gun Yaw Pose Param: aim_yaw
Gun Pitch Pose Param: aim_pitch

6. Now you'll need to set the fire properties. You can experiment with different settings, but here is how I've set up mine:

Rate of Fire: 10
Damage per bullet: 15
Bullet Accuracy: Medium Cone

7. More experimenting can be done with the movement of the turret, by setting the Yaw and Pitch. Yaw controls all horizontal movement and Pitchs is for all vertical movement. Range will determine how far you can turn the gun and rate controls the speed of the turn.

My settings of choice:
Yaw rate: 45
Yaw rang: 120
Yaw tolerance: 15
Pitch rate: 45
Pitch range: 15
Pitch tolerance: 5

8. And you're done! Go ingame and see if the turret behaves like you want it to. You might want to tweak some fire and movement properties to make it perfect for your setting. In Hammer it should look something like this now:

User Posted Image

NPC Controlled 50 Cal. Machinegun
To make NPCs use the 50 cal. you'll need to make a few additions and changes. First, create a 50cal by using the tutorial above. If you make a second 50cal like I do, make sure you use unique names for this second gun. For this my tutorial I'm using a prefix: npc_50cal_gun. Note that you don't need to do this for the Attachment and Pose parameters of the func_50cal. If you're not making a second 50cal, leave out the npc_ prefix.

1. Create a human_grunt and put him right behind the gun in firing position.
Name: npc_50cal_grunt
Tag Flags: Long Visibility/Shoot

2. Between the Grunt's boots, place an info_target.
Name: npc_50cal_manpoint

This is where the grunt will stand when he shoots the 50cal. Make sure it has the same view angle as the gun itself.

3. In the func_50cal add the following:
Firing Persistence: 2
Firing Persitance2: 1
Damage per bullet vs player: 10
NPC Man Point: npc_50cal_manpoint
Player Lock time: 1
Tag Flags: Only Direct, Controllable, NPC Controllable, Non-Solid

4. In the trigger_multiple (the control field):
Tag Flags: Clients, NPCs

5. Now create a trigger_auto. Set the following Output:
OnMapSpawn > npc_50cal_grunt > FindNPCToManTank > npc_50cal_grunt

This will cause the grunt to take control of the 50cal at the start of the map. You can also set this up with a different trigger if you want him to start using the turret at a given time.

If you start the map now, the grunt will start using the turret after he sees you. There is only one draw-back. If you rush towards him and stand behind him, he'll hold on to the turret, not able to fight you anymore. We want him to let go off the turret and fight the player with his mp5, once the player gets too close. Here is how that's done:

6. Create a brush with the toolstrigger texture and make it a trigger_once. Put it in front of the gun, so the player will touch it when he gets close. You can also create brushes along the side of the grunt's position in case the player flanks him.

Create the following Output:
OnTrigger > npc_50cal_gun > ForceNPCOff

7. All done! Compile and give it a try. Hammer should look something like this:
User Posted Image

Hope these tutorials were helpful. You can download the example VMF here:
50 Cal Tutorial

Post comment Comments
SCP-3141
SCP-3141 - - 5 comments

Great tutorial!

Reply Good karma Bad karma+4 votes
Hezus Author
Hezus - - 561 comments

Thanks! :)

Reply Good karma+2 votes
Guest
Guest - - 687,512 comments

الاسود. الألعاب الوزارة الدفاع.

Reply Good karma Bad karma+1 vote
LastLifeOfficial
LastLifeOfficial - - 979 comments

Thank you :D

Reply Good karma Bad karma+1 vote
Stanlyhalo
Stanlyhalo - - 7 comments

Can't download also Step 5 of player controlled 50cal is confusing to me.

Reply Good karma Bad karma+1 vote
Guest
Guest - - 687,512 comments

This comment is currently awaiting admin approval, join now to view.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: