Sophisticated Player Dash

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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!)
Post Reply
User avatar
Hornetzero
Posts: 312
Joined: Wed Dec 05, 2012 12:42 am
Location: Twighlight zone

Sophisticated Player Dash

Post by Hornetzero »

Hey everyone,
I was looking for an easy and efficient way to implement a custom move for the player in which he dashes a certain distance forward via a custom action key defined as a CVAR. I'm still new to Zscript and haven't gotten to use it much, but If an example could be provided, it would certainly be easier to do over Decorate or ACS, only because I have some experience with coding in those.

So to elaborate on the type of dash maneuver I want to setup in terms of pseudo code:

1, Upon pressing the dash key, the player activates the PASSTHROUGHACTOR flag, that allows him to pass through enemies like a ghost, until the dash finishes.
2, Defining the distance covered with a fast moving velocity. If the player just taps the dash key, he would move a certain distance forward, and if he holds and releases this key, the distance covered increases.
3, If the player has picked up a Berserker pack, the dash would damage enemies and create a fire trail behind the player.

So whats the best way to set this up?

Thank you
Kagur
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Sophisticated Player Dash

Post by Jarewill »

I did it as a function that gets called every tic and checks if the player is holding a button.
I used the [Run] button instead of a custom bind though.
Spoiler:
User avatar
Hornetzero
Posts: 312
Joined: Wed Dec 05, 2012 12:42 am
Location: Twighlight zone

Re: Sophisticated Player Dash

Post by Hornetzero »

Thanks. It works great. The only things off are that the dash maneuver is occasionally blocked by enemies for some unknown reason, and that the velocity reduces when its done while crouching (velocity while jumping, standing and walking is fine and consistent).
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Sophisticated Player Dash

Post by Jarewill »

I don't seem to be able to replicate the issues.
I can dash through monsters fine and the velocity when crouching is the same as when standing.
Was the function modified? Maybe there's something affecting it from the outside?
Could you post your mod?
User avatar
Hornetzero
Posts: 312
Joined: Wed Dec 05, 2012 12:42 am
Location: Twighlight zone

Re: Sophisticated Player Dash

Post by Hornetzero »

Sure thing, here is the file.
Attachments
Specialmovement.pk3
(1.69 KiB) Downloaded 217 times
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Sophisticated Player Dash

Post by Jarewill »

Now that is weird.
Crouching issue doesn't seem to happen with lower velocities, not sure what could be done about that.

As for getting stuck on monsters, I still seem to not encounter that issue.
The only time I got stuck on monsters was when the dash ran out.
It could be fixed by extending the THRUACTORS flag a little bit.
Try this:
Spoiler:
User avatar
Hornetzero
Posts: 312
Joined: Wed Dec 05, 2012 12:42 am
Location: Twighlight zone

Re: Sophisticated Player Dash

Post by Hornetzero »

It didn't resolve it, but its fine. I'm still quite happy with the results and I thank you very much for this.
Post Reply

Return to “Scripting”