AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [ANY] Bullet Penetration Filter (1.3) (https://forums.alliedmods.net/showthread.php?t=201464)

Sheepdude 11-22-2012 10:46

[ANY] Bullet Penetration Filter (1.3)
 
2 Attachment(s)
Bullet Penetration Filter

Version 1.3 (final)


Table of Contents
----------------------------------------------------
Description
Commands and Cvars
Installation
Dependencies
Changelog
Notes
Download


Description
----------------------------------------------------
Allows server administrators to define bullet penetration rules.
Bullets are prevented from penetrating certain entities.


Commands and Cvars
----------------------------------------------------
Cvars
sm_penetration_version Plugin version.
sm_penetration_players (Default 1) Determines which players bullets can penetrate (0 - any players, 1 - only enemies, 2 - only teammates, 3 - no players)
sm_penetration_geometry (Default 1) Determines whether bullets can penetrate geometry and props (0 - no penetration, 1 - regular penetration)


Installation
----------------------------------------------------
Place bulletpenetrationfilter.smx into the server's /addons/sourcemod/plugins/ directory.


Dependencies
----------------------------------------------------
SDKHooks must be installed.


Changelog
----------------------------------------------------
Spoiler
  • Version 1.3 (27 November 2012)
    -Bug fix: Plugin now blocks damage correctly in the case where a bullet penetrates a non-player entity and continues to penetrate through one or more players.
    -Non-player entity penetration and player penetration are now tracked independently.
    -Added convar sm_penetration_geometry to determine bullet penetration through non-player entities.
    -Changed name of player filter convar to sm_penetration_players for consistency.


Notes
----------------------------------------------------
-The rationale of the plugin is to prevent players from shooting through their teammates when FF is off. This negates the cheap tactic of using your teammates as human shields.


Download
----------------------------------------------------

thetwistedpanda 11-22-2012 12:50

Re: [ANY] Bullet Penetration Filter (1.0)
 
Interesting method! It appears that it would be fairly trivial to also add support in for blocking damage for bullets that have penetrated corners of buildings or thin walls, if you were interested. Also, OnTakeDamage needs only to be hooked once within OnClientPutInServer.

Leonardo 11-22-2012 13:07

Re: [ANY] Bullet Penetration Filter (1.0)
 
Quote:

Originally Posted by thetwistedpanda (Post 1841957)
Also, OnTakeDamage needs only to be hooked once within OnClientPutInServer.

and OnPluginStart/OnMapStart (in case of late-load)

thetwistedpanda 11-22-2012 13:10

Re: [ANY] Bullet Penetration Filter (1.0)
 
Quote:

Originally Posted by Leonardo (Post 1841971)
and OnPluginStart/OnMapStart (in case of late-load)

Or just check in OnPluginsLoad2 for a late load scenario ;3.

minimoney1 11-22-2012 13:25

Re: [ANY] Bullet Penetration Filter (1.0)
 
Quote:

Originally Posted by thetwistedpanda (Post 1841974)
Or just check in OnPluginsLoad2 for a late load scenario ;3.

Rant:

AskPluginLoad2(), you mean?

Sheepdude 11-22-2012 19:15

Re: [ANY] Bullet Penetration Filter (1.0)
 
Should I unhook the players OnDisconnect too?

thetwistedpanda 11-22-2012 19:23

Re: [ANY] Bullet Penetration Filter (1.0)
 
Negative, SDKHooks does this automatically.

Sheepdude 11-23-2012 00:17

Re: [CS:GO] Bullet Penetration Filter (1.1)
 
Thanks for the feedback, I did what you guys suggested and uploaded it as "oldbulletpenetrationfilter.sp". Unfortunately the traceray solution had a couple problems which I couldn't remedy, one of which being that if the first player to be shot died, the traceray wouldn't be able to detect them and would think the second player was not being hit by a penetrating bullet. The second issue was that it was impossible to deal with bullet spread.

When I started thinking about how to fix the first problem, I realized my solution didn't need tracerays at all. So here you go. This solution still has problems with shotguns, though.

New Version
  • Version 1.1 (22 November 2012)
    -Plugin no longer uses tracerays to determine penetration. As a result:
    -Bug fix: Weapon spread is no longer an issue.
    -Bug fix: Penetration rules work as intended if the first player to get shot dies.
    -Plugin no longer affects bullet penetration through world entities and non-player entities.
    -Added convar sm_penetration_shotguns as a workaround for an introduced issue:
    -Known issue: Shotgun spread which hits multiple players may not work as intended. Use sm_penetration_shotguns 0 to fix this.
    -Plugin is now specific to CS:GO.

RedSword 11-24-2012 03:19

Re: [CS:GO] Bullet Penetration Filter (1.1)
 
Just for your next update and code consistency, I suggest you put an "else" on L85, since you did put one on L94.

And the no-TR version surprises me a bit... if I got it right, OnTakeDamage is executed multiple times, for every hit player, in the order the bullet goes through, right ?

Cool thing.

Sheepdude 11-24-2012 03:54

Re: [CS:GO] Bullet Penetration Filter (1.2)
 
Quote:

Originally Posted by RedSword (Post 1842773)
Just for your next update and code consistency, I suggest you put an "else" on L85, since you did put one on L94.

And the no-TR version surprises me a bit... if I got it right, OnTakeDamage is executed multiple times, for every hit player, in the order the bullet goes through, right ?

Cool thing.

Funny you say that. Yes, that's how it works - I came up with the idea when I was trying to solve the problem of the "disappearing obstruction" - that is, if a player that WOULD have been in the way dies, the traceray didn't detect that anything was in the way, because the player had already died by the time OnTakeDamage was called for the second player.

HOWEVER. Completely eliminating tracerays did more harm than good. Since OnTakeDamage isn't called if players don't take damage, not using tracerays means that players who don't take damage (but are still in the way) aren't account for, such as friendlies when ff is off. And since the entire point of the plugin was to PREVENT bullets from going through friendlies, ESPECIALLY when friendly fire is off, I ended up removing the very feature I was trying to program!

So I went back to the traceray method, but I still had to deal with the "disappearing obstruction", so I had to do two tracerays, one from the attacker to the victim, and another from the attacker BEYOND the victim, to see if anyone beyond the victim had the potential to get hurt by penetrating bullets.

tl;dr I think I fixed the issues with the plugin. I'm still confused by the order in which damage from shotgun bullets fire, but the way I've coded it -should- account for multiple shotgun bullets penetrating, even if the player dies and those bullets intend to hit a second player.

New Version
  • Version 1.2 (24 November 2012)
    -Reverted to traceray method, with bullet spread accounted for. As a result:
    -Bug fix: Previously, bullets would still penetrate players that were in the way but didn't take damage (such as friendlies with ff off).
    -Bug fix: Shotgun damage is handled correctly.
    -Plugin can now account for penetration through geometry and non-player entities.
    -Plugin now works on any mod.

This plugin has been very trial-and-error for me. It's definitely tested and working, although it is quite difficult to thoroughly test the shotgun bullets (since there are three categories - bullets that hit player 1, bullets that hit player 2, and bullets that hit player 1 and pass through to player 2, further complicated by the fact that if player 1 dies in the process, he is no longer a traceray obstruction for player 2). I'll just have to have faith that it works as intended.


All times are GMT -4. The time now is 20:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.