Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Replace the legacy ASM-based static shotgun spread patch with a detour hook for
SharedRandomFloat, providing a configurable and extensible shotgun pellet pattern system.The plugin preserves the existing static spread logic while allowing further customization of pellet distribution.
Changes:
1. Configurable pellet patterns — support for custom rings and radius factors.
2. Corrected spread direction calculation — use the full 0°–<180° range instead of the restricted ranges produced by the legacy ASM patch.
3. Disabled unnecessary spread offsets — remove shot-relative up/down and left/right offsets to ensure accurate static patterns.
4. Detour-based implementation — replace the legacy ASM patch with a function hook, making the implementation easier to understand, maintain, and extend.
5. Preserved legacy behavior — retain compatibility with the existing static spread logic.
Technical details:
The implementation is based on reverse engineering and analysis of
CTerrorPlayer::FireBullets,CTerrorGun::FireBullet,FireTerrorBullets, and their calls toSharedRandomFloat.The legacy ASM patch was analyzed and compared against the behavior of the
l4d2_static_shotgun_spreadplugin. The new implementation was also tested using a C++ test.Credits:
Jahze — original ASM patch,
l4d2_static_shotgun_spread, and related spread manipulation and testing plugins.ProdigySim — proposed the
SharedRandomFloathook approach and provided the initial plugin implementation.ProdigySim, Visor, Rena — maintenance of the legacy plugin and ASM patch.
Alan — testing, feedback, and verification of the initial implementation.
Future improvements:
Add Gaussian distribution support.
Support individual patterns for each shotgun without dynamically patching the central pellet.
Fix prediction seed precision issues for large values (Cvar issue).
Investigate cases where the saved seed reaches INT_MAX.
Explore Left 4 Dead 1 support.