summaryrefslogtreecommitdiffstats
path: root/TemplePushing.c4s/System.c4g/Arrowpack.c
blob: da2c5ec106ac83cbe4931fee5e33860cf85277a4 (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
42
43
44
45
46
/*-- Arrow packs shoot arrows --*/

#strict 2

#appendto ARWP

local coolingDown;

protected func Initialize()
{
	iUsedItems = RandomX(7,8);
}

private func CooledDown()
{
	return !coolingDown;
}

protected func Activate(object clonk) 
{
	[$Shoot$|Image=BOW1|Condition=CooledDown]

	if (!CooledDown()) return 0;

	// Extract an arrow from the pack
	var arrow = GetItem();

	// Make shooting clonk responsible for possible kill and owner of the arrow
	arrow->SetOwner(clonk->GetOwner());
	arrow->SetController(clonk->GetOwner());
	
	// Shoot
	// Do not launch fire arrows too close to the clonk to prevent incineration when launched while climbing
	var arrowPosX = IIf(arrow->GetID() == FARW, -10 + 20 * clonk->GetDir(), -3 + 6 * clonk->GetDir());
	arrow->Exit(0, arrowPosX, 5, -90 + 180 * clonk->GetDir(), -8 + 16 * clonk->GetDir(), -2);
	arrow->~Launch();
	
	// Start cooldown
	coolingDown = true;
	Schedule("coolingDown = false", RandomX(3, 5));
	
	// Play sound
	Sound("Arrow");

	return 1;
}