You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'm looking into having weapons autoassign themselves to weapon slots, for a mod where the player can carry any 3 weapons at once--think something like Borderlands-style weapon equipping. Unfortunately, there's no clean way to manipulate a weapon's current slotnumber...yet.
With the introduction of the WeaponSlots struct, there's now a data structure that contains weapon slot info. But, WeaponSlots is very opaque on the zscript side--from what I can tell, it only exposes a way of checking what slot a weapon has or checking whether there's a weapon in a given slot.
Describe the solution you'd like
Ideally, there'd be a function--say, AssignWeaponSlot(Class<Weapon> weapon, int slot, int idx = -1). Calling player.WeaponSlots.AssignWeaponSlot("Pistol",4) would attempt to assign the Pistol weapon to slot 4, in the first available index. Calling player.WeaponSlots.AssignWeaponSlot("Pistol",4,0) would instead remove whatever weapon is in slot 4 index 0, and replace it with the pistol. Passing null as the weapon class simply removes whatever was in the specified slot and index, or--if no index is specified--clears the slot entirely.
This would allow me to assign weapons to arbitrary weapon slots without having to do any kind of gross hacks (such as having "dummy" weapons on slots 2, 3, and 4 that instantly select the real weapon when selected).
Describe alternatives you've considered
Obviously, I could just continue doing gross hacks. It's currently possible to fake weapon-slot reassignment by intercepting input events, but this is kind of a headache. There's also the aforementioned method of having a "fake" weapon in each slot that then gets assigned a pointer to the real weapon it should swap to.
Another, possibly messier alternative to a dedicated AssignWeaponSlot function is simply exposing the underlying data structure of WeaponSlots to zscript, and letting modders interact with that array directly. I don't know how much work has to be done when a weapon switches slot numbers, so I wouldn't know if this is viable.
Add any other context or screenshots about the feature request here.
No response
The text was updated successfully, but these errors were encountered:
you don't need to intercept input events or modify slots to change the behavior of weapon selection, you just need to override PickNextWeapon/PickPrevWeapon for scrolling up/down and PickWeapon for directly selecting weapons via keys
(WeaponSlots, since it is designed to be fully constant, cannot be exported without a rewrite, if modification was allowed without that, slots would completely break when loading saves for mods that modify it, since it is only initialized on engine startup/save loads, and never serialized to saves)
Thanks for the info! I guess I should've dug a bit further before opening this issue, lol. These should do what I need without jumping through the hoops I saw when I looked at how Gearbox did it.
GZDoom version
No response
Which game are you running with GZDoom?
None
What Operating System are you using?
None
If Other OS, please describe
No response
Relevant hardware info
No response
Is your feature request related to a problem? Please describe.
I'm looking into having weapons autoassign themselves to weapon slots, for a mod where the player can carry any 3 weapons at once--think something like Borderlands-style weapon equipping. Unfortunately, there's no clean way to manipulate a weapon's current slotnumber...yet.
With the introduction of the WeaponSlots struct, there's now a data structure that contains weapon slot info. But, WeaponSlots is very opaque on the zscript side--from what I can tell, it only exposes a way of checking what slot a weapon has or checking whether there's a weapon in a given slot.
Describe the solution you'd like
Ideally, there'd be a function--say,
AssignWeaponSlot(Class<Weapon> weapon, int slot, int idx = -1)
. Callingplayer.WeaponSlots.AssignWeaponSlot("Pistol",4)
would attempt to assign the Pistol weapon to slot 4, in the first available index. Callingplayer.WeaponSlots.AssignWeaponSlot("Pistol",4,0)
would instead remove whatever weapon is in slot 4 index 0, and replace it with the pistol. Passingnull
as the weapon class simply removes whatever was in the specified slot and index, or--if no index is specified--clears the slot entirely.This would allow me to assign weapons to arbitrary weapon slots without having to do any kind of gross hacks (such as having "dummy" weapons on slots 2, 3, and 4 that instantly select the real weapon when selected).
Describe alternatives you've considered
Obviously, I could just continue doing gross hacks. It's currently possible to fake weapon-slot reassignment by intercepting input events, but this is kind of a headache. There's also the aforementioned method of having a "fake" weapon in each slot that then gets assigned a pointer to the real weapon it should swap to.
Another, possibly messier alternative to a dedicated AssignWeaponSlot function is simply exposing the underlying data structure of WeaponSlots to zscript, and letting modders interact with that array directly. I don't know how much work has to be done when a weapon switches slot numbers, so I wouldn't know if this is viable.
Add any other context or screenshots about the feature request here.
No response
The text was updated successfully, but these errors were encountered: