Persistent fire causing zscript error on corpseless actors

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
Pandut
Posts: 231
Joined: Tue Mar 23, 2010 4:47 pm
Preferred Pronouns: No Preference
Graphics Processor: nVidia with Vulkan support
Location: existential dread

Persistent fire causing zscript error on corpseless actors

Post by Pandut »

Code;
Spoiler:
This is an edited version of a script made by kodi for a flame effect that sticks to enemies and deals damage over time.

It works fine for what I need BUT it causes a "Attempted to read from address zero" error when the fire actors are on an actor that doesn't leave a corpse ie lost soul, pain elemental, explosivebarrel, etc. The error occurs when the corpseless actor death phase ends without some sort of -1 line. I can short-term fix it by just using a "TNT1 A -1 Stop" line. However I intend this project to be used for gameplay addons like Corruption Cards which has it's own corpseless actors.

I tried to fix it on my own but my massive lack of zscript knowledge has left me ill-equipped. I believe the problem is somewhere in WPHitActorFlame. This occurs on the unedited script too.
User avatar
Dan_The_Noob
Posts: 880
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Persistent fire causing zscript error on corpseless actors

Post by Dan_The_Noob »

can you share the error message?
User avatar
Pandut
Posts: 231
Joined: Tue Mar 23, 2010 4:47 pm
Preferred Pronouns: No Preference
Graphics Processor: nVidia with Vulkan support
Location: existential dread

Re: Persistent fire causing zscript error on corpseless actors

Post by Pandut »

Derp, sorry completely forgot that lol -

VM execution aborted: tried to read from address zero. Called from WPHitActor.StateFunction.6 at 1Pan-DOOMTIDE.pk3:zscript/firestuff.txt, line 106 Called from state WPHitActor.6 in WPHitActor
The lines alternate between lines 104-108 which are the A_SpawnItemEx calls.
User avatar
Dan_The_Noob
Posts: 880
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Persistent fire causing zscript error on corpseless actors

Post by Dan_The_Noob »

ya so its failing to place the fire because no more radius to read?
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: Persistent fire causing zscript error on corpseless actors

Post by Jarewill »

What's causing the error is that once an actor stop existing (example: Using stop at its death state so it doesn't leave a corpse), then the tracer pointer the fire uses becomes null.
And that's why you get a VM abort, it's because it's trying to read the radius of null.

To fix this, alter your burning state to either:
1) Include this line between every A_SpawnItemEx call:
TNT1 A 0 A_JumpIf(!tracer,"Death");
Or 2) Alter your A_SpawnItemEx frame to be this: (untested)

Code: Select all

TNT1 A 1{
	If(!tracer){Return ResolveState("Death");}
	Else{A_spawnitemex("wpactorflame",frandom(-tracer.radius, tracer.radius),frandom(-tracer.radius, tracer.radius),frandom(-tracer.height, tracer.height),0,0,0,0,SXF_NOCHECKPOSITION);}
	Return ResolveState(null);
}
User avatar
Pandut
Posts: 231
Joined: Tue Mar 23, 2010 4:47 pm
Preferred Pronouns: No Preference
Graphics Processor: nVidia with Vulkan support
Location: existential dread

Re: Persistent fire causing zscript error on corpseless actors

Post by Pandut »

Jarewill wrote: Fri Jan 27, 2023 6:57 am What's causing the error is that once an actor stop existing (example: Using stop at its death state so it doesn't leave a corpse), then the tracer pointer the fire uses becomes null.
And that's why you get a VM abort, it's because it's trying to read the radius of null.

To fix this, alter your burning state to either:
1) Include this line between every A_SpawnItemEx call:
TNT1 A 0 A_JumpIf(!tracer,"Death");
Or 2) Alter your A_SpawnItemEx frame to be this: (untested)

Code: Select all

TNT1 A 1{
	If(!tracer){Return ResolveState("Death");}
	Else{A_spawnitemex("wpactorflame",frandom(-tracer.radius, tracer.radius),frandom(-tracer.radius, tracer.radius),frandom(-tracer.height, tracer.height),0,0,0,0,SXF_NOCHECKPOSITION);}
	Return ResolveState(null);
}
Ye, first one did the trick perfectly! Thanks for the help, I would've been scratching my head for a long time because zscript is still an alien language to me lol.
Post Reply

Return to “Scripting”