summaryrefslogtreecommitdiffstats
path: root/TemplePushing.c4s/System.c4g/Clonk.c
blob: 2308576da06ad11327b375227b95dded8554e521 (plain)
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
#strict 2
#appendto CLNK

protected func ControlSpecial()
{
	[$Push$|Image=CXIV]

	if (GetAction() != "Walk") return 0;

	// Use action "Throw" starting with phase 3
	SetAction("Throw");
	SetPhase(3);

	// Find clonks in range
	var clonks = FindObjects(
		Find_ID(CLNK),
		Find_InRect(-10 + GetDir() * 20, 0, 10, 10),
		Find_OCF(OCF_Alive),
		// Only include allied players' clonks if "friendly pushing" rule is present
		Find_Or(Find_Func(FindObject(FYPG)), Find_Hostile(GetOwner())));

	if (GetLength(clonks) == 0) return 0;

	// Randomly select clonk to be pushed
	Fling(clonks[Random(GetLength(clonks))], -1 + GetDir() * 2, -1);
	return 1;
}