/////////////////////////////////////////////////////////////////////
SOUND* click = "click.wav";
/////////////////////////////////////////////////////////////////////
//--------------------------------------------------------------------
// Flashlight
//--------------------------------------------------------------------
var flashlighton = 0;
function attach_light(ENTITY* flashlight)
{
if(flashlight)
{
if(flashlighton == 1)
{
vec_set(flashlight.x, camera.x);
flashlight.z = camera.z;
flashlight.pan = camera.pan;
flashlight.tilt = camera.tilt;
sc_light_update(flashlight);
}
}
}
///////////////////////////////////////////////////////////////////////////////
action hero_flashlight()
{
var lightcreated = 0;
wait(-1);
set(my,INVISIBLE|PASSABLE);
wait(1);
ENTITY* flashlight = NULL;
while(heroEnt.health>0)
{
if(key_f)
{
if(flashlighton == 0){flashlighton = 1;}
else{flashlighton = 0;}
while(key_f)
{
if(flashlight){attach_light(flashlight);}
wait(1);
}
}
//////////
if(flashlighton == 1 && lightcreated == 0)
{
snd_play(click,100,0);
lightcreated = 1;
wait(3);
flashlight = sc_light_create(vector(camera.x, camera.y, camera.z), 1000, vector(50,25,0), SC_LIGHT_SPOT | SC_LIGHT_SPECULAR | SC_LIGHT_SHADOW , vector(0, -25, 0), 45);
wait(1);
}
if(flashlighton == 0)
{
if(lightcreated == 1)
{lightcreated = 0;/*snd_play(click,100,0);*/}
sc_light_remove(flashlight);
flashlight = NULL;
}
if(flashlight){attach_light(flashlight);}
wait(1);
}
wait(1);
lightcreated = 0;
flashlighton = 0;
sc_light_remove(flashlight);
flashlight = NULL;
}