﻿###########################################################
# Modified by raceskinning.de (2026-12-03): road_rolling_slip_feel 1.0->0.3, texture_scale 1.0->0.5, kerbs_surface_scale 3.9->3.3, kerb_bump_scale 3.0->6.0, boost_on_curb 9->13, large_track_bump_scale 0.60->0.90, suspension_scale 0.65->0.80, rear_bump_scale 0.5->0.7. Everything else unchanged.
###########################################################
# NAME: rFuktor5.0.1.3-By Karsten with Shadak,Panos,Kuku,tUMi
# The original Momentum Rack, with Damper as damper.
#
# Any modification/tuning/reposting anywhere is allowed, only requirement is to 
# KEEP the 1st line with original name and creds as it is. Additional naming and creds can be put in the 2nd line.
#
# Special THANKS to Santos for all his early dedication and work.
#
# HUGE THANKS! to everybody for helping this file on the way:
# 
# Shadak, Panos, Santos, tUMi, Peter Stefani, Stakanov, GodzillaGTR, Richard Appleyard, NuScorpii, Kuku, Alegunner, AxisMagi, SlapShot82, Chip, tpw, inthebagbud, Michael Enright, TorsteinVh, Ray Sheppard, psone, Dean Ogurek, John Ellis, Gillish, Mikk Schleifer, CycloZeb
# & everybody else I missed in the Reiza forum for continued suggestions, expertise & help balancing this file!
#
# If you copy this over in full or partly, or base a solution on the same general methods after seeing it, please credit "Momentum Rack" however used("included"/"extended"/"modified"/"based on"), I would be pleased - Thanks.
#
# File tuned for front end feel and slip angle grip levels by Peter Stefani for VRS DFP. 11/30/2024 Starting In-Game values  Gain 65 / LFB 0 / FX 17 / Damp 0    

###########################################################
#
# Madness bug madness
#
# Create many vars here so the madness bug will hit that.
#

(madness_bug1       1.0)
(madness_bug2       1.0)
(madness_bug3       1.0)
(madness_bug4       1.0)
(madness_bug5       1.0)
(madness_bug6       1.0)
(madness_bug7       1.0)
(madness_bug8       1.0)
(madness_bug9       1.0)
(madness_bug10      1.0)
(madness_bug11      1.0)
(madness_bug12      1.0)
(madness_bug13      1.0)
(madness_bug14      1.0)
(madness_bug15      1.0)
(madness_bug16      1.0)
(madness_bug17      1.0)
(madness_bug18      1.0)
(madness_bug19      1.0)
(madness_bug20      1.0)
(madness_bug21      1.0)
(madness_bug22      1.0)
(madness_bug23      1.0)
(madness_bug24      1.0)
(madness_bug25      1.0)
(madness_bug26      1.0)
(madness_bug27      1.0)
(madness_bug28      1.0)
(madness_bug29      1.0)
(madness_bug30      1.0)

###########################################################
#
# Main dials
#

(master_rack                  0.74)				#Rack and road scale.
(master_road                  1.40)				#Road bumps, details and suspension
(master_effects               1.65)				#Effects scale.
(gain2                        (min 1 gain))
(lfb_slider2                  (* 0.6 (power (/ (+ 0.05 lfb_slider) 0.95) 1.2)))
(df_compression               (power (max 0 (* (/ 1 0.6) (- gain2 0.4))) 1.5))	#calculated range 0-1. 0 is result for gain 0-40%. This will keep DD bases at compression of 0, when using high output on the hardware.
(damping                      damping_slider)	#use in range 0.0 - 1.0
(lfbval                       lfb_slider)
(force_scale                  (* 1.7 (/ 0.24 centering)))


###########################################################
#
# Set dt to old static value
#

(dt 0.0033333333333333333333333333333333333))


###########################################################
#
# Rack settings 
#

(tighten_range                0)		#Use for lower end wheel bases.
(tighten_falloff              0)		#Use for lower end wheel bases.
(tyre_initial_resist          2.97)
(tyre_resistance1_timing      0.001)    #higher for larger time build up of resistance force. higher gives less friction fell, but also more delay in the steering.
(tyre_resistance1_lo_df       0.6)		#higher for more resistance on turning. works in combination with tyre_resistance_timing.
(tyre_resistance1_hi_df       0.3)		#higher for more resistance on turning. works in combination with tyre_resistance_timing.
(tyre_resistance2_timing      0.002)	#higher for larger time build up of resistance force. higher gives less friction fell, but also more delay in the steering.
(tyre_resistance2_lo_df       1.6)		#higher for more resistance on turning. works in combination with tyre_resistance_timing.
(tyre_resistance2_hi_df       1.5)		#higher for more resistance on turning. works in combination with tyre_resistance_timing.
(tyre_resistance3_timing      0.005)	#higher for larger time build up of resistance force. higher gives less friction fell, but also more delay in the steering.
(tyre_resistance3_lo_df       0.55)		#higher for more resistance on turning. works in combination with tyre_resistance_timing.
(tyre_resistance3_hi_df       0.5)		#higher for more resistance on turning. works in combination with tyre_resistance_timing.
(rack_friction                (* damping 0.5))
(lfb_slider_strength          0.85)		#0.0-1.0. How steep lfb slider adjusts the curve.
(center_full                  1.00)		#0.0-2.0. Higher than 2 does not really do anything good.
(over_steer_scale             1.3)
(under_steer_scale            1.5)
(exaggerate_front_load_feel   0.18)
(exaggerate_front_load_feel_hi_df 0.07)
(power_steering_angle         0.4)		#https://www.desmos.com/calculator/kye3awmnqf
(limit_high_df                1.0)		#Limits how stiff the steering becomes in high df cars. Range: 0.0-1.0. 0.0=most extreme high df possible, 1.0=limit high df as much as possible.
(velocity_res_scale          -0.1)		#How much velocity reduces resistance
(velocity_res_offset          1.0)		#How much resistance at velocity 0
(vel_rot_scale                1.0)
(vel_rot_limit_coef           1.0)
(static_force_reduction_timing 0.14)		#Lower will make static force "low" force quicker, higher will make it slower to adjust to current force.
(normal_static_force_reduction 0.06)	#Range: 0.0 - 1.0. Always reduce the averaged force. This gives less constant/slow force on cornering or quick turning, and preserves the quick forces.
(exp_static_force_reduction   0.15)		#Range: 0.0 - 1.0. Under low df, reduce the highest end of averaged force only.
(exp_static_force_reduction_hi_df 0.15)	#Range: 0.0 - 1.0. Under high df, reduce the highest end of averaged force only.
(rear_grip_loss_feel          0.02)		#How much rear grip loss decreases feel of grip
(yaw_scale_fast               0.019)
(yaw_scale_delayed            0.029)
(yaw_delay                    0.005)
(slip_crossover_pos           0.188)#slip effect graph: https://www.desmos.com/calculator/iskij6snwe
(slip_crossover_width         0.150)
(slip_crossover_line1_slope   0.2)
(slip_crossover_line2_start_y 0.11)
(slip_crossover_line2_end_y   0.85)
(subtract_rot_velocity        (* damping 2))
(accel_feel                   1.4)
(brake_feel                   2.7)
(front_drive_torque_feel      3.0)
(rear_drive_torque_feel       0.10)
(front_tyre_stretch_feel      0.28)
(rear_tyre_stretch_feel       0.11)
(relax_us_line2_start_y       0.0007)#relax_us used for under-steer: https://www.desmos.com/calculator/bftmcp0sfc
(relax_us_pos                 0.0011)
(relax_us_width               0.00263)
(relax_us_coef                -0.01)
(relax_yaw_line2_start_y      0.0)		#relax_yaw used for yaw relaxation: https://www.desmos.com/calculator/ls4b3rme9l
(relax_yaw_pos                0.0016)
(relax_yaw_width              0.00306)
(relax_yaw_coef               -0.0157)
(bump_feel_follow_weight      0.25)
(brake_feel_follow_weight     0.16)
(brake_coef                   1.2)
(centering                    0.66)
(on_off_throttle_feel         0.75)		#is felt on: fast throttel up/down and so also on gear shifts with auto-clutch.
(tear_threshold               0.13)		#how early the tear feel appears - the higher the later.
(scrub_threshold              0.35)
(road_rolling_slip_feel       0.3)


###########################################################
#
# Road features settings
#

(texture_scale                0.5)
(micro_bumps_scale            1.0)
(micro_bumps_smooth           0.002)
(kerbs_surface_scale          3.3)
(kerbs_surface_smooth         0.002)
(kerb_bump_scale              6.0)		#How big the tall curb bumps are.
(large_track_bump_scale       0.90)		#how much bumps on the track are felt.
(large_offroad_bump_scale     0.05)		#how much bumps off the track are felt.


###########################################################
#
# Effect scales - Change here to make an effect more or less pronounced.
#

(engine_scale_at_still        0.0)
(engine_scale_at_speed        0.0)
(scrub_scale                  2.27)
(tear_scale                   0.33)
(tear_hard                    0.4)
(scrub_frq_scale              0.30)
(tear_frq_scale               3.2)
(flatspots_scale              0.04)		#how much you feel the flat spotting. At default 1.0 flatspots are nicely felt in a formula V10.
(suspension_scale             0.80)		#how much the suspension is felt.
(rear_bump_scale              0.7)
(rear_bump_hard               0.8)


###########################################################
#
# Dynamic adjustment to bump feel based on car weight
#

(bump_weight_scale            (/ 500 (/ (+ corner_FL corner_FR) 9.8)))
(bump_weight_scale            (+ 1 (* bump_feel_follow_weight (- bump_weight_scale 1))))
(texture_scale                (* texture_scale bump_weight_scale))
(micro_bumps_scale            (* micro_bumps_scale bump_weight_scale))
(kerbs_surface_scale          (* kerbs_surface_scale bump_weight_scale))
(kerb_bump_scale              (* kerb_bump_scale bump_weight_scale))
(suspension_scale             (* suspension_scale bump_weight_scale))
(rear_bump_scale              (* rear_bump_scale bump_weight_scale))


###########################################################
#
# Dynamic adjustment to brake feel based on car weight
#

(brake_weight_scale           (/ 500 (/ (+ corner_FL corner_FR) 9.8)))
(brake_weight_scale           (+ 1 (* brake_feel_follow_weight (- brake_weight_scale 1))))
(brake_feel                   (/ brake_feel brake_weight_scale))

#Dynamic adjustment to accel feel based on car weight


(accel_weight_scale           (/ 500 (/ (+ corner_FL corner_FR) 9.8)))
(accel_weight_scale           (+ 1 (* accel_feel_follow_weight (- accel_weight_scale 1))))
(accel_feel                   (/ accel_feel accel_weight_scale))

###########################################################
#
# Kart adjustments
#

(isKart                  (if (min 0 (- steer_ratio 5)) 1 0))

(master_rack             (if isKart 1.0		master_rack))
(master_road             (if isKart 3.5		master_road))
(centering               (if isKart 0.99	centering))
(force_scale             (if isKart 2.0  	force_scale))
(tyre_initial_resist     (if isKart 0.5 	tyre_initial_resist))
(tyre_resistance1_lo_df  (if isKart 0.5	    tyre_resistance1_lo_df))
(tyre_resistance1_hi_df  (if isKart 0.5  	tyre_resistance1_hi_df))
(tyre_resistance2_lo_df  (if isKart 0.5  	tyre_resistance2_lo_df))
(tyre_resistance2_hi_df  (if isKart 0.5  	tyre_resistance2_hi_df))
(tyre_resistance3_lo_df  (if isKart 0.35	tyre_resistance3_lo_df))
(tyre_resistance3_hi_df  (if isKart 0.35 	tyre_resistance3_hi_df))
(rack_friction           (if isKart 0.5 	rack_friction))
(vel_rot_scale           (if isKart 1.5 	vel_rot_scale))
(over_steer_scale        (if isKart 0.9		over_steer_scale))
(under_steer_scale       (if isKart 0.2	    under_steer_scale))
(accel_feel              (if isKart 0.0		accel_feel))
(brake_feel              (if isKart 6.0		brake_feel))
(front_drive_torque_feel (if isKart 0.0		front_drive_torque_feel))
(rear_drive_torque_feel  (if isKart 3.5		rear_drive_torque_feel))
(suspension_scale        (if isKart 2.5		suspension_scale))
(rear_bump_scale         (if isKart 2.0		rear_bump_scale))
(front_tyre_stretch_feel (if isKart 0.05 	front_tyre_stretch_feel))
(rear_tyre_stretch_feel  (if isKart 0.3 	rear_tyre_stretch_feel))
(rear_grip_loss_feel     (if isKart 0.0 	rear_grip_loss_feel))
(relax_us_width          (if isKart 0.01 	relax_us_width))
(vel_rot_limit_coef      (if isKart 5.0 	vel_rot_limit_coef))
(yaw_scale_fast          (if isKart 0.0 	yaw_scale_fast))
(yaw_scale_delayed       (if isKart 0.05 	yaw_scale_delayed))
(yaw_delay               (if isKart 0.15 	yaw_delay))
(kerbs_surface_scale     (if isKart 7.5 	kerbs_surface_scale))
(kerb_bump_scale         (if isKart 0.2 	kerb_bump_scale))
(subtract_rot_velocity   (if isKart 0.8     subtract_rot_velocity))
(texture_scale           (if isKart 0.35    texture_scale))
(micro_bumps_scale       (if isKart 0.2     micro_bumps_scale))
(scrub_scale 		     (if isKart 2.0     scrub_scale ))
(tear_scale 		     (if isKart 0.32    tear_scale ))
(tear_threshold 	     (if isKart 0.2     tear_threshold ))
(scrub_threshold 	     (if isKart 0.35    scrub_threshold ))
(engine_scale_at_still 	 (if isKart 0.9     engine_scale_at_still ))
(large_track_bump_scale  (if isKart 3.0     large_track_bump_scale))


###########################################################
#
# Helper vars & prep
#

(ratio_scale        (/ steer_ratio 8))
(kmh                (* (abs vel_mag) 3600 0.001))
(speed_bias10       (max 0.0 (min 1.0 (/ (- kmh 3) 7.0))))
(delta_sa_max       (* dt 3.14 2 ratio_scale))
(e                  2.71828182846)

(flatspot_smoothing (blend (min 1 (* kmh 0.005)) 0.06 0.01))
(flatspot_vol       (blend (min 1 (* kmh 0.005)) 2.5 1))
(fl_fs_sm           (* 10 (smooth FL_Flatspot flatspot_smoothing)))
(fr_fs_sm           (* 10 (smooth FR_Flatspot flatspot_smoothing)))

(RL_slide           (min 1 (/ RL_scrub 13)))
(RR_slide           (min 1 (/ RR_scrub 13)))

(slide_factor       1.0)
(FL_sl              (* 1.0 (min 1 (* slide_factor FL_slide))))
(FR_sl              (* 1.0 (min 1 (* slide_factor FR_slide))))
(RL_sl              (* 1.0 (min 1 (* slide_factor RL_slide))))
(RR_sl              (* 1.0 (min 1 (* slide_factor RR_slide))))

(FL_sl              (* FL_sl (if (max 0 (- FL_load 1)) 1 0)))
(FR_sl              (* FR_sl (if (max 0 (- FR_load 1)) 1 0)))
(RL_sl              (* RL_sl (if (max 0 (- RL_load 1)) 1 0)))
(RR_sl              (* RR_sl (if (max 0 (- RR_load 1)) 1 0)))

(slip_fl            FL_sl)
(slip_fr            FR_sl)
(slip_rl            RL_sl)
(slip_rr            RR_sl)

(tear_threshold_half (max 0.0001 (* tear_threshold 0.5)))
(FL_tear_early      (max 0 (- 1 (/ (max 0 (- FL_sl tear_threshold_half)) tear_threshold_half))))
(FR_tear_early      (max 0 (- 1 (/ (max 0 (- FR_sl tear_threshold_half)) tear_threshold_half))))
(RL_tear_early      (max 0 (- 1 (/ (max 0 (- RL_sl tear_threshold_half)) tear_threshold_half))))
(RR_tear_early      (max 0 (- 1 (/ (max 0 (- RR_sl tear_threshold_half)) tear_threshold_half))))

(FL_tear            (max 0 (- FL_sl tear_threshold)))
(FR_tear            (max 0 (- FR_sl tear_threshold)))
(RL_tear            (max 0 (- RL_sl tear_threshold)))
(RR_tear            (max 0 (- RR_sl tear_threshold)))

(FL_scrub           (* 15 (power (/ (max 0 (- FL_sl scrub_threshold)) (- 1 scrub_threshold)) 0.6)))
(FR_scrub           (* 15 (power (/ (max 0 (- FR_sl scrub_threshold)) (- 1 scrub_threshold)) 0.6)))
(RL_scrub           (* 15 (power (/ (max 0 (- RL_sl scrub_threshold)) (- 1 scrub_threshold)) 0.6)))
(RR_scrub           (* 15 (power (/ (max 0 (- RR_sl scrub_threshold)) (- 1 scrub_threshold)) 0.6)))

(FL_sl_lat          (/ FL_vel_y (max 0.5 (abs FL_vel_x))))
(FR_sl_lat          (/ FR_vel_y (max 0.5 (abs FR_vel_x))))
(RL_sl_lat          (/ (- RL_vel_y FL_vel_y) (max 0.5 (* 2 (abs RL_vel_x)))))
(RR_sl_lat          (/ (- RR_vel_y FR_vel_y) (max 0.5 (* 2 (abs RR_vel_x)))))
(FL_sl_lat          (hard_clip FL_sl_lat 1.0))
(FR_sl_lat          (hard_clip FR_sl_lat 1.0))
(RL_sl_lat          (hard_clip RL_sl_lat 1.0))
(RR_sl_lat          (hard_clip RR_sl_lat 1.0))

(p slip_crossover_pos)
(w slip_crossover_width)

(l1 (* slip_fl slip_crossover_line1_slope))
(l2 (* (if (min 0 slip_fl) -1 1) (+ slip_crossover_line2_start_y (* (abs slip_fl) (- slip_crossover_line2_end_y slip_crossover_line2_start_y)))))
(b       (/ 1 (+ 1 (power e (* 9 (- (/ (- slip_fl p) w) 0.5))))))
(slip_fl2 (+ (* l1 b) (* l2 (- 1 b))))
(l1 (* slip_fr slip_crossover_line1_slope))
(l2 (* (if (min 0 slip_fr) -1 1) (+ slip_crossover_line2_start_y (* (abs slip_fr) (- slip_crossover_line2_end_y slip_crossover_line2_start_y)))))
(b       (/ 1 (+ 1 (power e (* 9 (- (/ (- slip_fr p) w) 0.5))))))
(slip_fr2 (+ (* l1 b) (* l2 (- 1 b))))
(l1 (* slip_rl slip_crossover_line1_slope))
(l2 (* (if (min 0 slip_rl) -1 1) (+ slip_crossover_line2_start_y (* (abs slip_rl) (- slip_crossover_line2_end_y slip_crossover_line2_start_y)))))
(b       (/ 1 (+ 1 (power e (* 9 (- (/ (- slip_rl p) w) 0.5))))))
(slip_rl2 (+ (* l1 b) (* l2 (- 1 b))))
(l1 (* slip_rr slip_crossover_line1_slope))
(l2 (* (if (min 0 slip_rr) -1 1) (+ slip_crossover_line2_start_y (* (abs slip_rr) (- slip_crossover_line2_end_y slip_crossover_line2_start_y)))))
(b       (/ 1 (+ 1 (power e (* 9 (- (/ (- slip_rr p) w) 0.5))))))
(slip_rr2 (+ (* l1 b) (* l2 (- 1 b))))

(slip_fl2           (min 1 slip_fl2))
(slip_fr2           (min 1 slip_fr2))
(slip_rl2           (min 1 slip_rl2))
(slip_rr2           (min 1 slip_rr2))

(slip_fl2           (smooth slip_fl2 0.01))
(slip_fr2           (smooth slip_fr2 0.01))
(slip_rl2           (smooth slip_rl2 0.01))
(slip_rr2           (smooth slip_rr2 0.01))

(grip_fl            (- 1 slip_fl2))
(grip_fr            (- 1 slip_fr2))
(grip_rl            (- 1 slip_rl2))
(grip_rr            (- 1 slip_rr2))

(FL_def             (* FL_def (power (max 0 (- 1 FL_tear)) 2)))
(FR_def             (* FR_def (power (max 0 (- 1 FR_tear)) 2)))
(FL_stretch         (power FL_stretch (power (abs FL_stretch) -0.025)))
(FR_stretch         (power FR_stretch (power (abs FR_stretch) -0.025)))
(RL_stretch         (power RL_stretch (power (abs RL_stretch) -0.05)))
(RR_stretch         (power RR_stretch (power (abs RR_stretch) -0.05)))

(steering_angle_rack (* (+ steering_angle_FL steering_angle_FR) 0.5 3.14159265 ratio_scale))
(steering_angle_l steering_angle_rack)
(steering_angle_r steering_angle_rack)

(sa_delta_rack    (* (/ 1 (* dt 333)) (- steering_angle_rack old_sa_rack)))
(old_sa_rack      steering_angle_rack)
(sa_delta_rack    (hard_clip sa_delta_rack delta_sa_max))

(lat_l_oversteer  (* RL_sl_lat over_steer_scale))
(lat_r_oversteer  (* RR_sl_lat over_steer_scale))

(lat_l_understeer (* FL_sl_lat under_steer_scale))
(lat_r_understeer (* FR_sl_lat under_steer_scale))
(lat_l_understeer (blend (/ 1 (+ 1 (power e (* 7 (- (/ (- (abs lat_l_understeer) relax_us_pos) relax_us_width) 0.5))))) (* (if (min 0 lat_l_understeer) -1 1) (+ relax_us_line2_start_y (* (abs lat_l_understeer) (- 1 relax_us_line2_start_y)))) (power lat_l_understeer (power (abs lat_l_understeer) relax_us_coef))))
(lat_r_understeer (blend (/ 1 (+ 1 (power e (* 7 (- (/ (- (abs lat_r_understeer) relax_us_pos) relax_us_width) 0.5))))) (* (if (min 0 lat_r_understeer) -1 1) (+ relax_us_line2_start_y (* (abs lat_r_understeer) (- 1 relax_us_line2_start_y)))) (power lat_r_understeer (power (abs lat_r_understeer) relax_us_coef))))

(lat_oversteer    (* 0.5 (+ lat_l_oversteer lat_r_oversteer)))

(lat_l            (+ lat_oversteer lat_l_understeer))
(lat_r            (+ lat_oversteer lat_r_understeer))
(lat_l            (blend speed_bias10 0 lat_l))
(lat_r            (blend speed_bias10 0 lat_r))

(steering_angle_l (- steering_angle_l (* lat_l 3.14159265)))
(steering_angle_r (- steering_angle_r (* lat_r 3.14159265)))

(sa_delta_l       (* (/ 1 (* dt 333)) (- steering_angle_l old_sa_l)))
(sa_delta_r       (* (/ 1 (* dt 333)) (- steering_angle_r old_sa_r)))
(old_sa_l         steering_angle_l)
(old_sa_r         steering_angle_r)

(sa_delta_l       (hard_clip sa_delta_l delta_sa_max))
(sa_delta_r       (hard_clip sa_delta_r delta_sa_max))

(FL_start_load    (/ corner_FL 9.8))
(FR_start_load    (/ corner_FR 9.8))
(RL_start_load    (/ corner_RL 9.8))
(RR_start_load    (/ corner_RR 9.8))									
(FL_load_norm     (/ FL_load FL_start_load))
(FR_load_norm     (/ FR_load FR_start_load))

(rel_weight_FL    (smooth FL_load_norm 0.1))
(rel_weight_FR    (smooth FR_load_norm 0.1))
(load_df          (+ (* 0.66 (min rel_weight_FL rel_weight_FR)) (* 0.33 (max rel_weight_FL rel_weight_FR))))
(load_power_fx    (max 0.0 (min 1.0 (* 2.5 (- load_df 1)))))
(load_power_fx    (min load_power_fx (smooth load_power_fx 0.1)))

(limit_high_df_scale1 (blend df_compression 1 100))
(limit_high_df_scale2 5)
(limit_high_df    (* limit_high_df (max limit_high_df_scale1 limit_high_df_scale2)))
(x                (+ 0.01 (* 0.2 limit_high_df)))
(y                (- 1 (/ 1 (+ 1 x))))
(FL_load_norm_s   (smooth FL_load_norm 0.3))
(FR_load_norm_s   (smooth FR_load_norm 0.3))
(FL_load_norm_s   (if (min 0 (- FL_load_norm_s 1)) (* 1.0625 (- 1 (/ 1 (+ 1 (* 16 FL_load_norm_s))))) (+ 1 (* 1.0 (- (* (/ 1 y) (- 1 (/ 1 (+ 1 (* x (power (abs FL_load_norm_s) 0.5)))))) 1)))))
(FR_load_norm_s   (if (min 0 (- FR_load_norm_s 1)) (* 1.0625 (- 1 (/ 1 (+ 1 (* 16 FR_load_norm_s))))) (+ 1 (* 1.0 (- (* (/ 1 y) (- 1 (/ 1 (+ 1 (* x (power (abs FR_load_norm_s) 0.5)))))) 1)))))
(FL_load_norm     (max 0 (+ FL_load_norm_s (* 0.5 (- (smooth FL_load_norm 0.01) (smooth FL_load_norm 0.3))))))
(FR_load_norm     (max 0 (+ FR_load_norm_s (* 0.5 (- (smooth FR_load_norm 0.01) (smooth FR_load_norm 0.3))))))
(FL_load_norm     (* FL_load_norm (+ 1 (* grip_rl rear_end_feel (- (min 2 (/ (smooth RL_load 0.2) (max 1 (smooth RL_load 2.0)))) 1)))))
(FR_load_norm     (* FR_load_norm (+ 1 (* grip_rr rear_end_feel (- (min 2 (/ (smooth RR_load 0.2) (max 1 (smooth RR_load 2.0)))) 1)))))
(load_norm_wheel  500.0)
(FL_load_norm     (* FL_load_norm load_norm_wheel))
(FR_load_norm     (* FR_load_norm load_norm_wheel))

(m_FL_load        (smooth FL_load_norm 0.1))
(m_FR_load        (smooth FR_load_norm 0.1))

(ex_front_load_l  (max (- 1 load_power_fx) (/ (smooth FL_load_norm 0.01) (max 0.2 (smooth FL_load_norm 0.025)))))
(ex_front_load_r  (max (- 1 load_power_fx) (/ (smooth FR_load_norm 0.01) (max 0.2 (smooth FR_load_norm 0.025)))))
(ex_front_load_l  (max 0.0 (+ 1.0 (* (blend load_power_fx exaggerate_front_load_feel exaggerate_front_load_feel_hi_df) (- ex_front_load_l 1.0)))))
(ex_front_load_r  (max 0.0 (+ 1.0 (* (blend load_power_fx exaggerate_front_load_feel exaggerate_front_load_feel_hi_df) (- ex_front_load_r 1.0)))))
(m_FL_load        (* m_FL_load ex_front_load_l))
(m_FR_load        (* m_FR_load ex_front_load_r))

(acc              (/ kmh (max 1 (smooth kmh 0.005))))
(acc2_vel         (- acc (smooth acc 0.1)))
(acc2             (+ 1 (* accel_feel 0.3 600 (max 0 acc2_vel))))
(acc2             (max 0.66 (min acc2 1.5)) 0.1)
(m_FL_load        (/ m_FL_load acc2))
(m_FR_load        (/ m_FR_load acc2))

(rel_weight_relaxed_FL (/ m_FL_load load_norm_wheel))
(rel_weight_relaxed_FR (/ m_FR_load load_norm_wheel))
(rel_weight_relaxed_FL (min rel_weight_relaxed_FL (blend (power grip_fl 1.2) 1 rel_weight_relaxed_FL)))
(rel_weight_relaxed_FR (min rel_weight_relaxed_FR (blend (power grip_fr 1.2) 1 rel_weight_relaxed_FR)))

(x                (* 10 (/ (min kmh 250) 400)))
(vel_mag_k_pull   (/ 1 (+ 1 (* 20 x))))
(vel_mag_k_pull   (+ 1 (* (- vel_mag_k_pull 1) 0.6)))
(vel_mag_k_pull   (* vel_mag_k_pull 1.2))

(mom_FL2          (* rel_weight_relaxed_FL vel_mag_k_pull))
(mom_FR2          (* rel_weight_relaxed_FR vel_mag_k_pull))

(mom_FL           mom_FL2)
(mom_FR           mom_FR2)

(grip_feel_rear   (min 1 (/ (+ (* grip_rl rel_weight_FL) (* grip_rr rel_weight_FR)) (max 0.0001 (+ rel_weight_FL rel_weight_FR)))))
(grip_feel_front  (min 1 (/ (+ (* grip_fl rel_weight_FL) (* grip_fr rel_weight_FR)) (max 0.0001 (+ rel_weight_FL rel_weight_FR)))))
(grip_l           (max 0 (- grip_fl (* rear_grip_loss_feel (- 1 grip_rl)))))
(grip_r           (max 0 (- grip_fr (* rear_grip_loss_feel (- 1 grip_rr)))))


############
#
# Momentum Rack - If you copy this over in full or partly, or base a solution on the same general methods after seeing it, please credit "Momentum Rack" however used("included"/"extended"/"modified"/"based on"), I would be pleased - Thanks.
#
# Handles each front wheel separately to calculate FFB when wheels are not in equal conditions.
#
# Calculations have not been shortened to make it easier to understand what is going on.
#

## limit rot velocity
(a                (abs kmh))
(f                (* vel_rot_limit_coef 1.1 0.004))
(a                (- 1 (/ 1 (+ 1 (* f a)))))
(a                (/ a (- 1 (/ 1 (+ 1 f)))))
(a                (/ a (max 0.000000001 (abs kmh))))
(n                1)
(pn               (/ (- 1 (/ 1 (+ 1 (* f n)))) (- 1 (/ 1 (+ 1 f)))))
(kmh_l            (* kmh a (/ n pn)))

(travel_l         (* vel_rot_scale 0.001 kmh_l))
(travel_r         (* vel_rot_scale 0.001 kmh_l))
(travel_l         (- travel_l (* grip_fl 0.00015 (+ (* front_drive_torque_feel (min 0 FL_long)) (* (/ kmh 100) rear_drive_torque_feel (min 0 (- RL_long (smooth RL_long 0.3))))))))
(travel_r         (- travel_r (* grip_fr 0.00015 (+ (* front_drive_torque_feel (min 0 FR_long)) (* (/ kmh 100) rear_drive_torque_feel (min 0 (- RR_long (smooth RR_long 0.3))))))))
(travel_l         (+ travel_l (* 0.00015 brake_feel (max 0 FL_long))))
(travel_r         (+ travel_r (* 0.00015 brake_feel (max 0 FR_long))))

(travel_l         (* travel_l (max 0.7 (+ 1 (* on_off_throttle_feel (- (smooth throttle 0.4) (smooth throttle 0.02)))))))
(travel_r         (* travel_r (max 0.7 (+ 1 (* on_off_throttle_feel (- (smooth throttle 0.4) (smooth throttle 0.02)))))))

(m_l              (if (min 0 (- travel_l 0.00001)) 1 (power (- 1 centering) travel_l)))
(m_r              (if (min 0 (- travel_r 0.00001)) 1 (power (- 1 centering) travel_r)))

(wanted_sa_l      (* (- steering_angle_l sa_delta_l) (blend m_l 0.5 1)))	#getting the old angle, to calc where it would have gone by itself
(wanted_sa_r      (* (- steering_angle_r sa_delta_r) (blend m_r 0.5 1)))

(angle_d_l        (- wanted_sa_l steering_angle_l))		#diff from where it would have gone by itself to actual steering
(angle_d_r        (- wanted_sa_r steering_angle_r))
(angle_d_l        (* angle_d_l 2.3))
(angle_d_r        (* angle_d_r 2.3))

(vel_res          (+ velocity_res_offset (* velocity_res_scale (min 1 (* kmh 0.004)))))
(angle_d_l        (* angle_d_l vel_res))
(angle_d_r        (* angle_d_r vel_res))

(angle_d_l        (* angle_d_l force_scale))
(angle_d_r        (* angle_d_r force_scale))

(angle_d_l        (- angle_d_l (* subtract_rot_velocity sa_delta_l)))
(angle_d_r        (- angle_d_r (* subtract_rot_velocity sa_delta_r)))

# power steering
(a_l              (abs angle_d_l))
(a_r              (abs angle_d_r))
(f                (* (max 0.001 power_steering_angle) 25))
(a_l              (- 1 (/ 1 (+ 1 (* f a_l)))))
(a_l              (/ a_l (- 1 (/ 1 (+ 1 f)))))
(a_r              (- 1 (/ 1 (+ 1 (* f a_r)))))
(a_r              (/ a_r (- 1 (/ 1 (+ 1 f)))))
(a_l              (/ a_l (max 0.000000001 (abs angle_d_l))))
(a_r              (/ a_r (max 0.000000001 (abs angle_d_r))))
(n                0.00001)
(pn               (/ (- 1 (/ 1 (+ 1 (* f n)))) (- 1 (/ 1 (+ 1 f)))))
(angle_d_l        (* angle_d_l a_l (/ n pn)))
(angle_d_r        (* angle_d_r a_r (/ n pn)))

# center full
	
(angle_d_l2       (* angle_d_l 25))
(angle_d_r2       (* angle_d_r 25))
(angle_d_lfb      (* center_full 2.5))
(angle_d_l2       (* (if (min 0 angle_d_l2) -1 1) (/ (+ (* 15 0.8 (abs angle_d_l2)) (- 1 (/ 1 (+ 1 (* 15 angle_d_lfb (abs angle_d_l2)))))) 13)))
(angle_d_r2       (* (if (min 0 angle_d_r2) -1 1) (/ (+ (* 15 0.8 (abs angle_d_r2)) (- 1 (/ 1 (+ 1 (* 15 angle_d_lfb (abs angle_d_r2)))))) 13)))
(angle_d_l2       (/ angle_d_l2 25))
(angle_d_r2       (/ angle_d_r2 25))
(angle_d_l2       (blend grip_fl angle_d_l angle_d_l2))
(angle_d_r2       (blend grip_fr angle_d_r angle_d_r2))

(tyre_resistance1 (blend load_power_fx tyre_resistance1_lo_df tyre_resistance1_hi_df))
(tyre_resistance2 (blend load_power_fx tyre_resistance2_lo_df tyre_resistance2_hi_df))
(tyre_resistance3 (blend load_power_fx tyre_resistance3_lo_df tyre_resistance3_hi_df))

(tyre_l_init      (* tyre_initial_resist (- (smooth angle_d_l 0.004) (smooth angle_d_l 0.02))))
(tyre_r_init      (* tyre_initial_resist (- (smooth angle_d_r 0.004) (smooth angle_d_r 0.02))))
(tyre_l_res1      (* tyre_resistance1 (smooth angle_d_l2 tyre_resistance1_timing)))
(tyre_r_res1      (* tyre_resistance1 (smooth angle_d_r2 tyre_resistance1_timing)))
(tyre_l_res2      (* tyre_resistance2 (smooth angle_d_l2 tyre_resistance2_timing)))
(tyre_r_res2      (* tyre_resistance2 (smooth angle_d_r2 tyre_resistance2_timing)))
(tyre_l_res3      (* tyre_resistance3 (smooth angle_d_l2 tyre_resistance3_timing)))
(tyre_r_res3      (* tyre_resistance3 (smooth angle_d_r2 tyre_resistance3_timing)))

(tyre_fl_stretch  (* front_tyre_stretch_feel FL_stretch angle_d_l wheel_diam_FL 0.5))
(tyre_fr_stretch  (* front_tyre_stretch_feel FR_stretch angle_d_r wheel_diam_FR 0.5))
(tyre_rl_stretch  (* rear_tyre_stretch_feel grip_rl RL_stretch angle_d_l wheel_diam_RL 0.5))
(tyre_rr_stretch  (* rear_tyre_stretch_feel grip_rr RR_stretch angle_d_r wheel_diam_RR 0.5))

(tyre_l           (+ tyre_l_init tyre_l_res1 tyre_l_res2 tyre_l_res3 tyre_fl_stretch tyre_rl_stretch))
(tyre_r           (+ tyre_r_init tyre_r_res1 tyre_r_res2 tyre_r_res3 tyre_fr_stretch tyre_rr_stretch))

(rack_momentum_l  (* 22 (spring tyre_l 100000 1 1) mom_FL))
(rack_momentum_r  (* 22 (spring tyre_r 100000 1 1) mom_FR))

# LFB
# weirdnes line here. without this "rack_momentum_2" does not get assigned in the next line

(rack_momentum_2  (+ (* rack_momentum_l grip_l) (* rack_momentum_r grip_r)))
(x                rack_momentum_2)
(x                (* (if (min 0 x) -1 1) (* (- 1 (/ 1 (+ 1 (* lfb_slider_strength 12 (abs x))))) (+ lfb_slider2 (* (abs x) (- 1 lfb_slider2))))))
(rack_momentum_2  x)

(rack_momentum_l  (* rack_momentum_l 2))
(rack_momentum_r  (* rack_momentum_r 2))
(x                rack_momentum_l)
(x                (* (if (min 0 x) -1 1) (* (- 1 (/ 1 (+ 1 (* lfb_slider_strength 12 (abs x))))) (+ lfb_slider2 (* (abs x) (- 1 lfb_slider2))))))
(rack_momentum_l  x)
(x                rack_momentum_r)
(x                (* (if (min 0 x) -1 1) (* (- 1 (/ 1 (+ 1 (* lfb_slider_strength 12 (abs x))))) (+ lfb_slider2 (* (abs x) (- 1 lfb_slider2))))))
(rack_momentum_r  x)
(rack_momentum_l  (* rack_momentum_l 0.5))
(rack_momentum_r  (* rack_momentum_r 0.5))

(rack_momentum    (+ (* rack_momentum_l grip_l) (* rack_momentum_r grip_r)))

(single_lfb_part  lfbval)
(rack_momentum    (blend single_lfb_part rack_momentum rack_momentum_2))

# Yaw

(yaw_l            (* (/ wanted_sa_l (* ratio_scale 3.14)) kmh -1 0.05))
(yaw_r            (* (/ wanted_sa_r (* ratio_scale 3.14)) kmh -1 0.05))
(yaw_l            (+ (* yaw_scale_fast yaw_l) (* yaw_scale_delayed (smooth yaw_l (/ yaw_delay (/ (max 1 kmh) 50)) ))))
(yaw_r            (+ (* yaw_scale_fast yaw_r) (* yaw_scale_delayed (smooth yaw_r (/ yaw_delay (/ (max 1 kmh) 50)) ))))
(yaw_l            (* yaw_l   grip_fl rel_weight_relaxed_FL grip_feel_rear)) 
(yaw_r            (* yaw_r   grip_fr rel_weight_relaxed_FR grip_feel_rear)) 
(yaw_l            (blend (/ 1 (+ 1 (power e (* 7 (- (/ (- (abs yaw_l) relax_yaw_pos) relax_yaw_width) 0.5))))) (* (if (min 0 yaw_l) -1 1) (+ relax_yaw_line2_start_y (* (abs yaw_l) (- 1 relax_yaw_line2_start_y)))) (power yaw_l (power (abs yaw_l) relax_yaw_coef))))
(yaw_r            (blend (/ 1 (+ 1 (power e (* 7 (- (/ (- (abs yaw_r) relax_yaw_pos) relax_yaw_width) 0.5))))) (* (if (min 0 yaw_r) -1 1) (+ relax_yaw_line2_start_y (* (abs yaw_r) (- 1 relax_yaw_line2_start_y)))) (power yaw_r (power (abs yaw_r) relax_yaw_coef))))

# Rack effects

(rack_effect      (+ yaw_l yaw_r))
(rack_effect      (blend 0.5 rack_effect (lfb rack_effect 0.175)))

(rack_momentum    (+ rack_momentum rack_effect))

# Rack friction
(rack_friction    (* 20 sa_delta_rack rack_friction))
(rack_momentum    (- rack_momentum rack_friction))

# Rack spring

(steer_spring_strength 0.0)
(want_steer       want_steer)
(steer_delta      (- want_steer steering_angle_rack))
(steer_delta      (if (max 0 (- (abs steer_delta) 0.5)) (* 0.5 (/ steer_delta (abs steer_delta))) steer_delta))
(want_steer       (+ steering_angle_rack steer_delta))
(steer_pull       (hard_clip (* steer_spring_strength steer_delta 0.4) 0.5))
(want_steer       (- want_steer (- steer_delta (hard_clip steer_delta (* 0.15 (max 0 (- (/ 1 (max kmh 2)) 0.05)))))))
(steer_pull       (- steer_pull (* 6 sa_delta_rack)))

(steer_pull       (* 12 (/ 1.5 master_rack) steer_pull grip_feel_front (* (/ 1 8) (+ FL_def FR_def 5))))
(rack_momentum    (blend (min 1 (/ kmh 3)) steer_pull rack_momentum))

# Smooth slightly
(rack_momentum    (smooth rack_momentum 0.0097))


###########################################################
#
# Normal static force reduction + Exponential static force reduction(affects the top end of the force exponentially)
#

(rack_momentum_long  (smooth rack_momentum static_force_reduction_timing))
(rack_momentum_short (- rack_momentum rack_momentum_long))
(rack_momentum_long  (* rack_momentum_long (- 1 normal_static_force_reduction)))
(rack_momentum_long  (* rack_momentum_long (blend (power (min 1 (abs rack_momentum_long)) 1.0) 1 (- 1 (blend load_power_fx exp_static_force_reduction exp_static_force_reduction_hi_df)))))
(rack_momentum       (+ rack_momentum_long rack_momentum_short))


###########################################################
#
# Build road slope details & bumps
#

(curb_started     curb_started)		#-1 means left, 1 means right. 0 means no curb active.
(curb_dist        curb_dist)
(curb_started     (if curb_started curb_started (if FL_bump_kerb -1 (if FR_bump_kerb 1 0))))
(curb_dist        (if (+ FL_bump_kerb FR_bump_kerb) 0 curb_dist))
(curb_started     (if (min 0 (- curb_dist 10)) curb_started 0))	#within 10m we keep same curb side
(curb_dist        (+ curb_dist (* dt (/ kmh 3.6))))
(boost_on_curb    13)

(FL_bump_kerb_active FL_bump_kerb_active)
(FR_bump_kerb_active FR_bump_kerb_active)
(FL_bump_kerb_active (if FL_bump_kerb 1 FL_bump_kerb_active))
(FR_bump_kerb_active (if FR_bump_kerb 1 FR_bump_kerb_active))
(FL_bump_kerb_active (max 0 (- FL_bump_kerb_active (* 4 dt))))
(FR_bump_kerb_active (max 0 (- FR_bump_kerb_active (* 4 dt))))

(FL_bal           FL_bal)
(FR_bal           FR_bal)
(FL_bal           (* FL_bal (power 0.03 dt)))
(FR_bal           (* FR_bal (power 0.03 dt)))
(FL_bal           (max FL_bal FL_load))
(FR_bal           (max FR_bal FR_load))

(FL_load3         (if FL_bump_kerb_active FL_bal FL_load))
(FR_load3         (if FR_bump_kerb_active FR_bal FR_load))

(dist_time_mult   (max 0.5 (/ 50 (max 10 kmh))))
(fast             (* 0.01 dist_time_mult))
(slow             (* 0.02 dist_time_mult))
(tyre_l           (- (smooth FL_load3 fast) (smooth FL_load3 slow)))
(tyre_r           (- (smooth FR_load3 fast) (smooth FR_load3 slow)))
(tyre_l           (/ tyre_l load_norm_wheel))
(tyre_r           (/ tyre_r load_norm_wheel))
(tyre_l           (max 0 (- tyre_l 0.05)))
(tyre_r           (max 0 (- tyre_r 0.05)))

(tyre_l           (* tyre_l (min 1 (/ (smooth FL_load3 fast) load_norm_wheel))))
(tyre_r           (* tyre_r (min 1 (/ (smooth FR_load3 fast) load_norm_wheel))))

(tyre_l           (* (* boost_on_curb FL_bump_kerb_active) 0.5 tyre_l))
(tyre_r           (* (* boost_on_curb FR_bump_kerb_active) 0.5 tyre_r))
(tyre_l           (* (if (min 0 tyre_l) -1 1) (- 1 (/ 1 (+ (abs (* 2 tyre_l)) 1)))))
(tyre_r           (* (if (min 0 tyre_r) -1 1) (- 1 (/ 1 (+ (abs (* 2 tyre_r)) 1)))))

(tyre_l           (* tyre_l (if (- curb_started 1) 1 -1)))	#curb started right side means multiply left side with -1
(tyre_r           (* tyre_r (if (+ curb_started 1) 1 -1)))	#curb started left side means multiply right side with -1
(slope_large      (spring (- tyre_r tyre_l) 100 0.3))

(slope_large      (* linkage_sign (- 1 (/ 1 (+ 1 (abs slope_large)))) (if (min 0 slope_large) -1 1)))


###########################################################
#
# Road features
#

(supress_micro_bumps 1)
(supress_large_bumps 2)

(left_texture_o   left_texture_o)
(right_texture_o  right_texture_o)
(left_texture     (* 0.002 (if (+ FL_bump_kerb FL_bump_offroad) 0 1) (- FL_load left_texture_o)))
(right_texture    (* 0.002 (if (+ FR_bump_kerb FR_bump_offroad) 0 1) (- FR_load right_texture_o)))
(left_texture_o   FL_load)
(right_texture_o  FR_load)
(texture          (+ left_texture right_texture))
(texture          (smooth texture 0.003))
(texture          (hard_clip texture 0.06))
(texture          (if (min 0 (- (abs texture) 0.0001)) 0 (power texture (power (abs texture) 0.02))))

(left_details      (* 0.002 (- FL_load (smooth FL_load 0.008))))
(right_details     (* 0.002 (- FR_load (smooth FR_load 0.008))))

(left_details_pos  left_details_pos)
(right_details_pos right_details_pos)
(left_details_pos  (+ left_details_pos (* (- left_details left_details_pos) (power 0.001 dt))))
(right_details_pos (+ right_details_pos (* (- right_details right_details_pos) (power 0.001 dt))))
(left_details_pos  (max left_details_pos left_details))
(right_details_pos (max right_details_pos right_details))
(left_details      (spring left_details_pos  80000 0.1))
(right_details     (spring right_details_pos 80000 0.1))
(left_details      (* (power (- 1 (min 1 (abs left_details))) supress_micro_bumps) left_details))
(right_details     (* (power (- 1 (min 1 (abs right_details))) supress_micro_bumps) right_details))
(left_details      (* left_details (if FL_bump_offroad 0 1) (blend (smooth FL_bump_kerb 0.01) micro_bumps_scale kerbs_surface_scale)))
(right_details     (* right_details (if FR_bump_offroad 0 1) (blend (smooth FR_bump_kerb 0.01) micro_bumps_scale kerbs_surface_scale)))
(left_details      (smooth left_details  (blend (smooth FL_bump_kerb 0.01) micro_bumps_smooth kerbs_surface_smooth)))
(right_details     (smooth right_details (blend (smooth FR_bump_kerb 0.01) micro_bumps_smooth kerbs_surface_smooth)))
(kerbs_details     (- left_details right_details))
(road_details      (blend (smooth (min 1 (+ FL_bump_kerb FR_bump_kerb)) 0.02) (+ left_details right_details) kerbs_details))

(left_bump        (* 0.002 (- FL_load (smooth FL_load 0.015))))
(right_bump       (* 0.002 (- FR_load (smooth FR_load 0.015))))
(left_bump_pos    left_bump_pos)
(right_bump_pos   right_bump_pos)
(left_bump_pos    (+ left_bump_pos (* (- left_bump left_bump_pos) (power 0.001 dt))))
(right_bump_pos   (+ right_bump_pos (* (- right_bump right_bump_pos) (power 0.001 dt))))
(left_bump_pos    (max left_bump_pos left_bump))
(right_bump_pos   (max right_bump_pos right_bump))
(left_bump        (spring left_bump_pos  10000 0.1))
(right_bump       (spring right_bump_pos 10000 0.1))
(left_bump        (* (power (- 1 (min 1 (abs left_bump))) supress_large_bumps) left_bump))
(right_bump       (* (power (- 1 (min 1 (abs right_bump))) supress_large_bumps) right_bump))
(left_bump        (* left_bump (if FL_bump_kerb 0 (if FL_bump_offroad large_offroad_bump_scale large_track_bump_scale))))
(right_bump       (* right_bump (if FR_bump_kerb 0 (if FR_bump_offroad large_offroad_bump_scale large_track_bump_scale))))
(road_bumps       (blend (smooth (min 1 (+ FL_bump_kerb FR_bump_kerb)) 0.02) (+ left_bump right_bump) (- left_bump right_bump)))

(left             (- (smooth FL_load 0.02) (smooth FL_load 0.1)))
(right            (- (smooth FR_load 0.02) (smooth FR_load 0.1)))
(suspension       (+ (* left mom_FL2) (* right mom_FR2 )))
(suspension       (spring suspension 2500 1.0))
(suspension       (* suspension 0.002 suspension_scale))
(as               (blend (min 1 (* (abs steering_angle_rack) 10)) 1 0))
(as               (power as 0.7))
(as               (smooth as 0.1))
(suspension       (* suspension as))

(left             (* 0.7 (- RL_load (smooth RL_load 0.01))))
(right            (* 0.7 (- RR_load (smooth RR_load 0.01))))
(left1            left1)
(right1           right1)
(left1            (* left1 (power 0.02 dt)))
(right1           (* right1 (power 0.02 dt)))
(left1            (max left left1))
(right1           (max right right1))
(left1            (+ left1  (* 0.5 (- (smooth RL_load 0.004) (smooth RL_load 0.008)))))
(right1           (+ right1 (* 0.5 (- (smooth RR_load 0.004) (smooth RR_load 0.008)))))
(rear             (+ (* left1 mom_FL2 (if FL_bump_offroad 0 1)) (* right1 mom_FR2 (if FR_bump_offroad 0 1))))
(rear             (- rear (smooth rear 0.02)))
(rear             (spring rear (* rear_bump_hard 10000) 1.0))
(rear             (* rear 0.0036 rear_bump_scale))

# LFB

# road features lfb according to fx
(lfb_apply        0.5)

(slope_large      (* slope_large kerb_bump_scale))
(slope_large2     (power slope_large (power (abs slope_large) (* -0.05))))
(slope_large2     (lfb slope_large2 0.15))
(slope_large      (blend lfb_apply slope_large slope_large2))

(road_features    (+ slope_large suspension rear road_bumps road_details (* texture texture_scale 0.5)))

(road_features    (blend speed_bias10 0.0 road_features))
(road_features    (* road_features 1.1 master_road (* 2 (power fx 1.6))))


###########################################################
#
# Scrub FX
#

(scrub_scale_front 0.32)
(scrub_scale_rear  0.28)

(FL_scrub   (* (if FL_bump_offroad 0 1) (smooth (abs FL_scrub) 0.01)))
(FR_scrub   (* (if FR_bump_offroad 0 1) (smooth (abs FR_scrub) 0.01)))
(RL_scrub   (* (if RL_bump_offroad 0 1) (smooth (abs RL_scrub) 0.01)))
(RR_scrub   (* (if RR_bump_offroad 0 1) (smooth (abs RR_scrub) 0.01)))

(F_scrub          (max FL_scrub FR_scrub))
(R_scrub          (max RL_scrub RR_scrub))

(F_scrub          (min 1 (* 0.1 F_scrub)))
(R_scrub          (min 1 (* 0.1 R_scrub)))

(scrub_deadzone 0.0)
(F_scrub          (max 0 (- F_scrub scrub_deadzone)))
(R_scrub          (max 0 (- R_scrub scrub_deadzone)))
(F_scrub          (/ F_scrub (- 1 scrub_deadzone)))
(R_scrub          (/ R_scrub (- 1 scrub_deadzone)))

(F_scrubVol       (power F_scrub 1))
(R_scrubVol       (power R_scrub 1))

#(F_scrubS         (* scrub_frq_scale (+ 0.5 (* 0.5 F_scrub))))
#(R_scrubS         (* scrub_frq_scale (+ 0.5 (* 0.5 R_scrub))))
(F_scrubS         (* scrub_frq_scale (+ 0.3 (* 0.7 kmh 0.01)) (+ 0.5 (* 0.5 F_scrub))))
(R_scrubS         (* scrub_frq_scale (+ 0.3 (* 0.7 kmh 0.01)) (+ 0.5 (* 0.5 R_scrub))))

(F_scrubP         F_scrubP)
(R_scrubP         R_scrubP)

(F_scrubP         (+ F_scrubP (* dt F_scrubS 0.4 750)))
(R_scrubP         (+ R_scrubP (* dt R_scrubS 0.4 500)))

(F_curve1_o       F_curve1_o)
(F_curve1         (sin (* 1.23 F_scrubP)))
(F_curve1         (power F_curve1 1.8))
(F_curve1_now     (if (min 0 (* F_curve1 (- F_curve1 F_curve1_o))) (* F_curve1 0.5) F_curve1))
(F_curve1_o       F_curve1)
(F_curve1_now     (spring F_curve1_now 2000000 1))

(R_curve1_o       R_curve1_o)
(R_curve1         (sin (* 1.23 R_scrubP)))
(R_curve1         (power R_curve1 1.8))
(R_curve1_now     (if (min 0 (* R_curve1 (- R_curve1 R_curve1_o))) (* R_curve1 0.5) R_curve1))
(R_curve1_o       R_curve1)
(R_curve1_now     (spring R_curve1_now 2000000 1))

(F_scrub          (+ (* 0.15 (sin (* 1.9 F_scrubP))) (* 0.1 (sin (* 2.23 F_scrubP))) (* 0.4 F_curve1_now)))
(R_scrub          (+ (* 0.15 (sin (* 1.9 R_scrubP))) (* 0.1 (sin (* 2.23 R_scrubP))) (* 0.4 R_curve1_now)))

(F_scrub          (* F_scrub F_scrubVol))
(R_scrub          (* R_scrub R_scrubVol))

(R_scrub          (* R_scrub (blend (abs F_scrub) 1 0.3)))


(F_scrub          (* F_scrub scrub_scale_front))
(R_scrub          (* R_scrub scrub_scale_rear))

(scrub_effect     (* scrub_scale (+ F_scrub R_scrub)))
(scrub_effect     (spring scrub_effect 75000 1 1))


###########################################################
#
# Tear FX
#

(FL_tear_early_vol (- 1 FL_tear_early))
(FL_tear_early_frq (+ 1 (* 5 FL_tear_early)))

(FR_tear_early_vol (- 1 FR_tear_early))
(FR_tear_early_frq (+ 1 (* 5 FR_tear_early)))

(RL_tear_early_vol (- 1 RL_tear_early))
(RL_tear_early_frq (+ 1 (* 5 RL_tear_early)))

(RR_tear_early_vol (- 1 RR_tear_early))
(RR_tear_early_frq (+ 1 (* 5 RR_tear_early)))

(o                (oscillator (* FL_tear_early_frq tear_frq_scale (+ 0.3 (* 0.7 kmh 0.01)) (+ 0.5 (* 0.4 FL_tear)) dt 50)))
(o                (power o 1.8))
(o2               (if (min 0 (* o (- o oo1))) (* o 0.5) o))
(oo1              o)
(FL_tear          (* tear_scale 0.5 (+ (* FL_tear_early_vol 0.3) (power FL_tear 0.75)) o2))
(FL_tear          (spring FL_tear (* tear_hard 700000) 1))

(o                (oscillator (* FR_tear_early_frq tear_frq_scale (+ 0.3 (* 0.7 kmh 0.01)) (+ 0.5 (* 0.4 FR_tear)) dt 50)))
(o                (power o 1.8))
(o2               (if (min 0 (* o (- o oo2))) (* o 0.5) o))
(oo2              o)
(FR_tear          (* tear_scale 0.5 (+ (* FR_tear_early_vol 0.3) (power FR_tear 0.75)) o2))
(FR_tear          (spring FR_tear (* tear_hard 700000) 1))

(o                (oscillator (* RL_tear_early_frq tear_frq_scale (+ 0.3 (* 0.7 kmh 0.01)) (+ 0.5 (* 0.4 RL_tear)) dt 50)))
(o                (power o 1.8))
(o2               (if (min 0 (* o (- o oo3))) (* o 0.5) o))
(oo3              o)
(RL_tear          (* tear_scale 0.5 (+ (* RL_tear_early_vol 0.3) (power RL_tear 0.75)) o2))
(RL_tear          (spring RL_tear (* tear_hard 700000) 1))

(o                (oscillator (* RR_tear_early_frq tear_frq_scale (+ 0.3 (* 0.7 kmh 0.01)) (+ 0.5 (* 0.4 RR_tear)) dt 50)))
(o                (power o 1.8))
(o2               (if (min 0 (* o (- o oo4))) (* o 0.5) o))
(oo4              o)
(RR_tear          (* tear_scale 0.5 (+ (* RR_tear_early_vol 0.3) (power RR_tear 0.75)) o2))
(RR_tear          (spring RR_tear (* tear_hard 700000) 1))

(tear_effect      (+ FL_tear FR_tear RL_tear RR_tear))


###########################################################
#
# Rolling road slip feel
#

(steer_angle      (* (+ steering_angle_FL steering_angle_FR) 0.5))
(steerPct         (* steer_angle steer_ratio 0.25))
(road_feel_pos    (+ road_feel_pos (* 10 (+ 0.02 (abs (* steerPct (/ 1.5 200)))) (+ 1 (* kmh 0.01)))))
(road_effect      (* road_rolling_slip_feel 4 (sin road_feel_pos) 0.01 (power kmh 0.5) 0.1 (+ 0.4 (* 1 (abs (* steerPct 1.3))))))


###########################################################
#
# Clipping
#

(rack_big         rack_momentum)
(rack_big         rack_momentum)

# Smart clip
(rack_big         (* gain2 rack_big master_rack))
(rack_big2        (smooth (abs rack_big) 0.04))
(pos_neg          (if (min 0.0 rack_big) -1 1))
(rack_big         (if (max 0 (- (abs rack_big) 0.5)) (+ (min 0.90 rack_big2) (- (abs rack_big) rack_big2)) (abs rack_big)))
(rack_big         (* rack_big pos_neg))

(max_rack_big     max_rack_big)
(rack_big2        (smooth (abs rack_big) 0.01))
(max_rack_big     (if (max 0 (- rack_big2 max_rack_big)) rack_big2 max_rack_big))
(rack_big         (if (max 0 (- max_rack_big 0.9)) (/ (* 0.9 rack_big) max_rack_big) rack_big))
(max_rack_big     (* max_rack_big (power 0.1 dt)))


###########################################################
#
# Engine FX
#

(max_rps          8000.0)
(cp               (+ cp (min 6.28 (* dt crankshaft 0.7))))
(cp               (if (min 0 cp) 0 cp))
(cp               (if (max 0 (- cp 6.283)) (- cp 6.283) cp))
(cp               (if (max 0 (- cp 6.283)) 0 cp))
(cp               (max 0 (min cp 6.283)))
(m                (min (/ kmh 80.0) 1.0))
(engine_scale     (blend m engine_scale_at_still engine_scale_at_speed))
(rps_scale        (/ crankshaft max_rps))
(rps_scale        (power rps_scale 0.8))
(rps_scale        (min rps_scale 0.02))
(rps_scale        (max rps_scale 0.14))
(load_mult        (smooth throttle 0.1))
(load_mult        (max load_mult 0.5))
(n                (if (max 0 (- cp 3.14159265)) -1 1))
(x                (if (max 0 (- cp 3.14159265)) (- cp 3.14159265) cp))
(engine_vibe      (/ (* 16 x (- 3.14159265 x)) (- (* 5 3.14159265 3.14159265) (* 4 x (- 3.14159265 x)))))
(engine_vibe      (* engine_vibe n))
(engine_effect    (* engine_scale load_mult engine_vibe rps_scale))


###########################################################
#
# Flatspots effect
#

(flatspots_effect (* flatspots_scale flatspot_vol (+ (* fl_fs_sm load_power_fx) (* fr_fs_sm load_power_fx))))


###########################################################
#
# Effects blend & scale
#

(effects          (+ engine_effect tear_effect scrub_effect flatspots_effect road_effect))
(effects          (* effects (* 2 (power fx 1.6)) master_effects))


###########################################################
#
# Final Rack & Effects Blending
#

(rack_big         (spring rack_big 200000 1 1))
(all              (+ rack_big road_features effects))

# Damping
(damping2         (* (min 1 (/ kmh 250)) 1500 damping))
(all              (- all (* damping2 (- sa_delta_rack (smooth sa_delta_rack 0.005)))))

# Limit explosions on time differences
(all              (* all (if (min 0 (- dt 0.1)) 1 0)))
(all              (* all (min 1 (* (max 0 (- et 0.5)) 0.5))))

(output           all)


###########################################################
#
# Scaler for info, no affect on output
#

(scale_window_init 10.0)
(scale_window_nominal 2.0)
(scale_soft_clear_t 10.0)
(scale_min 0.2)
(scale_max 2.0)
(scale_blend_t 2.0)
(signal_scale output
        1.0 1.0 1.0 1.0 1.0
        0.0
        0.0 0.0)


###########################################################
#
# Statistics output
#

(histogram output)

(info2 output)

(output (if (+ tighten_range tighten_falloff) (tighten output tighten_range tighten_falloff) output))


###########################################################
#
# Lock Stops
#

(custom_lock_stop 2.0)
(stops (bumpstop output 0.15 0.5 0.2 1.0))
(output (+ output (* stops custom_lock_stop)))

(doom_check output)
(output (hard_clip output 1.0))
