Nexuiz Ninjaz - Practicing the Ninja Art of Nexuiz

Full Version: [cfg] Weapon Switching Script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Group weapons and select from the group by pressing the same key repeatedly.

HOW IT WORKS
Press the middle mouse button to select the nex. Press it again to select the machine gun. Press f to select the hagar. Again for the electro and again for the mortar. This binds 5 weapons to just 2 keys. Then I have some regular binds for the shotgun, rocket launcher and laser.

WHY
There are 9 weapons, so it is difficult to quickly select the right weapon with the mouse wheel. Some people bind weapons to keys, but to access all of the weapons would require....anyone? Yes, it would require 9 keys. That just seems too hard to handle in the midst of battle. Hats off to those that can pull that off.

CUSTOMIZE IT
Change the key binds to whatever works best for you. Make your own groupings or add or delete from the groups I set up. If you look at the alias commands carefully you can see how they cycle.

USAGE NOTES
I use this with the auto-select weapon feature from the options screen. I think it does a pretty good job of picking the right weapon. If I don't want the weapon Nexuiz selects I can quickly switch to the one I do want.

When you start a game, the explosive weapon selection cycles through the group from choice 1 to 2 to 3 . But be aware that if you have the hagar, then switch to the shotgun and switch to explosive weapons again, it is cycling to the next explosive weapon, the electro. If you want the hagar press 2 more times.

You need to be somewhat aware of what weapons you have, so you aren't wasting time trying to select a weapon you don't have. If you don't have a weapon or you don't have ammo for a weapon, it won't select it. That means you'll still have the same weapon as before the key press (a message at the top of the screen tells you that the weapon couldn't be selected). Press again to get the next weapon in the group. With a little practice this becomes automatic.

I didn't put the crylink in at all. I can get it via auto-select if I have only the machine gun and shotgun and that works for me. I used to have it grouped with the shotgun, but decided to keep the shotgun by itself for maximum speed. I use the shotgun for when someone is right beside me, which means there is no time for an extra button press. Feel free to add the crylink in somewhere if you want it.

THE SCRIPT

Code:
// AceOfThumbs weapon grouping script -----------------------------
// switch weapons based on groupings by type
// Nexuiz impulse numbers: 9=rocket, 8=hagar, 7=nex, 6=crylink, 5=electro, 4=mortar, 3=machinegun, 2=shotgun, 1=laser

// this sets up a toggle for sniper weapons
// mg and nex will alternate each time this is called
alias "aot_ws1" "alias aot_nextws aot_ws2 ; impulse 3"
alias "aot_ws2" "alias aot_nextws aot_ws1 ; impulse 7"
alias "aot_nextws" "aot_ws1"

// this sets up a toggle for explosive weapons
// hagar, electro, mortor will alternate each time this is called
alias "aot_wp1" "alias aot_nextwp aot_wp2 ; impulse 8"
alias "aot_wp2" "alias aot_nextwp aot_wp3 ; impulse 5"
alias "aot_wp3" "alias aot_nextwp aot_wp1 ; impulse 4"
alias "aot_nextwp" "aot_wp1"

// key bindings
// sniper weapon
bind "MOUSE3" "aot_nextws"

// explosive weapon
bind "e" "aot_nextwp"

// shotgun
bind "MOUSE4" "impulse 2"

// rocket
bind "r" "impulse 9"

// laser
bind "MOUSE5" "impulse 1"

// END WEAPON SCRIPT

Well, I'm changing up my key binds and I'm not actually using this any more. It works pretty well on CTF, but doesn't seem to be the right set up for DM. I don't know if this will be my final set up, but I now use separate keys for RL, nex, shotgun and laser. I access the other weapons with the mouse wheel.

If any qc programmers are reading this, we really need the bestweapon command to work right.
No sooner did I post about bestweapon than I heard of a way to make it work!! Credit to div by way of Ronan for the code. You create one or many lists of weapons in the order you prefer. Bind those to keys and the script gives you the best weapon that you have and have ammo for.

For example, I made 3 groups, based on help from mkzelda and morfar's weapon data chart. One for the best close range weapon, one for the best medium range weapon and another for the best long range weapon. The groups may need a little tweaking, but initially seem pretty good.

Code:
// weapon grouping script --------------------------------------------------------------
// -------------------------------------------------------------------------------------
// Nexuiz impulse numbers: 9=rocket, 8=hagar, 7=nex, 6=crylink, 5=electro, 4=mortar, 3=machinegun, 2=shotgun, 1=laser

// fix for bestweapon command-doesn't work on 2.3 or earlier clients
alias aot_bw "register_bestweapon clear; register_bestweapon 1 1 4096 1 9 0; register_bestweapon 2 2 1 2 6 1; register_bestweapon 3 3 2 3 7 1; register_bestweapon 4 4 4 4 8 2; register_bestweapon 5 5 8 5 9 2; register_bestweapon 6 6 16 6 9 1; register_bestweapon 7 7 32 7 9 5; register_bestweapon 8 8 64 8 8 1; register_bestweapon 9 9 128 9 8 3"
aot_bw

// bind to b so you can execute again when a new game starts
bind b aot_bw

//close - sorted by small blast radius then damage per sec
// for crylink use alt fire for more shots at once
alias aot_w1  "bestweapon 8 3 2 6 7 1 4 5 9"

// medium - sorted by blast radius then damage per sec
alias aot_w2 "bestweapon 5 4 9 8 6 3 7 2 1"

// far - sorted by speed then minimum spread then damage per sec
// for mg use alt fire for less spread
alias aot_w3  "bestweapon 7 3 1 8 6 4 5 9 2"

alias aot_weap1 "aot_w1; alias aot_weap_in aot_weap2; alias aot_weap_out aot_weap1"
alias aot_weap2 "aot_w2; alias aot_weap_in aot_weap3; alias aot_weap_out aot_weap1"
alias aot_weap3 "aot_w3; alias aot_weap_in aot_weap3; alias aot_weap_out aot_weap2"
aot_weap2

// make bestweapon groups the default wheel behavior
in_bind 0 mwheelup aot_weap_in
in_bind 0 mwheeldown aot_weap_out

// rocket
bind "r" "impulse 9"

// laser
bind "MOUSE5" "impulse 1"

// END WEAPON SCRIPT


Warning: this doesn't work with the 2.3 version of Nexuiz. You need the newer SVN engine. You can learn how to get the newer engine here:
http://www.nexuizninjaz.com/forum/showthread.php?tid=53

Edited the post above: The fix is lost when a new game starts, so I added a key bind to the b key, so you can easily execute the fix again when you need to. If anyone knows a way to automatically execute an alias or config each time a new game starts, let me know.

Also, I switched the groupings. Originally, I had only a best hitscan weapon group and a best explosive weapon group. This was not quite enough.
Hey AoT, this might not be the best fix but it works...

code
// fix for bestweapon command-doesn't work on 2.3 or earlier clients
alias aot_bw "register_bestweapon clear; register_bestweapon 1 1 4096 1 9 0; register_bestweapon 2 2 1 2 6 1; register_bestweapon 3 3 2 3 7 1; register_bestweapon 4 4 4 4 8 2; register_bestweapon 5 5 8 5 9 2; register_bestweapon 6 6 16 6 9 1; register_bestweapon 7 7 32 7 9 5; register_bestweapon 8 8 64 8 8 1; register_bestweapon 9 9 128 9 8 3"
//aot_bw
//bind b aot_bw

// far - sorted by speed then minimum spread then damage per sec
bind "KP_HOME" "aot_bw; bestweapon 7 3 1 6 8 4 5 9 2"

//close - sorted by minimum blast radius then damage per sec
bind "KP_MINUS" "aot_bw; bestweapon 6 3 2 7 8 1 5 4 9"

// medium - sorted by blast radius then damage per sec
bind "KP_PGUP" "aot_bw; bestweapon 9 5 4 8 6 7 3 1 2"
//end
btw how did you get that neat little "code box" on your script
If you click on "Add Reply" then you get the full editor which will have options for inserting code. Or you can use the BBCode tags, which are just code and /code (with the brackets)

SoulBringer Wrote:
Hey AoT, this might not be the best fix but it works...

The lines you quoted out with the // are the ones that make bestweapon work on 2.3 servers. If you play only on an SVN server or your own computer, you don't need the register_bestweapon stuff.

It can seem like it is working on a 2.3 server without the fix, but it isn't really. For example, if you have a weapon that shoots rockets, it will switch to the nex properly. But if you have no rockets, it won't switch to the nex. In 2.3 servers, the bestweapon command is confused about what type of ammo some weapons use.

Edit: I updated post#3 above. I adjusted the order a bit. Notably, I made the 3 ranges accessible with the mouse wheel. Note that this overrides the default weapon wheel menu. So you scroll down for closer enemies, scroll up for further enemies. It takes a little while to get used to it, but the 3 position smart weapon wheel selection seems better to me than the 9 position standard menu.

Also, in the medium range I put the rocket launcher after electro and mortar because it is slow. It is useful though for spamming an area for possible lucky hits, for hitting multiple enemies with its wide blast radius and for quick movement, so I added a separate key for the RL. Also, the laser is on its own key.
Check out how I implemented this in the 'ninja config' I posted in -V-'s Bind Thread.
Pages: 1 2
Reference URL's