Make landing ontop of enemy kills them?
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!)
Make landing ontop of enemy kills them?
I have been playing the early Splinter Cell, love the series so much. Playing it has summoned me with some ideas how to make Shadow Elite, my mod more like it. Anyways currently I am wondering what kind of code I would be looking at to make it where if the player lands on an enemy from above, it kills them, would be a perfect stealth kill element for me as my maps are extremely dynamic and there will be areas where you have elevation over the opposition. Perfer if it was just a normal death in regards to the enemies dying, as them exploding when you land on them seems a bit excessive.
Re: Make landing ontop of enemy kills them?
TestMObjZ can get any actor another might be standing on top of
then check if Vel.Z was negative the previous ticand zero the current to detect landing from the air
then inflict damage from there
then check if Vel.Z was negative the previous ticand zero the current to detect landing from the air
then inflict damage from there
Re: Make landing ontop of enemy kills them?
How do I use this and where is this suspose to go?
- Caligari87
- Admin
- Posts: 6236
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: Make landing ontop of enemy kills them?
The short answer: In ZScript as part of some script that manages or monitors the player's movement.
The longer version:
There's two paths here. The first is if you're okay using custom zscripted player classes, then you can add a few lines to your MovePlayer() override. The second is more compatible for non-customized player classes, and involves using an invisible zscripted inventory item with a DoEffect() override to monitor the player's movement (by referencing the item's owner).
Either way, your script needs to have a variable for the player's old Z-vel. Each tic, you check if TestMObjZ on the player returns true, and if so whether there's also a returned actor. This indicates the player is currently standing on another actor. Next you compare the player's current z velocity to their old z velocity. If it's less than zero (maybe by some threshold), then the player was moving downwards the previous tic. Then damage or kill the returned actor the player is standing on, however that needs to be managed. Finally, regardless of all the previous checks, set the "old" z velocity variable to the current z velocity, so it can be rechecked next loop.
If most of the above sounds like greek gibberish, then your first order of business is to start trying to learn ZScript, as this is a slightly more advanced application than simply making DECORATE monsters.

The longer version:
There's two paths here. The first is if you're okay using custom zscripted player classes, then you can add a few lines to your MovePlayer() override. The second is more compatible for non-customized player classes, and involves using an invisible zscripted inventory item with a DoEffect() override to monitor the player's movement (by referencing the item's owner).
Either way, your script needs to have a variable for the player's old Z-vel. Each tic, you check if TestMObjZ on the player returns true, and if so whether there's also a returned actor. This indicates the player is currently standing on another actor. Next you compare the player's current z velocity to their old z velocity. If it's less than zero (maybe by some threshold), then the player was moving downwards the previous tic. Then damage or kill the returned actor the player is standing on, however that needs to be managed. Finally, regardless of all the previous checks, set the "old" z velocity variable to the current z velocity, so it can be rechecked next loop.
If most of the above sounds like greek gibberish, then your first order of business is to start trying to learn ZScript, as this is a slightly more advanced application than simply making DECORATE monsters.

- 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: Make landing ontop of enemy kills them?
A really crude, simple way to do this, should be doable without ZScript but I don't know how:
Every tick, see if the player's (or whatever's) Z velocity is lower than a certain negative value.
If it is, spawn a projectile that lasts for 2 ticks, has a radius equal to the player's and a height of like 2 or something, starts at 2 units immediately below the player, and starts with the same velocity as the player.
That projectile will proceed to hit whatever the player lands on, and inflict damage accordingly.
The downside of this method is that you're spawning actors every single tick while falling and that's not very nice from an optimization point of view (and will be much worse if you're doing this for monsters as well as players). But given how often anything's going to be falling fast enough, this would be one of the less serious cases.
Every tick, see if the player's (or whatever's) Z velocity is lower than a certain negative value.
If it is, spawn a projectile that lasts for 2 ticks, has a radius equal to the player's and a height of like 2 or something, starts at 2 units immediately below the player, and starts with the same velocity as the player.
That projectile will proceed to hit whatever the player lands on, and inflict damage accordingly.
The downside of this method is that you're spawning actors every single tick while falling and that's not very nice from an optimization point of view (and will be much worse if you're doing this for monsters as well as players). But given how often anything's going to be falling fast enough, this would be one of the less serious cases.
Re: Make landing ontop of enemy kills them?
Last edited by Viper on Wed Oct 30, 2019 11:50 pm, edited 17 times in total.
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Make landing ontop of enemy kills them?
Matt, seems that's better to use short-ranged hitscan attack with lethal puff instead of missile.
Viper, AFAIK bouncing works only for actor with MISSILE flag or MBFBOUNCER. And even if it will work correct for player (that's doubtely) then player will jump into "Bounce.Actor" just when touch actor. Not good idea, I guess. Also _Explode isn't good solution too if mechanics purposes only single kill.
Viper, AFAIK bouncing works only for actor with MISSILE flag or MBFBOUNCER. And even if it will work correct for player (that's doubtely) then player will jump into "Bounce.Actor" just when touch actor. Not good idea, I guess. Also _Explode isn't good solution too if mechanics purposes only single kill.
As option for deco\anon:If (GetActorZ(0) != GetActorFloorZ(0))
Code: Select all
If(GetZAt(0,0,0)!=floorz){Return state("killing_state");}
Re: Make landing ontop of enemy kills them?
The player's actor can be set to bounce. There's a few edits there now however it doesn't seem to work by just jumping on top of a zombieman (tested) . May need to have some velocity from a higher floor possibly, or perhaps try A_RadiusGive instead of A_Explode.. Bounce state confirmed working by setting the bounce count to 1 and dying after one bounce..
However if you cannot get the bounce to work as desired, then use a continuous running script which first asks if vertical velocity is 0 to prevent anything from happening while idle.
ACS:
I'd call this in the player spawn state, and use a bool to prevent it from re-executing.
---------
Tested further using a jetpack, Player definitely bounces on monsters, just the killing them part seems to be ineffective.. I will test another attack yet..
However if you cannot get the bounce to work as desired, then use a continuous running script which first asks if vertical velocity is 0 to prevent anything from happening while idle.
ACS:
Code: Select all
Script "NewScript" (void)
If (GetActorVelY(0) != 0.0)
{
If (GetActorZ(0) >= (GetActorFloorZ(0)+32.0))
{
Do stuff;
}
delay(1);
restart;
}
---------
Tested further using a jetpack, Player definitely bounces on monsters, just the killing them part seems to be ineffective.. I will test another attack yet..
Re: Make landing ontop of enemy kills them?
Scratch that last message, I forgot the Flag +USEBOUNCESTATE.
This method works perfectly.. Just need a high enough jump..

This method works perfectly.. Just need a high enough jump..
There's a lot more you can do to fancy it up but that's the base for it. One thing you may want is to make the kill only happen if the player is holding the crouch button.Viper wrote:Give the player a "BOUNCEONACTORS" flag and the "USEBOUNCESTATE" flag, and set the bounce count to ....
Code: Select all
if (GetPlayerInput(-1, INPUT_BUTTONS) & BT_CROUCH)
{
}
Last edited by Viper on Sat Oct 19, 2019 10:40 pm, edited 1 time in total.
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Make landing ontop of enemy kills them?
Thank you Viper, it's really interesting solution.
I didn't know before that bouncing will work with player.
But the missile solution seems to me a bit easier, and it can take into account player input too:
EDIT: Also added a bit different extended way: now it can deal a some damage which depends on falling height, instead of instakill.

But the missile solution seems to me a bit easier, and it can take into account player input too:
Code: Select all
ACTOR CrusherGuy : DoomPlayer
{
var int user_heightMult;
States
{
Spawn:
PLAY A 1 NoDelay A_Overlay(3,"LandingKill",1)
Loop
LandingKill:
TNT1 A 1
{
If(VelZ<0
//&&GetPlayerInput(MODINPUT_OLDBUTTONS)&BT_CROUCH //Open it to make landing kill work only while crouch button holded
){user_heightMult++;A_SpawnItemEx("LandingKiller",0,0,-5,0,0,-5,0,SXF_SETMASTER);A_GiveToChildren("HeightCounter",user_heightMult);Return state("");}
Else{user_heightMult=0;Return state("");}
}
Loop
}
}
ACTOR LandingKiller
{
Height 4
Radius 4
Projectile
Damage (0)
+HITTRACER
States
{
Spawn:
BAL1 AA 1
Death:
TNT1 A 0 A_CheckFlag("ISMONSTER","CheckFurther",AAPTR_TRACER) //Harmless for objects
Goto SafeEnd
CheckFurther:
TNT1 A 0 A_CheckFlag("FRIENDLY","SafeEnd",AAPTR_TRACER) //Harmless for friends
TNT1 A 0 A_KillTracer //Instakill. Close it and...
//TNT1 A 0 A_DamageTracer(CountInv("HeightCounter"),"LandingDmg",0,"None","None",AAPTR_TARGET) //... and open it to inflict falling height correlated damage instead of instakill
SafeEnd:
TNT1 A 0
Stop
}
}
ACTOR HeightCounter : Inventory{Inventory.MaxAmount 0x7FFFFFFF}
Last edited by Void Weaver on Sat Oct 19, 2019 4:24 pm, edited 5 times in total.
Re: Make landing ontop of enemy kills them?
Hmm. some interesting stuff here. I will try all these out when I get back from my trip. Anyways, would it be possible to only make this eliminate enemies and not "All actors" (for instence, I have destroyable objects, such as eplosives, trashcans with items inside and such) Would seem weird if you landed on top of an explosive and it blows up.
Re: Make landing ontop of enemy kills them?
Actors that aren't to be hurt get the property : DamageFactor "PlayerStomp", 0.0
Revision of above. BounceType isn't wanted and the custom flags do the work it seems. Also A_Explode is unreliable when called from the player during bounce so spawning an actor that drops and explodes works 100% better.
Revision of above. BounceType isn't wanted and the custom flags do the work it seems. Also A_Explode is unreliable when called from the player during bounce so spawning an actor that drops and explodes works 100% better.
Code: Select all
BounceCount 99999
BounceFactor 2.0
+BOUNCEONACTORS
+ALLOWBOUNCEONACTORS
+USEBOUNCESTATE
States
{
Bounce:
Bounce.Actor:
TNT1 A 0 ACS_NamedExecute("playerStomp",0)
Goto See
BounceKill:
TNT1 A 0 A_SpawnItem("DropAttack")
Code: Select all
ACTOR DropAttack
{
+INVULNERABLE
+GHOST
+THRUACTORS
+NEVERTARGET
+NOBLOCKMAP
+ALWAYSTELEFRAG
DamageType PlayerStomp
Obituary "YOU WERE FLATTENED"
States
{
Spawn:
TNT1 A 0
TNT1 AA 1 A_Explode(100,48)
Stop
}
}
Code: Select all
Plus the "Script" Above
Re: Make landing ontop of enemy kills them?
Assuming this is all ZScript?Viper wrote:Actors that aren't to be hurt get the property : DamageFactor "PlayerStomp", 0.0
Re: Make landing ontop of enemy kills them?
Well, thanks Void, and everbody else that has come to help me. I got everything working, Made the projectile invisible, and added a hit sound that sounds like the enemies neck it breaking when you land on them. Very cool.
Re: Make landing ontop of enemy kills them?
Real quick, I am noticing that the enemies are alerted when you are well away from them, about to land on them. Don't know if its the projectile under the player that is alerting them or not, but they get alerted when your close to them. Even if you have elevation over them...Void Weaver wrote:Thank you Viper, it's really interesting solution.I didn't know before that bouncing will work with player.
But the missile solution seems to me a bit easier, and it can take into account player input too