CortTest
Class RainGen

source: e:\games\UnrealTournament\CortTest\Classes\RainGen.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Effects
         |
         +--CortTest.RainGen
Direct Known Subclasses:None

class RainGen
extends Engine.Effects

//================================================= // RainGen. // author: c0mpi1e(Carlos Cuello) // Total Time So Far: 20 hrs. // // legal: Everything in this class is 100% original and is the // property of me. It was originally // produced for the USCM:Infestation TC, and any revisions // to this mod will be used in that. This is the final // version that I will release to the public. You may use // this in any map and release it as part of any map you // create as long as you give me full credit. If you need // anything added in particular you can email me and I'll see // what I can do. // // This is basically what controls the Rain and is the only thing you // will have to work with. I wanted to keep this something that anyone // can use, tried to keep it very configurable and tried to make // everything be handled from UnrealEd. So for all you map makers, // simply add as many raingen's to the ceiling of the sky where you want // it to fall from. The RainGen delivers a limited range of raindrops, so // do not expect one raingen to create a monsoon. To change the various // settings for the rain, select all the RainGens in your map and click // on the properties dialog box, then click on the several Rain propety // menu's that appear(Rain_Behaviour, Rain_Looks, Rain_Sounds). The // intensity variable should be kept between 0 and 5 or so to keep // rendering speed good. DropSpeed should be negative for faster rain, // and positive for slower rain, however beware that a positive integer // greater than 100 or so will cause the raindrops to go up and hit the // ceiling. // // Note: For this release, lightning is not working, if you absolutley // need it, then email me and I'll see what I can do. //=================================================
Variables
 Effects D
           the actual raindrop
 Effects L
           used for lightining
 vector NewLoc
           the location of the random rain drop
 int ct
           misc counter variable, used for


Function Summary
 
simulated
PreBeginPlay()
     
// Set all our variables.
 int RandomNeg(int Max)
     
// Find a random number from -Max to Max
 void Tick(float deltatime)
     
// This is where everything takes place
 void Timer()
     
// This is where thunder and lightning are handled



Source Code


00001	//=================================================
00002	// RainGen.
00003	// author: c0mpi1e(Carlos Cuello)
00004	// Total Time So Far: 20 hrs.
00005	//
00006	// legal: Everything in this class is 100% original and is the
00007	//        property of me.  It was originally
00008	//      produced for the USCM:Infestation TC, and any revisions
00009	//      to this mod will be used in that.  This is the final
00010	//      version that I will release to the public.  You may use
00011	//      this in any map and release it as part of any map you
00012	//      create as long as you give me full credit.  If you need
00013	//      anything added in particular you can email me and I'll see
00014	//      what I can do. 
00015	//
00016	// This is basically what controls the Rain and is the only thing you
00017	// will have to work with.  I wanted to keep this something that anyone
00018	// can use, tried to keep it very configurable and tried to make
00019	// everything be handled from UnrealEd.  So for all you map makers,
00020	// simply add as many raingen's to the ceiling of the sky where you want
00021	// it to fall from.  The RainGen delivers a limited range of raindrops, so
00022	// do not expect one raingen to create a monsoon.  To change the various
00023	// settings for the rain, select all the RainGens in your map and click
00024	// on the properties dialog box, then click on the several Rain propety
00025	// menu's that appear(Rain_Behaviour, Rain_Looks, Rain_Sounds).  The
00026	// intensity variable should be kept between 0 and 5 or so to keep
00027	// rendering speed good.  DropSpeed should be negative for faster rain,
00028	// and positive for slower rain, however beware that a positive integer
00029	// greater than 100 or so will cause the raindrops to go up and hit the
00030	// ceiling. 
00031	//
00032	// Note: For this release, lightning is not working, if you absolutley
00033	//      need it, then email me and I'll see what I can do.
00034	//=================================================
00035	class RainGen expands Effects;
00036	// Variables you can manipulate from UnrealED
00037	// This enum lets a mapper or whatnot choose between 3 different sprites
00038	// for the rain drop.  The parenthesis after var tells unreal that this
00039	// variable can be changed from Unrealed, if you put something in the
00040	// parenthesis then that will be the parent menu of the variable.
00041	var(Rain_Looks) enum ERainType
00042	{
00043	  Rain_Drop,
00044	  Rain_Line,
00045	  Rain_LongLine
00046	} RainDrawType;
00047	var(Rain_Looks) float DropSize;    // The size of each drop
00048	var(Rain_Looks) Texture Drop1Tex, Drop2Tex, Drop3Tex, Drop4Tex; // textures for the drops
00049	var(Rain_Behaviour) int intensity; // The intensity of the rain
00050	var(Rain_Behaviour) int DropSpeed; // determines the drop speed. Neg numbers
00051	                                   // make it drop faster, positive slows it
00052	                                   // down, should be modified for the
00053	                                   // default properties dialog
00054	var(Rain_Behaviour) int RainRadius;   // The radius of the rain, which is
00055	                                      // random from 0 to RainRadius
00056	var(Rain_Behaviour) bool bThunder; 
00057	var(Rain_Behaviour) bool bLightning;  // not implemented yet
00058	var(Rain_Sounds)  Sound ThunderSound1;
00059	var(Rain_Sounds)  Sound ThunderSound2;
00060	var(Rain_Sounds)  int SoundRadius;
00061	var(Rain_Sounds)  int RainVolume;
00062	// Private Variables we want to keep to ourselves
00063	var  int ct;      // misc counter variable, used for
00064	                  // for loops, rather have it as a global
00065	                  // variable because we might use it more
00066	                  // than once.
00067	var  Effects D;   // the actual raindrop
00068	var  Effects L;   // used for lightining
00069	var  vector NewLoc;  // the location of the random rain drop
00070	// Set all our variables.
00071	simulated function PreBeginPlay()
00072	{
00073	  Super.PreBeginPlay();
00074	  // We want to enable the timer
00075	  Enable('Timer');
00076	  // Set the timer for every ten clicks we want the thunder to be
00077	  // handled here, randomly.  If you put this into the tick function
00078	  // it slows things down considerably.
00079	  SetTimer(10, true);
00080	  // Play the rain sound, using the Ambient slot
00081	  PlaySound(EffectSound1, Slot_Ambient, RainVolume,, SoundRadius);
00082	}
00083	// Find a random number from -Max to Max
00084	function int RandomNeg(int Max)
00085	{
00086	    local int k;
00087	  k = Rand(Max + 1);
00088	  if (Rand(2) == 1)
00089	    k = -k;
00090	  return k;
00091	}
00092	// This is where thunder and lightning are handled
00093	function Timer()
00094	{
00095	  Super.Timer();
00096	  if (bThunder == true && Rand(5) < 3)
00097	  {
00098	    // Randomly choose which thunder sound to use
00099	    if (Frand() < 0.5)
00100	      PlaySound(ThunderSound1, Slot_Misc, 25, true);
00101	    else
00102	      PlaySound(ThunderSound2, Slot_Misc, 25, true);
00103	  }
00104	
00105	  // If we go into the timer, but have bThunder set to false
00106	  // then we no longer want to call the timer, we can put this before
00107	  // in PreBeginPlay, but because we use default properties
00108	  // to handle everything, we will not know then.
00109	  if (bThunder == false)
00110	    Disable('Timer');
00111	}
00112	// This is where everything takes place
00113	function Tick(float deltatime)
00114	{
00115	  // For the number of intensity that is set from UnrealEd, then
00116	  // spawn a new raindrop
00117	  for (ct = 0; ct < intensity; ct ++) {
00118	    // Find a new location for the spawned RainDrop, using my
00119	    // function RandomNeg() and base it off of the current Location
00120	    // we only want to produce one on the horizontal plane of
00121	    // sky or ceiling, so we leave the Z axes alone.
00122	    NewLoc.X = Location.X + RandomNeg(RainRadius);
00123	    NewLoc.Y = Location.Y + RandomNeg(RainRadius);
00124	    NewLoc.Z = Location.Z;
00125	    // Spawn a raindrop at NewLoc
00126	    d = Spawn(class'RainDrops',,,NewLoc);
00127	    // Set the size to what the user specified
00128	    d.DrawScale = DropSize; 
00129	    // Same with the speeed
00130			d.Velocity = 150.0 * Normal(VRand());
00131	    d.Velocity.Z = DropSpeed;
00132	
00133	    // Depending on what you choose for RainDrawType then set
00134	    // the appropriate Texture.
00135	    switch RainDrawType
00136	    {
00137	      case Rain_Drop:
00138					d.Texture = Drop1Tex;
00139	        //d.Texture = Texture'RainDrop4';
00140	        break;
00141	      case Rain_Line:
00142					d.Texture = Drop2Tex;
00143	        //d.Texture = Texture'RainLong';
00144	        break;
00145	      case Rain_LongLine:
00146					d.Texture = Drop3Tex;
00147	        //d.Texture = Texture'RainLonger';
00148	        break;
00149	      default:
00150					d.Texture = Drop4Tex;
00151	        //d.Texture = Texture'RainDrop4';
00152	   
00153	    }
00154	  }
00155	}
00156	
00157	defaultproperties
00158	{
00159		DrawType=DT_Sprite
00160		Drop1Tex=Texture'genfx.LensFlar.New1';
00161		Drop2Tex=Texture'genfx.LensFlar.New1';
00162		Drop3Tex=Texture'genfx.LensFlar.New1';
00163		Drop4Tex=Texture'genfx.LensFlar.New1';
00164	}

End Source Code