Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Weapon SlotNumber Manipulation #2717

Closed
Derpford opened this issue Sep 17, 2024 · 4 comments
Closed

[Feature] Weapon SlotNumber Manipulation #2717

Derpford opened this issue Sep 17, 2024 · 4 comments

Comments

@Derpford
Copy link

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). 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

@RicardoLuis0
Copy link
Collaborator

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

@RicardoLuis0
Copy link
Collaborator

(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)

@Derpford
Copy link
Author

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.

@MajorCooke
Copy link
Contributor

In my case for Keyconf Destroyer, I do have to intercept inputs. Which is why I need this.

@coelckers coelckers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants