Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 |
//NEW: ScriptedLight //============================================================================= // $Author: Mfox $ // $Date: 6/25/02 11:36p $ // $Revision: 3 $ //============================================================================= //------------------------------------------------------------------------------ // Name: ScriptedLight.uc // Author: Aaron R Leiby // Date: 07 December 1999 //------------------------------------------------------------------------------ // Description: A light that can be scripted to change its properties // over time. //------------------------------------------------------------------------------ // How to use this class: // // + Set up some templates by filling in the ScriptedLightData array. // (Slot 0 is associated with the letter A. 1 is B, 2 is C, etc.) // // + TweenToTime is the amount of time it takes to reach the desired // settings. The color will tween using the associated RGB values // (rather than HSB) to avoid rainbow effects that would be caused // by iterating across Hue values. If you want the transition to // happen instantly, simply leave this value at zero. // // + Duration is the amount of time the light will remain at the desired // settings for that template, once it reaches it. Once again, this // value can be left at zero if you simply want it to reach the settings // and then continue onto the next settings. Most likely, you won't // want both TweenToTime and Duration to be zero, since the settings // won't show up in that case. // // + Brightness, Hue and Saturation are same as the settings for any // other light. They get converted to RGB values under the hood for // smooth transitioning, but that shouldn't affect how you use them. // // + Once you have a few templates filled in, you can then create a // Script using that data by filling in the LightScript string. // Note: You should only use the capital letters A...Z. All other // ASCII values are undefined. // You can use any slot in the ScriptedLightData array. There's nothing // sacred about starting with ABC. If you want, you can go right to the // end and start with XYZ, or whatever your heart desires. Personally, // I don't know what letter the number 14 represents without singing // through my alphabet, counting on my fingers. So usually starting with // ABC is easiest. I doubt most lights will use more than the first // couple slot. In any case, I've provide a quick reference chart to allow // you to look up the associated letters. // This Script can include any of the set templates, in any order, and // may be repeated as many times as desired. (Example: ABCB) This will // Use template A, then B, then C, then back to B, then it will start all // over again with ABCBABCBABCB... forever. Obviously this will allow // for some cool effects. // // + Finally, you can use the LightScriptTimeOffset, to offset the starting // time for the first template to be used. This is generally used to // make lights that "propogate" -- first one turns on, then the next, then // the next... light runner lights at an airport. This value is in seconds. // Because this time is only taken into account when the light is first // created, it makes it hard to visualize how it will all come out in the // editor. In an effort to cater to this, if you turn off real-time mode // in the perspective window (the little joystick icon) for more than 3 // seconds (or do any other operation that will stop time for more than 3 // seconds -- light rebuilding the level or lighting or whatever), this // will reset the lights, and they will all start over at the same time, // bringing them back into sync. // //------------------------------------------------------------------------------ // Quick Reference: // // A=0 // B=1 // C=2 // D=3 // E=4 // F=5 // G=6 // H=7 // I=8 // J=9 // K=10 // L=11 // M=12 // N=13 // O=14 // P=15 // Q=16 // R=17 // S=18 // T=19 // U=20 // V=21 // W=22 // X=23 // Y=24 // Z=25 //------------------------------------------------------------------------------ class ScriptedLight extends Light native; var() struct ScriptedLightInfo { var() float TweenToTime; var() float Duration; // Doesn't include TweenToTime. var() byte Brightness, Hue, Saturation; } ScriptedLightData[26]; // ABCDEF...Z var() string LightScript; // Repeating light sequence. var() string LightScriptRampUp; // Script executed when turned on (non-repeating). var() string LightScriptRampDown; // Script executed when turned off (non-repeating). var() float LightScriptTimeOffset; // Countdown before execution once turned on. var() bool bRandomizeScript; // Picks a random entry in LightScript each iteration, // rather than iterating through it sequentially. // (Does not affect RampUp or RampDown.) var() bool bReset; // Set this to true to reset the light. // (Useful for getting a bunch of lights // back in sync in the editor.) // [It will automatically be reset back to false for // you, so it works like a button.] // Used interally. var private transient float SL_Brightness; var private transient vector SL_Color; var private transient float SL_LastBrightness; var private transient vector SL_LastColor; var private transient bool SL_Initialized; var private transient int SL_Index; var private transient float SL_Duration; var private transient float SL_TweenTime; var private transient float SL_Countdown; var private transient float SL_TweenBrightness; var private transient vector SL_TweenColor; var private transient byte SL_DesiredBrightness; var private transient vector SL_DesiredColor; var private transient float SL_BrightnessRate; var private transient vector SL_ColorRate; var private transient bool SL_RampingUp; var private transient bool SL_RampingDown; // Embedded data structure. var private ScriptedLight NextScriptedLight; /////////////////////// // Trigger mechanism // /////////////////////// var() bool bInitiallyOn; var() float TimerDuration; var() name ProximityTypes[8]; //////////////////// // Initialization // //////////////////// //------------------------------------------------------------------------------ simulated event PreBeginPlay() { Super.PreBeginPlay(); bReset = true; if( bInitiallyOn ) { TurnOn(); } else { LightType = LT_None; ScaleGlow = 0; } } /////////////////////// // Public interfaces // /////////////////////// //------------------------------------------------------------------------------ public simulated function TurnOn() { LightType = LT_Scripted; SL_RampingUp = true; SL_RampingDown = false; SL_Index = 0; SL_Initialized = false; SL_Duration = 0; // start immediately. } //------------------------------------------------------------------------------ public simulated function TurnOff() { LightType = LT_Scripted; // just in case. SL_RampingUp = false; SL_RampingDown = true; // this will eventually set LightType to LT_None. SL_Index = 0; SL_Initialized = false; SL_Duration = 0; // start immediately. } //////////////////////// // Triggerable states // //////////////////////// //------------------------------------------------------------------------------ // Toggles us on and off when triggered. //------------------------------------------------------------------------------ simulated state() TriggerToggle { //NEW (mdf) simulated function Trigger( Actor Other, Pawn EventInstigator, optional name EventName ) /*OLD simulated function Trigger( Actor Other, Pawn EventInstigator ) */ { if( LightType != LT_Scripted || SL_RampingDown ) { TurnOn(); } else { TurnOff(); } } } //------------------------------------------------------------------------------ // Toggled when Triggered. // Toggled back to initial state when UnTriggered. //------------------------------------------------------------------------------ simulated state() TriggerControl { //NEW (mdf) simulated function Trigger( Actor Other, Pawn EventInstigator, optional name EventName ) /*OLD simulated function Trigger( Actor Other, Pawn EventInstigator ) */ { if( bInitiallyOn ) { TurnOff(); } else { TurnOn(); } } //NEW (mdf) simulated function UnTrigger( Actor Other, Pawn EventInstigator, optional name EventName ) /*OLD simulated function UnTrigger( Actor Other, Pawn EventInstigator ) */ { if( bInitiallyOn ) { TurnOn(); } else { TurnOff(); } } } //------------------------------------------------------------------------------ // Toggled when triggered. // Toggled back to initial state after TimerDuration seconds. //------------------------------------------------------------------------------ simulated state() TriggerTimed { //NEW (mdf) simulated function Trigger( Actor Other, Pawn EventInstigator, optional name EventName ) /*OLD simulated function Trigger( Actor Other, Pawn EventInstigator ) */ { if( bInitiallyOn ) { TurnOff(); } else { TurnOn(); } SetTimer( TimerDuration, false ); } simulated event Timer() { if( bInitiallyOn ) { TurnOn(); } else { TurnOff(); } } } //------------------------------------------------------------------------------ simulated state() ProximityBased { public simulated event BeginState() { SetCollision( true, bBlockActors, bBlockPlayers ); } public simulated event EndState() { SetCollision( bCollideActors, bBlockActors, bBlockPlayers ); } public simulated event Touch( Actor Other ) { if( ValidTouch(Other) ) { if( bInitiallyOn ) TurnOff(); else TurnOn(); } } public simulated event UnTouch( Actor Other ) { if( ValidTouch(Other) ) { if( bInitiallyOn ) TurnOn(); else TurnOff(); } } protected simulated function bool ValidTouch( Actor Other ) { local int i; if( Other != None ) for( i=0; i<ArrayCount(ProximityTypes); i++ ) if( Other.IsA( ProximityTypes[i] ) ) return true; return false; } } //OLD defaultproperties { bInitiallyOn=true ProximityTypes(0)='Pawn' LightType=LT_Scripted bStatic=false UseReticleOnEvents(0)="UseReticleText" UseReticleOnEvents(1)="UseReticleCorners" UseReticleOnEvents(2)="UseReticleTopBars" ProximityReticleOnEvents(0)="ProximityReticleCorners" ProximityReticleOnEvents(1)="ProximityReticleTopBars" } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |