Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ported trigger_userinput from Momentum Mod #389

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Nbc66
Copy link

@Nbc66 Nbc66 commented Feb 10, 2025

This PR Ports the trigger_momentum_userinput trigger from Momentum Mod from mom_triggers.cpp

this allows you to check if a user has:

  • Pressed a button
  • is holding a button
  • has released a button

the fgd should look like this:

@SolidClass base(Trigger) = trigger_userinput : "Trigger that fires on user KeyPress if inside trigger."
[
    output OnKeyPressed(void) : "Fires when the desired key is pressed"
    output OnKeyHeld(void) : "Fires every tick while the desired key is held"
    output OnKeyReleased(void) : "Fires when the desired key is released"
    lookedkey(choices) : "Key that fires" : "Forward" =
    [
        0 : "Forward"
        1 : "Back"
        2 : "Move Left"
        3 : "Move Right"
        4 : "Jump"
        5 : "Duck"
        6 : "Attack"
        7 : "Attack 2"
        8 : "Reload"    
    ]
]

PR Checklist

  • My PR follows all guidelines in the CONTRIBUTING.md file
  • My PR targets a develop branch OR targets another branch with a specific goal in mind

@Nbc66 Nbc66 changed the title ported trigger_userinput from Momentum Mod Ported trigger_userinput from Momentum Mod Feb 10, 2025
@meatspace
Copy link

oh yeah one thing i forgot mapbase has that momentum doesnt is a third tertiary attack, idk if its possible to add easily but might be cool

Copy link
Member

@Blixibon Blixibon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this trigger would be welcome in Mapbase overall, but I'm uncertain of the way it was implemented.

While you're free to address or respond to the points I raised, I'm interested enough that I would be alright with fixing this up myself in the future if you would prefer to move on from this.

Comment on lines +386 to +399
enum Key
{
KEY_FORWARD = 0,
KEY_BACK,
KEY_MOVELEFT,
KEY_MOVERIGHT,
KEY_JUMP,
KEY_DUCK,
KEY_ATTACK,
KEY_ATTACK2,
KEY_RELOAD
};
int m_ButtonRep;
Key m_eKey;
Copy link
Member

@Blixibon Blixibon Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why this uses its own separate enum instead of allowing mappers to check button bits directly, but that's a question for Momentum Mod more-so than for this PR.

While I would prefer to keep functionality the same between the way it works in Mapbase and the way it works in Momentum Mod, I think it would make sense to allow for explicit button bits, especially if this may get extended to other buttons like +attack3. Perhaps there could be an alternate keyvalue to handle that.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is any need for parity with another mod for such a stupid simple entity. If this entity is to be added, the empty base class and this enum should be removed. I suppose keeping this separate would make changes to the order of IN_BUTTONS enum not break this entity, but that's really unlikely.

"Key" name is usually used for keyboard keys instead of player input buttons. "OnKey" outputs don't make much sense. "lookedkey" also sounds weird.

It seems more appropriate to have this as a point entity or an extension for game_ui instead of limiting it to a trigger. Mappers looking for something like this would certainly want to use it without a trigger.

Copy link
Author

@Nbc66 Nbc66 Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i agree this pr just ports what Momentum Mod did i can modify this pr to make it be a point entity that just checks the players input or be an extension of game_ui

If there is anything else you guys would like me to do pls feel free to write it here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is any need for parity with another mod for such a stupid simple entity. If this entity is to be added, the empty base class and this enum should be removed. I suppose keeping this separate would make changes to the order of IN_BUTTONS enum not break this entity, but that's really unlikely.

"Key" name is usually used for keyboard keys instead of player input buttons. "OnKey" outputs don't make much sense. "lookedkey" also sounds weird.

It seems more appropriate to have this as a point entity or an extension for game_ui instead of limiting it to a trigger. Mappers looking for something like this would certainly want to use it without a trigger.

also I just realized that this trigger works with multiple people unlike the game_ui entity which is needed for each player on a map

if you got any code suggestions pls feel free to write em here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants