2014-12-31 12:36:22 +00:00
|
|
|
/*-- Light --*/
|
|
|
|
|
|
|
|
local Visibility = VIS_None;
|
|
|
|
local Name = "$Name$";
|
|
|
|
|
|
|
|
// Light types to be used for light_type parameter in CreateLight
|
|
|
|
local LGT_Constant = 0;
|
|
|
|
local LGT_Blast = 1; // light up and remove again after some time
|
2015-05-07 18:26:16 +00:00
|
|
|
local LGT_Temp = 2; // light up and remove again after some time
|
2014-12-31 12:36:22 +00:00
|
|
|
local range, ltype, t;
|
|
|
|
|
2015-05-07 18:26:16 +00:00
|
|
|
global func CreateLight(int x, int y, int range, int light_type, player, int fadeout, int time)
|
2014-12-31 12:36:22 +00:00
|
|
|
{
|
|
|
|
// create light object. player may be nil
|
2015-01-10 09:14:02 +00:00
|
|
|
var light = CreateObjectAbove(Fx_Light, x, y, player);
|
2015-05-07 18:26:16 +00:00
|
|
|
if (light) light->Init(range, light_type, fadeout, time);
|
2014-12-31 12:36:22 +00:00
|
|
|
return light;
|
|
|
|
}
|
|
|
|
|
2015-05-07 18:26:16 +00:00
|
|
|
func Init(int lrange, int light_type, int fadeout, int time)
|
2014-12-31 12:36:22 +00:00
|
|
|
{
|
|
|
|
// Init depending on type
|
|
|
|
range = lrange;
|
|
|
|
ltype = light_type;
|
|
|
|
t = 0;
|
|
|
|
if (ltype == LGT_Constant)
|
|
|
|
{
|
|
|
|
// Just a fixed light
|
2015-01-02 00:06:00 +00:00
|
|
|
SetLightRange(range);
|
2014-12-31 12:36:22 +00:00
|
|
|
}
|
|
|
|
else if (ltype == LGT_Blast)
|
|
|
|
{
|
2015-01-02 00:06:00 +00:00
|
|
|
SetLightRange(range);
|
2015-05-07 18:26:16 +00:00
|
|
|
time = Sqrt(range)+10;
|
|
|
|
ScheduleCall(this, Global.RemoveObject, time, 1);
|
|
|
|
}
|
|
|
|
else if (ltype == LGT_Temp)
|
|
|
|
{
|
|
|
|
SetLightRange(range, fadeout);
|
2014-12-31 12:36:22 +00:00
|
|
|
ScheduleCall(this, Global.RemoveObject, time, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Invalid light type
|
|
|
|
FatalError(Format("Light init: Invalid light type %v", light_type));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Temp or helper object not stored
|
|
|
|
func SaveScenarioObject() { return false; }
|
|
|
|
|