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 2
  • 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

Posted (edited)

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

Posted (edited)

@stgatilovThank you for trying out the patch and giving feedback! I'm glad that the diff format worked out ok!

re code:

  1. If you are referring to m_CrouchToggleBypassed, I couldn't think of a state where it would need to be restored. Is there a situation where it may cause a problem? Also, wouldn't that make the save file incompatible with other versions?
  2. Good suggestion. How does "Set to 1 to toggle crouch on key down instead of key up." sound?

re testing:

  1. Great! Glad you like it! :)
  2. That's understandable. It's really subjective. How about I make a separate option for auto-stand on ladder? (The reason I made the player stand up automatically is that I don't like the traditional behavior. Usually, when I climb up and mantle onto a platform, I want to be standing. It may be because I'm used to that behavior from Thief.)

Given that we should probably have two separate options instead of "tdm_new_toggle_crouch", how about the new options be: "tdm_toggle_crouch_on_keydown" and "tdm_toggle_crouch_autostand_on_climb_up"?

tdm_toggle_crouch_on_keydown             (default: 1)  "Set to 1 to toggle crouch on key down instead of key up."
tdm_toggle_crouch_autostand_on_climb_up  (deafult: 0)  "Set to 1 to automatically stand up when climbing up."

 

Edited by Daft Mugi
Link to comment
Share on other sites

Personally, I don't see a reason for having a cvar for "crouch toggle on key down".
I think it is a universal improvement, and it does not go against people's habits.

As for ladder/rope thing, I'd better wait to hear more opinions.
 

  • Like 1
Link to comment
Share on other sites

2 hours ago, stgatilov said:

As for ladder/rope thing, I'd better wait to hear more opinions.

Maybe this can be implemented in a dev build so people can test it before giving an opinion (or maybe that was your idea already?).

Link to comment
Share on other sites

Posted (edited)

A side effect of making toggle crouch on key down without changing anything else is a difference in slide outcome.

  • With traditional toggle crouch (on key up), if the player is already crouched, they will land crouched at the end of their slide. This, I imagine, can have stealth advantages as it is quieter. This is the same advantage that regular crouch players have.
  • With on-keydown toggle crouch, if the player is already crouched, they will land standing at the end of their slide. This, I imagine, may surprise the player as the landing may make more noise and be less stealthy. They thought they were crouched and performed the slide action, so why are they standing and making more noise?!

That's the main issue that needs careful consideration. How does on-keydown toggle crouch work on ladders/ropes?

The way I chose to solve this issue was to make on-keydown toggle crouch behave like regular crouch while on ladders/ropes.

As another option, on slide, the player could go into the crouching position and stand up on key up. I'll look at the code to see if this is possible and easy enough.

Edited by Daft Mugi
Link to comment
Share on other sites

Posted (edited)

I do think their needs to be an option available to autostand on ladders/ropes.

It's challenging to work on that until on-keydown toggle crouch is finalized, though.

The main motivation behind autostand is to have parity with regular crouch and also have parity between Thief/New Dark and The Dark Mod, so I think there should be a new-dark toggle crouch option at the very least. The other motivation behind autostand is to make climbing up a rope/ladder be more consistent with regards to crouch state — always standing at the top.

tdm_new_dark_toggle_crouch    (default: 0)  "Set to 1 to make toggle crouch be similar to New Dark on ropes/ladders"

I haven't looked into the work involved yet, but I think this option should be available in the settings menu as well. This will make TDM more friendly for folks coming from playing a lot of Thief.

Edited by Daft Mugi
Link to comment
Share on other sites

Another point to consider about the crouch state on a ladder/rope is that the player may become disoriented if the state is not consistent. With traditional toggle crouch, the player may become unsure about their crouch state on a ladder/rope and have to look at the crouch state indicator near the light gem. So, having a consistent crouch state on a ladder/rope, such as always standing or always crouching, can be helpful — maybe even a climbing state instead.

Link to comment
Share on other sites

  • 3 weeks later...

I'm very sorry for the long delay on this matter.

I have extracted two fixes from the patch and committed them to SVN (no cvar):

 
  • 5961  Fix rope/ladder speed while crouched
  • 5973  Change crouch state on key down with crouch toggle

Speaking of the rest of the patch (5962), I did not commit it.
As I said, I personally don't like this behavior change, and given that it adds some stuff to the code, I'd commit it only if several team members agree that it is worth it.

However, @Daft Mugi has found two more issues which are still present:

  • 4247  Using the crouch key when climbing a ladder or a pipe
  • 1746  Climbing physics should use crouched player bounding box

I think the real problem here is that when player is on rope/ladder he can oncrouch, but he cannot crouch. I have no idea why.

I'd say: we should allow player to crouch and uncrouch regardless of whether he is on rope/ladder or not. That would be simple and consistent, and will solve the issue of going into narrow ventilation shaft immediately after climbing a ladder.

     
Link to comment
Share on other sites

Ok, I know why crouching on ladder and rope is blocked!

That's because when "toggle crouch" is disabled, you cannot crouch on rope/ladder anyway. Because to achieve that, you need to hold crouch button for long time, and that would trigger slide down to the very bottom. So even if I allow crouching on ladder/rope, players without "toggle crouch" will have very hard time trying to move from the top of the ladder into ventilation shaft.

The easiest way around that would be to force "toggle crouch" behavior when on rope/ladder.

Otherwise I don't know how to achieve all of the following at once:

  • support "toggle crouch" = off
  • allow sliding down on ladder/rope by holding crouch button
  • allow player to fully control whether he is crouched or not on a ladder/rope
Link to comment
Share on other sites

@stgatilov One thing to consider is that some folks have tdm_crouch_toggle_hold_time set to 0, so they will immediately slide instead of crouch on a ladder. Having tdm_crouch_toggle_hold_time = 0 matches Thief/New Dark behavior.

In my patch, I decided to match the behavior of regular crouch while on a ladder/rope, because I didn't think any previously-made mission would have a space that only toggle-crouch players would be able to enter.

  • support "toggle crouch" = off
    • No change required.
  • allow sliding down on ladder/rope by holding crouch button
    • Always behave like regular crouch.
  • allow player to fully control whether he is crouched or not on a ladder/rope
    • Don't let them, since it doesn't make sense. In real life, 1) you would be standing flat against the ladder while climbing, 2) you would be crouched (not really, though!) and have your hands and feet close together with your behind sticky out while climbing, making you more visible than "standing", or 3) stopped with your knees tucked in close to your body while not climbing, making you stick out more than "standing". So, standing on a ladder usually makes you less visible.
    • In game life, the main thing is the visibility, destination, and camera. How visible does the game engine make you on a ladder/rope? Can you land in the crouching position, so you make less noise? Can you mantle into the standing position? Does the camera have any jarring movements when attaching to a ladder?
Link to comment
Share on other sites

Posted (edited)

@stgatilov I do not agree with how the patch was applied and the current state of toggle crouch.

Players requested an option to toggle between traditional toggle crouch and the new toggle crouch. The way the patch was applied ignored this request, because the cvar was not included. This breaks sliding for traditional-toggle-crouch players, since they will now slide and land in the standing position (if already in the crouch position on the ladder). This makes more noise. With traditional toggle crouch, they would slide and land in the crouch position (if already in the crouch position on the ladder). This makes less noise. And, we don't know what other scenarios they prefer having toggle crouch happen on key up.

Edited by Daft Mugi
Link to comment
Share on other sites

Well... yes, sliding down has an issue now for "toggle crouch" people.

Do you think that clunky slide-down is worse than toggle-crouch on key release?
Do you think it would be better if sliding down forced player to become crouched?

On the other hand, I don't agree with what your patch does.
I find it particularly bad that crouch state depends on direction of movement when on rope/ladder.

P.S. To me crouching on ropes/ladders has two major ponts:

  1. If I enter rope/ladder crouched, I expect to remain crouched when I detach (and same for standing state).
  2. It would be great if player could detach rope/ladder in crouched state so that he could pass through narrow hole. I agree that existing missions probably avoid such case, and that is not good.
     
Link to comment
Share on other sites

Posted (edited)
Quote

Do you think that clunky slide-down is worse than toggle-crouch on key release?
Do you think it would be better if sliding down forced player to become crouched?

I think toggling the opposite crouch position before initiating the slide on key down is worse than how it worked originally on key up. We need a solution for sliding down into the crouch position, so the player makes less noise. Forcing the player into the crouch position and having to toggle to stand up is not good. I like my compromise of behaving like regular crouch, so the player crouches until key up. They at least have control over their noise level. But there's probably another solution/compromise.

Quote

On the other hand, I don't agree with what your patch does.
I find it particularly bad that crouch state depends on direction of movement when on rope/ladder.

If I enter rope/ladder crouched, I expect to remain crouched when I detach (and same for standing state).

I agree that not all players will like it, so I'm glad you pointed that out to me. However, I do think players like me, who prefer how Thief/New Dark behaves, should not be ignored just as you don't want your preference to be ignored. My patch was a compromise, since autostand can be jarring in some cases as it moves the camera. Autostand only on move up was the least jarring and matches Thief/New Dark behavior. On move down, I couldn't think of a scenario for autostand and the player can always slide to stand. A compromise of a cvar option sounds like a win-win to me.

Quote

It would be great if player could detach rope/ladder in crouched state do that he could pass through narrow hole. I agree that existing missions probably avoid such case, and that is not good.

This is already achieved through mantling, no? On mantle, the player position matches the space.

Edited by Daft Mugi
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

    • STiFU

      Be honest: Who of you have actually finished Cuphead? This game is freaking tough! It might even be harder than Sekiro. Dark Souls is a joke in comparison to Cuphead! :-D 
      · 8 replies
    • duzenko

      Please, can we finally group the missions by year in the game menu?
      · 6 replies
    • duzenko

      I vaguely recall someone recently complained about two-sided materials (curtains?) not getting lighting from both sides
      I just found a piece of code that's supposed to do just that
      Where was that discussed? (@nbohr1more?)
      · 9 replies
    • Xolvix

      I still play classic Doom (albeit with user-made mods and maps rather than the original campaign) on a regular basis. A game from the early 90's which has still got a healthy following in 2022. Pretty amazing.
      · 3 replies
    • Nort

      I'm beginning to understand why people who aren't into social clubbing "don't last long" on this project, and why it's so full of holes. When moderators are siding with bullies, by closing down threads that they derail, then I start to wonder if I should support the platform to begin with.
      I'm sure that the core development is solid, but when you're constantly tone policed and bullied, and moderators are playing into it too, then the project will just drive away talent, and replace it with socialites instead. ...and without talent, you only end up with a small skeleton crew trying to do everything themselves.
      ...so Dragofer and Airship Ballet, and all you other socialites, you win. From now on I'll just keep to myself. You'll never be able to do my work, but at least you'll be happy together, and that's what matters to you.
       
      Update
      Actually, I have to revise my statement:
      I actually messaged greebo - the top dog, I gather - about nbohr1more's outburst of insanity below, and since I haven't even heard back from him, I just have to assume that there's not a single core programmer here, who's not backing nbohr's threats. ...and that's bad.
      ...so if you're a newbie reading this, or an honest soul like ZergRush, then just slowly back out of these forums, run, and don't look back. This is nothing more than a cult posing as a game development project, using Thief and IDTech4 to sucker hopefuls in, to do work for them, while trying to cajole them into something going on behind the scenes, which apparently - according to nbohr - is something that should be hidden from the state. These people aren't programmers - they don't even understand things like how to fix the simplest bugs. All they have, is an engine, and an IP, and some sort of fascist social cult. There was some other project I saw being made in the Unreal Engine. Try joining that project. ...or start a project of your own. Anything but this asylum.
      Hopefully that was "divisive" enough for a final post, because at this point I really want people to leave this place. This project is, on a management level, just awful garbage, run by garbage people, apparently from the top down, and I'm just glad that they have a garbage place to stay, together, and hopefully forever.
      Nort
      · 16 replies
×
×
  • Create New...