[Solved] Weapon crashes the game, when going into Hold

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
tonbren
Posts: 2
Joined: Sat Apr 27, 2019 2:50 pm
Graphics Processor: ATI/AMD (Modern GZDoom)

[Solved] Weapon crashes the game, when going into Hold

Post by tonbren »

Hello, everyone. I'm looking for someone more experienced than me in DECORATE to explain to me what I'm doing wrong and/or perhaps correct my mistake.

Here's part of the code of my axe weapon. What I'm trying to achieve is a weapon, where you can wind up the swing, hold the mouse button to keep it raised up, and then swing upon release. However, with my current code whenever it goes into Hold state and A_Refire function is applied, the game CTDs instantly.

Code: Select all

	Ready:
		AXEG A 1 A_WeaponReady
		loop
	Fire:
		AXEG ABCDE 2
		AXEG HGF 3
		goto Hold
	Fire2:
		AXEG ABCDE 2
		AXEG HGF 3
		TNT1 A 4
		AXEG I 2 A_PlaySound("weapons/axeswing", CHAN_WEAPON)
		AXEG A 1 
		AXEG J 2 A_CustomPunch(20, 1, 0, "AxeHitPuff")
		AXEG K 2
		NULL A 6
		TNT1 A 2
		AXEG JAB 2
		Goto Ready
	Hold:
		AXEG F 1 A_Refire
		goto Fire2
Is there something wrong with it, something missing, or is it just that I just have crappy luck and it crashes for literally no reason? Thanks in advance for the help.
Last edited by tonbren on Sat Apr 27, 2019 7:15 pm, edited 1 time in total.
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
Contact:

Re: Weapon crashes the game, when going into Hold

Post by wildweasel »

The trouble is that A_Refire is checked before its attached state is shown, so regardless of its duration, it's entering into a zero duration loop. I tend to solve this by adding a one tic state that otherwise does nothing, immediately before the Refire line.
tonbren
Posts: 2
Joined: Sat Apr 27, 2019 2:50 pm
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Weapon crashes the game, when going into Hold

Post by tonbren »

wildweasel wrote:The trouble is that A_Refire is checked before its attached state is shown, so regardless of its duration, it's entering into a zero duration loop. I tend to solve this by adding a one tic state that otherwise does nothing, immediately before the Refire line.
I gave it a shot and just added a NULL A 1 before the frame. It worked. Thanks a lot.
Post Reply

Return to “Scripting”