A SWEP base for making ‘realistic’ SWEPs (or anything you want really). This is more geared towards developers, but if you’re not a developer I don’t care if you use it or not. It comes with some spiffy features, which are listed below. Under garrysmod/addons/lua/weapons/weapon_rg_example/shared.lua there’s an example SWEP that shows you how to use all of the stuff.
The longer you hold fire, the less accurate and more unpredictable your gun becomes. Crouching, aiming down the sights = more accurate. Jumping, running = less accurate. Just like Counter-Strike. Spiffy. This has been done before of course, but I added a few things that I think make it cool and unique or something.
[‘Realistic’ Bullet Physics]
Bullets aren’t just tracelines anymore. They travel with their own velocity and acceleration. You can give them gravity so that they travel in an arc. This has the delightful side effect of making sniping more challenging for the sniper and less sucky for the sniped.
Note: The bullets work pretty well in singleplayer, but I don’t know how well they work in multiplayer. Bullet prediction is done serverside, so things might get laggy or slow if there are too many people firing. This is something to test out.
This is surely a necessary requirement for any ‘realism’ buff. The SWEP base comes with four default fire modes: Semi-Automatic, Fully-Automatic, Three-Round Burst, and Grenade. Defining a the firemode’s a gun is capable of is as simple as adding/removing some strings from a table. As an added bonus, you get to see a cute little icon next to your health telling you what firemode you’re in.
This is probably the niftiest feature of the whole SWEP. I added a type of framework thingy that allows you to define your own firemodes from outside the base SWEP. You can do pretty much anything in these firemodes- it’s pretty open ended. Check out the example SWEP to see what I mean.
[Cool ‘Realistic’ Effects]
You get six muzzle flash effects and three shell ejection effects. I made the muzzle flash effects after watching videos of various guns on youtube, so apparently they are ‘realistic.’ I also added little details like sexy crosshairs, raising your rifle to view through the scope, plus a little sound/fadein when you zoom in or out. Oh, and did I mention that you can have an arbitrary amount of scope magnification levels to switch to?
[Works With NPCs]
Well, it works with citizens at least. Combine soldiers just point at you and tremble. But citizens know how to use it very well, and it looks cool too (if you can ignore their hands clipping the world model). To spawn a citizen with the example swep, type “npc_create_equipment weapon_rg_example” in the console, then look at the ground and type “npc_create npc_citizen.” It should also work with any other gun-wielding friendly.
I suppose that depends on your definition of “well.” I did put comments in this SWEP more than I usually do though, so other people can look at it and hopefully get an idea as to wtf I am doing. Plus, it might make it a helpful example for Lua newbs to mess with (just please don’t pick up any of my horrible programming habits!).
There’s probably a bunch more that I forgot already. See for yourself if you wish.
Extract to C:\Program Files\Steam\SteamApps\YOUR STEAM NAME\garrysmod
This is very much a work in progress. And there’s always something to do…
- Clean up code
- Add custom ammo types
- Develop/Test clientside bullet prediction
- Get it working with other NPCs (probably impossible)
- Make a cheasy FPSbanana weapon pack using this as a base
- Something else, I just forgot what it was.
Teta_Bonita: 99% of the coding
Garry: Various bits of Lua code that I filched from the garrysmod GCF
NightEagle: Looked through his CSE pack for ideas when I got stuck; Certain variable names xD
Wang - Chung: Sexy parabolic scope sight
-Initial beta/alpha/omega/whatever Release
Screenie: (same one from the download link )
Here’s a video, showing off the SWEP base and a custom firemode I added called “Underwater Shotgun”:
The phrase “I don’t know why this works, but it does” appears at least twice in the code commentary.
You may modify/distribute this to your heart’s content, as long as you give credit where it is due.
Let me know what you think about this. Is it useful? Does it rock? What about it rocks? Does it suck? What about it sucks? What do you want added? Removed? Is it too confusing? Found any bugs? etc…
Also, I’m thinking of making a SWEP pack using this. Something involving the Soviet Union. Because the Soviet Union is badass.
Damn, I just looked at the code from TWMCSWEP and found out that it does everything my SWEP does, only better. :uhoh: Back to the drawing board…