Rain splashes: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Finished this up, thanks for working on this ghost, you're awesome :))
No edit summary
Line 1: Line 1:
[[Category:Free source code]]
[[Category:Free source code]]
== Source Code ==
== Source Code ==


By default the rain splashes done in c_effects.cpp in the Simulate Rain function take place 20% of the time, and more importantly, only on water. This snippet will allow the rain to work on almost all surfaces, and also allows for a custom Rain Splash Particle Effect.
By default the rain splashes done in c_effects.cpp in the Simulate Rain function take place 20% of the time, and more importantly, only on water. This snippet will allow the rain to work on almost all surfaces, including static props, and also allows for a custom rain splash particle effect.


First, replace line 36 in c_effects.cpp with the following code.
First, replace line 36 in c_effects.cpp with the following code.
Line 26: Line 25:
       }
       }
[[Image:Rain_standards0005.jpg|thumb|If you set up things correctly, you will see this!]]
[[Image:Rain_standards0005.jpg|thumb|If you set up things correctly, you will see this!]]
== Particle Setup ==
== Particle Setup ==
[[Image:Rain_standards0000.jpg|thumb|What will happen if your particle is not precached.]]
[[Image:Rain_standards0000.jpg|thumb|What will happen if your particle is not precached.]]
The only specifications needed for your splash particle are that it be precached (See [[Particles_manifest.txt]]), and that it has "Constrain distance between control points" in the Constraints section of your particle.
The only specifications needed for your splash particle are that it be precached (See [[Particles_manifest.txt]]), and that it has "Constrain distance between control points" in the Constraints section of your particle.
Line 32: Line 33:
== Issues ==
== Issues ==


Currently this does not work on glass surfaces; looking for a way to fix this.
Currently this does not work on glass or displacement surfaces; looking for a way to fix this. Splashes will no longer appear on water.

Revision as of 19:54, 2 April 2009

Source Code

By default the rain splashes done in c_effects.cpp in the Simulate Rain function take place 20% of the time, and more importantly, only on water. This snippet will allow the rain to work on almost all surfaces, including static props, and also allows for a custom rain splash particle effect.

First, replace line 36 in c_effects.cpp with the following code.

ConVar r_RainSplashPercentage( "r_RainSplashPercentage", "99", FCVAR_CHEAT ); // N% chance of a rain particle making a splash.

NOTE: PLEASE REPLACE XXX'S WITH YOUR PARTICLE SYSTEM

Now, simply replace the "if" function at line 331 in c_effects.cpp, in the Temporary Entites section of the client code, with the following code.

     if ( m_Splashes.Count() < 99 )
     {
        if ( RandomInt( 0, 100 ) < r_RainSplashPercentage.GetInt() )
        {
           trace_t trace;
           UTIL_TraceLine(vOldPos, pParticle->m_Pos, MASK_ALL, NULL, COLLISION_GROUP_NPC, &trace);
           if( trace.fraction < 1 )
           {
              DispatchParticleEffect( "XXXX", trace.endpos, trace.m_pEnt->GetAbsAngles() , NULL );                      
           }
        }
     }
If you set up things correctly, you will see this!

Particle Setup

What will happen if your particle is not precached.

The only specifications needed for your splash particle are that it be precached (See Particles_manifest.txt), and that it has "Constrain distance between control points" in the Constraints section of your particle.

Issues

Currently this does not work on glass or displacement surfaces; looking for a way to fix this. Splashes will no longer appear on water.