Key Press Delay (as in, forcing one)

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
User avatar
DeadHeartProductions
Posts: 36
Joined: Sun Apr 09, 2023 10:49 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 7
Graphics Processor: Intel (Modern GZDoom)
Location: Eastern North Southlandia, West Side. Formerly NeoTerraNova

Key Press Delay (as in, forcing one)

Post by DeadHeartProductions »

Greetings, everyone. I hope everyone is having a stress-free holiday season. Thanks to everyone that stops by to help!

I was wondering, if there's a way to force either a momentary delay, or force a re-press of a key, for either the RELOAD or ZOOM functions, in DECORATE, other than having a long animation sequence?

For example, if I only wanted to have about 3 frames of animation for raising a weapon into ZOOM mode, if the ZOOM key is held down, the ZOOM (and unzoom) animation plays over and over very quickly. Is there some way to make that ZOOM animation play once, enter the ZOOM state, and STAY there until the player releases the ZOOM key and presses it again?

I hope you all have a wonderful day. Thanks again!
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Key Press Delay (as in, forcing one)

Post by Jarewill »

The way I solved this was adding a state that the Zoom state goes to at the end which loops indefinitely as long as the zoom button is pressed:

Code: Select all

  ZoomEnd:
	TNT1 A 1 A_WeaponReady(WRF_NOPRIMARY|WRF_NOSECONDARY) //Still make the weapon bob
	TNT1 A 0 A_JumpIf(GetPlayerInput(MODINPUT_BUTTONS,-1)&BT_ZOOM,"ZoomEnd") //Loop this state for the duration of the button press
	Goto Ready //Go back to ready once zoom is released
This will also work for Reload and User states by changing BT_ZOOM with either BT_RELOAD or BT_USERX, where X is 1-4.
User avatar
DeadHeartProductions
Posts: 36
Joined: Sun Apr 09, 2023 10:49 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 7
Graphics Processor: Intel (Modern GZDoom)
Location: Eastern North Southlandia, West Side. Formerly NeoTerraNova

Re: Key Press Delay (as in, forcing one)

Post by DeadHeartProductions »

Jarewill wrote: Fri Nov 24, 2023 10:53 am ..casually solves the problem like it ain't no thang..
Thank you, Jare! You're always a Lifesaver! And a Snickers, too.
Post Reply

Return to “Scripting”