VM abort when using Weapon Power up

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!)
User avatar
Posts: 249
Joined: Thu Aug 10, 2017 9:38 am

VM abort when using Weapon Power up

Post by Virathas »

Hey all

I am back with a pretty weird crash, might be an actual bug in code, but I am not certain - perhaps i am simply doing something wrong.

Short story, whenever i use inherited heretic weapons, add A_SetTics to the fire state, and use a Tome of Power when attacking, the game crashes. The simplest way to repro this is (only DECORATE).

Creating the weapons:
When firing this "weapon", when tome of power is used a VM abort will happen.

However, this is where thing become interesting.
1) If i remove "GWND D 3" from the fire state, it will no longer crash
2) If all A_SetTics are removed, there will be no crash
3) if i set a sisterweapon to a completely unrelated, new powered weapon, it will work
4) if the poweredweapon will inherit directly from "NewGoldWand" it will also no longer crash

The question that comes from this all is... Why? Why does it crash in so specific condition and not others? Is it because inheritance from a powered weapon?
User avatar
Posts: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support

Re: VM abort when using Weapon Power up

Post by Player701 »

This looks like a bug to me, so I'd recommend filing a bug report. I've been able to reproduce it in both GZDoom 4.9.0 and the latest Git master (g4.10pre-81-g70df34674 as of now). Perhaps the mods could move this thread to the bugs subforum?

Regarding your question, I can provide a definite answer to 2) and 4). The abort is triggered by an action function being called with a wrong caller (in this case, it complains that it is actually NewGoldWandPowered while NewGoldWand is what was expected). Obviously enough, this check only runs when there is a function to call, so if all function calls are removed, it doesn't run, hence no VM abort. The check also passes when the actual caller's class does not equal to the expected one but is instead a subclass of the latter, hence no VM abort if the powered weapon inherits from the normal one.

As far as I'm aware, since GZDoom 4.6.0 the behavior of PowerWeaponLevel2 was changed to immediately switch between the original and powered weapons. It's likely that the scenario where the powered weapon doesn't inherit from the normal one hasn't been tested properly. It might be that such a restriction is necessary for the powerup to function correctly at all times, but I couldn't find any mention of that requirement here on the forums or in the wiki.

Return to “Scripting”