Scriptable weapon slots and priorities

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

Moderator: GZDoom Developers

Scriptable weapon slots and priorities

Postby Major Cooke » Sat Dec 01, 2018 5:27 pm

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 5:38 pm, edited 1 time in total.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: Remove meta from SlotNumber and SlotPriority

Postby Graf Zahl » Sat Dec 01, 2018 5:33 pm

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
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Scriptable weapon slots and priorities

Postby Major Cooke » Sat Dec 01, 2018 5:38 pm

I see. Renamed the thread accordingly.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: Scriptable weapon slots and priorities

Postby m8f » Sat Dec 01, 2018 9:42 pm

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 1:57 am, edited 1 time in total.
User avatar
m8f
 
 
 
Joined: 29 Dec 2017

Re: Scriptable weapon slots and priorities

Postby Graf Zahl » Sun Dec 02, 2018 1:35 am

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
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Scriptable weapon slots and priorities

Postby Major Cooke » Sun Dec 02, 2018 12:00 pm

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
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: Scriptable weapon slots and priorities

Postby Nash » Sun Dec 02, 2018 7:38 pm

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
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: Scriptable weapon slots and priorities

Postby phantombeta » Sun Dec 02, 2018 7:58 pm

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
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_

Re: Scriptable weapon slots and priorities

Postby m8f » Sun Dec 02, 2018 8:57 pm

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
m8f
 
 
 
Joined: 29 Dec 2017

Re: Scriptable weapon slots and priorities

Postby Major Cooke » Fri Jan 25, 2019 4:41 pm

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.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846


Return to Feature Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest