Rain splashes: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(New page: Category:Free source code == Source Code == By default the rain splashes done in c_effects.cpp in the Simulate Rain function take place randomly, and more importantly only on water...)
 
(Finished this up, thanks for working on this ghost, you're awesome :))
Line 3: Line 3:
== 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 randomly, and more importantly only on water. This snippet will allow the rain to work on all surfaces, 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'''
'''NOTE: PLEASE REPLACE XXX'S WITH YOUR PARTICLE SYSTEM'''


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.  
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() < 20 )
       if ( m_Splashes.Count() < 99 )
       {
       {
         if ( RandomInt( 0, 100 ) < r_RainSplashPercentage.GetInt() )
         if ( RandomInt( 0, 100 ) < r_RainSplashPercentage.GetInt() )
Line 22: Line 25:
         }
         }
       }
       }
[[Image:Rain_standards0005.jpg|thumb|If you set up things correctly, you will see this!]]
== Particle Setup ==
[[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.
== Issues ==
Currently this does not work on glass surfaces; looking for a way to fix this.

Revision as of 19:50, 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, 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 surfaces; looking for a way to fix this.