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
on:start {
	local $branches, $leaves;
	$branches = 20; $leaves = 30;
}
on:use {
	$break = 0;
	scantarget;
	$tmp_id = targetid();
	$tool = getplayerweapon();
	if ( $branches == 0 ) {
		msg "Tree is stripped of branches.", 600;
	} elseif ( $tool == 87 ) {
		event "gthr_branch", "object", $tmp_id;
	} elseif ( $tool == 28 ) {
		event "gthr_leaves", "object", $tmp_id;
	} else {
		msg "Need a tool.", 600;
	}
}
on:gthr_branch {
	if ( $break == 1 ) {
		msg "Stopped gathering.", 600;
	} elseif ( $branches > 0 ) {
		$branches--;
		local $id;
		$id = create( "item", 24 );
		store $id, "unit", 1;
		process "Removing branch.", 1400, "recurse";
		animate $hands, 11, 20, 0.52, 3;
		freevar $id;
	} else {
		msg "Tree is stripped of branches.", 600;
	}
}
on:gthr_leaves {
	if ( $break == 1 ) {
		msg "Stopped gathering.", 600;
	} elseif ( $leaves > 0 ) {
		$leaves--;
		local $id;
		$id = create( "item", 15 );
		store $id, "unit", 1;
		process "Removing leaf.", 1100, "recurse";
		animate $hands, 11, 20, 0.58, 3;
		freevar $id;
	} else {
		msg "Tree is stripped of leaves.", 600;
	}
}
// Global recursive event written into game.inf
on:recurse {
	if ( $tool == 87 ) {
		event "gthr_branch", "object", $tmp_id;
	} elseif ( $tool == 28 ) {
		event "gthr_leaves", "object", $tmp_id;
	}
}
// Break action code also in game.inf
	on:keydown01 {
		event "break", "global";
	}
	on:break {
		$break = 1;
	}