Left 4 Dead 2

Left 4 Dead 2

158 ratings
RNG in 10 seconds (for modders)
By Ellie
This Guide explains how to add RNG (+ SYS rerandomize support) in 10 seconds, with the latest RNG codes.
   
Award
Favorite
Favorited
Unfavorite
STEP 1
Make sure you have a VTF with multiple frames, one for each skin.

If you do not know how to do this, read this guide (Animated Textures : Steps 1 to 5) or this guide ([Appendix] VTF with multiple textures)
STEP 2
In the VMT that needs to have multiple skins (frames) and that uses the VTF with multiple textures (frames), copy and paste just above the last } what you can find under ⚪️ below.

If this doesn't work and crashes the game when it loads (it does so if the object can never move, like map objects), copy and paste 🔶 instead.

Oh... and if you are doing a survivor, you can copy 🔵 instead. This will allow its dead corpse to match the skin it had when it was alive, just for you to know.
⚪️
////////////////////////////////////////////////////////////////////////////////////////////////// // RNG Pure 2020 (inline) - by Ellie ////////////////////////////////////////////////////////////////////////////////////////////////// $oneSkinPerMap "0" // Set to 1 to limit the skin at 1 per map $proxThreshold "500" // Add +100 if you can see the skin change $toleranceThreshold "10" $invisibleIsAlsoASkin "0" // 1 if any skin in the MOD has invisible skin $invisibleIsAlsoASkinHere "0" // 1 for invisible to be a skin for this VMT $boomerEffects "0" // Set to 1 and unquote for Boomer effects // $detail "models/survivors/survivor_it" // $detailscale 3 // $detailblendfactor ".001" // $detailblendmode "0" $meleeBloodEffects "0" // Set to 1 and unquote for Melee blood // $detail "models/infected/hunter/hunter_01_detail" // $detailscale "1.75" // $detailblendfactor .001 // $detailblendmode "0" /////////////////////////////////////////////////////////////////////////////// $randSYS "0.0" $randSYSTemp "0.0" $randSYSOverflow "0.0" $prepareStore "1000.0" $randSYSStored "1000.0" $randSYSInject "0.0" $randOffset "1000.0" $roundOffset ".05" $time "0" $hasBeenFar "0" $isEntity "0" $rerollRaw "0" $rerollRawStored "0" $rerollRNG "0" $checkMax "0.0" $maxFrame "0.0" $maxFramePlusOne "1.0" $maxFramePlusInvisible "1.0" $countingFinished "0.0" $injectFrame "0.0" $RNGInjectFrame "0.0" $prox "0" $proxCheck "0" $triggerPureRNG "0" $clampLimit "0.0" $tempDIV "0.0" $tempMULT "0.0" $tempFRAC "0.0" $tempOFFSET "0.0" $boomerAmount "0.0" $bloodAmount "0.0" $mo "-1" $zero "0.0" $one "1.0" $two "2.0" $three "3" $twentyfour "24" $oh "100" $fh "500" $ot "1000" Proxies { Add { srcVar1 "$maxFrame" srcVar2 "$one" resultVar "$maxFramePlusOne" } Add { srcVar1 "$invisibleIsAlsoASkin" srcVar2 "$maxFramePlusOne" resultVar "$maxFramePlusInvisible" } AnimatedTexture { animatedtexturevar "$basetexture" animatedtextureframenumvar "$checkMax" animatedtextureframerate "25" } LessOrEqual { LessEqualVar "$maxFrame" greaterVar "$checkMax" srcVar1 "$checkMax" srcVar2 "$maxFrame" resultVar "$maxFrame" } LessOrEqual { LessEqualVar "$one" greaterVar "$countingFinished" srcVar1 "$checkMax" srcVar2 "$zero" resultVar "$countingFinished" } LessOrEqual { LessEqualVar "$zero" greaterVar "$countingFinished" srcVar1 "$maxFrame" srcVar2 "$zero" resultVar "$countingFinished" } ConVar { convar "cl_buy_favorite_nowarn" resultVar "$rerollRaw" } Int { srcVar1 "$rerollRaw" resultVar "$rerollRaw" } Subtract { srcVar1 "$rerollRaw" srcVar2 "$rerollRawStored" resultVar "$rerollRNG" } Abs { srcVar1 "$rerollRNG" resultVar "$rerollRNG" } Equals { srcVar1 "$rerollRaw" resultVar "$rerollRawStored" } LessOrEqual { LessEqualVar "$randOffset" greaterVar "$ot" srcVar1 "$rerollRNG" srcVar2 "$zero" resultVar "$randOffset" } LessOrEqual { LessEqualVar "$randSYSStored" greaterVar "$ot" srcVar1 "$rerollRNG" srcVar2 "$zero" resultVar "$randSYSStored" } CurrentTime { resultVar "$time" } Divide { srcVar1 "$time" srcVar2 "$maxFramePlusInvisible" resultVar "$tempDIV" } Frac { srcVar1 "$tempDIV" resultVar "$tempDIV" } Multiply { srcVar1 "$tempDIV" srcVar2 "$maxFramePlusInvisible" resultVar "$tempDIV" } Add { srcVar1 "$tempDIV" srcVar2 "$roundOffset" resultVar "$tempDIV" } LessOrEqual { LessEqualVar "$randOffset" greaterVar "$tempDIV" srcVar1 "$randOffset" srcVar2 "$fh" resultVar "$randOffset" } EntityRandom { scale "$maxFramePlusInvisible" resultVar "$randSYSTemp" } Add { srcVar1 "$randSYSTemp" srcVar2 "$randOffset" resultVar "$randSYSTemp" } Subtract { srcVar1 "$randSYSTemp" srcVar2 "$maxFramePlusInvisible" resultVar "$randSYSOverflow" } LessOrEqual { LessEqualVar "$randSYSTemp" greaterVar "$randSYSOverflow" srcVar1 "$randSYSTemp" srcVar2 "$maxFramePlusInvisible" resultVar "$randSYS" } LessOrEqual { LessEqualVar "$prepareStore" greaterVar "$randSYS" srcVar1 "$countingFinished" srcVar2 "$zero" resultVar "$prepareStore" } LessOrEqual { LessEqualVar "$randSYSStored" greaterVar "$prepareStore" srcVar1 "$randSYSStored" srcVar2 "$fh" resultVar "$randSYSStored" } LessOrEqual { LessEqualVar "$randSYS" greaterVar "$randSYSStored" srcVar1 "$oneSkinPerMap" srcVar2 "$zero" resultVar "$randSYSInject" } Multiply { srcVar1 "$countingFinished" srcVar2 "$randSYSInject" resultVar "$injectFrame" } EntityRandom { scale "1" resultVar "$isEntity" } PlayerProximity { scale "1" resultVar "$prox" } Subtract { srcVar1 "$prox" srcVar2 "$proxThreshold" resultVar "$proxCheck" } Abs { srcVar1 "$proxCheck" resultVar "$proxCheck" } LessOrEqual { LessEqualVar "$one" greaterVar "$zero" srcVar1 "$proxCheck" srcVar2 "$toleranceThreshold" resultVar "$triggerPureRNG" } Add { srcVar1 "$triggerPureRNG" srcVar2 "$rerollRNG" resultVar "$triggerPureRNG" } LessOrEqual { LessEqualVar "$zero" greaterVar "$isEntity" srcVar1 "$triggerPureRNG" srcVar2 "$zero" resultVar "$isEntity" } LessOrEqual { LessEqualVar "$hasBeenFar" greaterVar "$one" srcVar1 "$RNGinjectFrame" srcVar2 "$zero" resultVar "$hasBeenFar" } LessOrEqual { LessEqualVar "$one" greaterVar "$isEntity" srcVar1 "$hasBeenFar" srcVar2 "$zero" resultVar "$isEntity" } LessOrEqual { LessEqualVar "$RNGinjectFrame" greaterVar "$injectFrame" srcVar1 "$isEntity" srcVar2 "$zero" resultVar "$injectFrame" } LessOrEqual { LessEqualVar "$RNGinjectFrame" greaterVar "$injectFrame" srcVar1 "$isEntity" srcVar2 "$zero" resultVar "$injectFrame" } LessOrEqual { LessEqualVar "$maxFrame" greaterVar "$maxFramePlusOne" srcVar1 "$invisibleIsAlsoASkinHere" srcVar2 "$zero" resultVar "$clampLimit" } LessOrEqual { LessEqualVar "$injectFrame" greaterVar "$clampLimit" srcVar1 "$injectFrame" srcVar2 "$clampLimit" resultVar "$RNGinjectFrame" } Equals { srcVar1 "$RNGinjectFrame" resultVar "$frame" } Int { srcVar1 "$frame" resultVar "$frame" } LessOrEqual { LessEqualVar "$one" greaterVar "$zero" srcVar1 "$frame" srcVar2 "$maxframe" resultVar "$alpha" } IT { resultVar "$boomerAmount" } LessOrEqual { LessEqualVar "$detailblendfactor" greaterVar "$boomerAmount" srcVar1 "$boomerEffects" srcVar2 "$zero" resultVar "$detailblendfactor" } BloodyHands { resultVar "$bloodAmount" } LessOrEqual { LessEqualVar "$detailblendfactor" greaterVar "$bloodAmount" srcVar1 "$meleeBloodEffects" srcVar2 "$zero" resultVar "$detailblendfactor" } }
🔶
////////////////////////////////////////////////////////////////////////////////////////////////// // RNG Map 2020 (inline) - by Ellie ////////////////////////////////////////////////////////////////////////////////////////////////// $distancePerFrame "4000" $oneSkinPerMap "0" // Set to 1 to limit to 1 skin per map $frameOffset "0" // Offset for the frame if skinfamilies ////////////////////////////////////////////////////////////////////////////////////////////////// $pos "[0 0 0]" $posX "0.0" $posY "0.0" $time "0" $timeOffset "0" $rerollRaw "0" $rerollRawStored "0" $rerollRNG "0" $randSYS "0.0" $prepareStore "1000.0" $randSYSStored "1000.0" $randSYSInject "0.0" $randSYSOffset "0.0" $randSYSOverflow "0.0" $checkMax "0.0" $maxFrame "0.0" $maxFramePlusOne "1.0" $countingFinished "0.0" $injectFrame "0.0" $RNGInjectFrame "0.0" $distanceRollback "0.0" $tempDIV "0.0" $tempMULT "0.0" $tempOFFSET "0.25" $tempFRAC "0.0" $mo "-1" $zero "0.0" $one "1.0" $two "2.0" $oh "100" $fh "500" $ot "1000" $tt "10000" Proxies { AnimatedTexture { animatedtexturevar "$basetexture" animatedtextureframenumvar "$checkMax" animatedtextureframerate "25" } LessOrEqual { LessEqualVar "$maxFrame" greaterVar "$checkMax" srcVar1 "$checkMax" srcVar2 "$maxFrame" resultVar "$maxFrame" } Add { srcVar1 "$maxFrame" srcVar2 "$one" resultVar "$maxFramePlusOne" } LessOrEqual { LessEqualVar "$one" greaterVar "$countingFinished" srcVar1 "$checkMax" srcVar2 "$zero" resultVar "$countingFinished" } LessOrEqual { LessEqualVar "$zero" greaterVar "$countingFinished" srcVar1 "$maxFrame" srcVar2 "$zero" resultVar "$countingFinished" } Multiply { srcVar1 "$distancePerFrame" srcVar2 "$maxFramePlusOne" resultVar "$distanceRollback" } PlayerPosition { scale 1 resultVar "$pos" } Clamp { srcVar1 "$zero" min "$pos[0]" max "$pos[0]" resultVar "$posX" } Abs { srcVar1 "$posX" resultVar "$posX" } LessOrEqual { LessEqualVar "$posX" greaterVar "$timeOffset" srcVar1 "$timeOffset" srcVar2 "$zero" resultVar "$timeOffset" } Clamp { srcVar1 "$zero" min "$pos[1]" max "$pos[1]" resultVar "$posY" } Abs { srcVar1 "$posY" resultVar "$posY" } Add { srcVar1 "$posY" srcVar2 "$posX" resultVar "$posY" } Divide { srcVar1 "$posY" srcVar2 "$distanceRollback" resultVar "$posY" } Frac { srcVar1 "$posY" resultVar "$posY" } Multiply { srcVar1 "$posY" srcVar2 "$maxFramePlusOne" resultVar "$randSYS" } CurrentTime { resultVar "$time" } Add { srcVar1 "$time" srcVar2 "$timeOffset" resultVar "$tempMULT" } Divide { srcVar1 "$tempMULT" srcVar2 "$maxFramePlusOne" resultVar "$tempDIV" } Frac { srcVar1 "$tempDIV" resultVar "$tempDIV" } Multiply { srcVar1 "$tempDIV" srcVar2 "$maxFramePlusOne" resultVar "$tempDIV" } LessOrEqual { LessEqualVar "$tempDIV" greaterVar "$randSYSOffset" srcVar1 "$randSYSOffset" srcVar2 "$zero" resultVar "$randSYSOffset" } Add { srcVar1 "$randSYSOffset" srcVar2 "$randSYS" resultVar "$randSYS" } Subtract { srcVar1 "$randSYS" srcVar2 "$maxFramePlusOne" resultVar "$randSYSOverflow" } LessOrEqual { LessEqualVar "$randSYS" greaterVar "$randSYSOverflow" srcVar1 "$randSYS" srcVar2 "$maxFramePlusOne" resultVar "$randSYS" } Add { srcVar1 "$randSYS" srcVar2 "$frameOffset" resultVar "$randSYS" } Subtract { srcVar1 "$randSYS" srcVar2 "$maxFramePlusOne" resultVar "$randSYSOverflow" } LessOrEqual { LessEqualVar "$randSYS" greaterVar "$randSYSOverflow" srcVar1 "$randSYS" srcVar2 "$maxFramePlusOne" resultVar "$randSYS" } ConVar { convar "cl_buy_favorite_nowarn" resultVar "$rerollRaw" } Int { srcVar1 "$rerollRaw" resultVar "$rerollRaw" } Subtract { srcVar1 "$rerollRaw" srcVar2 "$rerollRawStored" resultVar "$rerollRNG" } Abs { srcVar1 "$rerollRNG" resultVar "$rerollRNG" } Equals { srcVar1 "$rerollRaw" resultVar "$rerollRawStored" } LessOrEqual { LessEqualVar "$randSYSOffset" greaterVar "$zero" srcVar1 "$rerollRNG" srcVar2 "$zero" resultVar "$randSYSOffset" } LessOrEqual { LessEqualVar "$randSYSStored" greaterVar "$ot" srcVar1 "$rerollRNG" srcVar2 "$zero" resultVar "$randSYSStored" } LessOrEqual { LessEqualVar "$prepareStore" greaterVar "$randSYS" srcVar1 "$countingFinished" srcVar2 "$zero" resultVar "$prepareStore" } LessOrEqual { LessEqualVar "$randSYSStored" greaterVar "$prepareStore" srcVar1 "$randSYSStored" srcVar2 "$fh" resultVar "$randSYSStored" } LessOrEqual { LessEqualVar "$randSYS" greaterVar "$randSYSStored" srcVar1 "$oneSkinPerMap" srcVar2 "$zero" resultVar "$randSYSInject" } Multiply { srcVar1 "$countingFinished" srcVar2 "$randSYSInject" resultVar "$injectFrame" } LessOrEqual { LessEqualVar "$frame" greaterVar "$randSYSInject" srcVar1 "$injectFrame" srcVar2 "$zero" resultVar "$frame" } LessOrEqual { LessEqualVar "$frame" greaterVar "$maxframe" srcVar1 "$frame" srcVar2 "$maxframe" resultVar "$frame" } }
🔵
////////////////////////////////////////////////////////////////////////////////////////////////// // RNG Entity 2020 (inline) - by Ellie ////////////////////////////////////////////////////////////////////////////////////////////////// $oneSkinPerMap "0" // Set to 1 to limit the skin at 1 per map $invisibleIsAlsoASkin "0" // 1 if any skin in the MOD has invisible skin $invisibleIsAlsoASkinHere "0" // 1 for invisible to be a skin for this VMT $boomerEffects "0" // Set to 1 and unquote for Boomer effects // $detail "models/survivors/survivor_it" // $detailscale 3 // $detailblendfactor ".001" // $detailblendmode "0" $meleeBloodEffects "0" // Set to 1 and unquote for Melee blood // $detail "models/infected/hunter/hunter_01_detail" // $detailscale "1.75" // $detailblendfactor .001 // $detailblendmode "0" /////////////////////////////////////////////////////////////////////////////// $randSYS "0.0" $randSYSTemp "0.0" $randSYSOverflow "0.0" $prepareStore "1000.0" $randSYSStored "1000.0" $randSYSInject "0.0" $randOffset "1000.0" $roundOffset ".05" $time "0" $isEntity "0" $rerollRaw "0" $rerollRawStored "0" $rerollRNG "0" $checkMax "0.0" $maxFrame "0.0" $maxFramePlusOne "1.0" $maxFramePlusInvisible "1.0" $countingFinished "0.0" $injectFrame "0.0" $RNGInjectFrame "0.0" $clampLimit "0.0" $tempDIV "0.0" $tempMULT "0.0" $tempFRAC "0.0" $tempOFFSET "0.25" $boomerAmount "0.0" $bloodAmount "0.0" $mo "-1" $zero "0.0" $one "1.0" $two "2.0" $three "3" $four "4" $oh "100" $fh "500" $ot "1000" Proxies { Add { srcVar1 "$maxFrame" srcVar2 "$one" resultVar "$maxFramePlusOne" } Add { srcVar1 "$invisibleIsAlsoASkin" srcVar2 "$maxFramePlusOne" resultVar "$maxFramePlusInvisible" } AnimatedTexture { animatedtexturevar "$basetexture" animatedtextureframenumvar "$checkMax" animatedtextureframerate "25" } LessOrEqual { LessEqualVar "$maxFrame" greaterVar "$checkMax" srcVar1 "$checkMax" srcVar2 "$maxFrame" resultVar "$maxFrame" } LessOrEqual { LessEqualVar "$one" greaterVar "$countingFinished" srcVar1 "$checkMax" srcVar2 "$zero" resultVar "$countingFinished" } LessOrEqual { LessEqualVar "$zero" greaterVar "$countingFinished" srcVar1 "$maxFrame" srcVar2 "$zero" resultVar "$countingFinished" } ConVar { convar "cl_buy_favorite_nowarn" resultVar "$rerollRaw" } Int { srcVar1 "$rerollRaw" resultVar "$rerollRaw" } Subtract { srcVar1 "$rerollRaw" srcVar2 "$rerollRawStored" resultVar "$rerollRNG" } Abs { srcVar1 "$rerollRNG" resultVar "$rerollRNG" } Equals { srcVar1 "$rerollRaw" resultVar "$rerollRawStored" } LessOrEqual { LessEqualVar "$randOffset" greaterVar "$ot" srcVar1 "$rerollRNG" srcVar2 "$zero" resultVar "$randOffset" } LessOrEqual { LessEqualVar "$randSYSStored" greaterVar "$ot" srcVar1 "$rerollRNG" srcVar2 "$zero" resultVar "$randSYSStored" } CurrentTime { resultVar "$time" } Divide { srcVar1 "$time" srcVar2 "$maxFramePlusInvisible" resultVar "$tempDIV" } Frac { srcVar1 "$tempDIV" resultVar "$tempDIV" } Multiply { srcVar1 "$tempDIV" srcVar2 "$maxFramePlusInvisible" resultVar "$tempDIV" } Add { srcVar1 "$tempDIV" srcVar2 "$roundOffset" resultVar "$tempDIV" } LessOrEqual { LessEqualVar "$randOffset" greaterVar "$tempDIV" srcVar1 "$randOffset" srcVar2 "$fh" resultVar "$randOffset" } EntityRandom { scale "$maxFramePlusInvisible" resultVar "$randSYSTemp" } Add { srcVar1 "$randSYSTemp" srcVar2 "$randOffset" resultVar "$randSYSTemp" } Subtract { srcVar1 "$randSYSTemp" srcVar2 "$maxFramePlusInvisible" resultVar "$randSYSOverflow" } LessOrEqual { LessEqualVar "$randSYSTemp" greaterVar "$randSYSOverflow" srcVar1 "$randSYSTemp" srcVar2 "$maxFramePlusInvisible" resultVar "$randSYS" } LessOrEqual { LessEqualVar "$prepareStore" greaterVar "$randSYS" srcVar1 "$countingFinished" srcVar2 "$zero" resultVar "$prepareStore" } LessOrEqual { LessEqualVar "$randSYSStored" greaterVar "$prepareStore" srcVar1 "$randSYSStored" srcVar2 "$fh" resultVar "$randSYSStored" } LessOrEqual { LessEqualVar "$randSYS" greaterVar "$randSYSStored" srcVar1 "$oneSkinPerMap" srcVar2 "$zero" resultVar "$randSYSInject" } Multiply { srcVar1 "$countingFinished" srcVar2 "$randSYSInject" resultVar "$injectFrame" } EntityRandom { scale "1" resultVar "$isEntity" } LessOrEqual { LessEqualVar "$RNGinjectFrame" greaterVar "$injectFrame" srcVar1 "$isEntity" srcVar2 "$zero" resultVar "$injectFrame" } LessOrEqual { LessEqualVar "$maxFrame" greaterVar "$maxFramePlusOne" srcVar1 "$invisibleIsAlsoASkinHere" srcVar2 "$zero" resultVar "$clampLimit" } LessOrEqual { LessEqualVar "$injectFrame" greaterVar "$clampLimit" srcVar1 "$injectFrame" srcVar2 "$clampLimit" resultVar "$RNGinjectFrame" } Equals { srcVar1 "$RNGinjectFrame" resultVar "$frame" } Int { srcVar1 "$frame" resultVar "$frame" } LessOrEqual { LessEqualVar "$one" greaterVar "$zero" srcVar1 "$frame" srcVar2 "$maxframe" resultVar "$alpha" } IT { resultVar "$boomerAmount" } LessOrEqual { LessEqualVar "$detailblendfactor" greaterVar "$boomerAmount" srcVar1 "$boomerEffects" srcVar2 "$zero" resultVar "$detailblendfactor" } BloodyHands { resultVar "$bloodAmount" } LessOrEqual { LessEqualVar "$detailblendfactor" greaterVar "$bloodAmount" srcVar1 "$meleeBloodEffects" srcVar2 "$zero" resultVar "$detailblendfactor" } }
CONGRATULATIONS
Congratulations, you have just added RNG to your mod, with the latest, up to date codes.

You do not need to tell the code how many skins (frames) you have.

Even if the code is big, it doesn't slow the game. It works at 300fps.

Note that unlike the old codes, these codes are especially useful for items and guns, because now, the item/gun you have in hand will match the one you pick in the world (if they use the same VMT).

Enjoy! And if you liked this guide, please give it a thumbs up.

For any question, feel free to ask.
21 Comments
Crabby Cakes 19 Jun @ 9:14am 
Pasting these creates an error for me
Bane 3 Dec, 2024 @ 8:46am 
i'm not sure if you are still reading these, but please could you explain how to make the other costumes in the mdl aka the jacket (hibari dlc2 model appear)?
multoman 1 Oct, 2024 @ 2:30am 
is there way a to change the rng textures ingame, it would be useful to check the skins and get some pictures for thumbnails faster instead of restarting the map everytime.
Pwnage Peanut 3 Aug, 2024 @ 10:28pm 
The Nobel Prize is waiting for you
SPC_Samhain 28 Nov, 2023 @ 5:49pm 
how do I make one but only for models? I'm just starting out making a L4D2 Mod
SuperMario20 28 May, 2023 @ 11:34pm 
🔶 doesn't seem to work evenly in localhost games, like in the previous guide.
SuperMario20 23 May, 2023 @ 3:51pm 
Oh, NVM. The tutorials on SYS RNG explained it
SuperMario20 21 May, 2023 @ 5:18pm 
Found out it was the ConVar line. Why does it use the value of "cl_buy_favorite_nowarn"? I changed "ConVar" to an "Equals" line and "convar" to "srcVar1", and "cl_buy_favorite_nowarn" to "$zero" and now it works fine. What was this line supposed to do?
SuperMario20 21 May, 2023 @ 8:36am 
From a distance, the RNG textures seem to just change, even when the .vtf has no mipmaps. Do you know what could be causing this? Using 🔶 btw
Watermelon Farmer 6 Aug, 2022 @ 6:45am 
Best tutorial ever.