FA:S weapons fix for DarkRP.

Hey, whats up everyone? I want to first start this thread off by saying this is my first post and I just want to say thank you to everyone in advance for helping me out. So, here’s the deal… I have a Gmod DarkRP server and I’m using the FA:S weapon pack. The problem I’m having is that all the weapons are shooting threw all map props (downtown_v4c_v2) and threw most props (including the ones people build with mostly) and this is really disrupting RP game play. Since FA:S is a M9K weapon base weapon pack I thought that M9KDisablePenetration 1 would work, but apparently it doesn’t. Can I get some help from people to teach me step by step how to disable the guns shooting threw map walls/doors and props please? Thanks in advance guys!


Oh, I see. I have always thought it was, sorry for the miss-info.

How is bullet penetration disrupting RP? That should make it more realistic…

Because FA:S’ bullet penetration system is horribly unbalanced and goes through many props (barring some types) with no issue, and from what I’ve experienced, no obvious damage reduction.

Well my server has a certain type of game play that mixes in realistic and unrealistic game play to optimize the game play. I want a fix for this (bullet penetration) because players are spending a lot of time building bases and then all of a sudden when they get raided it’s like they did all the effort for nothing because no matter how good they made their defense the raider/s can just spam bullets rite threw props. Also if you are just chilling inside your base their is always a fear in the back of your mind that someone can just run up to your base and just start shooting threw your walls. This bullet penetration is really breaking the fabric of game play in my server.

If they’re able to shoot right *through *walls using FAS2 then *there *should be a console command to alter the behavior of the swep-base. If *there *isn’t an “easy” ( read as: No console command or other configuration method available ) solution, you can always extract the gma file and alter the Lua ( don’t forget to remove the gma file from your collection so the server doesn’t automatically download it again and overwrite your changes ). Instead of throwing the original gma into the recycle bin ( ie deleting it ), you could move it to a different folder.

I’d consider the extraction method if people are worried that their bases are going to get raided because people can spam-shoot whereby the bullets travel through too many props instead of stopping sooner.

Well, there is no preset config commands to disable the bullet penetrations which is why I made this thread. My knowledge of LUA is only little and I can’t find the actual coding to disable it. Even if I were to find the coding for it I wouldn’t know what to do which is why I asked for step by step instructions from someone to help me with this if possible.

I downloaded it ( http://steamcommunity.com/sharedfiles/filedetails/?id=180507408 ) to look through the code… in lua/weapons/fas2_base/ I found:

		if not NoPenetration[trace.MatType] then
			dot = -Dir2:DotProduct(trace.HitNormal)
			ent = trace.Entity
			if self.PenetrationEnabled and dot > 0.26 and not ent:IsNPC() and not ent:IsPlayer() then

in the bullet code. That means you can set _w.PenetrationEnabled = false; when a weapon is created using OnEntityCreated. You could use Player Switched Weapon or so to set it there if you prefer, etc… Then penetration will be non-existent.

Another option is running through the NoPenetration table and setting the values to true for k, v in pairs… although, because it is a local variable in the bullet code, you may get away with creating a global table and it should over-ride because it’s defined local to file, not local in the function.

However, setting SWEP.PenetrationEnabled is by far the easiest and most viable. I hope this is enough to go on; let us know how it goes.

Okay, I got good news and bad news for myself for the last post. Good news is that apparently someone has found and is helping me with this problem =D (which I highly appreciate). Bad news is that you guys have completely underestimated how bad I am when it comes to more advances coding like this. I can do stuff like add jobs, add entities, configure config files, but when I go the next step up in coding (like this stuff) I have no idea what to do. The very idea that I need to get every space and comma correct frightens me dearly. I also want to add that I’m not here to just try to freeload off people. I’m currently going to start studying LUA at least a couple hours a week to slowly improve. So, here’s what I ask of Acecool, can you tell what I should try first and tell me how to do it step by step (all the coding and where the files are and lines of code are) and I will implement what you told me in my server files to check to see if it works? Thanks again in advance Acecool. =D =D

This is simple… You’re basically modifying a variable in a hook; 3 lines, 5 if you believe this should use 3 lines for the if, 7-9 if you’re an airy coder…

hook.Add( "PlayerSwitchWeapon", "DisableOverPenetration", function( _p, _oldW, _w )
 	if ( IsValid( _p ) && IsValid( _w ) ) then _w.PenetrationEnabled = false; end
end );

If it even deserves it’s own file… SHARED:

So I should just make a new LUA file in my autorun folder and add that?

edit: I tested this out on my server. Works great! Thanks Acecool.

Yeah. You can either add it to addons/ which “create” virtual directories which merge with garrysmod/

or add it to lua/autorun/

or to your game-mode as long as it is shared…

Another method would be to use hook.Initialize and go through all of the SWEP tables altering the data there which should prevent any issues too and wouldn’t require any additional work. The thing is, setting a var when a player switches to it is lightweight, running a loop through hundreds of weapons isn’t terribly bad but when compared to how many times a player may switch weapons in a game and it’s distributed over time, it may be the better option…

Also, because I’m not overly familiar with FAS2, I don’t know if Penetration is altered within the SWEP so setting in when you switch is good but could be flawed in that regard ( both solutions would be up the creek )…

Here’s the second example:

hook.Add( "Initialize", "PreventOverPenetrationAndRicochet", function( )
	for k, _tab in pairs( weapons.GetList( ) ) do
		_tab.PenetrationEnabled	= false;
		_tab.RicochetEnabled	= false;
end );

I did some tests… altering the table in GetList will modify it for good, so … That disables Ricochet too, just found that in the code after the penetration portion.

First one with the other bit added:

hook.Add( "PlayerSwitchWeapon", "DisableOverPenetration", function( _p, _oldW, _w )
	if ( IsValid( _p ) && IsValid( _w ) ) then
		_w.PenetrationEnabled	= false;
		_w.RicochetEnabled	= false;
end );

Honestly, the loop method is likely to be the better method to change the vars right away… I don’t think that they’re reactivated anywhere else ( because why would they be ) so… Whichever you use, stick it into shared file. If you want ricochet then comment out the line to keep default preferences

All I know is that the first method you gave me is working good. To be honest I barely understand a lot of what your saying but I really appreciate the extra help. I would say I’m good to go. Thanks again!

note: I’m going to be making another thread in this section about setting a custom job for only a specific player or admin (not all admins). If you can help out, please do again! Thanks!