Light up target door on remote control by switch (#1296).

stable-6.1
Sven Eberhardt 2015-05-07 20:26:16 +02:00 committed by Maikel de Vries
parent afd1dcba7f
commit 4da413b6ae
3 changed files with 34 additions and 7 deletions

View File

@ -6,17 +6,18 @@ 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
local LGT_Temp = 2; // light up and remove again after some time
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
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;
}
func Init(int lrange, int light_type)
func Init(int lrange, int light_type, int fadeout, int time)
{
// Init depending on type
range = lrange;
@ -30,7 +31,12 @@ func Init(int lrange, int light_type)
else if (ltype == LGT_Blast)
{
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);
}
else

View File

@ -128,6 +128,15 @@ private func DoGraphics()
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 = {
Door = {
Prototype = Action,

View File

@ -1,6 +1,6 @@
/*-- Spin Wheel --*/
local targetdoor;
local targetdoor, temp_light;
public func Initialize()
{
@ -17,7 +17,13 @@ public func ControlUp(object clonk)
{
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();
SetAction("SpinLeft");
Sound("Chain");
@ -28,7 +34,13 @@ public func ControlDown(object clonk)
{
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();
SetAction("SpinRight");
Sound("Chain");