What's the equivalent of GZDoom's GetCrouchFactor in Zandronum?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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
shotgunguy1993
Posts: 2
Joined: Sun Apr 05, 2026 11:35 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11

What's the equivalent of GZDoom's GetCrouchFactor in Zandronum?

Post by shotgunguy1993 »

I'm trying to convert one of my mod's weapons to Zandronum for multiplayer, but Zandronum seems to be missing like 65% of the action functions UZDoom/GZDoom has. One of them is GetCrouchFactor and I'm going crazy trying to figure out how to replicate it.

It's a machine gun that will only keep the bipod deployed if you are holding crouch or have crouch toggled on, if the player uncrouches the weapon will automatically undeploy the bipod.

This is one part of the original UZDoom code, when the player is crouched it will jump to the Deploy state:

DECORATE

Code: Select all

TNT1 A 0 A_JumpIf(GetCrouchFactor == 0.5, "Deploy")
This is what I currently have for Zandronum (all it does is make the weapon disappear when crouched and holding right click)
Keep in mind I almost never use ACS and know next to nothing about it

ACS

Code: Select all

#libdefine PLAYER_VIEWHEIGHT 42

script "CheckPlayerCrouching" (void)
{
    if(GetActorViewHeight(0) <= PLAYER_VIEWHEIGHT / 2 << 16)
    {
        GiveInventory("Deployed", 1);
    }
    delay(1);
}
DECORATE

Code: Select all

    TNT1 A 0 A_TakeInventory("Deployed", 0)
    TNT1 A 0 ACS_NamedExecuteWithResult("CheckPlayerCrouching")
    TNT1 A 0 A_JumpIfInventory("Deployed", 1, "Deploy")
Post Reply

Return to “Scripting”