Jump to content
The Dark Mod Forums

Add option to "toggle crouch" on key press


Recommended Posts

I read a post under Tech Support about making an option for "toggle crouch" to happen on "key press" rather than "key release".

I've added "toggle crouch", which works like Thief, to my build. That is "toggle crouch" on key press. I've been playing that way since the end of March.

It's not as simple as changing it to "toggle crouch" on key press, because ladders and ropes need to be carefully considered. I'd imagine there may be differing opinions about how to handle those scenarios. I made it work as similar to New Dark as I could.

I've changed the code in my build to always work that way. In the Tech Support post, there was a request for an option to choose between new and old "toggle crouch" behavior, so I'll have to add that functionality to my patch. How shall I prepare my patch?

Some things that I found that I needed to consider:

  • When on a ladder/rope, what happens when "toggle crouch" is pressed?
  • When detaching from a ladder/rope, what happens when "toggle crouch" is held down after a slide?
  • When attaching to a ladder/rope, what happens to the crouch/stand position?
  • When on a ladder/rope, does "toggle crouch" crouch/stand or slide?

Here are the decisions that I made, which I hope is a good starting point for us to discuss what we all may want.

  • Do NOT use crouch speed while climbing on a rope/ladder. (This is actually a separate issue / bug that I fixed.)
  • While on a ladder/rope, "toggle crouch" behaves like regular crouch.
  • While sliding, stay crouched until "toggle crouch" key is released. The player will stay crouched once detached from a ladder/rope and will stand (crouch off) on "toggle crouch" key release.
  • When the player is crouched ("toggle crouch"), looking up, and moving up on a rope/ladder, change to standing position (crouch off). This makes it more likely for a player to be in a standing position after mantling from a rope/ladder. Note, on "looking up" is important, otherwise there would be a jarring, unexpected upwards movement on ladder/rope attachment when the player intends to go downwards.
  • When the player is crouched ("toggle crouch"), attaches to a ladder, and is looking down, stay crouched.

It may be difficult to imagine how this works. Feeling it while playing makes a big difference.

Summary: I've been playing with my custom build since the end of March. Feels great. Feels like Thief/New Dark. I look forward to hearing your thoughts. How shall I prepare my patch?

Cheers

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thanks @New Horizon!

Quick update.

I've added the cvar option, tdm_new_toggle_crouch. It's enabled by default as I think new players would prefer it. Folks can disable it to use the previous crouch code path.

idCVar cv_tdm_new_crouch_toggle(
  "tdm_new_toggle_crouch",
  "1",
  CVAR_GAME | CVAR_ARCHIVE | CVAR_BOOL,
  "Set to 1 to make toggle crouch on key press instead of key release."
);

The only work left is to test it more, write a clearer description of the changes, and prepare the patch. Also, feedback and discussion is welcome.

Link to comment
Share on other sites

About ways to share a patch.

If you have SVN working copy, you can simply create SVN patch and attach it to forums post. Better mention which SVN revision your patch is based on.

If you don't have SVN working copy (e.g. downloaded source code archive), then I guess you have to use some diff tool between directories. To be honest, I don't remember doing it myself. WinMerge is good for directory diff, but I don't know if it can actually save the changes as some patch...

I'm currently travelling and don't have access to TDM development, so I'll trust the decision of "how should it work in various situations" and testing to the other members of TDM team. But I'd be happy to read a source code patch anyway.

Link to comment
Share on other sites

As I prepare the patch, I'm trying to match the code style I see throughout the codebase.

I noticed that there are many comments that begin with the name of the developer who wrote the code. What is that for in this codebase? And, should I do the same?

Link to comment
Share on other sites

Nice! Thanks a lot for making it, I do hope it can be added into the next TDM update.

As for this...
 

15 hours ago, Daft Mugi said:

I noticed that there are many comments that begin with the name of the developer who wrote the code. What is that for in this codebase? And, should I do the same?

I think this is, for one, to give credit to the author (and I know it's kind of ironic, "self-credit") and for two, to know who made it so he or she can be contacted again if possible.
Or at least I think so, not a TDM developer, just have experience with other development teams.

Link to comment
Share on other sites

19 hours ago, Daft Mugi said:

I noticed that there are many comments that begin with the name of the developer who wrote the code. What is that for in this codebase? And, should I do the same?

Sometimes people leave such prefix, sometimes they don't.
It is especially helpful when you do a small change to the code you did not originally implement, so that it is clearly modification by another person.

In the worst case, one can always do svn blame and see author + commit message.

Link to comment
Share on other sites

Personally, if editing original Doom 3 code, I always put my code between #ifdef macros, just like the D3xp team did and I think is a good idea, in that way, I can immediately know it is my code later (blame my self not idSoftware) or disable my edits, if necessary, for debugging or something.

Link to comment
Share on other sites

Written below, I tried to more clearly document the changes that "new toggle crouch" introduces and how it compares to other crouch rules, so others may more easily reason about the changes. There's quite a bit of interactions between game state and player intentions.

With regular crouch, the player is always in the standing position while climbing. This has two notable behaviors:

  1. When mantling a platform from a rope/ladder, the player will end the mantle in the standing position.
  2. When sliding, the player will end the slide in the crouching position. The player will change to the standing position on crouch key release.

With traditional toggle crouch, the crouching position does not change on rope/ladder attachment. This has two notable behaviors:

  1. To mantle a platform from a rope/ladder and end the mantle in a standing position, the player must toggle crouch to the standing position while on the rope/ladder before initiating the mantle.
  2. To slide and land in the crouching position, the player must toggle crouch to the crouching position while on the rope/ladder before initiating the slide. The player will change to the standing position on toggle crouch key release.

With Thief/New Dark toggle crouch, the player is always in the standing position while climbing. This has two notable behaviors:

  1. On rope/ladder attachment, the crouching position is automatically changed to the standing position. This is fine for moving upwards, but it can be a bit jarring for moving downwards as the view jerks upwards.
  2. On rope/ladder detachment either mantling on a platform or dropping off (unmount) to the ground, the player will end in the standing position.

With new toggle crouch, the rules are a combination of Thief, TDM regular crouch, and TDM traditional toggle crouch. This has the following notable behaviors:

  1. While on a rope/ladder and moving upwards, the crouching position is automatically changed to the standing position. (Like Thief)
  2. While on a rope/ladder and moving downwards, the crouching position is the same as prior to the attachment. Therefore, a player in the crouching position and moving downwards will stay in the crouching position and will not experience a jarring upwards view change. (Like TDM traditional toggle crouch) Note: If the player moves upwards before moving downwards, the player will be in the standing position.
  3. When mantling a platform from a rope/ladder, the player will likely end the mantle in the standing position because of some prior upwards movement. (Like TDM regular crouch)
  4. When sliding, the player will end the slide in the crouching position. The player will change to the standing position on toggle crouch key release. (Like TDM regular crouch)
Edited by Daft Mugi
Link to comment
Share on other sites

On 5/16/2022 at 11:46 PM, Daft Mugi said:

I've created a ticket for this patch at https://bugs.thedarkmod.com/view.php?id=5962
This patch was created using `git diff --no-prefix`. I hope it works out ok and can be easily merged with SVN.
It's based on r9920.

new-toggle-crouch-v1-r9920.diff 6.38 kB · 1 download

Yep, this diff format can be naturally applied with TortoiseSVN.

Speaking of the code:

  1. You don't save/restore the new flag in idPlayer.
  2. Cvar description "Set to 1 to make toggle crouch on key press instead of key release"... standard terminology for keyboard events is keydown/keyup, and keypresss, where keypress is a composite event which happens only when the button is released 😃 Maybe clarify it as "to toggle crouch on keydown instead of keyup"  ?...

Speaking of the testing:

  1. It feels much better when crouch toggle triggers on key down instead of key up. I like it 😀
  2. I don't like the auto-standup behavior on a ladder. The old behavior makes more sense to me 😥

To me, these two changes (keydown vs keyup  and  ladder+rope interaction) are orthogonal. Maybe I miss something?
Is there some problem with the old behavior regarding ropes/ladders?

Other opinions on the change of behavior are welcome.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recent Status Updates

    • Nort

      I want to be a fish, but I'm not a fish. My mom wants to be a fish too, and so she's killing herself eating plankton and sh***ng blood, and tells me to stop nagging her about taking her medication. I spent several hours today, just lying in bed, having anxiety over just existing, and not being a fish. You fish, you don't know how lucky you are. You can eat all the plankton you want. I tried eating plankton again yesterday, and I just got sick. I hate being a shark.
      · 0 replies
    • Nort

      I just gave myself vertigo. A pleasant kind of vertigo, like the world has been lifted off my shoulders. I'll explain:
      Yesterday I saw to my dismay, that I had made my entire map two - two - units too short on every level - that every set01 piece was sticking 2 units into the ceiling. That's basically 402 brushes that needs to be realigned (minus the ground floor brushes).
      I knew enough about selections to do all of that in a very tense five minutes, and it compiled without leaks. (Thank you so much, Dark Radiant devs, for making an editor with such care for precision that you can align hundreds of brushes perfectly at once (which is not something I can say for Valve's Hammer editor, which has some serious issues on that front, which actually made me just quit it in disgust).) However, the result is that the entire level has now been stretched a barely noticable 2 units, and it will take some getting used to psychologically.
      · 0 replies
    • Nort

      My workflow is basically running from a chain of disasters, eventually trying to seek shelter in former disasters. It's not ideal - it's just my life.
      When I abandoned my first map, it was out of a typical mental breakdown, and so I returned to find a skybox void where the kitchen door should have been (due to a misplaced visportal) and two overlapping brushes Z-fighting on the kitchen floor.
      I've now cleaned up the last bit of mess, by cleanly separating every floor into its own layer. Now I can finally work on each floor in peace.
      ...not that I really needed to. Once you get skilled enough, the orthographic messes, well, I'll let this video speak for itself:
       
      · 1 reply
    • Nort

      Beams, beams, beams...
      Support beams, and cross beams, and then beams to fixate the support beams to the cross beams. The more beams you have in a map, the better. There's walls, floors and ceilings, but the rest of the map is pretty much just beams. Beams makes a thief happy.
      · 0 replies
    • jaxa

      Embracer Group is Buying Square Enix Montréal, Eidos, and Crystal Dynamics for “Only” 300 Million USD: https://wccftech.com/embracer-group-square-enix-montreal-eidos-crystal-dynamics/
      · 1 reply
×
×
  • Create New...