Page 1 of 2
spawning a light entity?
Posted: Sat Jul 03, 2004 4:06 pm
by Master-Of-Fungus-Foo-D
How would you script-spawn a light. Not a static light model but the actual LIGHT. Could someone help me a little?
._
/..\
\_/
Posted: Sat Jul 03, 2004 5:56 pm
by Angex
I don't think you can spawn a light it terms of a light enttiy, as the lighting is calculated at compile time.
You can however assign a dynamic light to an entity, this is how muzzel flashes are done for example, but you may notice an impact on performance if you over use it.
So you could spawn a script_origin or script_model and use the
light( Float red, Float green, Float blue, Float radius )
, I think the rgb variables are within the range of 0 - 1.
E.G.
Code: Select all
// Spawn some kind of entity.
$my_entity light 0 0.5 1 128
Posted: Sat Jul 03, 2004 7:36 pm
by Master-Of-Fungus-Foo-D
what do you mean by
You can however assign a dynamic light to an entity, this is how muzzel flashes are done for example, but you may notice an impact on performance if you over use it.
and
Float red, Float green, Float blue, Float radius
Posted: Sat Jul 03, 2004 10:02 pm
by lizardkid
red value of light, blue value of light, green value of light, each is applied to the entity. float means floating-point, or decimal. these values are applied jsut like ambinetlight or farplane_color but to the entity.
spawn a Dynamic light
Posted: Sat Jul 03, 2004 11:06 pm
by tltrude
This may help. It should spawn a bright light just above the very center of the map.
mylite_thread:
local.lite = spawn script_model model "fx/dummy.tik"
local.lite.origin = ( 0 0 128 ) // coordinates
local.lite light 1 1 1 300 // last number is how big it is, ( 1 1 1 is white light).
end
Posted: Sun Jul 04, 2004 8:13 am
by bdbodger
The light can also be turned on and off if you do a light this way
mylite_thread:
local.lite = spawn script_model model "fx_dummy.tik" targetname mylight
local.lite.origin = ( 0 0 128 ) // coordinates
local.lite light 1 1 1 300 // last number is how big it is, ( 1 1 1 is white light).
thread blink_light
end
blink_light:
while(1)
{
$mylight lighton
wait 3
$mylight lightoff
wait 3
}
end
Posted: Sun Jul 04, 2004 12:47 pm
by nuggets
or you can make it fade in and out by using
mylite_thread:
local.lite = spawn script_model model "fx_dummy.tik" targetname mylight
local.lite.origin = ( 0 0 128 ) // coordinates
local.lite light 1 1 1 0 // last number is how big it is, ( 1 1 1 is white light).
local.lite.strength = 0
thread brighten local.lite
end
brighten local.lite:
while (1)
{
if (local.lite.strength <=300)
{
local.lite light 1 1 1 local.strength
local.strength = (local.strength + 2)
wait .02
}
else
{
thread dim local.lite
break
}
}
end
dim local.lite:
while (1)
{
if (local.lite.strength = 0)
{
local.lite light 1 1 1 local.strength
local.strength = (local.strength - 2)
wait .02
}
else
{
thread brighten local.lite
break
}
}
end
also a thing to note:
these dynamic lights aren't affected by walls, they'll shine on the other side of them, so be careful where you place them
Posted: Sun Jul 04, 2004 10:14 pm
by Master-Of-Fungus-Foo-D
cool. I should try these techniques.(man thats hard to spell)
Posted: Wed Aug 11, 2004 12:24 pm
by Runt
hey, a bit late reply .. but i need help..
Code: Select all
// DESTROYED VILLAGE
// ARCHITECTURE: NED
// SCRIPTING: NED
main:
// set scoreboard messages
setcvar "g_obj_alliedtext1" "Destroyed Village"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""
setcvar "g_scoreboardpic" "mohdm2"
// call additional stuff for playing this map round based is needed
if(level.roundbased)
thread roundbasedthread
level waittill prespawn
//*** Precache Dm Stuff
exec global/DMprecache.scr
exec global/door_locked.scr::lock
level.script = maps/dm/mohdm2.scr
exec global/ambient.scr mohdm2
level waittill spawn
mylite_thread:
local.lite = spawn script_model model "fx_dummy.tik"
local.lite.origin = ( 0 0 128 ) // coordinates
local.lite light 1 1 1 300 // last number is how big it is, ( 1 1 1 is white light).
end
end
//-----------------------------------------------------------------------------
roundbasedthread:
// Can specify different scoreboard messages for round based games here.
level waitTill prespawn
level waittill spawn
// set the parameters for this round based match
level.dmrespawning = 0 // 1 or 0
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = kills // set to axis, allies, kills, or draw
level waittill roundstart
end
why this doesn't work ?
console:

Posted: Wed Aug 11, 2004 1:12 pm
by Angex
Try changing the model to "fx/dummy.tik":
Code: Select all
local.lite = spawn script_model model "fx/dummy.tik"
Plus you should move the mylite_thread definition out your main thread, because I think that will also cause a problem.
Posted: Wed Aug 11, 2004 2:29 pm
by Runt
Doesn't work with fx/dummy.tik
what do you exactly mean with
move the mylite_thread definition out your main thread
what is my main thread ?

Posted: Wed Aug 11, 2004 7:02 pm
by G3mInI
Like this:
// DESTROYED VILLAGE
// ARCHITECTURE: NED
// SCRIPTING: NED
main:
// set scoreboard messages
setcvar "g_obj_alliedtext1" "Destroyed Village"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""
setcvar "g_scoreboardpic" "mohdm2"
thread mylite_thread
// call additional stuff for playing this map round based is needed
if(level.roundbased)
thread roundbasedthread
level waittill prespawn
//*** Precache Dm Stuff
exec global/DMprecache.scr
exec global/door_locked.scr::lock
level.script = maps/dm/mohdm2.scr
exec global/ambient.scr mohdm2
level waittill spawn
end
//-----------------------------------------------------------------------------
roundbasedthread:
// Can specify different scoreboard messages for round based games here.
level waitTill prespawn
level waittill spawn
// set the parameters for this round based match
level.dmrespawning = 0 // 1 or 0
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = kills // set to axis, allies, kills, or draw
level waittill roundstart
end
mylite_thread:
local.lite = spawn script_model model "fx/dummy.tik"
local.lite.origin = ( 0 0 128 ) // coordinates
local.lite light 1 1 1 300 // last number is how big it is, ( 1 1 1 is white light).
end
Your main thread is all the satements between main: and the first end statement, in this case I made it all in bold yellow type so you can see what the main thread consists of. So what you do is tell the script to call the thread mylite_thread before the end statement, highlighted in red text. It will jump down to that thread and do whatever and then jump back and continue on in the main thread. I placed this line here because if it were a roundbased game the very next line jumps down to the roundbased thread, and would skip over your thread statement if it came after it. This way, no matter what gametype you play, the thread will be exectued. Next you place the mylite_thread somewhere down the bottom of your script, outside of the boundaries of your main thread.
G3mInI
my bad
Posted: Thu Aug 12, 2004 5:41 am
by tltrude
Yes, it should be "fx/dummy.tik".
Posted: Thu Aug 12, 2004 10:12 am
by Runt
It works fine now ! thanks !
Posted: Tue Aug 17, 2004 7:27 pm
by SkiLLeT
Hello i need some help I made a fx/corona red and I used the blinking on then off method and it work great by the way. Now i need to figure out how to take the the fx/corona red out at the same time the light turns off. how can i do this? would i just put
mylite_thread:
local.lite = spawn script_model model "fx/corona_Red.tik" targetname mylight
local.lite.origin = ( 1514 2174 749.70 ) // coordinates
local.lite light 1 0 0 200 // last number is how big it is, ( 1 1 1 is white light).
thread blink_light
thread coronaoff
end
coronaoff:
wait 3
$mylight_thread remove
wait 3
thread mylight_thread
end
blink_light:
while(1)
{
$mylight lighton
wait 3
$mylight lightoff
wait 3
}
end
would that work or would the remove mylight thread disable the blinkingoff?