forked from Mirrors/openclonk
Fixed coconut tree to procreate properly
parent
32cdba7415
commit
0afe958618
|
@ -15,5 +15,6 @@ Mass=9
|
|||
Components=Coconut=1
|
||||
ContactCalls=1
|
||||
Projectile=1
|
||||
Float=1
|
||||
Rotate=1
|
||||
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
|
||||
local seedTime;
|
||||
|
||||
protected func Construction()
|
||||
protected func Initialize()
|
||||
{
|
||||
//AddEffect to grow trees
|
||||
AddEffect("Seed", this, 30, 18, this);
|
||||
AddEffect("IntSeed", this, 1, 18, this);
|
||||
seedTime = 15 * 2;
|
||||
}
|
||||
|
||||
public func FxSeedTimer(object coconut, int num, int timer)
|
||||
public func FxIntSeedTimer(object coconut, proplist effect, int timer)
|
||||
{
|
||||
//Start germination timer if in the environment
|
||||
if(!Contained()){
|
||||
seedTime--;
|
||||
}
|
||||
//If the coconut is on the earth
|
||||
if(seedTime <= 0 && !Contained() && GetMaterial(0,3) == Material("Earth") && GetCon() >= 100)
|
||||
if(seedTime <= 0 && !Contained() && GetMaterialVal("Soil","Material",GetMaterial(0,3)) == 1 && GetCon() >= 100)
|
||||
{
|
||||
//Are there any trees too close? Is the coconut underwater?
|
||||
if(!FindObject(Find_Func("IsTree"), Find_Distance(80)) && !GBackLiquid())
|
||||
|
@ -28,13 +28,13 @@ public func FxSeedTimer(object coconut, int num, int timer)
|
|||
|
||||
//Destruct if sitting for too long
|
||||
if(seedTime == -120) this.Collectible = 0;
|
||||
if(timer < -120) DoCon(-5);
|
||||
if(seedTime < -120) DoCon(-5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public func Germinate() { AddEffect("Germinate", this, 1,1, this); }
|
||||
public func FxGerminateTimer(object coconut, int num, int timer)
|
||||
public func FxGerminateTimer(object coconut, proplist effect, int timer)
|
||||
{
|
||||
if(timer == 1)
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ VertexX=0,0,0,0,0
|
|||
VertexY=40,20,0,-20,-40
|
||||
VertexCNAT=8,16,16,16,4
|
||||
VertexFriction=50,25,25,25,50
|
||||
Components=Wood=3
|
||||
Components=Wood=4
|
||||
Mass=110
|
||||
StretchGrowth=1
|
||||
Oversize=1
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include Library_Plant
|
||||
|
||||
private func SeedChance() { return 500; }
|
||||
private func SeedChance() { return 100; }
|
||||
private func SeedArea() { return 400; }
|
||||
private func SeedAmount() { return 12; }
|
||||
|
||||
|
@ -25,7 +25,7 @@ public func Seed()
|
|||
// If there are not much plants in the seed area compared to seed amount
|
||||
// the chance of seeding is improved, if there are much the chance is reduced.
|
||||
var chance = SeedChance();
|
||||
var chance = chance / Max(1, amount - plant_cnt) + chance * Max(0, plant_cnt - amount);
|
||||
// var chance = chance / Max(1, amount - plant_cnt) + chance * Max(0, plant_cnt - amount);
|
||||
// Place a plant if we are lucky, in principle there can be more than seed amount.
|
||||
if (!Random(chance) && GetCon() >= 100)
|
||||
{
|
||||
|
@ -33,13 +33,13 @@ public func Seed()
|
|||
// var plant = PlaceVegetation(GetID(), offset, offset, size, size, 3);
|
||||
var seed = CreateObject(Coconut, 0, -35);
|
||||
seed->SetXDir(-5 + Random(11));
|
||||
if (seed)
|
||||
seed->SetR(Random(360));
|
||||
seed->SetRDir(RandomX(-5,5));
|
||||
|
||||
//one coconut for each tree
|
||||
if(ObjectCount(Find_ID(Coconut)) > ObjectCount(Find_ID(Tree_Coconut)))
|
||||
{
|
||||
//one coconut for each tree
|
||||
if(ObjectCount(Find_ID(Coconut)) > ObjectCount(Find_ID(Tree_Coconut)))
|
||||
{
|
||||
seed->RemoveObject();
|
||||
}
|
||||
seed->RemoveObject();
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue