[Not needed] Control Option: Swap-to/from Chainsaw

Moderator: GZDoom Developers

Control Option: Swap-to/from Chainsaw

Postby boom-potato » Sun Dec 08, 2019 4:29 pm

Hello zdoomers,

Zdoom forum newbie here. I have been wanting something like this in conjunction with mods like Brutal Doom, Eviternity, and even (mostly) vanilla doom. I got the idea from playing half-life 2 shortly before playing some doom mods and realizing how useful the Gravity Gun button was. You can swap to and from with one button which I feel made the barrier to using it way lower. I often wished I used the chainsaw more often in doom but never do because switching back to my current weapon can be a pain.

I am posting this as a suggestion but I would like to give a crack at implementing the changes myself and submitting a formal pull request with this feature. I am finishing my bachelors in computer science currently so I am not brand new to throwing down some code but this is a huge and expansive project and I am still learning how to write actual code instead of just doing homework assignments. So I am suggesting this to see if anyone else is interested in something like this but also asking for pointers on what code to look at to start this and maybe some suggestions on implementation.

Outline:
When you want to quickly swap to the chainsaw you press SWAP_CHAINSAW_BUTTON. Then once you want to go back to the previously equipped weapon, press SWAP_CHAINSAW_BUTTON again. If you select the chainsaw with 1, the currently equipped weapon will go into the PREVIOUS_WEAPON buffer so you can still swap back with SWAP_CHAINSAW_BUTTON if you want to.

Settings(?):
SWAP_CHAINSAW_BUTTON: User defined button that swaps to the chainsaw and swaps back.
PREVIOUS_WEAPON: Internal variable for keeping track of the weapon the weapon used before selecting the chainsaw.

Potential issues:
  • If you are using mods that have multiple weapons in each slot you want to be able to get back to that specific weapon. PREVIOUS_WEAPON could be a kind of pointer directly to the weapon instead of the weapon number?
  • What if the mod doesn't have a chainsaw? maybe the user should be able to also select what weapon the button swaps to ultimately but the default will be set to the chainsaw.

Apologies for any confusing/improper wording.

Thanks for reading!
boom-potato
 
Joined: 08 Dec 2019
Github ID: aargolang
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Control Option: Swap-to/from Chainsaw

Postby m8f » Sun Dec 08, 2019 10:35 pm

It's not necessary to add this feature to the engine, because it's possible to add it as a mod.
Here is the working solution: https://github.com/mmaulwurff/m_gizmos - this thing is a collection of independent features, one of them is a key to select the previously selected weapon. So, you can assign a key to select the chainsaw (
Code: Select allExpand view
bind c "use chainsaw"
in console, replace c with your key), and swap back with a key from m_gizmos.

Edit: Oh, hello, and welcome to the ZDoom forum!
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit

Re: Control Option: Swap-to/from Chainsaw

Postby boom-potato » Mon Dec 09, 2019 12:15 am

Ok so with this mod I would have two keys. One of them goes directly to the chainsaw and the other swaps back and forth?
edit: accidental duplicate because I'm a noob
Last edited by boom-potato on Mon Dec 09, 2019 12:53 am, edited 1 time in total.
boom-potato
 
Joined: 08 Dec 2019
Github ID: aargolang
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Control Option: Swap-to/from Chainsaw

Postby boom-potato » Mon Dec 09, 2019 12:33 am

Thanks for the welcome!

Yeah ok so with this mod It would be two keys: one to switch to chainsaw and another to swap back and forth between the two weapons. correct?

Seems not too bad but it's not entirely what I had in mind. I might just follow his code as an example and make what I had in mind. I just really like the idea of the simplicity of one button for the swap.

Thanks a for pointing me in the right direction!
boom-potato
 
Joined: 08 Dec 2019
Github ID: aargolang
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Control Option: Swap-to/from Chainsaw

Postby Graf Zahl » Mon Dec 09, 2019 3:59 am

That's the best you will get. What you want is far too specific to become an engine feature.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Control Option: Swap-to/from Chainsaw

Postby Gez » Mon Dec 09, 2019 8:12 am

You can use a rebind command so the same single key alternates between swapping to chainsaw and swapping to previous weapon.
Gez
 
 
 
Joined: 06 Jul 2007

Re: Control Option: Swap-to/from Chainsaw

Postby boom-potato » Sat Dec 14, 2019 8:13 pm

Graf Zahl wrote:That's the best you will get. What you want is far too specific to become an engine feature.


For sure that makes sense. I think if I do implement anything I will just have it as a small mod.

Gez wrote:You can use a rebind command so the same single key alternates between swapping to chainsaw and swapping to previous weapon.


This sounds interesting. Can I bind a key to do more than just one action?
maybe something like this pseudo code?
Code: Select allExpand view
bind g "if (current_weap=chainsaw)
            use previous_weapon;
            rebind g to chainsaw;
        else
            use chainsaw;
            rebind g to previous_weapon;"


Thanks for the replies!
boom-potato
 
Joined: 08 Dec 2019
Github ID: aargolang
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Control Option: Swap-to/from Chainsaw

Postby Gez » Sun Dec 15, 2019 3:42 am

I don't think the console has a way of knowing which weapon is currently selected. If you could, the code would be much simpler than that, it'd look something like this:
Code: Select allExpand view
alias swap_to_chainsaw "use chainsaw"
alias weapon_swap "test weapon_is_chainsaw m8f_wm_select_last_used swap_to_chainsaw"
bind g weapon_swap

First alias is there just to make the swap to chainsaw command into a single word, "weapon_is_chainsaw" would be evaluated to true or false. I suppose you could do it by declaring a custom console variable and using a script (ACS or ZScript) to monitor player weapon, updating the value to true or false as appropriate.

[/code]

But you can do this:
Code: Select allExpand view
alias swap_to_chainsaw "use chainsaw; rebind g swap_to_previous"
alias swap_to_previous "m8f_wm_select_last_used; rebind g swap_to_chainsaw"
bing g swap_to_chainsaw

Type these three lines in the console. Now when you hit g, it swaps to the chainsaw, then rebinds g to swap to the previous weapon. And when you hit g again, it swaps to the previous weapon then rebinds g to the chainsaw. And if you hit g again, it swaps to the chainsaw again, then rebinds g to the previous weapon again, and so on and so forth.
Gez
 
 
 
Joined: 06 Jul 2007

Re: Control Option: Swap-to/from Chainsaw

Postby boom-potato » Sun Dec 15, 2019 2:28 pm

This works! Thank you for helping me!
After messing with it a bit these are the commands that finally worked:
Code: Select allExpand view
alias swap_to_chainsaw "use chainsaw; rebind swap_to_previous"
alias swap_to_previous "m8f_wm_select_last_used; rebind swap_to_chainsaw"
bind g swap_to_chainsaw
boom-potato
 
Joined: 08 Dec 2019
Github ID: aargolang
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests