Spawned Fire Actors going through walls into void space

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!)
XLightningStormL
Posts: 396
Joined: Mon May 09, 2016 1:38 am
Location: Anywhere but here

Spawned Fire Actors going through walls into void space

Post by XLightningStormL »

Currently overhauling the Oil Drum resource for Realm667, so that the fire actors (BarrelFlames) can be correctly extinguished by a Fire Extinguisher "weapon" luckily all that is done, there is however one major issue: the spawned BarrelFlames actors have the ability to ignore walls, and will spawn in "Null/Void" space, simply put I need to force the game to make sure that the BarrelFlames actors correctly respect this, and spawn in "playable" sectors instead of non-existent ones.

Here's the code:
Barrel Flames

Code: Select all

Actor BarrelFlames : barrelflames_zspatch
{

    MONSTER
    +SOLID
    +NOBLOOD
    +NOTARGET
    +NOTRIGGER
    +DONTTHRUST
    +NOTAUTOAIMED
    -ISMONSTER
    -COUNTKILL
    -PUSHABLE
    //ReactionTime 75
    Tag "Fire (Obstacle)"
    Obituary "%o was toast"
    Health 6
	Height 16
    Radius 24
    Mass 0x7FFFFFFF
    DamageType Fire
    DamageFactor Ice, 1.0
    DamageFactor Normal, 0

    States {
        Spawn:
            OILS A 0 bright
            OILS A 4 bright A_PlaySoundEx ("BarrelFire/Loop", "SoundSlot5", 1)
            OILS A 0 bright A_PlaySoundEx ("BarrelFire/Start", "SoundSlot6")
            OILS BC 4 bright
			goto spawnloop
        SpawnLoop:
            OILF AB 4 bright
            OILF C 4 bright A_Explode (5, 40)
            //OILF C 0 bright A_CountDown
            OILF AB 4 bright
            OILF C 4 bright A_Explode (5, 40)
            //OILF C 0 bright A_CountDown
            OILF AB 4 bright
            OILF C 4 bright A_Explode (5, 40)
            //OILF C 0 bright A_CountDown
            OILF AB 4 bright
            OILF C 4 bright A_Explode (5, 40)
            //OILF C 0 bright A_CountDown
			OILF AB 4 bright
            OILF C 4 bright A_Explode (5, 40)
            //OILF C 0 bright A_CountDown
			OILF AB 4 bright
            OILF C 4 bright A_Explode (5, 40)
            //OILF C 0 bright A_CountDown
			OILF AB 4 bright
            OILF C 4 bright A_Explode (5, 40)
            //OILF C 0 bright A_CountDown
			OILF AB 4 bright
            OILF C 4 bright A_Explode (5, 40)
            //OILF C 0 bright A_CountDown
			TNT1 A 0 A_Jump(128,"SpawnLoop")
			goto death
        Death:
        XDeath:
            OILS CB 4 bright
            OILS A 4 bright A_StopSoundEx ("SoundSlot5")
	        TNT1 AAAA 1 A_SpawnItem ("D3ImpSmoke2", 0, 0, 0, 0)
            Stop
		Extinguished:
	        OILS A 0 A_PlaySound("monsters/lostsoul/extinguish")
	        TNT1 AAAAA 1 A_SpawnItem ("D3ImpSmoke2", 0, 0, 0, 0)
	        stop
    }
}
Oil Drum Code itself (unchanged from R667)

Code: Select all

ACTOR OilDrum 8770
{
//$Category Obstacles
  Health 20
  Radius 10
  Height 34
  +SOLID
  +SHOOTABLE
  +NOBLOOD
  +ACTIVATEMCROSS
  +DONTGIB
  +NOICEDEATH
  +OLDRADIUSDMG
  DeathSound "world/barrelx"
  Obituary "$OB_BARREL"
	DamageFactor "Hands", 0.0
	damagefactor FireExtinguisher, 0
	DamageFactor "MonsterKnocked", 0.0
  States
  {
  Spawn:
    OILD A 6
    Loop
  Death:
    OILD A 5 BRIGHT
    OILD A 5 BRIGHT A_Scream
    OILD B 5 BRIGHT
    OILD C 5 BRIGHT A_Explode
    OILC CCCCC 0 BRIGHT A_SpawnItemEx ("BarrelFlames", random (0, 40), random (0, 40), 0, 0, 0, 0, random (0, 360)) 
    OILD D 10 BRIGHT
    OILD D 1050 BRIGHT A_BarrelDestroy
    OILD D 5 A_Respawn
    Wait
  }
}
User avatar
Cherno
Posts: 1339
Joined: Tue Dec 06, 2016 11:25 am

Re: Spawned Fire Actors going through walls into void space

Post by Cherno »

Maybe this helps?

A_SpawnItemEx has a flag "SXF_NOCHECKPOSITION" which doesn't check for room before spawning. In my logic, that would mean that not using this flag causes the function to check for room.
User avatar
phantombeta
Posts: 2225
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Spawned Fire Actors going through walls into void space

Post by phantombeta »

Cherno wrote:Maybe this helps?

A_SpawnItemEx has a flag "SXF_NOCHECKPOSITION" which doesn't check for room before spawning. In my logic, that would mean that not using this flag causes the function to check for room.
That'll just make it check if the actor would collide with/be stuck inside something - it won't check if it's in "void space".
That happens to be because there's no "actual" void space, all actors are always in a sector - which is why you're thrown back to the console if you try start a map that has no sectors. (and also why you can noclip "outside" of a sector and still receive damage from damaging sectors)
To do an actual "void" check, you need to do something more expensive, like check if a point is inside a subsector's lines. (which is actually possible, unlike checking sectors directly, as subsectors are always convex)

To deal with this, you can use ZScript's IsPointInMap function, which can check if a point is "inside" the map. It takes a Vector3, so simply do "level.IsPointInMap (point)" and only spawn the actor if it returns true.

Return to “Scripting”