RandomSpawner failing to spawn objects

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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
Virathas
Posts: 254
Joined: Thu Aug 10, 2017 9:38 am

RandomSpawner failing to spawn objects

Post by Virathas »

I have been experiencing an odd issue with RandomSpawners. One of my spawners may spawn either a mine item, that can be picked up or used or an active mine that is a trap.

Thing is, if a trap is spawned in a slightly "crampped" area, it will fail to spawn, but only if it is spawned from a subsequent spawner.

Spawners:
Spoiler:
The trap:
Spoiler:
If I put the MineSpawner list into the first spawner, it will spawn correctly. Removing the "missile" flag from the mine will also cause it to spawn. A good place to see this behavior is the start of MAP02 - where if a trap is chosen, it will fail to spawn.

The question is: Why is it behaving that way? Is this a bug on my side, or on the GZDoom's side?
(For me this is not a big deal, but it might be problematic in the future)
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: RandomSpawner failing to spawn objects

Post by Player701 »

OK, this is weird. It could be a bug, or maybe a case of "don't do that". Better ask a developer.

Here's what happens here:
  1. FlechetteSpawner calls BeginPlay and chooses to spawn a MineSpawner.
  2. FlechetteSpawner calls PostBeginPlay and actually spawns a MineSpawner.
  3. MineSpawner calls BeginPlay and chooses to spawn a Mine. Because Mine is a MISSILE, it sets the MISSILE flag on itself.
  4. FlechetteSpawner then discovers that the newly spawned MineSpawner is a MISSILE, and calls CheckMissileSpawn.
  5. CheckMissileSpawn realizes that the MineSpawner is too big to fit in (note that an actor's default height and radius are 16 and 20 respectively), and tries to explode the MineSpawner. Since the spawner does not have a nice explosion animation like your Mine probably does, it just disappears instead.
Your best bet right now would probably be to set the radius and height for MineSpawner to the same values that you've set for your Mine actor. It fixes the problem on my end, too.

The scenario itself (a RandomSpawner spawning another RandomSpawner spawning a missile) is probably bugged. This particular case can be rectified by not calling CheckMissileRange if newmobj is a RandomSpawner. There is another code block succeptible to this bug, which is executed when the missile is an actual missile shot by someone, and not just spawned in place of some item, a similar check should probably be added there as well.
User avatar
Dan_The_Noob
Posts: 880
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: RandomSpawner failing to spawn objects

Post by Dan_The_Noob »

MISSILE makes objects disappear when colliding with a surface... so they are possibly spawning then just disappearing.

try enabling degreeless (type "god" in the console) and spawning a few (type "summon MineSpawner")

also, try setting your mines radius/height to something like 2x2. if they do infact spawn.
User avatar
Virathas
Posts: 254
Joined: Thu Aug 10, 2017 9:38 am

Re: RandomSpawner failing to spawn objects

Post by Virathas »

I do have several work arounds for this, including removing missile flag and setting it back on frame "0" of the mine, or even editing the RandomSpawner itself. But the RandomSpawner spawning RandomSpawner spawning missile behavior was weird.
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: RandomSpawner failing to spawn objects

Post by Player701 »

I pushed a fix for this to the GZDoom repo via a PR yesterday. This issue should no longer be present in newer versions.
Post Reply

Return to “Scripting”