Scriptable weapon slots and priorities
Moderator: GZDoom Developers
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Scriptable weapon slots and priorities
Currently I'm using a monster piece of code and some hijacking of EventHandler to achieve what I'm trying to do here: customizable slot priorities.
It would be appreciated if I could adjust the slots now that all the weapon stuff has been exported.
It would be appreciated if I could adjust the slots now that all the weapon stuff has been exported.
Last edited by Major Cooke on Sat Dec 01, 2018 4:38 pm, edited 1 time in total.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Remove meta from SlotNumber and SlotPriority
These two values are only being read once at game startup when the weapon slots are initially created. They cannot be edited because when you get to them it's too late.
To make the weapon slots customizable a lot more work would be needed.
To make the weapon slots customizable a lot more work would be needed.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Scriptable weapon slots and priorities
I see. Renamed the thread accordingly.
- m8f
-
- Posts: 1445
- Joined: Fri Dec 29, 2017 4:15 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Manjaro Linux
- Location: Siberia (UTC+7)
- Contact:
Re: Scriptable weapon slots and priorities
Sorry for the self-promotion, but Weapon Menu mod allows weapon slot and priority customizing in run-time, without rebinding the keys. Maybe there is no need for doing this in engine.
Last edited by m8f on Sun Dec 02, 2018 12:57 am, edited 1 time in total.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Scriptable weapon slots and priorities
Ultimately all the weapon slots do is define the behavior of the 'slot' CCMD. So any attempt to work around this means to rebind some keys.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Scriptable weapon slots and priorities
m8f: I want to avoid rebinding keys, just as Graf said. Look closely at my event handler link. I hijack the "slot X" commands via event handler.
Re: Scriptable weapon slots and priorities
Does this work when the player changes weapons with the mousewheel or something that isn't even a keyboard (like a gamepad)?Major Cooke wrote:I hijack the "slot X" commands via event handler.
- phantombeta
- Posts: 2088
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: Scriptable weapon slots and priorities
Yes. It works for any key bound to "slot [0-9]", "weapnext" or "weapprev". Basically, it checks every keypress - if it matches a key bound to one of those commands, it hijacks the keypress. This is actually a method of doing custom slots I developed for my mod.Nash wrote:Does this work when the player changes weapons with the mousewheel or something that isn't even a keyboard (like a gamepad)?Major Cooke wrote:I hijack the "slot X" commands via event handler.
It's a somewhat janky way to do it, and it doesn't work with aliases. It also doesn't handle doublebinds (that is, keybinds triggered by pressing the key twice) and automap binds. This means it blocks the default scrollwheel zoom commands, but this isn't really fixable, as there's no way to check whether a key has an automap bind. (You can only get what keys a command is bound to, but not the other way around)
In my case this hack is already unnecessary, as I can override the virtuals for slot, weapnext and weapprev with my own code, as I use it for limited, customizable slots anyway. I imagine Major Cooke would prefer something simpler and more easily maintained, however.
- m8f
-
- Posts: 1445
- Joined: Fri Dec 29, 2017 4:15 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Manjaro Linux
- Location: Siberia (UTC+7)
- Contact:
Re: Scriptable weapon slots and priorities
Oh, the feature suggestion is to add a convenient way to override CCMDs behavior, not to make one particular possible implementation. Now I get it.Major Cooke wrote:m8f: I want to avoid rebinding keys, just as Graf said. Look closely at my event handler link. I hijack the "slot X" commands via event handler.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Scriptable weapon slots and priorities
Now that the Pick* functions have been exposed, I can actually port that functionality straight to the player which means removing meta from SlotPriority and SlotNumber can indeed be beneficial. Since they're only ever read once, no harm in doing so, especially since the defaults can be easily restored.