UGX-Mods

Call of Duty 5: World at War => Help Desk => Mapping => Topic started by: P0rkRoyalz on November 25, 2012, 02:07:36 am

Title: flickering lights
Post by: P0rkRoyalz on November 25, 2012, 02:07:36 am
i have flicking lights in my map atm but how do i make mine like the flickering lights like UGX Cabin? mine just fade in and out every 2 seconds and it looks weird, so yeah can some one help me out? thanks
Title: Re: flickering lights
Post by: SajeOne on November 25, 2012, 02:50:46 am
i would set two variables for on and off and set them to a random int for the time. then make them so it randomly changes on and off at different times. just an idea, idk how well that would work
Title: Re: flickering lights
Post by: P0rkRoyalz on November 25, 2012, 06:28:22 am
sorry do you mean by making my own little script for the lights..? i dont know how to script unfortunately... :'( but if in UGX Cabin they used one of the target names that was "unusable" i was hoping they would let me in on how they got it to work
Title: Re: flickering lights
Post by: treminaor on November 25, 2012, 08:52:12 am
sorry do you mean by making my own little script for the lights..? i dont know how to script unfortunately... :'( but if in UGX Cabin they used one of the target names that was "unusable" i was hoping they would let me in on how they got it to work
I wrote my own function based on what I knew at the time - there's probably a better way to do it but I don't care enough to rewrite anything.

Copy /raw/cientscripts/_lights.csc to your mod clientscripts folder, then replace generic_flickering with this:
Code Snippet
Plaintext
generic_flickering(clientNum)// by [ugx] treminaor
{
   assertex(isdefined(self.lights) && isdefined(self.lights[clientNum]), "Light not setup before script thread run on it.");
   self endon("stop_flicker");

   min_delay = 0.1;
   max_delay = 0.5;
   
   min_intensity = 0.05;
   max_intensity = 0.85;

   intensity = self.lights[clientNum] GetLightIntensity();
   curr_intensity = intensity;
   model_swap_1 = intensity + min_intensity + ((max_intensity - min_intensity) / 3);
   model_swap_2 = intensity + max_intensity - ((max_intensity - min_intensity) / 3);

    self.lights[clientNum] SetLightIntensity( 1 );

light_org = GetStruct(self.target, "targetname");

self.light_model = Spawn( clientNum, light_org.origin, "script_model" );

   model = "";
   level._effect["flicker_subway_light"] = loadFX("subway_light");

   fx =  level._effect["flicker_subway_light"];

   for( ;; )
{
temp_intensity = intensity * RandomFloatRange( min_intensity, max_intensity );
time = RandomFloatRange( min_delay, max_delay );
rand_delay = randomfloat(.5)+0.05;
wait(rand_delay);
steps = time * 20;
div = ( curr_intensity - temp_intensity ) / steps;
for( i = 0; i < steps; i++ )
{
curr_intensity -= div;
if( curr_intensity < 0 )
{
curr_intensity = 0;
}
if ( IsDefined( self.light_model ) )
{
if ( curr_intensity < 0.5 )
{
model = "light_0";
}
else if ( curr_intensity == 1 )
{
model = "light_2";
}
else
{
model = "light_1";
}
           
if ( model != self.light_model.model )
{
self.light_model SetModel( model );
self.lights[clientNum] SetLightIntensity( curr_intensity );
}
}
}
if(self.light_model.model != "light_0")
{
PlayFx( clientNum, fx, self.origin );
}
wait( 0.05 );

curr_intensity = temp_intensity;
   }
}
I don't remember if the fx are custom or not, so take care to check that yourself. You dont need the fx but it really makes the flickering more realistic. Also you need to precache the on and off models in your map.gsc before zombiemode::main is called.
Title: Re: flickering lights
Post by: P0rkRoyalz on November 25, 2012, 02:48:44 pm
I don't remember if the fx are custom or not, so take care to check that yourself. You dont need the fx but it really makes the flickering more realistic. Also you need to precache the on and off models in your map.gsc before zombiemode::main is called.

thanks for the code btw ;D,
anyway the fx is custom but that doesnt matter, how do i set it up in radiant? like i did with the previous light using the targtename>generic_pulsing?
i had the targetname on the light linked to an info_null, also do i have to add script_delay_min and scrip_delay_max to the light? to get it to have intervals, thanks
Title: Re: flickering lights
Post by: treminaor on November 25, 2012, 06:53:38 pm
thanks for the code btw ;D,
anyway the fx is custom but that doesnt matter, how do i set it up in radiant? like i did with the previous light using the targtename>generic_pulsing?
i had the targetname on the light linked to an info_null, also do i have to add script_delay_min and scrip_delay_max to the light? to get it to have intervals, thanks
I hardcoded the intervals and intensity. All you need is the targetname and a properly set up light node.

You also need a struct linked to the light. Here's a prefab: https://dl.dropbox.com/u/7345145/ugx_cabin_lightpost.zip