A_JumpIf Crouched?
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!)
-
- Posts: 63
- Joined: Sun Mar 04, 2018 4:42 am
- Graphics Processor: nVidia with Vulkan support
- Location: Portugal
A_JumpIf Crouched?
I wonder if it's possible to make a JumpIf if the player is crouching.
-
- Posts: 360
- Joined: Mon May 08, 2017 3:23 am
- Graphics Processor: Intel with Vulkan/Metal Support
- Location: The Netherlands
Re: A_JumpIf Crouched?
Yes it is:
Code: Select all
TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_CROUCH, "Crouching");
-
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: A_JumpIf Crouched?
Or A_JumpIf(height<40,"Crouching")
(There's a more complicated alternative that directly accesses the player's status but I don't remember it off the top of my head)
Checking for player input won't catch those few people who use toggle-crouch.
(There's a more complicated alternative that directly accesses the player's status but I don't remember it off the top of my head)
Checking for player input won't catch those few people who use toggle-crouch.
-
- Posts: 360
- Joined: Mon May 08, 2017 3:23 am
- Graphics Processor: Intel with Vulkan/Metal Support
- Location: The Netherlands
Re: A_JumpIf Crouched?
I indeed never used toggle crouch. Yes, your solution should also work, but I guess you mean the ViewHeight?Matt wrote:Or A_JumpIf(height<40,"Crouching")
(There's a more complicated alternative that directly accesses the player's status but I don't remember it off the top of my head)
Checking for player input won't catch those few people who use toggle-crouch.
-
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: A_JumpIf Crouched?
I mean height. After all, making your hitbox smaller to avoid incoming fire or to get under map geometry is the main point of crouching.
EDIT: And of course that 40 could be higher or lower depending on whether you want this to kick in sooner or later.
EDIT: And of course that 40 could be higher or lower depending on whether you want this to kick in sooner or later.
-
- Posts: 876
- Joined: Fri Sep 25, 2015 3:48 am
- Location: elsewhere
Re: A_JumpIf Crouched?
getcrouchfactor() < 1.0 ?
-
- Posts: 63
- Joined: Sun Mar 04, 2018 4:42 am
- Graphics Processor: nVidia with Vulkan support
- Location: Portugal
Re: A_JumpIf Crouched?
The crouching works very well, the A_JumpIf(height<40, "Crouching")
Thx
Also on ZScript is there any way to check actor velocity all the time and if the value is 1 to jump to another state?
Because vel.x>1 and vel.y>1 sometimes fail because it needs to go in certain directions.

Also on ZScript is there any way to check actor velocity all the time and if the value is 1 to jump to another state?
Because vel.x>1 and vel.y>1 sometimes fail because it needs to go in certain directions.
-
- Posts: 1235
- Joined: Thu Nov 06, 2014 1:53 pm
Re: A_JumpIf Crouched?
In ZScript, vel is a vector. This means you can call its Length() function to get the non-directional speed an actor is moving at, rather than calculating that yourself through the distance formula.
-
- Posts: 63
- Joined: Sun Mar 04, 2018 4:42 am
- Graphics Processor: nVidia with Vulkan support
- Location: Portugal
Re: A_JumpIf Crouched?
Could you explain me how to do that please?
Also could you explain why this doesn't work:?
Also could you explain why this doesn't work:
Code: Select all
BNNY A 1 { bNoTarget = true; }
-
- Admin
- Posts: 6209
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
Re: A_JumpIf Crouched?
Code: Select all
if(vel.length() > 1)

-
- Posts: 63
- Joined: Sun Mar 04, 2018 4:42 am
- Graphics Processor: nVidia with Vulkan support
- Location: Portugal
Re: A_JumpIf Crouched?
Code: Select all
BonnieStand:
BNNY A 1
{
if(vel.length() > 1)
{
Goto BonnieWalk;
}
}
Loop;
BonnieWalk:
BONY ABCDE 1;
TNT1 A 0 A_PlaySound("pstepm",0,1.0);
BONY FGHIJKLMNOPQ 1;
TNT1 A 0 A_PlaySound("pstepm",0,1.0);
BONY RSTUVWXY 1;
Loop;
(Sorry for being annoying but I'm really new with this

-
- Posts: 360
- Joined: Mon May 08, 2017 3:23 am
- Graphics Processor: Intel with Vulkan/Metal Support
- Location: The Netherlands
Re: A_JumpIf Crouched?
To be honest, it can be a bit confusing in the beginning, because of the old "Decorate" syntax and the new ZScript possibilities, which can be combined.
You can achieve this in several ways.
Example 1 (more classic way):
Example 2(inline Zscript code):
You can achieve this in several ways.
Example 1 (more classic way):
Code: Select all
BonnieStand:
BNNY A 1 A_JumpIf(vel.length() > 1, "BonnieWalk");
Loop;
BonnieWalk:
etc...
Code: Select all
BonnieStand:
BNNY A 1
{
if(vel.length() > 1)
return ResolveState("BonnieWalk");
else
return ResolveState(null); // nojump
}
Loop;
BonnieWalk:
etc...
-
- Posts: 63
- Joined: Sun Mar 04, 2018 4:42 am
- Graphics Processor: nVidia with Vulkan support
- Location: Portugal
Re: A_JumpIf Crouched?
Thanks 
