Scriptable weapon slots and priorities

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

User avatar
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

Post by Major Cooke »

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.
Last edited by Major Cooke on Sat Dec 01, 2018 4:38 pm, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Remove meta from SlotNumber and SlotPriority

Post by Graf Zahl »

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.
User avatar
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

Post by Major Cooke »

I see. Renamed the thread accordingly.
User avatar
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

Post by m8f »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Scriptable weapon slots and priorities

Post by Graf Zahl »

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.
User avatar
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

Post by Major Cooke »

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.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Scriptable weapon slots and priorities

Post by Nash »

Major Cooke wrote:I hijack the "slot X" commands via event handler.
Does this work when the player changes weapons with the mousewheel or something that isn't even a keyboard (like a gamepad)?
User avatar
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

Post by phantombeta »

Nash wrote:
Major Cooke wrote:I hijack the "slot X" commands via event handler.
Does this work when the player changes weapons with the mousewheel or something that isn't even a keyboard (like a gamepad)?
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.
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.
User avatar
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

Post by m8f »

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.
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.
User avatar
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

Post by Major Cooke »

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.
Post Reply

Return to “Feature Suggestions [GZDoom]”