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
|
/*
Wheat
Author: Clonkonaut
Easy crop for farming.
*/
#include Library_Plant
#include Library_Crop
local swing_anim;
local plant_seed_area = 60;
local plant_seed_chance = 40;
local plant_seed_amount = 4; // small seed area -> don't allow too many plants
local plant_seed_offset = 10;
public func SickleHarvesting() { return true; }
private func Construction()
{
StartGrowth(this.growth);
AddTimer("WaterCheck", 70+Random(10));
AddTimer("WindCheck", 350);
swing_anim = PlayAnimation("Swing", 1, Anim_Const(0));
return _inherited(...);
}
private func Initialize()
{
SetMeshMaterial("wheat_material_ripe");
_inherited(...);
}
// Create some particles when harvested so it doesn't look as awkward.
public func Harvest()
{
CreateParticle("Straw", PV_Random(-15, 15), PV_Random(-7, 7), PV_Random(-5, 5), PV_Random(-15, 5), PV_Random(30, 120), Particles_Straw(), 150);
return _inherited(...);
}
// Reverts the mesh material to the unripe green
public func Unripe()
{
SetMeshMaterial("wheat_material");
}
/* Check the wind to adjust the swinging speed of the stalks */
private func WindCheck()
{
var speed = 200 - Abs(GetWind());
SetAnimationPosition(swing_anim, Anim_Linear(GetAnimationPosition(swing_anim), 0, GetAnimationLength("Swing"), speed, ANIM_Loop));
}
local Name = "$Name$";
local Description = "$Description$";
local growth = 3;
local degrowth = -6;
local fastgrowth = 9;
local Components = {Seeds = 2};
|