spotlights on they own
Posted: Tue Nov 25, 2003 4:39 am
Below is my attenpt to make a modded spotlight scr, I have set it up just like it says but I have removed the gun and the ai. I was hopeing the spotlights would go on they own. I have had a small amount of success the spotlight has the beam and the corona (corona in wrong spot shucks) but they dont follow the path.
If someoen is keen to have a look and get it working for me I would be very happy, or at least give me some hints to try.
Thanks guys.
// Spotlight system created by Mackey McCandlish.
//
// Before level waittill prespawn "exec global/spotlight.scr".
//
// Used in m1l2a, m1l2b, m4l3, m6l2a, and probably some other place too.
//
// Create a script_model with model "miscobj/searchlightbase.tik"
//
// Give it a targetname "spotlight".
//
// Create an AI and a turretweapon_german_mg42. Target the spotlight to the guy to the gun.
//
// Create a trigger_multiple around the spotlight with targetname "spotdamage". Assign it the damage flag.
//
// Create a bunch of script_origins (At least 5) with targetname "spotsearch". These are the places the spotlight will flick
// to when it is in "Alert" mode.
//
// Give the spotlight, spotdamage, and spotsearches the same #set value. Also give them a #group value. The way it works is,
// and spotlights that are supposed to share proximity have the same #set value, but every set of spotlight/spotdamage/spot
// searches have their own unique #group to associate them together. So a bunch of spotlights working together would all have
// #set 1, but each set of spotlight/spotdamage/spotsearches would have a different #group.
//
// Along the ground, create a loop of info_splinepaths. The targetname of one of the splinepaths must be "spotpath#1_#2"
// where #1 is the #set value of the spotlight that is supposed to shine on this path, and #2 is the #group value of that
// spotlight.
//
// Whenever the spotlight completes its loop, level.spottime["spot#1_#2"] is equal to the current level.time. This let's you
// do neat stuff like the SAS agent dodging the spotlight.
//
// You can give vehicles coronas when their lights are on by doing:
// exec global/spotlight.scr::corona $truck "light left"
// exec global/spotlight.scr::corona $truck "light right"
//
// Where $truck is the name of the vehicle. "$truck.corona = 0" turns off the coronas (and you would normally do
// "$truck anim idlenolights" at the same place to turn off the model lights).
main:
level waittill prespawn
if ($spotlight == NULL)
level.spotlights = 0
else
level.spotlights = $spotlight.size
if (level.spotlights > 0)
{
level.spotlight = exec global/makearray.scr $spotlight
for (local.i=1;local.i<level.spotlights+1;local.i++)
{
level.spotlight[local.i] thread spotwatch
if (level.spotlight[local.i].set == NIL)
{
println ("Warning, spotlight at " + level.spotlight[local.i].origin + " has no #set, setting to 1")
level.spotlight[local.i].set = 1
}
}
}
end
spotpath:
local.path = $("spotpath" + self.set + "_" + self.group)
while (self.checkdeath == 0)
{
level.spottime[("spot" + self.set + "_" + self.group)] = level.time
self.org.origin = local.path.origin
self.org flypath local.path 250 750 200
self.org waitmove
}
end
seepath:
local.ent = spawn script_model
local.ent model animal/cockroach.tik
local.ent scale 100
local.ent notsolid
local.ent glue self
end
spotwatch:
level waittill spawn
if (self.target)
self scale 1
self.searchtime = level.time
self.lightdist = 0
local.light = spawn script_model
local.light model "fx/dummy.tik"
self.spotlight = local.light
if (getcvar(debug) == "1")
self.spotlight thread seepath
self.light = local.light
local.light light (1.0 1.0 1.0)
local.light lightRadius 300
local.light lightOn
local.light notsolid
self model "miscobj/searchlightbase.tik"
self.angles = (0 0 0)
local.bulb = spawn script_model
local.bulb model "miscobj/searchlight.tik"
local.bulb scale 1
local.bulb.origin = self.origin + (0 0 32)
self.bulb = local.bulb
local.bulb bind self
local.bulb notsolid
local.flare = spawn script_model
local.flare model "fx/searchlight.tik"
local.flare.origin = self.origin + (64 0 64)
self.flare = local.flare
local.flare bind self
local.flare notsolid
local.org = spawn script_origin
local.org.origin = self.origin
self.org = local.org
self.currentaim = self.org
self notsolid
// local.org anim start /////////////////////////////////////////////////////////////////////////////////////
local.org light (1.0 1.0 1.0)
local.org lightRadius 300
local.org lightOn
local.org notsolid
self thread spotpath
local.thread1 = parm.previousthread
self.mode = 0
local.skip = level.time
local.curframe = 0
local.threadtimer = level.time + 0.15
self thread light_corona
end
light_corona:
while (self.checkdeath == 0)
{
local.org = self.currentaim.origin
local.vect1 = (local.org - self.origin)
local.vect1 = vector_toangles (local.vect1)
local.angles = self.angles
local.angles[1] = local.vect1[1]
// self.angles = local.angles
local.angles = self.angles
local.angles[0] = local.vect1[0] + 180
local.angles[1] = 0
// self.bulb.angles = local.angles
local.vect = self.origin - self.currentaim.origin
local.vect = vector_normalize (local.vect)
local.dist = 16 // was 32
local.vect[0] = local.vect[0] * local.dist
local.vect[1] = local.vect[1] * local.dist
local.vect[2] = local.vect[2] * local.dist
self.flare.origin = self.bulb.origin - local.vect
self.flare scale 5
local.vect = $player.origin - self.origin
local.vect = vector_normalize (local.vect)
local.angles = angles_toforward ($player.angles)
local.vect[0] = local.vect[0] * local.angles[0]
local.vect[1] = local.vect[1] * local.angles[1]
local.vect[2] = local.vect[2] * local.angles[2]
local.org1 = $player.origin + (0 0 64)
local.ang1 = $player.angles
local.org2 = self.bulb.origin
local.ang2 = local.vect1
//println ("ang1 " + local.ang1 + " and ang2 " + local.ang2 + " and combined " + (local.ang1 + local.ang2))
// local.returnvalue = the value that you should use for an alpha
// local.v1 = angles_toforward local.ang1
local.v1 = vector_normalize (local.org1 - local.org2)
local.v2 = angles_toforward local.ang2
local.f1 = local.v1[0] * local.v2[0] + local.v1[1] * local.v2[1] + local.v1[2] * local.v2[2]
if(local.f1 > 0)
local.returnvalue = local.f1 * local.f1
else
local.returnvalue = 0
// corona
self.flare scale (local.returnvalue * 25)
waitframe
}
end
flame:
exec global/model.scr self.origin models/fx/fx_spotlighthit
end
If someoen is keen to have a look and get it working for me I would be very happy, or at least give me some hints to try.
Thanks guys.
// Spotlight system created by Mackey McCandlish.
//
// Before level waittill prespawn "exec global/spotlight.scr".
//
// Used in m1l2a, m1l2b, m4l3, m6l2a, and probably some other place too.
//
// Create a script_model with model "miscobj/searchlightbase.tik"
//
// Give it a targetname "spotlight".
//
// Create an AI and a turretweapon_german_mg42. Target the spotlight to the guy to the gun.
//
// Create a trigger_multiple around the spotlight with targetname "spotdamage". Assign it the damage flag.
//
// Create a bunch of script_origins (At least 5) with targetname "spotsearch". These are the places the spotlight will flick
// to when it is in "Alert" mode.
//
// Give the spotlight, spotdamage, and spotsearches the same #set value. Also give them a #group value. The way it works is,
// and spotlights that are supposed to share proximity have the same #set value, but every set of spotlight/spotdamage/spot
// searches have their own unique #group to associate them together. So a bunch of spotlights working together would all have
// #set 1, but each set of spotlight/spotdamage/spotsearches would have a different #group.
//
// Along the ground, create a loop of info_splinepaths. The targetname of one of the splinepaths must be "spotpath#1_#2"
// where #1 is the #set value of the spotlight that is supposed to shine on this path, and #2 is the #group value of that
// spotlight.
//
// Whenever the spotlight completes its loop, level.spottime["spot#1_#2"] is equal to the current level.time. This let's you
// do neat stuff like the SAS agent dodging the spotlight.
//
// You can give vehicles coronas when their lights are on by doing:
// exec global/spotlight.scr::corona $truck "light left"
// exec global/spotlight.scr::corona $truck "light right"
//
// Where $truck is the name of the vehicle. "$truck.corona = 0" turns off the coronas (and you would normally do
// "$truck anim idlenolights" at the same place to turn off the model lights).
main:
level waittill prespawn
if ($spotlight == NULL)
level.spotlights = 0
else
level.spotlights = $spotlight.size
if (level.spotlights > 0)
{
level.spotlight = exec global/makearray.scr $spotlight
for (local.i=1;local.i<level.spotlights+1;local.i++)
{
level.spotlight[local.i] thread spotwatch
if (level.spotlight[local.i].set == NIL)
{
println ("Warning, spotlight at " + level.spotlight[local.i].origin + " has no #set, setting to 1")
level.spotlight[local.i].set = 1
}
}
}
end
spotpath:
local.path = $("spotpath" + self.set + "_" + self.group)
while (self.checkdeath == 0)
{
level.spottime[("spot" + self.set + "_" + self.group)] = level.time
self.org.origin = local.path.origin
self.org flypath local.path 250 750 200
self.org waitmove
}
end
seepath:
local.ent = spawn script_model
local.ent model animal/cockroach.tik
local.ent scale 100
local.ent notsolid
local.ent glue self
end
spotwatch:
level waittill spawn
if (self.target)
self scale 1
self.searchtime = level.time
self.lightdist = 0
local.light = spawn script_model
local.light model "fx/dummy.tik"
self.spotlight = local.light
if (getcvar(debug) == "1")
self.spotlight thread seepath
self.light = local.light
local.light light (1.0 1.0 1.0)
local.light lightRadius 300
local.light lightOn
local.light notsolid
self model "miscobj/searchlightbase.tik"
self.angles = (0 0 0)
local.bulb = spawn script_model
local.bulb model "miscobj/searchlight.tik"
local.bulb scale 1
local.bulb.origin = self.origin + (0 0 32)
self.bulb = local.bulb
local.bulb bind self
local.bulb notsolid
local.flare = spawn script_model
local.flare model "fx/searchlight.tik"
local.flare.origin = self.origin + (64 0 64)
self.flare = local.flare
local.flare bind self
local.flare notsolid
local.org = spawn script_origin
local.org.origin = self.origin
self.org = local.org
self.currentaim = self.org
self notsolid
// local.org anim start /////////////////////////////////////////////////////////////////////////////////////
local.org light (1.0 1.0 1.0)
local.org lightRadius 300
local.org lightOn
local.org notsolid
self thread spotpath
local.thread1 = parm.previousthread
self.mode = 0
local.skip = level.time
local.curframe = 0
local.threadtimer = level.time + 0.15
self thread light_corona
end
light_corona:
while (self.checkdeath == 0)
{
local.org = self.currentaim.origin
local.vect1 = (local.org - self.origin)
local.vect1 = vector_toangles (local.vect1)
local.angles = self.angles
local.angles[1] = local.vect1[1]
// self.angles = local.angles
local.angles = self.angles
local.angles[0] = local.vect1[0] + 180
local.angles[1] = 0
// self.bulb.angles = local.angles
local.vect = self.origin - self.currentaim.origin
local.vect = vector_normalize (local.vect)
local.dist = 16 // was 32
local.vect[0] = local.vect[0] * local.dist
local.vect[1] = local.vect[1] * local.dist
local.vect[2] = local.vect[2] * local.dist
self.flare.origin = self.bulb.origin - local.vect
self.flare scale 5
local.vect = $player.origin - self.origin
local.vect = vector_normalize (local.vect)
local.angles = angles_toforward ($player.angles)
local.vect[0] = local.vect[0] * local.angles[0]
local.vect[1] = local.vect[1] * local.angles[1]
local.vect[2] = local.vect[2] * local.angles[2]
local.org1 = $player.origin + (0 0 64)
local.ang1 = $player.angles
local.org2 = self.bulb.origin
local.ang2 = local.vect1
//println ("ang1 " + local.ang1 + " and ang2 " + local.ang2 + " and combined " + (local.ang1 + local.ang2))
// local.returnvalue = the value that you should use for an alpha
// local.v1 = angles_toforward local.ang1
local.v1 = vector_normalize (local.org1 - local.org2)
local.v2 = angles_toforward local.ang2
local.f1 = local.v1[0] * local.v2[0] + local.v1[1] * local.v2[1] + local.v1[2] * local.v2[2]
if(local.f1 > 0)
local.returnvalue = local.f1 * local.f1
else
local.returnvalue = 0
// corona
self.flare scale (local.returnvalue * 25)
waitframe
}
end
flame:
exec global/model.scr self.origin models/fx/fx_spotlighthit
end