forked from Mirrors/openclonk
Light up target door on remote control by switch (#1296).
parent
afd1dcba7f
commit
4da413b6ae
|
@ -6,17 +6,18 @@ local Name = "$Name$";
|
||||||
// Light types to be used for light_type parameter in CreateLight
|
// Light types to be used for light_type parameter in CreateLight
|
||||||
local LGT_Constant = 0;
|
local LGT_Constant = 0;
|
||||||
local LGT_Blast = 1; // light up and remove again after some time
|
local LGT_Blast = 1; // light up and remove again after some time
|
||||||
|
local LGT_Temp = 2; // light up and remove again after some time
|
||||||
local range, ltype, t;
|
local range, ltype, t;
|
||||||
|
|
||||||
global func CreateLight(int x, int y, int range, int light_type, player)
|
global func CreateLight(int x, int y, int range, int light_type, player, int fadeout, int time)
|
||||||
{
|
{
|
||||||
// create light object. player may be nil
|
// create light object. player may be nil
|
||||||
var light = CreateObjectAbove(Fx_Light, x, y, player);
|
var light = CreateObjectAbove(Fx_Light, x, y, player);
|
||||||
if (light) light->Init(range, light_type);
|
if (light) light->Init(range, light_type, fadeout, time);
|
||||||
return light;
|
return light;
|
||||||
}
|
}
|
||||||
|
|
||||||
func Init(int lrange, int light_type)
|
func Init(int lrange, int light_type, int fadeout, int time)
|
||||||
{
|
{
|
||||||
// Init depending on type
|
// Init depending on type
|
||||||
range = lrange;
|
range = lrange;
|
||||||
|
@ -30,7 +31,12 @@ func Init(int lrange, int light_type)
|
||||||
else if (ltype == LGT_Blast)
|
else if (ltype == LGT_Blast)
|
||||||
{
|
{
|
||||||
SetLightRange(range);
|
SetLightRange(range);
|
||||||
var time = Sqrt(range)+10;
|
time = Sqrt(range)+10;
|
||||||
|
ScheduleCall(this, Global.RemoveObject, time, 1);
|
||||||
|
}
|
||||||
|
else if (ltype == LGT_Temp)
|
||||||
|
{
|
||||||
|
SetLightRange(range, fadeout);
|
||||||
ScheduleCall(this, Global.RemoveObject, time, 1);
|
ScheduleCall(this, Global.RemoveObject, time, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -128,6 +128,15 @@ private func DoGraphics()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func GetFloorOffset()
|
||||||
|
{
|
||||||
|
// Searches downwards from the lowest vertex to the floor
|
||||||
|
var y_off;
|
||||||
|
for (y_off=0; !GBackSolid(0, 20+y_off); ++y_off)
|
||||||
|
if (y_off > 20) break; // max range
|
||||||
|
return y_off;
|
||||||
|
}
|
||||||
|
|
||||||
local ActMap = {
|
local ActMap = {
|
||||||
Door = {
|
Door = {
|
||||||
Prototype = Action,
|
Prototype = Action,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*-- Spin Wheel --*/
|
/*-- Spin Wheel --*/
|
||||||
|
|
||||||
local targetdoor;
|
local targetdoor, temp_light;
|
||||||
|
|
||||||
public func Initialize()
|
public func Initialize()
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,13 @@ public func ControlUp(object clonk)
|
||||||
{
|
{
|
||||||
if (GetAction() == "Still" && targetdoor)
|
if (GetAction() == "Still" && targetdoor)
|
||||||
{
|
{
|
||||||
if (clonk) SetPlrView(clonk->GetController(), targetdoor);
|
if (clonk)
|
||||||
|
{
|
||||||
|
SetPlrView(clonk->GetController(), targetdoor);
|
||||||
|
if (temp_light) temp_light->RemoveObject();
|
||||||
|
var y_off = targetdoor->~GetFloorOffset();
|
||||||
|
temp_light = Global->CreateLight(targetdoor->GetX(), targetdoor->GetY() + y_off, 30, Fx_Light.LGT_Temp, clonk->GetController(), 30, 50);
|
||||||
|
}
|
||||||
targetdoor->OpenDoor();
|
targetdoor->OpenDoor();
|
||||||
SetAction("SpinLeft");
|
SetAction("SpinLeft");
|
||||||
Sound("Chain");
|
Sound("Chain");
|
||||||
|
@ -28,7 +34,13 @@ public func ControlDown(object clonk)
|
||||||
{
|
{
|
||||||
if (GetAction() == "Still" && targetdoor)
|
if (GetAction() == "Still" && targetdoor)
|
||||||
{
|
{
|
||||||
if (clonk) SetPlrView(clonk->GetController(), targetdoor);
|
if (clonk)
|
||||||
|
{
|
||||||
|
SetPlrView(clonk->GetController(), targetdoor);
|
||||||
|
if (temp_light) temp_light->RemoveObject();
|
||||||
|
var y_off = targetdoor->~GetFloorOffset();
|
||||||
|
temp_light = Global->CreateLight(targetdoor->GetX(), targetdoor->GetY() + y_off, 30, Fx_Light.LGT_Temp, clonk->GetController(), 30, 50);
|
||||||
|
}
|
||||||
targetdoor->CloseDoor();
|
targetdoor->CloseDoor();
|
||||||
SetAction("SpinRight");
|
SetAction("SpinRight");
|
||||||
Sound("Chain");
|
Sound("Chain");
|
||||||
|
|
Loading…
Reference in New Issue