summaryrefslogtreecommitdiffstats
path: root/Targets.c4d/System.c4g/CannonTower.c
blob: 6d7d2cea9f4a67e24ff8f1f1f7418563c3223804 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#strict 2
#appendto CTW0

func IsRemoteControllable() { return true; }

func RemoteControlMap()
{
	var ret = _inherited(...);
	ret[GetLength(ret)] = [RC7I_Control_T, "Shoot", "$CTW0_DirectShoot$"];
	return ret;
}

func GetNextAmmo()
{
	if(cannon)
	{
		for(var i = 0, content; content = Contents(i); ++i)
		{
			if(GetID(content) != GUNP && cannon->~CannonAmmo(content))
			{
				return content;
			}
		}
	}
}

func Shoot(object caller)
{
	if(cannon)
	{
		if(cannon->~IsDirectShoot())
		{
			return ContainedDig(caller);
		}
		else
		{
			var ammo = GetNextAmmo();
			return ammo && cannon->~Shoot(GetID(ammo), ammo, caller);
		}
	}
}