Skip to content

Commit

Permalink
Light up target door on remote control by switch (#1296).
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenTwo authored and MDT-Maikel committed May 14, 2015
1 parent afd1dcb commit 4da413b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
14 changes: 10 additions & 4 deletions planet/Objects.ocd/Effects.ocd/Light.ocd/Script.c
Expand Up @@ -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;
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/Script.c
Expand Up @@ -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,
Expand Down
@@ -1,6 +1,6 @@
/*-- Spin Wheel --*/

local targetdoor;
local targetdoor, temp_light;

public func Initialize()
{
Expand All @@ -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");
Expand All @@ -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");
Expand Down

0 comments on commit 4da413b

Please sign in to comment.