[ACS] Random spawning actor in indoor sectors?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
P.Rex
Posts: 54
Joined: Sun May 15, 2016 12:32 pm
Preferred Pronouns: She/Her
Contact:

[ACS] Random spawning actor in indoor sectors?

Post by P.Rex »

For a certain mini-mod I'm working on, I've been trying to write a script that upon game start will randomly spawn a bunch of actors of a specific class across the entire map, but only in indoor sectors (i.e. sectors where the ceiling texture is NOT F_SKY1). However, so far nothing seems to happen and I have absolutely no idea what I'm doing here, so any help would be appreciated.

I've been trying to base it off the following script (originally written by Vincent(PDP) and further modified by gwHero and myself) which in its original form does the opposite- that is, spawns actors only in outdoor sectors. I've been trying to find a way to "reverse it" but so far to no avail.

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(-3000.0, 3000.0); //All coordinates must end with .0 since they have to be fixed point
            Int randY = Random(3000.0, -3000.0);
            Int randZ = Random(-32.0, +200.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) //512
            {
                Worked = True;
            }
        }
		//delay(1);
    }
}
Any help would be greatly appreciated.
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: [ACS] Random spawning actor in indoor sectors?

Post by Logan MTM »

That "//Delay(1);" sounds not cool!
You just did an endless loop that gzdoom always terminate
Post Reply

Return to “Scripting”