I've been trying since yesterday to implement a script that would randomly spawn BigTree objects in all outdoor sectors (i.e. sectors that use the ceiling texture "F_SKY1") whenever I run its pk3 file, so that I wouldn't have to individually edit each map to add more trees. Unfortunately, so far I couldn't get it to work.
I've been basing it on a script made by Vincent(PDP) a few years back:
Code: Select all
Script "TreeSpawn" OPEN
{
//The count variable will be how many things you want to spawn. Let's say 64.
For(Int count=64; count>0; count --)
{
Bool Worked = False;
Int Tries = 0; //Amount of times it has tried to spawn a thing
While(Worked == False)
{
Int randX = Random(-32767.0, 32767.0); //All coordinates must end with .0 since they have to be fixed point
Int randY = Random(32767.0, -32767.0);
Int randZ = Random(-4096.0, 4096.0); //Just some z coords...
If(Spawn("BigTree", randX, randY, randZ, 3000+count, 0))
{
If(CheckActorCeilingTexture(3000+count, "F_SKY1") == True)
{
Worked = True;
}
Else
{
Thing_Remove(3000+count);
}
}
Tries ++;
If(Tries >= 512)
{
Worked = True;
}
}
}
}While we're at it, is it also possible to have the script destroy any tree item that was spawned on a floor with a liquid texture?