Scriptable weapon slots and priorities

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is ON
[img] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Scriptable weapon slots and priorities

Re: Scriptable weapon slots and priorities

by Major Cooke » Fri Jan 25, 2019 3: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.

Re: Scriptable weapon slots and priorities

by m8f » Sun Dec 02, 2018 7: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.

Re: Scriptable weapon slots and priorities

by phantombeta » Sun Dec 02, 2018 6: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.

Re: Scriptable weapon slots and priorities

by Nash » Sun Dec 02, 2018 6: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)?

Re: Scriptable weapon slots and priorities

by Major Cooke » Sun Dec 02, 2018 11:00 am

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

by Graf Zahl » Sun Dec 02, 2018 12: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.

Re: Scriptable weapon slots and priorities

by m8f » Sat Dec 01, 2018 8: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.

Re: Scriptable weapon slots and priorities

by Major Cooke » Sat Dec 01, 2018 4:38 pm

I see. Renamed the thread accordingly.

Re: Remove meta from SlotNumber and SlotPriority

by Graf Zahl » Sat Dec 01, 2018 4: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.

Scriptable weapon slots and priorities

by Major Cooke » Sat Dec 01, 2018 4: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.

Top