Why does this crash?

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
Tartlman
Posts: 226
Joined: Thu Oct 11, 2018 5:24 am
Location: meme hell

Why does this crash?

Post by Tartlman »

Hey, so I'm making a custom weapon, and there's a problem where whenever I fire the weapon with 0 ammo, the game crashes.
The code that crashes when firing the weapon without any ammo looks like this:

Code: Select all

Fire:
BG2G FGHIJ 1 A_RailAttack (25, 0, 1, "", "", 0, 10.0, "none", 0, 0, 8192, 50, 0.5, 2.0, "MiniPlasma")
Goto Ready
And that causes a crash. What I want to know is why the game crashes when I do this.
Currently, i'm using a workaround that looks like this:

Code: Select all

Fire:
		BG2G E 1 A_JumpIfInventory ("Cell", 1, "Shoot")
		BG2G E 1 A_PlaySound ("weapons/bfg10kcool")
		Goto Ready
		Shoot:
		BG2G FGHIJ 1 A_RailAttack (25, 0, 1, "", "", 0, 10.0, "none", 0, 0, 8192, 50, 0.5, 2.0, "MiniPlasma")
		BG2G E 1 A_TakeInventory ("Cell", 5) //weapon consumes no ammo normally
		Goto Ready
And it works perfectly fine, maybe it's actually a better way to do it, but what I want to know is why the game crashes if I don't do so.
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed

Re: Why does this crash?

Post by wildweasel »

Can you please post the whole actor (the variant that crashes)?

Return to “Scripting”