User Tools

Site Tools


hpl2:tutorials:level_editor:tutorial_6

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
hpl2:tutorials:level_editor:tutorial_6 [2011/10/05 13:29]
khyrpa
hpl2:tutorials:level_editor:tutorial_6 [2011/10/06 15:57] (current)
khyrpa [Billboards]
Line 47: Line 47:
  
  
-To create ​better looking ​billboards, not all of them should be of the same color, so create another point light and connect the billboards that you think need different colors to other point lights. For simplicitys sake I keep them connected to only 2 point lights. (Colors changed so you can see better what I did)+To create ​nice billboards, not all of them should be of the same color, so create another point light and connect the billboards that you think need different colors to other point lights ​(here the billboards on the edges were picked). For simplicitys sake I keep them connected to only 2 point lights, but if you think you need more variation go for more. (Colors changed so you can see better what I did)
  
  
Line 101: Line 101:
  
  
-<code c>​void ​OnStart() +<code c>​void ​OnEnter() 
-  +{  
-  +AddTimer("​start",​ 0, "​FlickerTimer"​); ​//Starts the loop 
-{ +SetLocalVarInt("​EventInt",​ 1); //sets the timer to loop case 1 
-  +//Spawn particles to bb_particle_+i areas and fog_particle_+i areas
-  +
-AddTimer("​start",​ 0, "​FlickerTimer"​);​ +
-SetPlayerMoveSpeedMul(0.7f);​ +
-SetLocalVarInt("​EventInt",​ 1);+
 for(int i=0;​i<​3;​i++) CreateParticleSystemAtEntityExt("​blue_particles",​ "​ps_light_dust_large.ps",​ "​bb_particle_"​+i,​ true, 0.6f, 0.75f, 1.0f, 1, true, 1, 2, 8, 11); for(int i=0;​i<​3;​i++) CreateParticleSystemAtEntityExt("​blue_particles",​ "​ps_light_dust_large.ps",​ "​bb_particle_"​+i,​ true, 0.6f, 0.75f, 1.0f, 1, true, 1, 2, 8, 11);
 for(int i=0;​i<​3;​i++) CreateParticleSystemAtEntityExt("​blue_fog_particles",​ "​ps_area_fog.ps",​ "​fog_particle_"​+i,​ true, 0.6f, 0.75f, 1.0f, 0.8f, true, 1, 2, 8, 11); for(int i=0;​i<​3;​i++) CreateParticleSystemAtEntityExt("​blue_fog_particles",​ "​ps_area_fog.ps",​ "​fog_particle_"​+i,​ true, 0.6f, 0.75f, 1.0f, 0.8f, true, 1, 2, 8, 11);
 } }
-  
    
 void FlickerTimer(string &in asTimer) void FlickerTimer(string &in asTimer)
 { {
 +//This stores the rand float into VarFloat so the amount can be checked later
 SetLocalVarFloat("​CheckBrightness",​ RandFloat(0.20f,​0.32f));​ SetLocalVarFloat("​CheckBrightness",​ RandFloat(0.20f,​0.32f));​
 +//This takes the random float from VarFloat so it can be easily placed into functions
 float fMainColor = GetLocalVarFloat("​CheckBrightness"​);​ float fMainColor = GetLocalVarFloat("​CheckBrightness"​);​
 +//This is the color for the bloody red lights for case 2
 float fBloodColor = RandFloat(0.3f,​0.45f);​ float fBloodColor = RandFloat(0.3f,​0.45f);​
 +//This tells how long fading the lights in takes and when the loop timer triggers this again
 float ftimer = RandFloat(0.4f,​0.7f);​ float ftimer = RandFloat(0.4f,​0.7f);​
 +//This switch function is placed here so you can easily control the lights and later if necessary, add more cases to have more control
 switch(GetLocalVarInt("​EventInt"​)) switch(GetLocalVarInt("​EventInt"​))
 {case 1: //This part loops forever when EventInt is 1 {case 1: //This part loops forever when EventInt is 1
 +    //These 2 below are for the lights that only control billboards, billboards look brighter than the light source
     FadeLightTo("​bb_bright",​ fMainColor+0.08f,​ fMainColor+0.05,​ fMainColor+0.1,​ 1, -1, ftimer);     FadeLightTo("​bb_bright",​ fMainColor+0.08f,​ fMainColor+0.05,​ fMainColor+0.1,​ 1, -1, ftimer);
     FadeLightTo("​bb_dark",​ fMainColor+0.01f,​ fMainColor, fMainColor+0.04,​ 1, -1, ftimer);     FadeLightTo("​bb_dark",​ fMainColor+0.01f,​ fMainColor, fMainColor+0.04,​ 1, -1, ftimer);
 +  //To get greater sync and effect, I made these to check when the billboards were bright or dark
 if(GetLocalVarFloat("​CheckBrightness"​) <0.26f){ if(GetLocalVarFloat("​CheckBrightness"​) <0.26f){
         for(int i=0;​i<​2;​i++) FadeLightTo("​window_light_bright_"​+i,​ fMainColor+0.22f,​ fMainColor+0.27f,​ fMainColor+0.43f,​ 1, -1, ftimer);         for(int i=0;​i<​2;​i++) FadeLightTo("​window_light_bright_"​+i,​ fMainColor+0.22f,​ fMainColor+0.27f,​ fMainColor+0.43f,​ 1, -1, ftimer);
         for(int i=0;​i<​2;​i++) FadeLightTo("​window_light_dark_"​+i,​ fMainColor+0.13f,​ fMainColor+0.19f,​ fMainColor+0.24f,​ 1, -1, ftimer);         for(int i=0;​i<​2;​i++) FadeLightTo("​window_light_dark_"​+i,​ fMainColor+0.13f,​ fMainColor+0.19f,​ fMainColor+0.24f,​ 1, -1, ftimer);
     }     }
 +  //If you dont use something similar to this, the change in lights stay way too small and it can look stupid
 if(GetLocalVarFloat("​CheckBrightness"​)>​= 0.26f){ if(GetLocalVarFloat("​CheckBrightness"​)>​= 0.26f){
         for(int i=0;​i<​2;​i++) FadeLightTo("​window_light_bright_"​+i,​ fMainColor+0.31f,​ fMainColor+0.36f,​ fMainColor+0.58f,​ 1, -1, ftimer);         for(int i=0;​i<​2;​i++) FadeLightTo("​window_light_bright_"​+i,​ fMainColor+0.31f,​ fMainColor+0.36f,​ fMainColor+0.58f,​ 1, -1, ftimer);
Line 141: Line 144:
     break;     break;
 } }
 +//This is the actual loop here, there is nothing that will stop this timer so it will all the time (unless RemoveTimer is used)
 AddTimer("​repeat",​ ftimer, "​FlickerTimer"​);​ AddTimer("​repeat",​ ftimer, "​FlickerTimer"​);​
 } }
    
    
-  +//Below is the script I used to jump to case 2 and red lighting, (Interact callback set inside level editor)
-  +
- +
 void Touched(string &in asEntity) void Touched(string &in asEntity)
-{SetLocalVarInt("​EventInt",​ 2);+{ 
 +//Sets EventInt to 2 so case 2: is triggered when the looping timer next time triggers 
 +SetLocalVarInt("​EventInt",​ 2); 
 +//just a quick effect to make things look better for demonstrations sake...
 StartScreenShake(0.01f,​ 0.9f, 0.2f, 0.2f); StartScreenShake(0.01f,​ 0.9f, 0.2f, 0.2f);
-//​destroyParticles+//​destroyParticles, removes the old light particles outta the way. Takes a long time for the fog to disappear, but I can't help that
 DestroyParticleSystem("​blue_particles"​);​ DestroyParticleSystem("​blue_particles"​);​
 DestroyParticleSystem("​blue_fog_particles"​);​ DestroyParticleSystem("​blue_fog_particles"​);​
-//create new ones+//create new ones, this had to be placed inside the callback because looping timer would just create new ones ontop each time it loops
 for(int i=0;​i<​3;​i++) CreateParticleSystemAtEntityExt("​red_particles",​ "​ps_light_dust_large.ps",​ "​bb_particle_"​+i,​ true, 1.0f, 0.1f, 0.1f, 1, true, 1, 2, 8, 11); for(int i=0;​i<​3;​i++) CreateParticleSystemAtEntityExt("​red_particles",​ "​ps_light_dust_large.ps",​ "​bb_particle_"​+i,​ true, 1.0f, 0.1f, 0.1f, 1, true, 1, 2, 8, 11);
 for(int i=0;​i<​3;​i++) CreateParticleSystemAtEntityExt("​red_particles",​ "​ps_area_fog.ps",​ "​fog_particle_"​+i,​ true, 1.0f, 0.1f, 0.1f, 0.9f, true, 1, 2, 8, 11); for(int i=0;​i<​3;​i++) CreateParticleSystemAtEntityExt("​red_particles",​ "​ps_area_fog.ps",​ "​fog_particle_"​+i,​ true, 1.0f, 0.1f, 0.1f, 0.9f, true, 1, 2, 8, 11);
 } }
 </​code>​ </​code>​
 +
 +
 +So in the end that loop could control all the billboards and lights needed in a map. The flickering effect might be very small buff to levels looks for the headache it could cause, but keeping billboards connected into lights makes changing colors **MILLION ** times more pleasant. It can also be used to for example: cool scares and changing light coming from outside from day to night
  
hpl2/tutorials/level_editor/tutorial_6.1317821389.txt.gz · Last modified: 2011/10/05 13:29 by khyrpa