News: 1up Discord VOIP
Invite Code: https://discord.gg/VPv9JhP

Author Topic: Toggle Question  (Read 1333 times)

0 Members and 1 Guest are viewing this topic.

Offline UncleSam

  • Posts: 279
  • Karma: -2
  • Since: 22/01/2013
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Toggle Question
« on: April 03, 2013, 04:21:12 PM »
If I wanted to press the mouse3 button to toggle between |having attack set to the scroll wheel both up and down| and |attack set to mouse1 where scroll wheel switches weapons| how would I do this?

It's for fast knife in zbomb and superts.

Thanks.
« Last Edit: April 03, 2013, 04:27:21 PM by UncleSam »

Offline HonoredMule

  • Posts: 54
  • Karma: 1
  • Since: 19/05/2012
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Toggle Question
« Reply #1 on: April 04, 2013, 12:14:27 AM »
The basic standalone procedure would be a fairly straightforward toggle script, with the only wrinkle being that you maintain two commands that are affected by the state instead of one--i.e:
set menter "set mouse_up attack; set mouse_dn attack; set mtoggle vstr mexit"
set mexit "set mouse_up THETHINGITDIDBEFORE; set mouse_dn THETHINGITDIDBEFORE; set mtoggle vstr menter"
set mtoggle "vstr menter"
vstr mexit //initialize the controls

bind MWHEELUP "vstr mouse_up"
bind MWHEELDOWN "vstr mouse_dn"


and either:
bind MYTOGGLEKEY "+vstr menter mexit" // for press-and-hold

or:
bind MYTOGGLEKEY "vstr mtoggle" // for sticky state

----

If you're using my control script, you can automatically have that behavior whenever the knife is selected, by making the following change:

Find the "wp_k" block of command states (setup for when knife is selected) and replace set mup vstr k_n; set mdn vstr k_p (select last used firearm and, respectively, switch to next and previous firearms from there) with something like set mup attack; set mdn attack.  This is all assuming you use the weapon selection binds and bound your "next" and "previous" weapon commands to mouse up and down (the presumptive reason for naming those commands mup and mdn).

All of the other states will take care of restoring normal behavior when de-selecting the knife or explicitly selecting any other item, and take care to note that going into zoom mode will also supersede this setup, though unzooming will restore it.

I haven't tested this, so where I said "attack" you might actually need "vstr some_command" and add somewhere set some_command "+attack; -attack".

No key would be required for a toggle, though the obvious downside is losing some weapon switching controls and having to use your knife toggle or other explicit weapon command to get back to a gun.  Luckily the possibility of attempting to select a knife while none are carried is generally a non-issue, or that could create some frustration with seemingly unreliable weapon switching controls.

----

It would also be possible to instead give your zoom key yet another overloaded function that toggles this mode instead of zoom mode when the knife is selected.  It's reasonably straightforward within the framework of my control script, but I'll leave it as a "do it yourself" exercise for the reader, should anyone actually care to do so.

The procedure would involve:
 - a new "wp_zk" state (zoomed while knife selected) based off wp_z (changing mup and mdn commands as before, and probably removing the fov/sensitivity-handling subcommands)
 - a "z_k" (zoom with knife) transition command for entering the state (which probably only needs to run wp_zk)
 - updating the ztoggle command to use the new transition command when in wp_k state (knife selected).

The command to transition out of zoom mode (zNot) will probably still work fine as is.  This setup has a different downside, in that you couldn't have this be a sticky toggle while zoom is a press-and-hold--which would probably be ideal--so either you'd give up the press-and-hold zoom or your mouse attack spamming would be kind of awkward.  You could instead add a whole new command set that works independently, possibly overloaded with something else, and then the task gets bigger again, looking like an amalgamation of the standalone version and the altered wp_k state version.

----

Keep in mind, however, that all this assumes the game would even recognize inputs getting spammed that quickly without choking.  It very well may not.
« Last Edit: April 04, 2013, 10:16:53 PM by HonoredMule »

Offline UncleSam

  • Posts: 279
  • Karma: -2
  • Since: 22/01/2013
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Toggle Question
« Reply #2 on: April 04, 2013, 05:54:14 PM »
It doesn't really work.  I'll go ask on urt forums.  Thanks.

Offline HonoredMule

  • Posts: 54
  • Karma: 1
  • Since: 19/05/2012
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Toggle Question
« Reply #3 on: April 04, 2013, 10:14:38 PM »
I had a typo which might have caused a problem for you.  Note the removal of '+' from before 'vstr' in the sticky bind.

Offline UncleSam

  • Posts: 279
  • Karma: -2
  • Since: 22/01/2013
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Toggle Question
« Reply #4 on: April 05, 2013, 10:53:52 AM »
I found that and replaced it before I tried the script, it still didn't work though.  When I clicked mouse3 it attacked extremely fast and then I could not switch weapons.  It was weird.  Some guy on the urt forums did answer me and it works you'll find it in the "some cool scripts" thread.

Offline HonoredMule

  • Posts: 54
  • Karma: 1
  • Since: 19/05/2012
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Toggle Question
« Reply #5 on: April 10, 2013, 10:14:57 PM »
When I clicked mouse3 it attacked extremely fast and then I could not switch weapons.

Then it sounds like you need "+attack; -attack" rather than just "attack"