File: Script.c

package info (click to toggle)
openclonk 8.1-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 169,520 kB
  • sloc: cpp: 180,479; ansic: 108,988; xml: 31,371; python: 1,223; php: 767; makefile: 145; sh: 101; javascript: 34
file content (52 lines) | stat: -rw-r--r-- 1,278 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*-- 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
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, 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, fadeout, time);
	return light;
}

func Init(int lrange, int light_type, int fadeout, int time)
{
	// Init depending on type
	range = lrange;
	ltype = light_type;
	t = 0;
	if (ltype == LGT_Constant)
	{
		// Just a fixed light
		SetLightRange(range);
	}
	else if (ltype == LGT_Blast)
	{
		SetLightRange(range);
		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
	{
		// 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; }