Page 1 of 1
A_JumpIf Crouched?
Posted: Tue Jul 03, 2018 2:46 pm
by TheGameratorT
I wonder if it's possible to make a JumpIf if the player is crouching.
Re: A_JumpIf Crouched?
Posted: Tue Jul 03, 2018 2:57 pm
by gwHero
Yes it is:
Code: Select all
TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_CROUCH, "Crouching");
Re: A_JumpIf Crouched?
Posted: Tue Jul 03, 2018 4:19 pm
by Matt
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.
Re: A_JumpIf Crouched?
Posted: Tue Jul 03, 2018 5:10 pm
by gwHero
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.
I indeed never used toggle crouch. Yes, your solution should also work, but I guess you mean the ViewHeight?
Re: A_JumpIf Crouched?
Posted: Tue Jul 03, 2018 5:30 pm
by Matt
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.
Re: A_JumpIf Crouched?
Posted: Tue Jul 03, 2018 10:32 pm
by comet1337
getcrouchfactor() < 1.0 ?
Re: A_JumpIf Crouched?
Posted: Wed Jul 04, 2018 4:07 am
by TheGameratorT
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.
Re: A_JumpIf Crouched?
Posted: Wed Jul 04, 2018 4:51 am
by Arctangent
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.
Re: A_JumpIf Crouched?
Posted: Wed Jul 04, 2018 5:16 am
by TheGameratorT
Could you explain me how to do that please?
Also could you explain why this doesn't work:
?
Re: A_JumpIf Crouched?
Posted: Wed Jul 04, 2018 12:39 pm
by Caligari87
Re: A_JumpIf Crouched?
Posted: Thu Jul 05, 2018 9:50 am
by TheGameratorT
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;
How can I do something like this for example?
(Sorry for being annoying but I'm really new with this

)
Re: A_JumpIf Crouched?
Posted: Thu Jul 05, 2018 11:04 am
by gwHero
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):
Code: Select all
BonnieStand:
BNNY A 1 A_JumpIf(vel.length() > 1, "BonnieWalk");
Loop;
BonnieWalk:
etc...
Example 2(inline Zscript code):
Code: Select all
BonnieStand:
BNNY A 1
{
if(vel.length() > 1)
return ResolveState("BonnieWalk");
else
return ResolveState(null); // nojump
}
Loop;
BonnieWalk:
etc...
Re: A_JumpIf Crouched?
Posted: Sun Jul 08, 2018 5:45 am
by TheGameratorT
Thanks
