Weapon sprint animation state/script?
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!)
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!)
- body_cleaner666
- Posts: 7
- Joined: Thu Aug 03, 2023 7:02 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: Intel (Modern GZDoom)
- Location: Russian Federation
Weapon sprint animation state/script?
Good day, everyone. I'm a newbie in this modding, and at one day I got an idea to add to all my guns sprint animation when player holds shift button (and when moving), but I have no clue how to realize this feature. How I can do this? And if possible, will it work only for Decorate type?
- body_cleaner666
- Posts: 7
- Joined: Thu Aug 03, 2023 7:02 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: Intel (Modern GZDoom)
- Location: Russian Federation
Re: Weapon sprint animation state/script?
Uh, excuse me, somebody here? I just really need some help here, please!
- Caligari87
- Admin
- Posts: 6233
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: Weapon sprint animation state/script?
Do not bump or double-post. If someone is able and willing to help you, they will.
It may help to post an example of your existing weapon code.

It may help to post an example of your existing weapon code.

- Alfred Don
- Posts: 45
- Joined: Mon Aug 01, 2022 11:52 am
- Contact:
Re: Weapon sprint animation state/script?
You could check the player's momentum with the decorate variables and jump to another state.body_cleaner666 wrote: ↑Thu Aug 03, 2023 7:21 am Good day, everyone. I'm a newbie in this modding, and at one day I got an idea to add to all my guns sprint animation when player holds shift button (and when moving), but I have no clue how to realize this feature. How I can do this? And if possible, will it work only for Decorate type?
Re: Weapon sprint animation state/script?
You can also use GetPlayerInput for this:
A_JumpIf(GetPlayerInput(MODINPUT_BUTTONS,-1)&BT_SPEED,"SprintState")
A_JumpIf(GetPlayerInput(MODINPUT_BUTTONS,-1)&BT_SPEED,"SprintState")
- body_cleaner666
- Posts: 7
- Joined: Thu Aug 03, 2023 7:02 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: Intel (Modern GZDoom)
- Location: Russian Federation
Re: Weapon sprint animation state/script?
Thank you, but how I can make when player not moves (but still can hold shift button), animation/different gun position won't animate?Jarewill wrote: ↑Mon Aug 07, 2023 11:36 am You can also use GetPlayerInput for this:
A_JumpIf(GetPlayerInput(MODINPUT_BUTTONS,-1)&BT_SPEED,"SprintState")
And for everyone, thank you for remarks and sorry for double-post.. and if something wrong will go, I'll post my weapon code here.
- openroadracer
- Posts: 496
- Joined: Mon Sep 23, 2019 1:03 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): SteamOS
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
- Location: SES Flame of Liberty
- Contact:
Re: Weapon sprint animation state/script?
I have no coding knowledge whatsoever, but I'd say that you'd need to run two checks, one after the other. Put the input check first; then, if it comes back "true", go to the velocity check; if it comes back with a high enough speed, it changes the animation state of the weapon.body_cleaner666 wrote: ↑Mon Aug 07, 2023 10:45 pmThank you, but how I can make when player not moves (but still can hold shift button), animation/different gun position won't animate?
And for everyone, thank you for remarks and sorry for double-post.. and if something wrong will go, I'll post my weapon code here.
- body_cleaner666
- Posts: 7
- Joined: Thu Aug 03, 2023 7:02 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: Intel (Modern GZDoom)
- Location: Russian Federation
Re: Weapon sprint animation state/script?
Got the idea with states, but don't know how to make the second speed state check for playing animation...openroadracer wrote: ↑Tue Aug 08, 2023 7:01 amI have no coding knowledge whatsoever, but I'd say that you'd need to run two checks, one after the other. Put the input check first; then, if it comes back "true", go to the velocity check; if it comes back with a high enough speed, it changes the animation state of the weapon.body_cleaner666 wrote: ↑Mon Aug 07, 2023 10:45 pmThank you, but how I can make when player not moves (but still can hold shift button), animation/different gun position won't animate?
And for everyone, thank you for remarks and sorry for double-post.. and if something wrong will go, I'll post my weapon code here.
Re: Weapon sprint animation state/script?
You can access the player's velocity with velx and vely expressions.
Untested example:
A_JumpIf(velx>=10||vely>=10,"SprintState")
Since velx and vely are absolute and not relative, you have to check both of them with an OR operator. ( || )
You could also add another key check to see if the player is also holding forward, for example:
A_JumpIf(GetPlayerInput(MODINPUT_BUTTONS,-1)&BT_SPEED && GetPlayerInput(MODINPUT_BUTTONS,-1)&BT_FORWARD, "SprintState")
It all depends on how you want it to work.
Untested example:
A_JumpIf(velx>=10||vely>=10,"SprintState")
Since velx and vely are absolute and not relative, you have to check both of them with an OR operator. ( || )
You could also add another key check to see if the player is also holding forward, for example:
A_JumpIf(GetPlayerInput(MODINPUT_BUTTONS,-1)&BT_SPEED && GetPlayerInput(MODINPUT_BUTTONS,-1)&BT_FORWARD, "SprintState")
It all depends on how you want it to work.
- body_cleaner666
- Posts: 7
- Joined: Thu Aug 03, 2023 7:02 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: Intel (Modern GZDoom)
- Location: Russian Federation
Re: Weapon sprint animation state/script?
Thank you very much, the first variant is fine for me, just what I needed.Jarewill wrote: ↑Tue Aug 08, 2023 2:54 pm You can access the player's velocity with velx and vely expressions.
Untested example:
A_JumpIf(velx>=10||vely>=10,"SprintState")
Since velx and vely are absolute and not relative, you have to check both of them with an OR operator. ( || )
You could also add another key check to see if the player is also holding forward, for example:
A_JumpIf(GetPlayerInput(MODINPUT_BUTTONS,-1)&BT_SPEED && GetPlayerInput(MODINPUT_BUTTONS,-1)&BT_FORWARD, "SprintState")
It all depends on how you want it to work.
(after some minutes of testing) A yes, the first variant is somewhere bugged because sometimes player still has ready state.. Tried second, works fine, but how to add also BT_BACK correctly? I tried to add it, but didn't worked.
- ramon.dexter
- Posts: 1562
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: Weapon sprint animation state/script?
Show what you tried doing.
- openroadracer
- Posts: 496
- Joined: Mon Sep 23, 2019 1:03 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): SteamOS
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
- Location: SES Flame of Liberty
- Contact:
Re: Weapon sprint animation state/script?
Just upload your mod file to some other file hosting website and link to it here, please. It'd help all of us.body_cleaner666 wrote: ↑Wed Aug 09, 2023 12:08 amThank you very much, the first variant is fine for me, just what I needed.
(after some minutes of testing) A yes, the first variant is somewhere bugged because sometimes player still has ready state.. Tried second, works fine, but how to add also BT_BACK correctly? I tried to add it, but didn't worked.
Re: Weapon sprint animation state/script?
How exactly did you try to do it?body_cleaner666 wrote: ↑Wed Aug 09, 2023 12:08 am Tried second, works fine, but how to add also BT_BACK correctly? I tried to add it, but didn't worked.
The simplest way would be to put another A_JumpIf that just differs with BT_BACK instead of BT_FORWARD.
However you can also do this to check if either of the keys was pressed:
GetPlayerInput(MODINPUT_BUTTONS,-1)&(BT_FORWARD|BT_BACK)
And you can add any other key there as long as you separate them with a binary OR operator. ( | )
- body_cleaner666
- Posts: 7
- Joined: Thu Aug 03, 2023 7:02 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: Intel (Modern GZDoom)
- Location: Russian Federation
Re: Weapon sprint animation state/script?
Ah, there is it. Thank you, now works finally as I wished. And here's codes (full of my gun and sprint only state) yet somewhere it's a bit gross.Jarewill wrote: ↑Wed Aug 09, 2023 5:02 amHow exactly did you try to do it?body_cleaner666 wrote: ↑Wed Aug 09, 2023 12:08 am Tried second, works fine, but how to add also BT_BACK correctly? I tried to add it, but didn't worked.
The simplest way would be to put another A_JumpIf that just differs with BT_BACK instead of BT_FORWARD.
However you can also do this to check if either of the keys was pressed:
GetPlayerInput(MODINPUT_BUTTONS,-1)&(BT_FORWARD|BT_BACK)
And you can add any other key there as long as you separate them with a binary OR operator. ( | )
Sprint:
Spoiler:Gun:
Spoiler: