IQM Weapon Stuck in "Select" State and is Unresponsive

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!)
milkFiend
Posts: 27
Joined: Tue Nov 21, 2023 10:30 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: Intel (Modern GZDoom)

IQM Weapon Stuck in "Select" State and is Unresponsive

Post by milkFiend »

To summarize: The IQM Model displays fine, but gets stuck in the first state called and is unresponsive

To be specific:
I've made an IQM Model of Arms and a Pistol with the intentions of attaching the Pistol Model later.
For now, I have a ModelDef, a ZScript file, and made the necessary additions to display the Arms model, which it does!

But when I use the weapon, it goes through the first set animation once then freezes completely, unable to switch to another weapon (not without dropping it with the drop command)

It seems to be reading the animations properly, but is getting stuck at the very first state called and I don't know why. I'd guess there's something wrong with the frame duration?
I'll paste the ZScript file for now then add the PK3 if need be

The ZScript:

Code: Select all

Class Model70 : Weapon
{
	Default
	{
		Weapon.SlotNumber 1;
		Weapon.AmmoType "Clip";
		Weapon.AmmoGive 32;
		Weapon.AmmoUse 1;
		+DECOUPLEDANIMATIONS
	}
	States
	{
		Spawn:
			MD70 A -1 NoDelay
				{
					A_SetAnimation("Pistol_Fire");
				}
			Stop;
		Ready:
			MD70 A -1 
				{
					A_SetAnimation("Pistol_Reload");
					A_WeaponReady;
				}
			Loop;
		Select: //As of now, the weapon plays the animation in this state once then freezes, making it un-switchable with any other weapon
			MD70 A -1
				{
					A_SetAnimation("Pistol_Fire");
					A_Raise;
				}
			Loop;
		Deselect:
			MD70 A -1
				{
					A_SetAnimation("Pistol_Fire");
					A_Lower;
				}
			Loop;
		Fire:
			MD70 A -1
				{
					A_SetAnimation("Pistol_Fire");
					A_FireBullets(1, 1, 1, 1);
				}
			GoTo Ready;
		Reload:
			MD70 A -1
				{
					A_SetAnimation("Pistol_Reload");
				}
			GoTo Ready;
	}
}
Blue Shadow
Posts: 5032
Joined: Sun Nov 14, 2010 12:59 am

Re: IQM Weapon Stuck in "Select" State and is Unresponsive

Post by Blue Shadow »

A duration of -1 tells the engine to stay on the current state ("frame animation", if you will) and not advance to the next one automatically. Typically, you'll want to set the duration of Ready, Select and Deselect states to 1.
milkFiend
Posts: 27
Joined: Tue Nov 21, 2023 10:30 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: Intel (Modern GZDoom)

Re: IQM Weapon Stuck in "Select" State and is Unresponsive

Post by milkFiend »

Blue Shadow wrote: Fri Jul 26, 2024 8:42 pm A duration of -1 tells the engine to stay on the current state ("frame animation", if you will) and not advance to the next one automatically. Typically, you'll want to set the duration of Ready, Select and Deselect states to 1.
I've set Ready, Select, and Deselect states to 1 and it's still frozen, but now it doesn't go through the first animation sequence.
milkFiend
Posts: 27
Joined: Tue Nov 21, 2023 10:30 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: Intel (Modern GZDoom)

Re: IQM Weapon Stuck in "Select" State and is Unresponsive

Post by milkFiend »

I've changed the "loop" line into "goto ready" in the select state, and that seems to fix it for now, but I don't know why every example of decoupled animations I've seen uses "loop". Is that important?
milkFiend
Posts: 27
Joined: Tue Nov 21, 2023 10:30 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: Intel (Modern GZDoom)

Re: IQM Weapon Stuck in "Select" State and is Unresponsive

Post by milkFiend »

milkFiend wrote: Sun Jul 28, 2024 1:23 am I've changed the "loop" line into "goto ready" in the select state, and that seems to fix it for now, but I don't know why every example of decoupled animations I've seen uses "loop". Is that important?
Nevermind, nothings fixed, I'm back at square 1
solvictusig
Posts: 5
Joined: Sun Oct 22, 2023 8:13 am
Preferred Pronouns: He/Him
Operating System Version (Optional): etc
Graphics Processor: Not Listed

Re: IQM Weapon Stuck in "Select" State and is Unresponsive

Post by solvictusig »

milkFiend wrote: Sun Jul 28, 2024 7:25 pm
milkFiend wrote: Sun Jul 28, 2024 1:23 am I've changed the "loop" line into "goto ready" in the select state, and that seems to fix it for now, but I don't know why every example of decoupled animations I've seen uses "loop". Is that important?
Nevermind, nothings fixed, I'm back at square 1
Use 1 instead of -1 everywhere in your cod
And specify the starting frame and the ending frame of the animation outside the brackets, example:

Code: Select all

		Fire:
			M000 B 0
				{
					A_FireBullets(1, 1, 1, 1);
				}
			M000 B 3 NoDelay A_SetAnimation("shoot");
			GoTo Ready;
milkFiend
Posts: 27
Joined: Tue Nov 21, 2023 10:30 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: Intel (Modern GZDoom)

Re: IQM Weapon Stuck in "Select" State and is Unresponsive

Post by milkFiend »

solvictusig wrote: Wed Oct 30, 2024 6:51 pm
milkFiend wrote: Sun Jul 28, 2024 7:25 pm
milkFiend wrote: Sun Jul 28, 2024 1:23 am I've changed the "loop" line into "goto ready" in the select state, and that seems to fix it for now, but I don't know why every example of decoupled animations I've seen uses "loop". Is that important?
Nevermind, nothings fixed, I'm back at square 1
Use 1 instead of -1 everywhere in your cod
And specify the starting frame and the ending frame of the animation outside the brackets, example:

Code: Select all

		Fire:
			M000 B 0
				{
					A_FireBullets(1, 1, 1, 1);
				}
			M000 B 3 NoDelay A_SetAnimation("shoot");
			GoTo Ready;
After trying to work with IQMs for a bit, setting the state duration to 1 doesn't really seem to work, as it only plays 1 frame of the specified animation.
Setting the duration to -1 plays the entire animation and loops it. But, if there's a workaround (other than manually setting the duration to the frame count of the animation) then I'm willing to listen.

Return to “Scripting”