Thing_SpawnAlways

Moderator: GZDoom Developers

Post Reply
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Thing_SpawnAlways

Post by Tormentor667 »

A little suggestion that would make many difficult and complicated script solutions obsolete and many other things even possible: A "Thing_Spawn" variant, that always spawns and if it can't get spawned, it tries unlimited times until it can get spawned or the amount of retries is through. Something like this might work:

Code: Select all

Thing_SpawnAlways (tid, type, angle, new tid, retries, timebetweenretriesintics)
Possible?
skadoomer
Posts: 1026
Joined: Fri Sep 05, 2003 12:49 pm

Re: Thing_SpawnAlways

Post by skadoomer »

You know, I've always used a LWM trick in situation. Basically it goes something like this:

Code: Select all

amusing your tid is 300
int tries;
While(thingcount(0, 300) == 0 && tries < 10)
{
Spawnspot("My guy", ...)
Delay(1);
tries++;
}
The time in between tries can be tweaked with a delay.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Thing_SpawnAlways

Post by Graf Zahl »

Spawnspot even returns whether it was successful so you don't need such a hack. Just check the return value. It's true if something was spawned.
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: Thing_SpawnAlways

Post by Tormentor667 »

Thanks for the info but how can I check this? I mean how would the script look like that checks if a monster has been spawned or not via Spawnspot?
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Re: Thing_SpawnAlways

Post by Zippy »

Tormentor667 wrote:Thanks for the info but how can I check this? I mean how would the script look like that checks if a monster has been spawned or not via Spawnspot?
Multiple ways. Some examples:

Code: Select all

// Take a different course of action based on whether the spawning was successful or not
if( SpawnSpot("whatever",1) ) {
   // Spawn successful
}
else {
  // Spawn failed
}

// ...

// Store the spawn result
int spawnSuccess = SpawnSpot("whatever", 1);

// Do something else if the spawning failed
if( spawnSuccess == FALSE ) {   // or if( !spawnSuccess )
  // Spawn failed
}

// ...

// Keep trying until you spawn it
while( !SpawnSpot("whatever",1) ) {
  delay(1);
}
skadoomer
Posts: 1026
Joined: Fri Sep 05, 2003 12:49 pm

Re: Thing_SpawnAlways

Post by skadoomer »

Good to know. I'll have to modify some code in light of this, as spawning an object and then checking the object's tid with thing count isn't always successful)
User avatar
Enjay
 
 
Posts: 27203
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Thing_SpawnAlways

Post by Enjay »

Often I might have a number of map spots with the same tid on a map and use a single spawnspot instruction to spawn actors at each one. The situation may be further complicated by having different numbers of map spots at different difficulty levels. Would the spawnsuccess thingy be able to cope with that (ie can it be used to ensure all actors that there were map spots for have spawned (I suspect not)) or would I have to use a different map spot and tid for each actor that I was going to check for?
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Re: Thing_SpawnAlways

Post by Zippy »

Enjay wrote:Often I might have a number of map spots with the same tid on a map and use a single spawnspot instruction to spawn actors at each one. The situation may be further complicated by having different numbers of map spots at different difficulty levels. Would the spawnsuccess thingy be able to cope with that (ie can it be used to ensure all actors that there were map spots for have spawned (I suspect not)) or would I have to use a different map spot and tid for each actor that I was going to check for?
Things get a bit more complicated, but it's still somewhat workable. To my understanding, SpawnSpot actually won't return TRUE and FALSE, but the number of things spawned. FALSE happens to be 0, so TRUE and FALSE work in cases of spawning a single thing. if (SpawnSpot("whatever",1)) will succeed so long as SOMETHING is spawned.

So if you have 5 spots with the same tid and use SpawnSpot, the return value for spawning EVERYTHING should be 5. If you get less, not everything was spawned. Your problem now becomes: at which spots were things spawned? And more problematically, if you only spawned some of them (say it returned 3. You're missing 2) how do you spawn the rest at the appropriate spots? You really can't. One thing you can try is if you don't get them all, remove the ones that were spawned and try again:

Code: Select all

// Keep trying to spawn all 5 at once...
while( SpawnSpot("whatever",1,2) != 5 ) {
   Thing_Remove(2);
   delay(1);
}
I think the system has enough for clever mappers to work within the confines. If you want to do something like "it spawned only 3, so spawn the other 2 later at the correct spots" you're going to have to accept the reality that in order to have full control over the individual, unique spawn points then you to assign them unique tid identifiers. Working with a different number of spots on different difficulties shouldn't be much more than using [wiki]ThingCount[/wiki] and [wiki]GameSkill[/wiki] to determine the appropriate number to spawn.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: Thing_SpawnAlways

Post by HotWax »

Couldn't you also do this by creating an actor that periodically attempts to spawn a child which kills its parent as soon as it appears?

That wouldn't require any TIDs and could be used entirely from Decorate.
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Re: Thing_SpawnAlways

Post by Zippy »

Seems like that would work.
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: Thing_SpawnAlways

Post by Xaser »

But what about a situation where you would want to spawn something inside a wall? I don't mean in a "hey look thars a mancoobus in tehwall!1" joke-y way either. Suppose I wanted to spawn a Candelabra close to a wall in a spot that would normally consitutite it being "stuck." Seeing how it's a static decoration, it wouldn't constitute the usual errors that tend to apply when part of the radius is stuck in the wall.
User avatar
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: Thing_SpawnAlways

Post by XutaWoo »

Xaser wrote:But what about a situation where you would want to spawn something inside a wall? I don't mean in a "hey look thars a mancoobus in tehwall!1" joke-y way either. Suppose I wanted to spawn a Candelabra close to a wall in a spot that would normally consitutite it being "stuck." Seeing how it's a static decoration, it wouldn't constitute the usual errors that tend to apply when part of the radius is stuck in the wall.
You could always spawn an actor that uses that A_SpawnItemEx flag to force spawning to spawn that Candelabra.

Horray for hacks I suppose.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”