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 (59 lines) | stat: -rw-r--r-- 1,245 bytes parent folder | download | duplicates (5)
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
53
54
55
56
57
58
59
/**
	Lava Bubble
	Looks dangerous

	@author Win
*/

local Name = "Lava Bubble";
local Plane = 500;

public func Construction()
{
	if (GBackSolid(0, 0))
	{
		RemoveObject();
		return;
	}
	
	AddEffect("Move", this, 1, 2, this);
	Sound("Liquids::Bubble*");
	return;
}

private func FxMoveTimer(object target, effect, int time)
{
	if ((!GBackLiquid(0, -3) || time > 108) && !GetEffect("ObjFade", this))
		FadeOut(50, true);

	// Bubbles burst into smaller bubbles
	if (!Random(25) && target->GetCon() > 100)
	{
		for (var i = 0; i < 2; i++)
		{
			var bubble = CreateObjectAbove(GetID());
			// Bubble could have been removed in its construction call.
			if (bubble)
			{
				bubble->SetCon(2 * target->GetCon() / 3);
				bubble->SetYDir(target->GetYDir());
			}
		}
		RemoveObject();
		return FX_Execute_Kill;
	}

	// Jittery movement
	SetYDir(GetYDir() - 3 + Random(7));
	if (Inside(GetXDir(), -6, 6))
		SetXDir(GetXDir() + 2 * Random(2) - 1);
	
	// Explodes near living things.
	var prey = FindObject(Find_Distance(GetCon() / 15), Find_OCF(OCF_Alive), Find_Not(Find_Property("CorrosionResist")));
	if (prey)
		Explode(10);
	return FX_OK;
}

// No need to blow up scenario object list with bubble spam.
func SaveScenarioObject() { return false; }