Skip to content

Instantly share code, notes, and snippets.

@iwanPlays
Last active May 4, 2020 06:56
Show Gist options
  • Save iwanPlays/783b04ca41b27388d3b9b139622a1501 to your computer and use it in GitHub Desktop.
Save iwanPlays/783b04ca41b27388d3b9b139622a1501 to your computer and use it in GitHub Desktop.
Modding instructions to make Ravenfield's time stop only slow down enemies and physics but not the player
# Based on NueSB's old Time Stop mod
# Thanks to NueSB and BlipBloop for helping with this on Ravenfield's discord #modding chat!
# Thanks to Litttle_fish for fixing some issues!
# Makes many things 120% fast (Factor 1.2) and slows down rest of the game to 1% speed (Factor 0.01).
############ TASKS
- WORKAROUND (Less overheat) Normalize weapon HEAT cooldown
- WORKAROUND (Disabled) Muzzle flash blocks view
- FIXED Don't slow down weapon recoil recovery
- FIXED Don't slow down player gravity
- FIXED Gun gets stuck while aim
- FIXED Don't slow down player jumping
- FIXED (maybe) speed up advancedreload (already works? weird)
- FIXED cannotentervehiclesaction and cannotleaveaction speedup
- TOO HARD Don't slow down currently controlled Vehicles
- UNIMPORTANT Don't slow down player Underwater
- UNIMPORTANT Shooting smoke make disappear
############ dnSpy Steps
############ Make sure you have at least version 5.0.5.
############
######### Assembly-CSharp.dll
###### FPSActorController.cs
### Update()
Replace slomo key timeScale block:
if (Time.timeScale < 1f)
{
Time.timeScale = 1f;
}
else
{
Time.timeScale = 0.2f;
}
Time.fixedDeltaTime = Time.timeScale / 60f;
this.mixer.SetFloat("pitch", Time.timeScale);
with:
if (Time.timeScale < 1f)
{
Time.timeScale = 1f;
this.actor.animator.speed = 1f;
Time.fixedDeltaTime = Time.timeScale / 60f;
this.mixer.SetFloat("pitch", Time.timeScale);
}
else
{
Time.timeScale = 0.01f;
this.actor.animator.speed = 120f;
Time.fixedDeltaTime = Time.timeScale / 60f;
this.mixer.SetFloat("pitch", Time.timeScale * 25f);
}
######### Assembly-CSharp-firstpass.dll
######### UnityStandardAssets.Characters.FirstPerson
######FirstPersonController.cs
### FixedUpdate()
To normalize walking and jumping/falling, replace:
this.m_MoveDir += Physics.gravity * this.m_GravityMultiplier * Time.fixedDeltaTime;
with:
this.m_MoveDir += Physics.gravity * this.m_GravityMultiplier * Time.fixedDeltaTime * ((Time.timeScale < 1f) ? 120f : 1f);
and replace:
this.m_CollisionFlags = this.m_CharacterController.Move(this.m_MoveDir * Time.fixedDeltaTime);
with:
this.m_CollisionFlags = this.m_CharacterController.Move(this.m_MoveDir * Time.fixedDeltaTime * ((Time.timeScale < 1f) ? 120f : 1f));
######### Assembly-CSharp.dll
###### Actor.cs
### LeaveSeat()
Actions prevent other actions from taking place (aiming prevents from shooting), so we need to speed them up when time is stopped.
Allow to enter vehicles normally fast (after exiting) by replacing:
this.cannotEnterVehicleAction.Start();
with
this.cannotEnterVehicleAction.StartLifetime((!this.aiControlled && Time.timeScale < 1f) ? 0.01f : 1f);
### UpdateWeapon()
Normalize aim action duration:
replace
this.aimingAction.Start();
with
this.aimingAction.StartLifetime((!this.aiControlled && Time.timeScale < 1f) ? 0.002f : 0.2f);
###### FPSActorController.cs
### SampleUseRay()
Allow exiting vehicles normally fast by replacing
this.cannotLeaveAction.Start();
with
this.cannotLeaveAction.StartLifetime((Time.timeScale < 1f) ? 0.01f : 1f);
### Update()
Prevent sprinting from blocking shooting by replacing
this.sprintCannotFireAction.Start();
with
this.sprintCannotFireAction.StartLifetime((Time.timeScale < 1f) ? 0.001f : 0.1f);
To normalize leaning speed, replace:
this.fpParent.lean = Mathf.MoveTowards(this.fpParent.lean, this.Lean(), Time.deltaTime * 8f);
with:
this.fpParent.lean = Mathf.MoveTowards(this.fpParent.lean, this.Lean(), Time.deltaTime * 8f * ((Time.timeScale < 1f) ? 120f : 1f));
###### PlayerFpParent()
### Update()
To fix aim FOV zoom, replace:
this.fovRatio = Mathf.MoveTowards(this.fovRatio, (!this.aiming) ? 0f : 1f, Time.deltaTime * this.fovSpeed);
with:
this.fovRatio = Mathf.MoveTowards(this.fovRatio, (!this.aiming) ? 0f : 1f, Time.deltaTime * this.fovSpeed* ((Time.timeScale<1f) ? 120f : 1f));
To normalize weapon "springing" after moving camera, after:
this.rotationSpring.Update();
add:
if (Time.timeScale < 1f)
{
for (int i = 1; i < 100; i++)
{
this.positionSpring.Update();
this.rotationSpring.Update();
}
}
### ApplyWeaponSnap()
To normalize weapon "snapping" after shooting (recoil), replace:
this.weaponSnapAction.StartLifetime(duration);
with:
this.weaponSnapAction.StartLifetime(duration * ((Time.timeScale < 1f) ? 0.01f : 1f));
###### Weapon.cs
### Update()
add to end:
this.animator.speed = 1f;
if (this.UserIsPlayer() && Time.timeScale == 0.01f)
{
this.animator.speed = 120f;
}
### CoolingDown()
"Cooldown" is the time gap between two bullets shot, this is not cooldown from overheating.
Normalize fire frequency by adding at beginning:
if (Time.timeScale == 0.01f && this.UserIsPlayer())
{
return Time.time - this.lastFiredTimestamp < this.configuration.cooldown / 120f;
}
### UpdateHeat()
Speed up cooldown by replacing
this.heat = Mathf.Clamp01(this.heat - this.configuration.heatDrainRate * Time.deltaTime);
with
this.heat = Mathf.Clamp01(this.heat - this.configuration.heatDrainRate * Time.deltaTime * ((this.UserIsPlayer() && Time.timeScale < 1f) ? 400f : 1f));
### Reload()
after:
this.reloading = true;
add:
if (this.UserIsPlayer() && Time.timeScale == 0.01f)
{
base.Invoke("ReloadDone", this.configuration.reloadTime / 120f);
return;
}
### Unholster()
at end before:
base.Invoke("UnholsterDone", this.configuration.unholsterTime);
add:
if (this.UserIsPlayer() && Time.timeScale == 0.01f)
{
base.Invoke("UnholsterDone", this.configuration.unholsterTime / 120f);
return;
}
### FireFromMuzzle()
I could not find a way to manipulate all muzzle flash speeds. As they are very annoying, removing them is best. Encapsulate the section following
if (this.muzzleFlash.ContainsKey(transform))
with
if (!this.UserIsPlayer() && Time.timeScale < 1f) {
}
############# Optional
######### Assembly-CSharp.dll
!!!!!!!!! Who cares about ladders?
###### FPSActorController.cs
###### Actor.cs
### ExitLadder()
###### FPSActorController.cs
### StartLadder()
### SampleUseRay()
Allow exiting/leaving ladders fast by replacing:
this.cannotLeaveAction.Start();
with
this.cannotLeaveAction.StartLifetime((Time.timeScale < 1f) ? 0.01f : 1f);
!!!!!!!!!!!! To probably make deafening take less time (if you're deaf you're most likely dead anyways so who cares).
######### Assembly-CSharp-firstpass.dll
###### FirstPersonController
### Deafen()
Replace:
base.Invoke("Undeafen", 5f);
with:
base.Invoke("Undeafen", 5f * ((Time.timeScale < 1f) ? 0.01f : 1f));
@CJjorphen24
Copy link

melee not working

@PIXEL-SHK
Copy link

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment