[ZSCRIPT] [SOLVED] My reloadable weapon locks up my PC for no reason.

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!)
yum13241
Posts: 556
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support

[ZSCRIPT] [SOLVED] My reloadable weapon locks up my PC for no reason.

Post by yum13241 »


The Weapon:
Spoiler:


ZMonstrousWeapon:
Spoiler:
The game just freezes, then ZMusic breaks (it plays the same notes over and over), then I have to hard reset the computer. I don't have any states with 0-duration frames only anywhere! Firing the gun and "reloading" the gun all trigger this bug.

SOLUTION: (replace Stop; with Goto Ready; in NoAmmo:)
ZSBattleRifle:
Spoiler:



---

The problem happened AGAIN! It freezes in the ready state, locking up my PC.

ZSBattleRifle:
Spoiler:
My guess is that the game goes to Ready, then it goes to NoAmmo and so on, but I HAVE AMMO when it freezes! What's going on!?
Last edited by yum13241 on Thu Mar 23, 2023 8:51 am, edited 5 times in total.
Jarewill
Posts: 1454
Joined: Sun Jul 21, 2019 8:54 am

Re: [ZSCRIPT] My reloadable weapon locks up my PC for no reason.

Post by Jarewill »

A_FireProjectile needs the first argument to work, I didn't know ZScript would even compile without it.
That's also not the right way to check for valid ammunition, use A_JumpIfInventory instead.
Also your Reload state in your custom weapon class won't work, because it's being overridden by the weapon that inherits from it.
yum13241
Posts: 556
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support

Re: [ZSCRIPT] My reloadable weapon locks up my PC for no reason.

Post by yum13241 »

I know, I would have renamed it to ReloadFinish had I not commented out the code.
SLADE says the following for A_CheckReload: Deprecated, use A_FireProjectile();

Anyways, I'll try using A_JumpIfNoAmmo and report back.
---
EDIT: Back now, and my PC locked up again.

ZSBattleRifle:
Spoiler:
ZMonstrousWeapon is the same but the reload code is uncommented.

And the same thing happens. I fire, which works fire, but then I release fire, which then locks up GZDoom, which proceeds to lock up my PC. (can't even alt + tab, no TTY, nothing)
User avatar
wildweasel
Moderator Team Lead
Posts: 21623
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: [ZSCRIPT] My reloadable weapon locks up my PC for no reason.

Post by wildweasel »

There's some zero-duration stuff going on between the NoAmmo, Ready, and Fire states that seems like it could throw gzdoom into an infinite busy-loop. Just to make sure, try giving the NoAmmo state a duration of 1. Also, I'm not sure you're supposed to end a weapon state with Stop, but I don't know what you should do instead there...
yum13241
Posts: 556
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support

Re: [ZSCRIPT] My reloadable weapon locks up my PC for no reason.

Post by yum13241 »

It'd be nice if GZDoom yelled at me if all the durations in a state are 0. Why there isn't a Runaway State Terminated thing like in ACS is beyond me.

I'll change the NoAmmo state duration to be 1.


EDIT: nope, my PC locks up when I release fire. I changed the line in the NoAmmo State to have a duration of 1, and changed the A_JumpIfNoAmmo calls to jump to NoAmmo directly (gotta cut out the middleman) and I still have it lock up my PC. (I can't even kill it fast enough)

Solution is now in the original post. Why do I feel stupid now?


ZSBattleRifle:
Spoiler:
How to annoy a person:
Spoiler:
ZScript is hard sometimes. EDIT: AHA! I was using Stop; in NoAmmo:! Why GZDoom locks up instead of just bombing out is beyond me. Anyways I replaced it with Goto Ready;and it works like a charm! Now to balance the thing... And the weirdest part is I thought of that when I was playing Geometry Dash of all things.

EDIT 2: It broke again, Goto OP; :)
Blue Shadow
Posts: 4929
Joined: Sun Nov 14, 2010 12:59 am
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: [ZSCRIPT] My reloadable weapon locks up my PC for no reason.

Post by Blue Shadow »

yum13241 wrote: Tue Dec 20, 2022 7:34 am SLADE says the following for A_CheckReload:
Deprecated, use A_FireProjectile();
That's a problem with SLADE and deprecation notes, which I just reported.

Obviously, A_CheckReload and A_FireProjectile have totally different functionalities. You can't substitute one for the other.
yum13241
Posts: 556
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support

Re: [ZSCRIPT] [NOT SOLVED] My reloadable weapon locks up my PC for no reason.

Post by yum13241 »

Hate to bump, but it was an issue in a powerup I made. I used if (!null) instead of if (toucher). My bad.

Return to “Scripting”