How to kill player if they move too fast? "CON script"
#1 Posted 02 September 2025 - 06:46 AM
Something with "ponground" but how can I check actor velocity?
#2 Posted 02 September 2025 - 12:47 PM
nuc, on 02 September 2025 - 06:46 AM, said:
Something with "ponground" but how can I check actor velocity?
wait do you mean the player dies from a collision if moving fast? or the player just dies if moving fast when there's no collision?
#3 Posted 02 September 2025 - 11:38 PM
Danukem, on 02 September 2025 - 12:47 PM, said:
No collision, insant death when touching fast moving conveyor belt floor
#4 Posted 03 September 2025 - 01:05 AM
nuc, on 02 September 2025 - 11:38 PM, said:
The player's posxv and posyv members store the current speeds on the x axis and y axis. You can take the absolute values of them and then add them together for an approximation of the player's velocity -- take the square root of that for more precision. Then just decide what the limit should be and kill the player with addphealth -1000 or whatever method you like if it's exceeded.
If this is only supposed to be caused by conveyer belts, run a for loop on the player's sector and confirm there is an SE24 in it before doing the speed check.
#5 Posted 03 September 2025 - 01:58 AM
This way you can treat the surface as damaging based on the belts movement speed rather than just player speed alone.. This way it can also become fully non-lethal once you stop it.
#6 Posted 03 September 2025 - 01:00 PM
oasiz, on 03 September 2025 - 01:58 AM, said:
This way you can treat the surface as damaging based on the belts movement speed rather than just player speed alone.. This way it can also become fully non-lethal once you stop it.
What do you think the odds are that nuc has any ability to act on either of our suggestions? It's not much to go on, but I'm guessing he has virtually no knowledge of the scripting language based on him saying the answer would include "ponground". It's not that that's wrong, but it's something you would say if you didn't know much.
#7 Posted 04 September 2025 - 01:43 AM
#8 Posted 04 September 2025 - 04:59 AM
nuc, on 02 September 2025 - 11:38 PM, said:
out of curiosity, are you making a train-vehicle map and want the player to die when he falls off?
if so, there are easier ways.
#9 Posted 04 September 2025 - 07:21 AM
jimbob, on 04 September 2025 - 04:59 AM, said:
if so, there are easier ways.
yeah that, just like that one Blood map with the train, if you fall off you die. Also, how do you get the values of player's posxv and posyv members?
PS. I have experience with C++ language but I'm new to CON scripting so kinda lost with variables, I tried to look a wiki (Confaq42 wiki) about the variables but there's not much info, or maybe I just missed them
This post has been edited by nuc: 04 September 2025 - 07:23 AM
#10 Posted 04 September 2025 - 12:13 PM
#11 Posted 04 September 2025 - 11:16 PM
nuc, on 04 September 2025 - 07:21 AM, said:
PS. I have experience with C++ language but I'm new to CON scripting so kinda lost with variables, I tried to look a wiki (Confaq42 wiki) about the variables but there's not much info, or maybe I just missed them
If you have C++ experience, you shouldn’t have any problems. I was learning C, and it helped me a lot to get better at CON. This page should give you enough information to get started, but you can always ask for help here if you run into trouble.
As for your situation, I’d probably create a useractor that checks whether its sector matches the player’s sector, and if so, kills the player by subtracting a large amount of health.
ck3D's solution also works if you know how to do it. I think it is 5 minutes longer to make than scripting the effect. So it mostly depends on whether you want to use CON or not.
This post has been edited by brullov: 04 September 2025 - 11:20 PM
#12 Posted 05 September 2025 - 03:01 AM
nuc, on 04 September 2025 - 07:21 AM, said:
PS. I have experience with C++ language but I'm new to CON scripting so kinda lost with variables, I tried to look a wiki (Confaq42 wiki) about the variables but there's not much info, or maybe I just missed them
to make it very easy, make a custom texture for the conveyor ( doesnt even need to be a conveyor, i animated one so i could add motion blurr ) and have that texture kill the player if he touches the floor. saves you a lot of trouble and is practically fail proof.
#13 Posted 05 September 2025 - 04:47 AM
Cheers
#14 Posted 06 September 2025 - 08:53 AM
ck3D, on 04 September 2025 - 12:13 PM, said:
Thought of the same thing. Normally you should look for the simplest solution and don't want to supply a custom con file just for the sake of a single effect that can be probably better dealt with using a teleporter effect (unless there are other more intricate effects coming into play).
#15 Posted 08 September 2025 - 04:19 AM
I came up with this code to kill the player, using sector lotag, issue was that player would die if leaning over an edge so I added a check to check distance to floor.
It works as intended but I have a problem: if the player keeps chaining jumps just at the right time the floor wont kill him, I assume that's because "ponground" never goes to true.
gamevar POSZ 0 0
gamevar SEC 0 0
gamevar FLOOR 0 0
actor APLAYER MAXPLAYERHEALTH PSTAND 0 0
getplayer[THISACTOR].posz POSZ
getsector[THISACTOR].lotag SEC
getsector[THISACTOR].floorz FLOOR
add POSZ 8888
ifp ponground
ife SEC 999
ifl FLOOR POSZ
addphealth -1000is it bad practise to use sector lotag for this or it's all ok?
EDIT: actually I just realised I can get rid of ponground line
This post has been edited by nuc: 08 September 2025 - 04:25 AM
#16 Posted 08 September 2025 - 05:24 AM
nuc, on 08 September 2025 - 04:19 AM, said:
EDIT: actually I just realised I can get rid of ponground line
Yes, using the on_ground property isn't reliable enough for checking the player touching the floor. If you need to handle all cases (including when the player is standing on a ledge but not actually inside a tagged sector), the most versatile solution is probably to call getzrange command for the player and check if floorhit returned is a tagged sector. The walldist may require some trial and error to get it work right though.
One pitfall about using lo-tagged sectors is that you can't open doors or press switches if they are placed behind sectors with a non-zero lotag, but it probably won't be an issue in your case.
This post has been edited by Jan Satcitananda: 08 September 2025 - 05:26 AM
#17 Posted 11 September 2025 - 12:47 PM
nuc, on 08 September 2025 - 04:19 AM, said:
You also don't need to declare any vars.
actor APLAYER MAXPLAYERHEALTH PSTAND 0 0
getp[].posz RETURN
add RETURN 8888
ife sector[].lotag 999
ifl sector[].floorz RETURN
addphealth -1000
#18 Posted 12 September 2025 - 11:58 AM
Danukem, on 11 September 2025 - 12:47 PM, said:
actor APLAYER MAXPLAYERHEALTH PSTAND 0 0
getp[].posz RETURN
add RETURN 8888
ife sector[].lotag 999
ifl sector[].floorz RETURN
addphealth -1000
will that work for any enemy too if I copy paste? (ofc not the addphealth func etc) or will it cause issues with/without gamevars?
This post has been edited by nuc: 12 September 2025 - 12:03 PM
#19 Posted 12 September 2025 - 12:31 PM
nuc, on 12 September 2025 - 11:58 AM, said:
Should be fine. RETURN is a predefined gamevar that is used for various EDuke32 events -- but it is safe to manipulate in actor code. The player structs are also readable from other actors as long as you understand that the code posted always going to refer to the closest player (but there is always only 1 player unless you are in multiplayer anyway).
addphealth is fine to use inside of enemy code as well, in fact it is already in the base game, that's how the bosses squish the player when close
#20 Posted 13 September 2025 - 08:57 AM
Danukem, on 12 September 2025 - 12:31 PM, said:
addphealth is fine to use inside of enemy code as well, in fact it is already in the base game, that's how the bosses squish the player when close
Alright thanks. I have an off-topic question about CON files: for example "HURTRAIL" (859) tile's code is not in the default duke3d CON files (along with others), I assume its located in the source code.. but can I overwrite its' behaviour somehow with CON scripts?
#21 Posted 13 September 2025 - 11:12 AM
nuc, on 13 September 2025 - 08:57 AM, said:
HURTRAIL has a hardcoded effect and I can't think of a simple way to negate it. It's not worth the effort, just use a different tile.

Help
Duke4.net
DNF #1
Duke 3D #1









