main local.origin local.color local.name local.health local.anglestart local.mountwall local.orient local.removeafterdeath: local.s0 = spawn script_model targetname (local.name) local.s0 model miscobj/searchlightbase.tik local.s0.origin = ( local.origin ) local.s0.color = ( local.color ) local.s0.health = local.health if(local.s0.health <= 0) { local.indestructible = 1 } local.s0 notsolid local.s0.removeafterdeath = local.removeafterdeath // if 1, spotlight and base will be gone when health <= 0. if(local.mountwall != 1 && local.mountwall != 2 && local.mountwall != 3 ) { local.s0.angles = ( 0 local.anglestart 0 ) } if(local.mountwall == 1 ) { if(local.orient != 1) { local.s0.angles = ( local.anglestart 0 90 ) } if(local.orient == 1) { local.s0.angles = ( local.anglestart -90 90 ) } } if(local.mountwall == 2 ) { local.s0.angles = ( 0 local.anglestart 180 ) } if(local.mountwall == 3 ) { if(local.orient != 1) { local.s0.angles = ( local.anglestart 0 -90 ) } if(local.orient == 1) { local.s0.angles = ( local.anglestart -90 -90 ) } } for(local.num = 1;local.num <= $(local.name).size;local.num++) { thread makespot $(local.name)[local.num] local.mountwall local.name local.indestructible local.orient } end makespot local.spotlight local.mountwall local.name local.indestructible local.orient: if(local.spotlight.color == NIL) local.color = ( 1 1 1 ) else local.color = local.spotlight.color if(local.mountwall != 1 && local.mountwall != 2 && local.mountwall != 3 ) { local.spot = spawn script_model model miscobj/searchlightoff.tik origin (local.spotlight.origin + ( 0 0 32 )) spawnflags 1 } if(local.mountwall == 1) { if(local.orient != 1) { local.spot = spawn script_model model miscobj/searchlightoff.tik origin (local.spotlight.origin + ( 0 -32 0 )) spawnflags 1 } if(local.orient == 1) { local.spot = spawn script_model model miscobj/searchlightoff.tik origin (local.spotlight.origin + ( -32 0 0 )) spawnflags 1 } } if(local.mountwall == 2) { local.spot = spawn script_model model miscobj/searchlightoff.tik origin (local.spotlight.origin + ( 0 0 -32 )) spawnflags 1 } if(local.mountwall == 3) { if(local.orient != 1) { local.spot = spawn script_model model miscobj/searchlightoff.tik origin (local.spotlight.origin + ( 0 32 0 )) spawnflags 1 } if(local.orient == 1) { local.spot = spawn script_model model miscobj/searchlightoff.tik origin (local.spotlight.origin + ( 32 0 0 )) spawnflags 1 } } local.spot.destroyed = 0 local.angles = local.spotlight.angles local.angles[1] = (local.angles[1] * -1) local.spot.angles = local.angles local.spotdamage = spawn trigger_multiple origin local.spot.origin spawnflags 144 local.spotdamage setsize ( -30 -30 -30 )( 30 30 30 ) if(local.spotlight.health == NIL || local.spotlight.health <= 0) local.spotdamage.health = 99999 else local.spotdamage.health = local.spotlight.health local.spottrigger = spawn trigger_multiple origin local.spotlight.origin local.spottrigger setsize ( -50 -50 -50 )( 50 50 50 ) if($(local.spotlight.target)) local.player = parm.other local.spottrigger origin $(local.spotlight.target).origin local.groundtarget = spawn script_origin local.groundspot_target = spawn script_origin local.light = spawn script_model local.light model "fx/searchlight.tik" local.light notsolid local.light.origin = local.spot.origin + local.spot.forwardvector * -16 local.light hide local.flare = spawn script_model targetname ("s_colorchange" + local.name) local.flare model "fx/searchlight.tik" local.flare notsolid local.flare scale 3.5 local.flare.origin = local.groundtarget.origin local.flare hide local.flare light local.color local.flare lightradius 250 local.flare.on = 0 //********** Added line local.flare.s_newcolor = local.color local.beam = spawn func_beam origin local.spot.origin local.beam alpha .2 local.beam maxoffset 0 local.beam numsegments 20 local.beam scale 50 local.beam activate local.beam life .1 local.beam color local.color local.beam hide thread aimspot local.groundspot_target local.name local.beam local.spot local.light local.groundtarget local.flare local.spotdamage local.spottrigger local.spotlight local.indestructible while(1) { local.spottrigger waittill trigger local.spottrigger nottriggerable local.player = parm.other while(local.player istouching local.spottrigger || local.player istouching local.spotlight) { local.fwd_vec = angles_toforward local.player.viewangles local.start = local.player gettagposition "Bip01 Head" local.range = 10240 local.groundtarget.origin = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * local.range ) 0 local.s_vec = ( local.groundtarget.origin - local.spot.origin ) local.s_ang = vector_toangles(local.s_vec) local.s_ang[1] = (local.s_ang[1] - 180) // rotate spotlight lightbulb away from player. local.s_ang[0] = (local.s_ang[0] * -1) // un-invert pitch rotation for floor & ceiling mounts local.spot.angles = local.s_ang // for left-side wall mounts (local.mountwall == 1) and right-side wall mounts (local.mountwall == 3) only, // make spotlightbase always rotate clockwise when looking upward. also check which side of spotlight the player is facing. // spotlightbase quickly reorients itself after looking vertically up or down. // if(local.mountwall != 1 && local.mountwall != 2 && local.mountwall != 3 ) { local.spotlight.angles = ( 0 local.s_ang[1] 0 ) } // default, mountwall = 0, floor mounts. if(local.mountwall == 2) { local.spotlight.angles = ( 0 local.s_ang[1] 180 ) } // mountwall = 2, ceiling spotlightbase mounts. if(local.orient != 1) { if(local.mountwall == 1 && ((local.player.angles[1] >= 90 && local.player.angles[1] < 180) || (local.player.angles[1] >= 180 && local.player.angles[1] < 270)) ) { local.spotlight.angles = ( local.s_ang[0] 0 90 ) } if(local.mountwall == 1 && ((local.player.angles[1] < 90 && local.player.angles[1] >= 0) || (local.player.angles[1] < 360 && local.player.angles[1] >= 270)) ) { local.spotlight.angles = ( -local.s_ang[0] 0 90 ) } if(local.mountwall == 3 && ((local.player.angles[1] >= 90 && local.player.angles[1] < 180) || (local.player.angles[1] >= 180 && local.player.angles[1] < 270)) ) { local.spotlight.angles = ( local.s_ang[0] 0 -90 ) } if(local.mountwall == 3 && ((local.player.angles[1] < 90 && local.player.angles[1] >= 0) || (local.player.angles[1] < 360 && local.player.angles[1] >= 270)) ) { local.spotlight.angles = ( -local.s_ang[0] 0 -90 ) } } if(local.orient == 1) { if(local.mountwall == 1 && ((local.player.angles[1] < 90 && local.player.angles[1] >= 0) || (local.player.angles[1] >= 90 && local.player.angles[1] < 180)) ) { local.spotlight.angles = ( local.s_ang[0] 0 90 ) + ( 0 -90 0 ) } if(local.mountwall == 1 && ((local.player.angles[1] >= 180 && local.player.angles[1] < 270) || (local.player.angles[1] < 360 && local.player.angles[1] >= 270)) ) { local.spotlight.angles = ( -local.s_ang[0] 0 90 ) + ( 0 -90 0 ) } if(local.mountwall == 3 && ((local.player.angles[1] < 90 && local.player.angles[1] >= 0) || (local.player.angles[1] >= 90 && local.player.angles[1] < 180)) ) { local.spotlight.angles = ( local.s_ang[0] 0 -90 ) + ( 0 -90 0 ) } if(local.mountwall == 3 && ((local.player.angles[1] >= 180 && local.player.angles[1] < 270) || (local.player.angles[1] < 360 && local.player.angles[1] >= 270)) ) { local.spotlight.angles = ( -local.s_ang[0] 0 -90 ) + ( 0 -90 0 ) } } local.light.origin = local.spot.origin + local.spot.forwardvector * -8 if(local.player.useheld == 1) { wait .2 if(local.showspot !=1) { local.showspot = 1 local.light show local.flare show local.flare.on = 1//********** Added line local.beam show } else { local.beam hide local.showspot = 0 local.light hide local.flare hide local.flare.on = 0 //********** Added line } } waitframe local.random1 = randomint(3) local.random2 = randomint(3) local.random3 = randomint(3) if(level.spotlight[local.name] == 1 || level.flags[allspotlights] == 1) { local.flare light ( (local.random1 * 0.5) (local.random2 * 0.5) (local.random3 * 0.5) ) local.beam color ( (local.random1 * 0.5) (local.random2 * 0.5) (local.random3 * 0.5) ) $("s_colorchange" + local.name).s_newcolor = ( (local.random1 * 0.5) (local.random2 * 0.5) (local.random3 * 0.5) ) level.spotlight[local.name] = 0 level.flags[allspotlights] = 0 } if(level.spotlight_rainbow[local.name] == 1 || level.flags[allspotlights_rainbow] == 1) { local.flare light ( (local.random1 * 0.5) (local.random2 * 0.5) (local.random3 * 0.5) ) local.beam color ( (local.random1 * 0.5) (local.random2 * 0.5) (local.random3 * 0.5) ) $("s_colorchange" + local.name).s_newcolor = ( (local.random1 * 0.5) (local.random2 * 0.5) (local.random3 * 0.5) ) } if(local.spot.destroyed == 1) break } if(local.spot.destroyed == 1) break local.spottrigger triggerable } end aimspot local.groundspot_target local.name local.beam local.spot local.light local.groundtarget local.flare local.spotdamage local.spottrigger local.spotlight local.indestructible: while(local.spot.destroyed != 1) { local.groundspot_target.origin = local.spot.origin + local.spot.forwardvector * -10240 local.p = trace local.spot.origin local.groundspot_target.origin 0 local.beam endpoint local.p local.flare.origin = local.p // ******** Added section ************************** if(local.flare.on == 1) { for(local.i=1;local.i<=$player.size;local.i++) { if(vector_length(local.p - $player[local.i].origin) < 50) { $player[local.i] thread map_triggers/led_spotlight.scr::spotted $("s_colorchange" + local.name).s_newcolor[0] $("s_colorchange" + local.name).s_newcolor[1] $("s_colorchange" + local.name).s_newcolor[2] wait 2 } } } //**************************************************** if(local.spotdamage.health <= 0 && local.indestructible != 1) { local.spark = spawn script_model local.spark model "fx/fx_spotlighthit.tik" local.spark.origin = local.spot.origin local.spark notsolid local.spark anim start local.spot playsound exp_searchlight local.spot.destroyed = 1 waitframe if(local.spotlight.removeafterdeath >= 1) { if(local.spotlight.removeafterdeath >= 2) { local.spotlight remove } // spotlight base local.spot remove // spotlight light } local.light delete local.flare delete local.spottrigger delete local.spotdamage delete local.groundtarget delete local.beam deactivate wait 0.1 // cannot use "waitframe" for "fx_spotlighthit.tik", the spark animation gets removed too fast. local.spark remove break } waitframe } end