User panel stuff on forum
  20 posts on 1 page  1
Client Talk
2012-10-21, 06:16
Member
14 posts

Registered:
Jan 2006
It makes extensive use of simple math. It has an execution stack. Weapons currently fired (by holding down the button) are being saved in a cvar. If button gets released, the weapon is deleted from the stack. It will always pop the latest weapon of the stack into your hand while firing. It will never block and cease firing when weapon-button is pressed.

An example for what it really does:

You can press and HOLD the buttons in a row:

First, you press RL, hold it, it fires RL.
Then press LG, hold it, it fires LG.
Then press GL, hold it, it fires GL.
Then press SNG, hold it, it fires SNG now.

At this time, you hold 4 buttons! - this won't happen in real, but the script can even handle 9 firing-buttons pressed at a time.

Now.. to the proof:
Release SNG button. It fires GL now - because it remembered the series .. remember, you still hold RL, LG and GL
Now, release LG, it still fires GL, because it's the last button in the series that is still active and you still hold it.
Release GL, and then it fires RL..

Whilst the whole process it never blocked the firing!

So .. why all the hassle? Because I can. It's the best non-blocking weapon script ever made.

For more info on crazyness, set h_debug 1 in the script there.

Now, to the .. history:
First it looked more like this... (warning, the following snippet does not work by copy&paste)

alias +h_quick5 "h_weapon5; set h_firing 5; +attack"
alias -h_quick5 "if $h_firing == 5 h_quick5over"
alias h_quick5over "-attack; h_3backweapon"
bind alt "+h_quick5"

alias +h_quick4 "noaim 0; h_weapon3; set h_firing 3; +attack"
alias -h_quick4 "if $h_firing == 3 h_quick4over"
alias h_quick4over "-attack; h_3backweapon; noaim 1"
bind shift "+h_quick4"

alias +h_quick3 "h_weapon8; set h_firing 8; h_shaftzoom; h_shaftsens; h_shaftcross; h_shaftcrosssize; h_debugsens; +attack"
alias -h_quick3 "if $h_firing == 8 h_quick3over; h_normsens; h_normfov; h_normcross; h_normcrosssize; h_debugsens"
alias h_quick3over "-attack; h_8backweapon"
bind ctrl "+h_quick3"

alias +h_quick2 "h_weapon6; set h_firing 6; +attack"
alias -h_quick2 "if $h_firing == 6 h_quick2over"
alias h_quick2over "-attack; h_6backweapon"
bind space "+h_quick2"

alias +h_quick1 "h_weapon7; set h_firing 7; +attack"
alias -h_quick1 "if $h_firing == 7 h_quick1over"
alias h_quick1over "-attack; h_7backweapon"
bind mouse1 "+h_quick1"


..But then, I thought, this can be real great stuff! Fuck mordor, I simply walk there and pitch a tent!:


// weapons
alias h_weapon "" // fake alias
alias h_weapon1 "impulse 1 2 3 5 8 4"
alias h_weapon2 "impulse 2 3 8 1"
alias h_weapon3 "impulse 3 2 8 1"
alias h_weapon4 "impulse 4 5 8 3 2 1"
alias h_weapon5 "impulse 5 3 8 4 2 1"
alias h_weapon6 "impulse 6 8 5 3 4 2 1" // insecure
alias h_weapon7 "impulse 7 8 5 3 4 2 1" // insecure
alias h_weapon8 "impulse 8 5 3 4 2 1"


///////////////////////////////////////////////////////////////////////
set h_debug 0 // for debug

set pushstr "0" // for debug always init with 0

// calculates h_multi which is the multiplyer for addition or deletion
alias h_calcmulti "if %1 == 0 then set h_multi 1; if %1 == 1 then set h_multi 10; if %1 == 2 then set h_multi 100; if %1 == 3 then set h_multi 1000; if %1 == 4 then set h_multi 10000; if %1 == 5 then set h_multi 100000; if %1 == 6 then set h_multi 1000000; if %1 == 7 then set h_multi 10000000; if %1 == 8 then set h_multi 100000000"

// pushes a value to %1
alias h_push "set_calc h_tmp strlen $%1; h_calcmulti $h_tmp; set_calc h_tmp $h_multi * %2; set_calc %1 $%1 + $h_tmp; if $h_debug == 1 echo pushed %2 into %1, now: $%1"

// saves pop value to h_popped
alias h_pop "set_calc h_popped substr %1 0 2; set_calc h_tmp strlen $%1; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmp $h_multi * $h_popped; set_calc %1 $%1 - $h_tmp; if $h_debug == 1 echo popped $h_popped from %1. %1 now $%1"

// saves topmost value to h_topped
alias h_top "set_calc h_topped substr %1 0 2"

// decrease by "50" or "500" .. or whatever
alias h_replace "set_calc h_tmppos pos %1 %2; set_calc h_tmplen strlen $%1; set_calc h_tmp $h_tmplen - $h_tmppos; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * %2; set_calc %1 $%1 - $h_tmpval; set h_npos $h_tmppos; if $h_npos > 0 then h_priv_replacenext %1"
alias h_priv_replacenext "set_calc h_npos $h_npos - 1; set_calc h_nnum substr %1 $h_npos 2; set_calc h_tmplen strlen $%1; set_calc h_tmp $h_tmplen - $h_npos; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * $h_nnum; set_calc %1 $%1 - $h_tmpval; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * $h_nnum; set_calc %1 $%1 + $h_tmpval; if $h_npos > 0 then h_priv_replacenext %1 else if $h_debug == 1 then echo deleted %2 so %1 now: $%1"



h_push pushstr 7 // for debug
h_push pushstr 5 // for debug
h_push pushstr 6 // for debug
h_push pushstr 9 // for debug

//h_pop pushstr // for debug
//echo pop: $h_popped // for debug

//h_push pushstr 9 // for debug

//h_pop pushstr // for debug
//echo pop: $h_popped // for debug


alias h_weaponpop "h_top h_firingstack; h_weapon$h_topped"

set h_firing 0
set h_firingstack "0"

alias +h_quick5 "h_weapon5; inc h_firing 1; h_push h_firingstack 5; +attack"
alias -h_quick5 "inc h_firing -1; h_replace h_firingstack 5; h_weaponpop; if $h_firing == 0 then h_quick5over"
alias h_quick5over "-attack; h_3backweapon"

alias +h_quick4 "noaim 0; h_weapon3; inc h_firing 1; h_push h_firingstack 3; +attack"
alias -h_quick4 "inc h_firing -1; h_replace h_firingstack 3; h_weaponpop; if $h_firing == 0 then h_quick4over"
alias h_quick4over "-attack; h_3backweapon; noaim 1"

alias +h_quick3 "h_weapon8; inc h_firing 1; h_shaftzoom; h_shaftsens; h_shaftcross; h_shaftcrosssize; h_debugsens; h_push h_firingstack 8; +attack"
alias -h_quick3 "inc h_firing -1; h_replace h_firingstack 8; h_weaponpop; if $h_firing == 0 h_quick3over; h_normsens; h_normfov; h_normcross; h_normcrosssize; h_debugsens"
alias h_quick3over "-attack; h_8backweapon"

alias +h_quick2 "h_weapon6; inc h_firing 1; h_push h_firingstack 6; +attack"
alias -h_quick2 "inc h_firing -1; h_replace h_firingstack 6; h_weaponpop; if $h_firing == 0 then h_quick2over"
alias h_quick2over "-attack; h_6backweapon"

alias +h_quick1 "h_weapon7; inc h_firing 1; h_push h_firingstack 7; +attack"
alias -h_quick1 "inc h_firing -1; h_replace h_firingstack 7; h_weaponpop; if $h_firing == 0 then h_quick1over"
alias h_quick1over "-attack; h_7backweapon"


bind alt "+h_quick5" // SNG, NG .. see h_weapon5 above.
bind mouse1 "+h_quick1" // RL .. see h_weapon7 above.
bind space "+h_quick2" // GL h_weapon6
bind ctrl "+h_quick3" // LG h_weapon8
bind shift "+h_quick4" // SG, SSG h_weapon 3


bind mouse2 "+jump"
///////////////////////////////////////////////////////////////////////

sensitivity "1"
///////////////////////////////////////////////////////////////////////

alias h_debugsens "if $h_debug == 1 echo fov: $fov m_pitch: $m_pitch m_yaw: $m_yaw"

crosshairimage haudrauf
alias h_shaftcross "crosshair 3"
alias h_normcross "crosshair 3"

alias h_shaftcrosssize "crosshairsize 1"
alias h_normcrosssize "crosshairsize 1"

alias h_shaftzoom "fov 125" // - SHAFT FOV (zoom) //
alias h_shaftsens "m_pitch 0.044; m_yaw 0.039" // - WELCHE SENS BEI SHAFT? //

alias h_normfov "fov 125" // - NORMAL FOV //
alias h_normsens "m_pitch 0.085; m_yaw 0.048" // - WELCHE SENS NORMAL // -> sens 7 m_pitch 0.022 = m_pitch 0.154 bei sens 1
////////////////////////////////////////////////////////////////////////////////////////
alias dmm3-8backweapon "h_weapon5" //
alias dmm3-7backweapon "h_weapon2" // which weapon after firing in hand on DMM3?
alias dmm3-6backweapon "h_weapon5" //
alias dmm3-3backweapon "h_weapon2" //
////////////////////////////////////////////////////////////////////////////////////////
alias dmm1-8backweapon "h_weapon2" //
alias dmm1-7backweapon "h_weapon2" // which weapon after firing in hand on DMM1?
alias dmm1-6backweapon "h_weapon2" //
alias dmm1-3backweapon "h_weapon2" //
////////////////////////////////////////////////////////////////////////////////////////
alias h_8backweapon dmm1-8backweapon // for defaults
alias h_7backweapon dmm1-7backweapon
alias h_6backweapon dmm1-6backweapon
alias h_3backweapon dmm1-3backweapon
/////////////



And then, it came to my mind ... it's all easier using TCL. So, I implemented the same functionality with a TCL script. So, you can forget all the code above (although it's the cool part with a lot of brainfuck)!

Put the following contents into a .TCL file.

For a nicer look at the TCL visit: http://pastebin.com/2Jqekx55

set weaponstack ""

proc lremove {thelist value} {
set idx [lsearch -exact -all $thelist $value]
set idx [lsort -decreasing -integer $idx]
foreach _idx $idx {
set thelist [lreplace $thelist $_idx $_idx]
}
return $thelist
}

alias +h_quick {weapon} {
global weaponstack


lappend weaponstack $weapon

cmd h_weapon$weapon
if {$::h_debug == 1} {
cmd echo w: $weapon stack: $weaponstack
}
cmd +attack
}

alias -h_quick {weapon} {
global weaponstack

set weaponstack [lremove "$weaponstack" "$weapon"]

if {$::h_debug == 1} {
cmd echo "released w: $weapon stack: $weaponstack"
}

set itemcnt [llength $weaponstack]
if {$itemcnt == 0} {
cmd -attack
} else {
set next_in_stack [lindex $weaponstack end]
if {$::weaponnum != $next_in_stack} {
cmd h_weapon$next_in_stack
}
}
}


Then, still, the h_weapon1-8 aliases are missing. The TCL-script will call the h_weapon1-8 aliases according to the binds.

Put these h_weapon1-8 aliases into a normal config and have that config exec the TCL script:

// weapons
alias h_weapon "" // fake alias
alias h_weapon1 "impulse 1 2 3 5 8 4"
alias h_weapon2 "impulse 2 3 8 1"
alias h_weapon3 "impulse 3 2 8 1"
alias h_weapon4 "impulse 4 5 8 3 2 1"
alias h_weapon5 "impulse 5 3 8 4 2 1"
alias h_weapon6 "impulse 6 8 5 3 4 2 1" // insecure
alias h_weapon7 "impulse 7 8 5 3 4 2 1" // insecure
alias h_weapon8 "impulse 8 5 3 4 2 1"

// EXEC the TCL script
set h_debug 1
tcl_exec weapons.tcl

//////// BINDINGS
// SNG, NG .. see h_weapon5 above.
bind alt "+h_quick 5"
// RL .. see h_weapon7 above.
bind mouse1 "+h_quick 7"
// GL h_weapon6
bind space "+h_quick 6"
// LG h_weapon8
bind ctrl "+h_quick 8"
// SG, SSG h_weapon 3
cmd bind shift "+h_quick 3"
////////// So, when you press mouse1, the TCL script will call the alias "h_weapon7". And, on ctrl it starts "h_weapon8", and so on.


Of course, you may as well use your own weapon-switcher impulses on h_weapon1-8.

Now it's all set. You probably only need to re-bind the functions to your needs.


If you can make any sense out of this, you're quite entitled to use this script.


Have fun.

edit: Updated this first post to have every explanation needed to use it.

(Edited 2012-10-22, 22:51)
The guy from #qwnet with the ServeMe bots. Also, #aq2world in case anyone cares. ;-)
2012-10-21, 11:40
Member
792 posts

Registered:
Feb 2006
hah, wow that's great, thanks. still reading through but i can already tell i like your approach
2012-10-21, 14:07
Member
14 posts

Registered:
Jan 2006
Thanks. I really appreciate any comment. I already thought nobody cares for cool stuff.
The guy from #qwnet with the ServeMe bots. Also, #aq2world in case anyone cares. ;-)
2012-10-21, 16:17
Administrator
864 posts

Registered:
Jan 2006
Hej!
Sounds like good thing to have. Now, does this come with an installer... How do one implement this? Thanks for sharing man!
IRC went Discord -> join the chats @ discord.quake.world
2012-10-21, 22:17
Member
14 posts

Registered:
Jan 2006
I implemented the same functionality now with TCL.
Of course, a lot easier

Put it into a .tcl file and do tcl_exec filename.tcl in your configs.

Code-Block follows .. or just visit: http://pastebin.com/2Jqekx55

set weaponstack ""
set ::h_debug 1

proc lremove {thelist value} {
set idx [lsearch -exact -all $thelist $value]
set idx [lsort -decreasing -integer $idx]
foreach _idx $idx {
set thelist [lreplace $thelist $_idx $_idx]
}
return $thelist
}

alias +h_quick {weapon} {
global weaponstack


lappend weaponstack $weapon

cmd h_weapon$weapon
if {$::h_debug == 1} {
cmd echo w: $weapon stack: $weaponstack
}
cmd +attack
}

alias -h_quick {weapon} {
global weaponstack

set weaponstack [lremove "$weaponstack" "$weapon"]

if {$::h_debug == 1} {
cmd echo "released w: $weapon stack: $weaponstack"
}

set itemcnt [llength $weaponstack]
if {$itemcnt == 0} {
cmd -attack
} else {
set next_in_stack [lindex $weaponstack end]
if {$::weaponnum != $next_in_stack} {
cmd h_weapon$next_in_stack
}
}
}

# SNG, NG .. see h_weapon5 above.
cmd bind alt "+h_quick 5"

# RL .. see h_weapon7 above.
cmd bind mouse1 "+h_quick 7"

# GL h_weapon6
cmd bind space "+h_quick 6"

# LG h_weapon8
cmd bind ctrl "+h_quick 8"

# SG, SSG h_weapon 3
cmd bind shift "+h_quick 3"


(Edited 2012-10-23, 11:08)
The guy from #qwnet with the ServeMe bots. Also, #aq2world in case anyone cares. ;-)
2012-10-21, 22:24
Member
1732 posts

Registered:
Jan 2007
(.)
I'm all ears!
Why?.... Because you can!
*** www.signedcmn.nl ***
2012-10-22, 09:16
Member
219 posts

Registered:
Aug 2011
I normally have no issues when trixing with cfgs, but I could not get this to work.

Can you perhaps dumb down the explanation on how to make it work a few notches?
carrier has arrived - twitch.tv/carapace_
2012-10-22, 09:21
Member
364 posts

Registered:
Oct 2006
By the looks of it, with a bit of effort this script could run Linux
2012-10-22, 09:28
Administrator
325 posts

Registered:
Jan 2006
if u have quickfire for different weapons on different buttons, u can press them simultaneously and it won't stop firing. I think that's the gist of it =)
ready!
2012-10-22, 09:43
Member
14 posts

Registered:
Jan 2006
Take the TCL-version: http://www.quakeworld.nu/forum/topic/5900/page/last#91681

Paste all into a weapons.tcl and then "tcl_exec weapons.tcl" from your normal configs.
Then, still, the h_weapon1-8 aliases are missing. The TCL-script will call the h_weapon1-8 aliases according to the binds.

Put these into a normal config:

set h_debug 1
// weapons
alias h_weapon "" // fake alias
alias h_weapon1 "impulse 1 2 3 5 8 4"
alias h_weapon2 "impulse 2 3 8 1"
alias h_weapon3 "impulse 3 2 8 1"
alias h_weapon4 "impulse 4 5 8 3 2 1"
alias h_weapon5 "impulse 5 3 8 4 2 1"
alias h_weapon6 "impulse 6 8 5 3 4 2 1" // insecure
alias h_weapon7 "impulse 7 8 5 3 4 2 1" // insecure
alias h_weapon8 "impulse 8 5 3 4 2 1"


The binds are, for example,

bind mouse1 "+h_quick 7"
bind ctrl "+h_quick 8"

So, when you press mouse1, the TCL script will call the alias "h_weapon7". And, on ctrl it starts "h_weapon8", and so on.

I updated the first post to have it explained better. The TCL-version is now there as well.

(Edited 2012-10-23, 00:38)
The guy from #qwnet with the ServeMe bots. Also, #aq2world in case anyone cares. ;-)
2012-10-22, 11:00
Member
219 posts

Registered:
Aug 2011
I dont understand the code at all, so I could perhaps never appreciate the code behind the script as much as appropriate. I do however appreciate how it works and the work you put behind it. Thank you!
carrier has arrived - twitch.tv/carapace_
2012-10-22, 14:04
Administrator
1246 posts

Registered:
Jan 2006
ahah using TCL for weapon scripts!
=)
can't wait to try it! gj and thanks for sharing!
=)
never argue with an idiot. they'll bring you back to their level and then beat you with experience.
2014-03-06, 10:18
Administrator
1246 posts

Registered:
Jan 2006
forgot to reply here,
been using this for 1 year! its fast and smart, and doesn't block. i remember i've had an issue with it, but i can't tell which right now. but i've stick to it, so its nothing important.

great job haudrauf!
never argue with an idiot. they'll bring you back to their level and then beat you with experience.
2015-07-04, 14:20
Member
219 posts

Registered:
Aug 2011
With the release of ezQ 3.0 and the lack of TCL-script support, I decided to share a regular config version of the weapon script that works in ezQ 3.0. This version is dumbed down enough for me to understand and work with, so I hope its easy enough for anyone to use.

Copy+paste the code blow into a wscript.cfg placed in your "nQuake/qw/" folder. Suggestion: Add "exec wscript.cfg" somewhere in your "nQuake/qw/autoexec.cfg".

What needs to be changed to fit your needs?
The weapon priority works well for me. You could however add LG (impulse 8) if youre not as concerned about cell count as me.
The script part should stay as is, unless you want to tidy it up a bit.
The binds are the important part;
The setup is currently set to have mouse2 as a variable button, firing either SG, SSG, SNG or LG upon my choosing. Mouse1 fires RL only and mouse3 GL only.
Changing the button of the bind should be self-explanatory.
If you want to use a specific button to fire a specific weapon: You need to use the '+h_quick#' command.
If you want to keep a button for firing variable: You need to re-alias your h_weapon9 (the variable) into something else by the press of a specific button, while keeping the variable firing button always set to '+h_quick9'. You are essentially "rebinding" your variable firing button over time, but by changing the aliases.

/// Weapon Priority

alias h_weapon ""
alias h_weapon1 "impulse 1 2 3 5 4"
alias h_weapon2 "impulse 2 3 1"
alias h_weapon3 "impulse 3 2 1"
alias h_weapon4 "impulse 4 5 3 2 1"
alias h_weapon5 "impulse 5 3 4 2 1"
alias h_weapon6 "impulse 6 5 3 4 2 1"
alias h_weapon7 "impulse 7 5 3 4 2 1"
alias h_weapon8 "impulse 8 5 3 4 2 1"

alias h_weapon9 "h_weapon2" // Default setting

/// Weapon Script

set h_debug 0 // for debug

set pushstr "0" // for debug always init with 0

// calculates h_multi which is the multiplyer for addition or deletion
alias h_calcmulti "if %1 == 0 then set h_multi 1; if %1 == 1 then set h_multi 10; if %1 == 2 then set h_multi 100; if %1 == 3 then set h_multi 1000; if %1 == 4 then set h_multi 10000; if %1 == 5 then set h_multi 100000; if %1 == 6 then set h_multi 1000000; if %1 == 7 then set h_multi 10000000; if %1 == 8 then set h_multi 100000000"

// pushes a value to %1
alias h_push "set_calc h_tmp strlen $%1; h_calcmulti $h_tmp; set_calc h_tmp $h_multi * %2; set_calc %1 $%1 + $h_tmp; if $h_debug == 1 echo pushed %2 into %1, now: $%1"

// saves pop value to h_popped
alias h_pop "set_calc h_popped substr %1 0 2; set_calc h_tmp strlen $%1; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmp $h_multi * $h_popped; set_calc %1 $%1 - $h_tmp; if $h_debug == 1 echo popped $h_popped from %1. %1 now $%1"

// saves topmost value to h_topped
alias h_top "set_calc h_topped substr %1 0 2"

// decrease by "50" or "500" .. or whatever
alias h_replace "set_calc h_tmppos pos %1 %2; set_calc h_tmplen strlen $%1; set_calc h_tmp $h_tmplen - $h_tmppos; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * %2; set_calc %1 $%1 - $h_tmpval; set h_npos $h_tmppos; if $h_npos > 0 then h_priv_replacenext %1"
alias h_priv_replacenext "set_calc h_npos $h_npos - 1; set_calc h_nnum substr %1 $h_npos 2; set_calc h_tmplen strlen $%1; set_calc h_tmp $h_tmplen - $h_npos; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * $h_nnum; set_calc %1 $%1 - $h_tmpval; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * $h_nnum; set_calc %1 $%1 + $h_tmpval; if $h_npos > 0 then h_priv_replacenext %1 else if $h_debug == 1 then echo deleted %2 so %1 now: $%1"

h_push pushstr 7 // for debug
h_push pushstr 5 // for debug
h_push pushstr 6 // for debug
h_push pushstr 9 // for debug

//h_pop pushstr // for debug
//echo pop: $h_popped // for debug

//h_push pushstr 9 // for debug

//h_pop pushstr // for debug
//echo pop: $h_popped // for debug

alias h_weaponpop "h_top h_firingstack; h_weapon$h_topped"

set h_firing 0
set h_firingstack "0"

alias +h_quick1 "h_weapon1; inc h_firing 1; h_push h_firingstack 1; +attack"
alias -h_quick1 "inc h_firing -1; h_replace h_firingstack 1; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick2 "h_weapon2; inc h_firing 1; h_push h_firingstack 2; +attack"
alias -h_quick2 "inc h_firing -1; h_replace h_firingstack 2; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick3 "h_weapon3; inc h_firing 1; h_push h_firingstack 3; +attack"
alias -h_quick3 "inc h_firing -1; h_replace h_firingstack 3; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick4 "h_weapon4; inc h_firing 1; h_push h_firingstack 4; +attack"
alias -h_quick4 "inc h_firing -1; h_replace h_firingstack 4; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick5 "h_weapon5; inc h_firing 1; h_push h_firingstack 5; +attack"
alias -h_quick5 "inc h_firing -1; h_replace h_firingstack 5; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick6 "h_weapon6; inc h_firing 1; h_push h_firingstack 6; +attack"
alias -h_quick6 "inc h_firing -1; h_replace h_firingstack 6; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick7 "h_weapon7; inc h_firing 1; h_push h_firingstack 7; +attack"
alias -h_quick7 "inc h_firing -1; h_replace h_firingstack 7; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick8 "h_weapon8; inc h_firing 1; h_push h_firingstack 8; +attack"
alias -h_quick8 "inc h_firing -1; h_replace h_firingstack 8; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick9 "h_weapon9; inc h_firing 1; h_push h_firingstack 9; +attack"
alias -h_quick9 "inc h_firing -1; h_replace h_firingstack 9; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"


/// Weapon Binds

bind mouse2 "+h_quick9" // Variable
bind mouse1 "+h_quick7" // RL
bind mouse3 "+h_quick6" // GL
bind r "alias h_weapon9 h_weapon5" // <SNG>
bind q "alias h_weapon9 h_weapon2" // <SG>
bind shift "alias h_weapon9 h_weapon8" // <LG>
bind e "alias h_weapon9 h_weapon3" // <SSG>


I hope my explanation was clear enough! All credit goes to Haudrauf for this script.

(Edited 2015-09-03, 13:40)
carrier has arrived - twitch.tv/carapace_
2015-07-04, 14:31
Member
278 posts

Registered:
Jan 2015
Why not to use alias +firerl "impulse 7 6 5 3 4 2; +attack" and -firerl "-attack; impulse 2 1" for example?
What do I get from all the scripting besides that?
dev
2015-07-05, 00:47
Member
219 posts

Registered:
Aug 2011
andrestone wrote:
Why not to use alias +firerl "impulse 7 6 5 3 4 2; +attack" and -firerl "-attack; impulse 2 1" for example?
What do I get from all the scripting besides that?


Read the first post.
carrier has arrived - twitch.tv/carapace_
2015-07-05, 12:04
Member
278 posts

Registered:
Jan 2015
cara wrote:
andrestone wrote:
Why not to use alias +firerl "impulse 7 6 5 3 4 2; +attack" and -firerl "-attack; impulse 2 1" for example?
What do I get from all the scripting besides that?


Read the first post.


Is it all about the ability to fire a weapon by pressing a button without needing to let go the button that fired the previous weapon?
dev
2015-07-29, 19:04
Member
278 posts

Registered:
Jan 2015
cara wrote:
With the release of ezQ 3.0 and the lack of TCL-script support, I decided to share a regular config version of the weapon script that works in ezQ 3.0. This version is dumbed down enough for me to understand and work with, so I hope its easy enough for anyone to use.

Copy+paste the code blow into a wscript.cfg placed in your "nQuake/qw/" folder. Suggestion: Add "exec wscript.cfg" somewhere in your "nQuake/qw/autoexec.cfg".

What needs to be changed to fit your needs?
The weapon priority works well for me. You could however add LG (impulse 8) if youre not as concerned about cell count as me.
The script part should stay as is, unless you want to tidy it up a bit.
The binds are the important part;
The setup is currently set to have mouse2 as a variable button, firing either SG, SSG, SNG or LG upon my choosing. Mouse1 fires RL only and mouse3 GL only.
Changing the button of the bind should be self-explanatory.
If you want to use a specific button to fire a specific weapon: You need to use the '+h_quick#' command.
If you want to keep a button for firing variable: You need to re-alias your h_weapon9 (the variable) into something else by the press of a specific button, while keeping the variable firing button always set to '+h_quick9'. You are essentially "rebinding" your variable firing button over time, but by changing the aliases.

/// Weapon Priority

alias h_weapon ""
alias h_weapon1 "impulse 1 2 3 5 4"
alias h_weapon2 "impulse 2 3 1"
alias h_weapon3 "impulse 3 2 1"
alias h_weapon4 "impulse 4 5 3 2 1"
alias h_weapon5 "impulse 5 3 4 2 1"
alias h_weapon6 "impulse 6 5 3 4 2 1"
alias h_weapon7 "impulse 7 5 3 4 2 1"
alias h_weapon8 "impulse 8 5 3 4 2 1"

alias h_weapon9 "h_weapon2" // Default setting

/// Weapon Script

set h_debug 0 // for debug

set pushstr "0" // for debug always init with 0

// calculates h_multi which is the multiplyer for addition or deletion
alias h_calcmulti "if %1 == 0 then set h_multi 1; if %1 == 1 then set h_multi 10; if %1 == 2 then set h_multi 100; if %1 == 3 then set h_multi 1000; if %1 == 4 then set h_multi 10000; if %1 == 5 then set h_multi 100000; if %1 == 6 then set h_multi 1000000; if %1 == 7 then set h_multi 10000000; if %1 == 8 then set h_multi 100000000"

// pushes a value to %1
alias h_push "set_calc h_tmp strlen $%1; h_calcmulti $h_tmp; set_calc h_tmp $h_multi * %2; set_calc %1 $%1 + $h_tmp; if $h_debug == 1 echo pushed %2 into %1, now: $%1"

// saves pop value to h_popped
alias h_pop "set_calc h_popped substr %1 0 2; set_calc h_tmp strlen $%1; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmp $h_multi * $h_popped; set_calc %1 $%1 - $h_tmp; if $h_debug == 1 echo popped $h_popped from %1. %1 now $%1"

// saves topmost value to h_topped
alias h_top "set_calc h_topped substr %1 0 2"

// decrease by "50" or "500" .. or whatever
alias h_replace "set_calc h_tmppos pos %1 %2; set_calc h_tmplen strlen $%1; set_calc h_tmp $h_tmplen - $h_tmppos; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * %2; set_calc %1 $%1 - $h_tmpval; set h_npos $h_tmppos; if $h_npos > 0 then h_priv_replacenext %1"
alias h_priv_replacenext "set_calc h_npos $h_npos - 1; set_calc h_nnum substr %1 $h_npos 2; set_calc h_tmplen strlen $%1; set_calc h_tmp $h_tmplen - $h_npos; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * $h_nnum; set_calc %1 $%1 - $h_tmpval; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * $h_nnum; set_calc %1 $%1 + $h_tmpval; if $h_npos > 0 then h_priv_replacenext %1 else if $h_debug == 1 then echo deleted %2 so %1 now: $%1"

h_push pushstr 7 // for debug
h_push pushstr 5 // for debug
h_push pushstr 6 // for debug
h_push pushstr 9 // for debug

//h_pop pushstr // for debug
//echo pop: $h_popped // for debug

//h_push pushstr 9 // for debug

//h_pop pushstr // for debug
//echo pop: $h_popped // for debug

alias h_weaponpop "h_top h_firingstack; h_weapon$h_topped"

set h_firing 0
set h_firingstack "0"

alias +h_quick1 "h_weapon1; inc h_firing 1; h_push h_firingstack 1; +attack"
alias -h_quick1 "inc h_firing -1; h_replace h_firingstack 1; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick2 "h_weapon2; inc h_firing 1; h_push h_firingstack 2; +attack"
alias -h_quick2 "inc h_firing -1; h_replace h_firingstack 2; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick3 "h_weapon3; inc h_firing 1; h_push h_firingstack 3; +attack"
alias -h_quick3 "inc h_firing -1; h_replace h_firingstack 3; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick4 "h_weapon4; inc h_firing 1; h_push h_firingstack 4; +attack"
alias -h_quick4 "inc h_firing -1; h_replace h_firingstack 4; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick5 "h_weapon5; inc h_firing 1; h_push h_firingstack 5; +attack"
alias -h_quick6 "inc h_firing -1; h_replace h_firingstack 5; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick6 "h_weapon6; inc h_firing 1; h_push h_firingstack 6; +attack"
alias -h_quick6 "inc h_firing -1; h_replace h_firingstack 6; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick7 "h_weapon7; inc h_firing 1; h_push h_firingstack 7; +attack"
alias -h_quick7 "inc h_firing -1; h_replace h_firingstack 7; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick8 "h_weapon8; inc h_firing 1; h_push h_firingstack 8; +attack"
alias -h_quick8 "inc h_firing -1; h_replace h_firingstack 8; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick9 "h_weapon9; inc h_firing 1; h_push h_firingstack 9; +attack"
alias -h_quick9 "inc h_firing -1; h_replace h_firingstack 9; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"


/// Weapon Binds

bind mouse2 "+h_quick9" // Variable
bind mouse1 "+h_quick7" // RL
bind mouse3 "+h_quick6" // GL
bind r "alias h_weapon9 h_weapon5" // <SNG>
bind q "alias h_weapon9 h_weapon2" // <SG>
bind shift "alias h_weapon9 h_weapon8" // <LG>
bind e "alias h_weapon9 h_weapon3" // <SSG>


I hope my explanation was clear enough! All credit goes to Haudrauf for this script.


I am using it. Thanks.
dev
2015-08-30, 14:34
Member
459 posts

Registered:
Mar 2008
cara wrote:
With the release of ezQ 3.0 and the lack of TCL-script support, I decided to share a regular config version of the weapon script that works in ezQ 3.0. This version is dumbed down enough for me to understand and work with, so I hope its easy enough for anyone to use.

Copy+paste the code blow into a wscript.cfg placed in your "nQuake/qw/" folder. Suggestion: Add "exec wscript.cfg" somewhere in your "nQuake/qw/autoexec.cfg".

What needs to be changed to fit your needs?
The weapon priority works well for me. You could however add LG (impulse 8) if youre not as concerned about cell count as me.
The script part should stay as is, unless you want to tidy it up a bit.
The binds are the important part;
The setup is currently set to have mouse2 as a variable button, firing either SG, SSG, SNG or LG upon my choosing. Mouse1 fires RL only and mouse3 GL only.
Changing the button of the bind should be self-explanatory.
If you want to use a specific button to fire a specific weapon: You need to use the '+h_quick#' command.
If you want to keep a button for firing variable: You need to re-alias your h_weapon9 (the variable) into something else by the press of a specific button, while keeping the variable firing button always set to '+h_quick9'. You are essentially "rebinding" your variable firing button over time, but by changing the aliases.

/// Weapon Priority

alias h_weapon ""
alias h_weapon1 "impulse 1 2 3 5 4"
alias h_weapon2 "impulse 2 3 1"
alias h_weapon3 "impulse 3 2 1"
alias h_weapon4 "impulse 4 5 3 2 1"
alias h_weapon5 "impulse 5 3 4 2 1"
alias h_weapon6 "impulse 6 5 3 4 2 1"
alias h_weapon7 "impulse 7 5 3 4 2 1"
alias h_weapon8 "impulse 8 5 3 4 2 1"

alias h_weapon9 "h_weapon2" // Default setting

/// Weapon Script

set h_debug 0 // for debug

set pushstr "0" // for debug always init with 0

// calculates h_multi which is the multiplyer for addition or deletion
alias h_calcmulti "if %1 == 0 then set h_multi 1; if %1 == 1 then set h_multi 10; if %1 == 2 then set h_multi 100; if %1 == 3 then set h_multi 1000; if %1 == 4 then set h_multi 10000; if %1 == 5 then set h_multi 100000; if %1 == 6 then set h_multi 1000000; if %1 == 7 then set h_multi 10000000; if %1 == 8 then set h_multi 100000000"

// pushes a value to %1
alias h_push "set_calc h_tmp strlen $%1; h_calcmulti $h_tmp; set_calc h_tmp $h_multi * %2; set_calc %1 $%1 + $h_tmp; if $h_debug == 1 echo pushed %2 into %1, now: $%1"

// saves pop value to h_popped
alias h_pop "set_calc h_popped substr %1 0 2; set_calc h_tmp strlen $%1; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmp $h_multi * $h_popped; set_calc %1 $%1 - $h_tmp; if $h_debug == 1 echo popped $h_popped from %1. %1 now $%1"

// saves topmost value to h_topped
alias h_top "set_calc h_topped substr %1 0 2"

// decrease by "50" or "500" .. or whatever
alias h_replace "set_calc h_tmppos pos %1 %2; set_calc h_tmplen strlen $%1; set_calc h_tmp $h_tmplen - $h_tmppos; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * %2; set_calc %1 $%1 - $h_tmpval; set h_npos $h_tmppos; if $h_npos > 0 then h_priv_replacenext %1"
alias h_priv_replacenext "set_calc h_npos $h_npos - 1; set_calc h_nnum substr %1 $h_npos 2; set_calc h_tmplen strlen $%1; set_calc h_tmp $h_tmplen - $h_npos; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * $h_nnum; set_calc %1 $%1 - $h_tmpval; set_calc h_tmp $h_tmp - 1; h_calcmulti $h_tmp; set_calc h_tmpval $h_multi * $h_nnum; set_calc %1 $%1 + $h_tmpval; if $h_npos > 0 then h_priv_replacenext %1 else if $h_debug == 1 then echo deleted %2 so %1 now: $%1"

h_push pushstr 7 // for debug
h_push pushstr 5 // for debug
h_push pushstr 6 // for debug
h_push pushstr 9 // for debug

//h_pop pushstr // for debug
//echo pop: $h_popped // for debug

//h_push pushstr 9 // for debug

//h_pop pushstr // for debug
//echo pop: $h_popped // for debug

alias h_weaponpop "h_top h_firingstack; h_weapon$h_topped"

set h_firing 0
set h_firingstack "0"

alias +h_quick1 "h_weapon1; inc h_firing 1; h_push h_firingstack 1; +attack"
alias -h_quick1 "inc h_firing -1; h_replace h_firingstack 1; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick2 "h_weapon2; inc h_firing 1; h_push h_firingstack 2; +attack"
alias -h_quick2 "inc h_firing -1; h_replace h_firingstack 2; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick3 "h_weapon3; inc h_firing 1; h_push h_firingstack 3; +attack"
alias -h_quick3 "inc h_firing -1; h_replace h_firingstack 3; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick4 "h_weapon4; inc h_firing 1; h_push h_firingstack 4; +attack"
alias -h_quick4 "inc h_firing -1; h_replace h_firingstack 4; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick5 "h_weapon5; inc h_firing 1; h_push h_firingstack 5; +attack"
alias -h_quick6 "inc h_firing -1; h_replace h_firingstack 5; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick6 "h_weapon6; inc h_firing 1; h_push h_firingstack 6; +attack"
alias -h_quick6 "inc h_firing -1; h_replace h_firingstack 6; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick7 "h_weapon7; inc h_firing 1; h_push h_firingstack 7; +attack"
alias -h_quick7 "inc h_firing -1; h_replace h_firingstack 7; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick8 "h_weapon8; inc h_firing 1; h_push h_firingstack 8; +attack"
alias -h_quick8 "inc h_firing -1; h_replace h_firingstack 8; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"

alias +h_quick9 "h_weapon9; inc h_firing 1; h_push h_firingstack 9; +attack"
alias -h_quick9 "inc h_firing -1; h_replace h_firingstack 9; h_weaponpop; if $h_firing == 0 then h_quickover"
alias h_quickover "-attack; h_weapon2"


/// Weapon Binds

bind mouse2 "+h_quick9" // Variable
bind mouse1 "+h_quick7" // RL
bind mouse3 "+h_quick6" // GL
bind r "alias h_weapon9 h_weapon5" // <SNG>
bind q "alias h_weapon9 h_weapon2" // <SG>
bind shift "alias h_weapon9 h_weapon8" // <LG>
bind e "alias h_weapon9 h_weapon3" // <SSG>


I hope my explanation was clear enough! All credit goes to Haudrauf for this script.


Thanks for sharing. Working as intended!

There is a small "bug" in the SNG alias (there is no alias -h_quick5, it says -h_quick6 instead in the SNG section).
2015-09-01, 19:58
Member
219 posts

Registered:
Aug 2011
Thanks for reporting. I'll edit it when I get home.
carrier has arrived - twitch.tv/carapace_
  20 posts on 1 page  1