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 (80 lines) | stat: -rw-r--r-- 1,580 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
	Vine Segment

	@author Maikel	
*/

#include Library_Ladder

local index;

// Called from the ladder object to set a master and the segment index.
public func SetMaster(object new_master, int new_index, ...) 
{
	// First perform setting the master in the library function.
	_inherited(new_master, new_index, ...);
	// Then set index and attach to master object.
	index = new_index;
	AddVertex(0, new_master->GetY() - GetY() + new_master->GetTop());
	SetAction("Attach", master);
	return;
}

// Returns whether the ladder can be climbed.
public func CanNotBeClimbed(bool is_climbing)
{
	var test_height = 10;
	if (is_climbing) 
		test_height = 8;
	if (GBackSolid(1, test_height) && GBackSolid(-1, test_height)) 
		return true;
	return false;
}

// Returns the segment (start x, start y, end x, end y, angle) on which the clonk can climb.
// The coordinate value must be specified with a precision of a 1000.
public func GetLadderData()
{
	return [
		GetX(1000),
		GetY(1000) + 4000,
		GetX(1000),
		GetY(1000) - 4000,
		0
	];
}

public func OnLadderGrab(object clonk)
{
	if (master)
		master->OnLadderGrab(clonk, this, index);
	return;
}

public func OnLadderClimb(object clonk)
{
	if (master)
		master->OnLadderClimb(clonk, this, index);
	return;
}

public func OnLadderReleased(object clonk)
{
	if (master)
		master->OnLadderReleased(clonk, this, index);
	return;
}

// Main vine object is saved.
public func SaveScenarioObject() { return false; }


/*-- Properties --*/

local ActMap = {
	Attach = {
		Prototype = Action,
		Name = "Attach",
		Procedure = DFA_ATTACH,
	},
};