Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype: Override Shared Random Values #528

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ProdigySim
Copy link
Contributor

What if we could just override any random value the game is given?

Prototypes a plugin to override SharedRandomFloat and provides the opportunity to return a static value in the requested range.

Impetus for this plugin: What if we used vanilla spread patterns for shotguns, but kept their spread static?

@ProdigySim
Copy link
Contributor Author

ProdigySim commented Aug 21, 2022

We should be a little careful when overriding calls to "SharedRandomValue". I don't know exactly how this system works, but I imagine every call to this on server side is paired with a similar call on the client side, and both systems will advance a shared RNG in a specific sequence.

I opted to use MRES_Override on the returns here to make sure the original function is still called, but its value is discarded. This should ensure that the RNG advances as normal server side.

We will still have desync between client and server, however--we can't get clients to use the override value. So, in the spread example, users will still see incorrect spread locally.

We may need to use the visualize_impacts plugin to diagnose spread changes.

@ProdigySim
Copy link
Contributor Author

Alan tested this plugin out and it resulted in 1 "single" pellet being fired. This suggests that the vanilla spread may just be 100% random within the spread range

@ProdigySim
Copy link
Contributor Author

ProdigySim commented Aug 21, 2022

Some logs, with 1 chrome shot:

SharedRandomfloat(CTerrorGun::FireBullet HorizSpread, -0.800000, 0.800000, 0)
SharedRandomfloat(CTerrorGun::FireBullet HorizSpread, -0.800000, 0.800000, 0) = 0.000000
SharedRandomfloat(CTerrorGun::FireBullet VertSpread, -0.800000, 0.800000, 0)
SharedRandomfloat(CTerrorGun::FireBullet VertSpread, -0.800000, 0.800000, 0) = 0.000000
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 2)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 2) = 0.000000
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 2)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 2) = 90.000000
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 3)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 3) = 0.000000
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 3)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 3) = 90.000000
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 4)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 4) = 0.000000
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 4)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 4) = 90.000000
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 5)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 5) = 0.000000
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 5)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 5) = 90.000000
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 6)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 6) = 0.000000
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 6)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 6) = 90.000000
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 7)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 7) = 0.000000
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 7)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 7) = 90.000000
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 8)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 8) = 0.000000
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 8)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 8) = 90.000000
SharedRandomfloat(CTerrorGun::FireBullet HorizSpread, -0.881854, 0.881854, 0)
SharedRandomfloat(CTerrorGun::FireBullet HorizSpread, -0.881854, 0.881854, 0) = -0.033390
SharedRandomfloat(CTerrorGun::FireBullet VertSpread, -0.881854, 0.881854, 0)
SharedRandomfloat(CTerrorGun::FireBullet VertSpread, -0.881854, 0.881854, 0) = 0.528265
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 2)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 2) = 0.308585
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 2)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 2) = 117.594230
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 3)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 3) = 2.425107
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 3)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 3) = 71.561386
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 4)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 4) = -2.952603
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 4)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 4) = 164.522476
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 5)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 5) = 0.052109
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 5)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 5) = 165.796127
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 6)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 6) = 1.983578
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 6)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 6) = 64.651893
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 7)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 7) = 1.833803
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 7)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 7) = 130.909347
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 8)
SharedRandomfloat(CTerrorPlayer::FireBullet Spread, -5.000000, 5.000000, 8) = -1.653429
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 8)
SharedRandomfloat(CTerrorPlayer::FireBullet SpreadDir, 0.000000, 180.000000, 8) = 64.514495

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant