Half-Life 2

Half-Life 2

Not enough ratings
How to make RNG (Using the Source Engine)
By Buggy Cheese
How to add RNG in 10 seconds
   
Award
Favorite
Favorited
Unfavorite
Step 1
Make sure you have a VTF with multiple frames, one for each skin, how?
Basically, edit the VTF file using VTFEdit. Select multiple images at once and then the other images will be in their own "frame" in order. Once you created the VTF, you'll want to include one of these two proxies below into your VMT

Note: this is the best I can do for now, still finding ways to improve them, and this guide is a simplified version, full version here
Step 2
Real RNG

Q : What effects does this do ?
➞ This makes every object have a different texture, even within the same map

Q : What can I use it on ?
➞ NPCs, some props, playermodels and ammo boxes

Pro: Every object have different texture on the same map
Con: Glitch out, crash if applied on static props or TF2 cosmetics.

Once created the VTF, you'll want to include this proxy into your VMT:

"Proxies" { "EntityRandom" { "scale" "@@" "resultVar" "$frame" } }

Change the @@ depending on how many frames your VTF will have. For example 1.99 = 2 frames, 5.99 = 6 frames, 9.99 = 10 frames, and etc.
The code directly injects the value of the EntityRandom in the $frame.
Step 2 (alt)
True RNG

Q : What effects does this do ?
➞ This randomizes the texture "per map". Every object will have the same texture within the map. Though it doesn't allow to make textures random on their own.

Q : What can I use it on ?
➞ NPCs, most props, playermodels and ammo boxes

Pro: will not glitch out
Con: will crash if improperly applied, or applied on static props. RNG per map is the only one avaliable

Once created the VTF, you'll want to include this proxy into your VMT:

$frame 1000 $fh 500 $rand 0 "Proxies" { "UniformNoise" { "minVal" "0" "maxVal" "@@" "resultVar" "$rand" } "LessOrEqual" { "LessEqualVar" "$frame" "greaterVar" "$rand" "srcVar1" "$frame" "srcVar2" "$fh" "resultVar" "$frame" } }

Change the @@ depending on how many frames your VTF will have. For example 1.99 = 2 frames, 5.99 = 6 frames, 9.99 = 10 frames, and etc.

The code does this :
1 : Compares $frame to $fh (500)
2 : If $frame > $fh* (500), then copy the $rand value into $frame...
3 : ...else copy $frame into $frame (= do nothing)
* this is only the case at the very beginning, since $frame has 1000 as default value.

The "UniformNoise" proxy keeps generating random numbers. $rand changes every fraction of second, this explains the need to "stop" the generation with the LessOrEqual proxy.
Step 2 (Alternative)
True RNG

Q : What effects does this do ?
➞ This allows the different VMT's of an items to share the same $frame. It's therefore useful if you can't use EntityRandom : True RNG (that does the same thing), especially if what you're replacing is a map item

Q : What can I use it on ?
➞ Anything

Pro: Works on everything
Con: The textures can sometimes be full-black for the first few seconds you came across the material, especially late in the map. RNG per map may be the only one available.

Once created the VTF, you'll want to include this proxy into your VMT:

$numberoflastframe @@ // <== [[MODIFY ONLY THIS BY THE N° OF YOUR LAST FRAME]] $framec 0 $numberoflastframeplus 0 $ramp 0 $inval 0 $frame 300 $zero 0 $nn .74 $one 1 $two 2 $docorr 0 $framecdo 0 "Proxies" { "Add" { "srcVar1" "$numberoflastframe" "srcVar2" "$nn" "resultVar" "$framec" } "Divide" { "srcVar1" "$framec" "srcVar2" "$two" "resultVar" "$numberoflastframeplus" } "LinearRamp" { "rate" "$numberoflastframeplus" "initialValue" "$inval" "resultVar" "$ramp" } "LessOrEqual" { "LessEqualVar" "$zero" "greaterVar" "$one" "srcVar1" "$ramp" "srcVar2" "$framec" "resultVar" "$docorr" } "Multiply" { "srcVar1" "$framec" "srcVar2" "$docorr" "resultVar" "$framecdo" } "Subtract" { "srcVar1" "$inval" "srcVar2" "$framecdo" "resultVar" "$inval" } "LessOrEqual" { "LessEqualVar" "$frame" "greaterVar" "$ramp" "srcVar1" "$frame" "srcVar2" "$framec" "resultVar" "$frame" } }

Change the @@ depending on how many frames your VTF will have. For example 1.99 = 2 frames, 5.99 = 6 frames, 9.99 = 10 frames, and etc.

The code is complicated ; basically, it generated a looping number using a LinearRamp proxy, this number "loops" by reducing the offset of the LinearRamp when the LinearRamp reaches the maximal frame of the VTF (reducing the result of the Proxy doesn't work).
What determines the RNG is actually the time it takes for the game to load (kinda), and more precisely the difference between the loading time of the different players.
Conclusion
Now you done it, simple RNG like ABC