Landing States for Monsters when they jump
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!)
- Aerosplinter
- Posts: 98
- Joined: Wed Feb 01, 2017 2:14 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
Landing States for Monsters when they jump
I am using A_ChangeVelocity to make my monsters jump, but is there a way to make landing states for the monsters when they land on the floor right after jumping?
- Matt
- 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
- Contact:
Re: Landing States for Monsters when they jump
The simplest way I can think of is to have the jump end in a state like this:
Code: Select all
flying:
SKUL CCDD 1 A_JumpIf(floorz==z,"land");
loop;
- Aerosplinter
- Posts: 98
- Joined: Wed Feb 01, 2017 2:14 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
Re: Landing States for Monsters when they jump
Unfortunately, It did not work. The enemy was staying "frozen" in its hopping state even if it landed on the floor.Matt wrote:The simplest way I can think of is to have the jump end in a state like this:Code: Select all
flying: SKUL CCDD 1 A_JumpIf(floorz==z,"land"); loop;
Here is my code. I used A_CheckFloor, but the results were the same with how I tried to use A_JumpIf(floorz==z,"land").
Code: Select all
Hop:
ROY4 VVUU 1 A_FaceTarget(3,270)
TNT1 A 0 A_Playsound("ROYHOP")
ROY4 R 1
{
A_ChangeVelocity(0,0,11);
A_FaceTarget(3,270);
A_Recoil(Frandom(-20,-8));
}
ROY4 RRRRRRR 1 A_CheckFloor("Land")
ROY4 RRRRR 1
{
A_Chase("_a_chase_default","_a_chase_default",CHF_DONTMOVE|CHF_DONTTURN);
A_CheckFloor("Land");
}
ROY4 SSSSSSSS 1
{
A_Chase("_a_chase_default","_a_chase_default",CHF_DONTMOVE|CHF_DONTTURN);
A_CheckFloor("Land");
}
ROY4 TTTTT 1
{
A_Chase("_a_chase_default","_a_chase_default",CHF_DONTMOVE|CHF_DONTTURN);
A_CheckFloor("Land");
}
TNT1 A 0 A_Jump(256,"HopContinue")
Loop
HopContinue:
ROY4 T 1
{
A_Chase("_a_chase_default","_a_chase_default",CHF_DONTMOVE|CHF_DONTTURN);
A_CheckFloor("Land");
}
Loop
Land:
ROY4 U 1 A_Playsound("ROYLAND")
ROY4 U 1
ROY4 VWWXX 1
Goto See
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Landing States for Monsters when they jump
If you've tried to use A_JumpIf like as do you use A_CheckFloor inside of anon. function, then it obviously wrong. It should be written like as if|else condition with a some 'return' exits:
Code: Select all
ROY4 RRRRR 1
{
A_Chase("_a_chase_default","_a_chase_default",CHF_DONTMOVE|CHF_DONTTURN); //Don't forget that A_Chase allow to jump out from the current state!
If(A_CheckFloor("Land")){Return state("Land");}
Else{Return state("");}
}
ROY4 SSSSSSSS 1
{
A_Chase("_a_chase_default","_a_chase_default",CHF_DONTMOVE|CHF_DONTTURN);
If(floorz==z)
{
Return state("Land");
}
Else
{
Return state("");
}
}
- Aerosplinter
- Posts: 98
- Joined: Wed Feb 01, 2017 2:14 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
Re: Landing States for Monsters when they jump
Void Weaver wrote:If you've tried to use A_JumpIf like as do you use A_CheckFloor inside of anon. function, then it obviously wrong. It should be written like as if|else condition with a some 'return' exits:
Code: Select all
ROY4 RRRRR 1 { A_Chase("_a_chase_default","_a_chase_default",CHF_DONTMOVE|CHF_DONTTURN); //Don't forget that A_Chase allow to jump out from the current state! If(A_CheckFloor("Land")){Return state("Land");} Else{Return state("");} } ROY4 SSSSSSSS 1 { A_Chase("_a_chase_default","_a_chase_default",CHF_DONTMOVE|CHF_DONTTURN); If(floorz==z) { Return state("Land"); } Else { Return state(""); } }
It finally worked!! However, it does not work on actors, so is there a way for this to work on actors?
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Landing States for Monsters when they jump
Because deco hasn't direct way to check what is landing plane is - actor or floor, AFAIK it's possible only via ZScript.
In your case is much logical to make check for -VelZ and once (after flying down after monster jump) it will equal to 0, then landing are happens.
Similar solution for similar question. Something like:
In your case is much logical to make check for -VelZ and once (after flying down after monster jump) it will equal to 0, then landing are happens.
Similar solution for similar question. Something like:
Code: Select all
ROY4 RRRRR 1
{
If(VelZ<0){A_Chase("_a_chase_default","_a_chase_default",CHF_DONTMOVE|CHF_DONTTURN);Return state("");}
Else{Return state("Land");}
}
- Aerosplinter
- Posts: 98
- Joined: Wed Feb 01, 2017 2:14 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
Re: Landing States for Monsters when they jump
I am still wondering if there is another way for this to work for actors, because with "If(VelZ<0)", it immediately goes to the landing state when they jump. There needs to be a clear solution for this...
Re: Landing States for Monsters when they jump
Had some old code for decorate before I switched to zscript that might work.
Try that. Its not as accurate as zscript but it worked for me.
Also the double check is needed since using momz==0 alone can cause them to stop when at the tip of their jump.
Code: Select all
FallState:
RVM4 S 1 A_JumpIf(momz<=0,1)
Wait
RVM4 S 1
RVM4 T 1 A_JumpIf(momz==0||waterlevel>1,"See")
Wait
Also the double check is needed since using momz==0 alone can cause them to stop when at the tip of their jump.
- Aerosplinter
- Posts: 98
- Joined: Wed Feb 01, 2017 2:14 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
Re: Landing States for Monsters when they jump
For your A_JumpIf, does it mean that it goes to the "Land" state as the actor surfaces on the floor?TXTX wrote:Had some old code for decorate before I switched to zscript that might work.Try that. Its not as accurate as zscript but it worked for me.Code: Select all
FallState: RVM4 S 1 A_JumpIf(momz<=0,1) Wait RVM4 S 1 RVM4 T 1 A_JumpIf(momz==0||waterlevel>1,"See") Wait
Also the double check is needed since using momz==0 alone can cause them to stop when at the tip of their jump.
Re: Landing States for Monsters when they jump
Yes, the "See" part at the end is the state you want after the monster stops falling. That can be changed to whatever you like. Change it to "Land" if you want to go specifically to that state.Aerosplinter wrote:For your A_JumpIf, does it mean that it goes to the "Land" state as the actor surfaces on the floor?TXTX wrote:Had some old code for decorate before I switched to zscript that might work.Try that. Its not as accurate as zscript but it worked for me.Code: Select all
FallState: RVM4 S 1 A_JumpIf(momz<=0,1) Wait RVM4 S 1 RVM4 T 1 A_JumpIf(momz==0||waterlevel>1,"See") Wait
Also the double check is needed since using momz==0 alone can cause them to stop when at the tip of their jump.