1 /*-- Lichen --*/
2 
3 #include Library_Plant
4 #include Library_Crop
5 
6 local grow_stage;
7 
8 local plant_seed_chance = 10;
9 local plant_seed_offset = 10;
10 
SickleHarvesting()11 private func SickleHarvesting() { return false; }
12 
Construction()13 protected func Construction()
14 {
15 	var graphic = Random(6);
16 	if(graphic)
17 		SetGraphics(Format("%d",graphic));
18 	_inherited(...);
19 
20 	if(GetCon() < 100) SetCon(100);
21 }
22 
Initialize()23 protected func Initialize()
24 {
25 	SetAction("Grow");
26 }
27 
Grow()28 protected func Grow()
29 {
30 	grow_stage++;
31 }
32 
Harvest(object clonk)33 public func Harvest(object clonk)
34 {
35 	var moss = CreateObjectAbove(Moss, 0, GetObjHeight()/2, NO_OWNER);
36 	clonk->Collect(moss);
37 	var particles =
38 	{
39 		Size = PV_Random(3, 7),
40 		Alpha = PV_KeyFrames(0, 0, 255, 900, 255, 1000, 0),
41 		ForceY = PV_Gravity(40),
42 		DampingX = 900, DampingY = 900,
43 		CollisionVertex = 750,
44 		OnCollision = PC_Stop(),
45 		Rotation = PV_Direction(PV_Random(900, 1100)),
46 		Phase = PV_Random(0, 1)
47 	};
48 	CreateParticle("Lichen", PV_Random(-5, 5), PV_Random(-5, 5), PV_Random(-30, 30), PV_Random(-30, 30), PV_Random(36, 36 * 4), particles, 40);
49 
50 	if (grow_stage)
51 	{
52 		if (GetAction() != "Grow") SetAction("Grow");
53 		grow_stage--;
54 		SetPhase(grow_stage);
55 	}
56 	else
57 		RemoveObject();
58 	return true;
59 }
60 
SaveScenarioObject(props)61 func SaveScenarioObject(props)
62 {
63 	if (!inherited(props, ...)) return false;
64 	if (GetAction() != "Grow" || GetPhase()) SaveScenarioObjectAction(props);
65 	return true;
66 }
67 
68 local Name = "$Name$";
69 local Description = "$Description$";
70 local BlastIncinerate = 1;
71 local ContactIncinerate = 3;
72 local Components = {Moss = 4};
73 
74 local ActMap = {
75 	Grow = {
76 		Prototype = Action,
77 		Name = "Grow",
78 		Procedure = DFA_NONE,
79 		Length = 4,
80 		Delay = 2500,
81 		X = 0,
82 		Y = 0,
83 		Wdt = 25,
84 		Hgt = 25,
85 		NextAction = "Grown",
86 		PhaseCall = "Grow"
87 	},
88 	Grown = {
89 		Prototype = Action,
90 		Name = "Grown",
91 		Procedure = DFA_NONE,
92 		Length = 1,
93 		Delay = 0,
94 		X = 75,
95 		Y = 0,
96 		Wdt = 25,
97 		Hgt = 25,
98 		NextAction = "Grown"
99 	}
100 };
101