2011-05-24 15:55:43 +00:00
|
|
|
/*-- Moss --*/
|
|
|
|
|
2011-05-24 19:32:13 +00:00
|
|
|
static const MOSS_MAXWETNESS = 30;
|
|
|
|
static const MOSS_LICHENDELAY = 30;
|
2011-05-24 15:55:43 +00:00
|
|
|
local wetness;
|
|
|
|
local graphic;
|
2011-05-24 19:32:13 +00:00
|
|
|
local lastpos;
|
|
|
|
local still;
|
2011-05-24 15:55:43 +00:00
|
|
|
func Initialize()
|
|
|
|
{
|
|
|
|
graphic = Random(3);
|
|
|
|
if(graphic)
|
|
|
|
SetGraphics(Format("%d",graphic));
|
|
|
|
else SetGraphics();
|
|
|
|
wetness = MOSS_MAXWETNESS;
|
2011-05-24 19:32:13 +00:00
|
|
|
lastpos = CreateArray();
|
2011-05-24 15:55:43 +00:00
|
|
|
AddEffect("MossMoisture",this,100,36,this,this.ID);
|
2011-05-24 19:32:13 +00:00
|
|
|
still=0;
|
2011-05-24 15:55:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private func FxMossMoistureTimer(target, effect, time)
|
|
|
|
{
|
|
|
|
if(GetMaterial() == Material("Water"))
|
|
|
|
{
|
2011-05-24 19:32:13 +00:00
|
|
|
|
2011-05-24 15:55:43 +00:00
|
|
|
if(wetness < MOSS_MAXWETNESS)
|
|
|
|
{
|
|
|
|
wetness = MOSS_MAXWETNESS;
|
|
|
|
if(graphic)
|
|
|
|
SetGraphics(Format("%d",graphic));
|
|
|
|
SetGraphics();
|
|
|
|
}
|
2011-05-24 19:32:13 +00:00
|
|
|
if([GetX(),GetY()]==lastpos)
|
|
|
|
still++;
|
|
|
|
else
|
|
|
|
still=0;
|
|
|
|
if(still>MOSS_LICHENDELAY)
|
|
|
|
TryToLichen();
|
|
|
|
lastpos=[GetX(),GetY()];
|
2011-05-24 15:55:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else if(!Contained() && !GBackSolid() && !GBackLiquid())
|
|
|
|
if(wetness)
|
|
|
|
{
|
|
|
|
wetness--;
|
|
|
|
if(wetness == 0)
|
|
|
|
{
|
|
|
|
if(graphic)
|
|
|
|
SetGraphics(Format("%dDry",graphic));
|
|
|
|
else SetGraphics("Dry");
|
|
|
|
}
|
2011-05-24 17:08:46 +00:00
|
|
|
}
|
2011-05-24 15:55:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-24 19:32:13 +00:00
|
|
|
protected func TryToLichen()
|
|
|
|
{
|
|
|
|
|
|
|
|
var x = RandomX(-MOSS_MAXDIST,MOSS_MAXDIST);
|
|
|
|
var y = RandomX(-MOSS_MAXDIST,MOSS_MAXDIST);
|
|
|
|
var i = 0;
|
|
|
|
var good=false;
|
|
|
|
while(i<10)
|
|
|
|
{
|
|
|
|
if(GetMaterial(x,y)!=Material("Earth") && GetMaterial(x,y)!=Material("Tunnel"))
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(FindObject(Find_ID(Moss_Lichen),Find_Distance(MOSS_MINDIST,x,y)))
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(Distance(0,0,x,y)>MOSS_MAXDIST)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
good = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(!good) return ;
|
|
|
|
|
2015-01-10 09:14:02 +00:00
|
|
|
CreateObjectAbove(Moss_Lichen,x,y,-1);
|
2011-05-24 19:32:13 +00:00
|
|
|
still = -MOSS_LICHENDELAY-Random(MOSS_LICHENDELAY);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-05-24 15:55:43 +00:00
|
|
|
local Collectible = 1;
|
|
|
|
local Name = "$Name$";
|
|
|
|
local Description = "$Description$";
|
2012-04-28 14:17:38 +00:00
|
|
|
local BlastIncinerate = 1;
|
|
|
|
local ContactIncinerate = 1;
|