Duke4.net Forums: How to kill player if they move too fast? - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to kill player if they move too fast?  "CON script"

User is offline   nuc 

#1

Hey, how to write CON script that kills player if they are moving too fast? (aka being on fast moving conveyor belt)

Something with "ponground" but how can I check actor velocity?
0

User is offline   Danukem 

  • Duke Plus Developer

#2

 nuc, on 02 September 2025 - 06:46 AM, said:

Hey, how to write CON script that kills player if they are moving too fast? (aka being on fast moving conveyor belt)

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?
0

User is offline   nuc 

#3

View PostDanukem, on 02 September 2025 - 12:47 PM, said:

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?


No collision, insant death when touching fast moving conveyor belt floor
0

User is offline   Danukem 

  • Duke Plus Developer

#4

View Postnuc, on 02 September 2025 - 11:38 PM, said:

No collision, insant death when touching fast moving conveyor belt floor


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.
0

User is offline   oasiz 

  • Dr. Effector

#5

Alternate thought... if you're looping for SE24 already then it's possible to get it's xvel values (I recall it being stored here) and checking ifponground for such a sector. This I recall is being used for bpos calculations as well to get the interpolation working.
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.
0

User is offline   Danukem 

  • Duke Plus Developer

#6

View Postoasiz, on 03 September 2025 - 01:58 AM, said:

Alternate thought... if you're looping for SE24 already then it's possible to get it's xvel values (I recall it being stored here) and checking ifponground for such a sector. This I recall is being used for bpos calculations as well to get the interpolation working.
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.
0

User is offline   brullov 

  • Senior Artist at TGK

#7

Let's see what nuc will reply. I don't want to take away the joy of discovery, and I think you’ve already given him more than enough information.
1

User is offline   jimbob 

#8

View Postnuc, on 02 September 2025 - 11:38 PM, said:

No collision, insant death when touching fast moving conveyor belt floor

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.
0

User is offline   nuc 

#9

View Postjimbob, on 04 September 2025 - 04:59 AM, 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.


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

0

User is online   ck3D 

#10

Are you sure you want to handle something like this through .con when it's so easy to make an in-map killzone? Just silent teleport the player into a zero height sector or a space sky (possibly concealed). Done right you get to come up with whichever visuals you might want for the death, too.
2

User is offline   brullov 

  • Senior Artist at TGK

#11

View Postnuc, on 04 September 2025 - 07:21 AM, said:

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


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

0

User is offline   jimbob 

#12

View Postnuc, on 04 September 2025 - 07:21 AM, said:

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

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.
0

User is offline   nuc 

#13

Thanks brullov for the scripting link, hadn't found that before, and jimbob for the custom texture idea. I think that's enough info for me to make it.

Cheers
2

#14

View Postck3D, on 04 September 2025 - 12:13 PM, said:

Are you sure you want to handle something like this through .con when it's so easy to make an in-map killzone? Just silent teleport the player into a zero height sector or a space sky (possibly concealed). Done right you get to come up with whichever visuals you might want for the death, too.

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).
1

User is offline   nuc 

#15

I'm making a mod so using CON scripting is alright.

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 -1000


is 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

0

#16

View Postnuc, on 08 September 2025 - 04:19 AM, said:

is 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

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

0

User is offline   Danukem 

  • Duke Plus Developer

#17

View Postnuc, on 08 September 2025 - 04:19 AM, said:

EDIT: actually I just realised I can get rid of ponground line


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


0

User is offline   nuc 

#18

View PostDanukem, on 11 September 2025 - 12:47 PM, 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




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

0

User is offline   Danukem 

  • Duke Plus Developer

#19

View Postnuc, on 12 September 2025 - 11:58 AM, said:

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?


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
0

User is offline   nuc 

#20

View PostDanukem, on 12 September 2025 - 12:31 PM, 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


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?
0

User is offline   Danukem 

  • Duke Plus Developer

#21

View Postnuc, on 13 September 2025 - 08:57 AM, said:

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?


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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options