Best Weapon switching script

Discuss Nexuiz gameplay here.

Moderators: Nexuiz Moderators, Moderators

Best Weapon switching script

Postby AceOfThumbs » Thu Sep 06, 2007 12:00 am

EDIT: In Nexuiz (the current version as I write this is 2.3), the bestweapon command that I use in this script doesn't always work right. Try the new script 3 posts further down in this topic.

Okay, here's another script that goes well with the mouse wheel zoom script. If you don't use the mouse wheel to switch weapons and don't want to press 9 different keys to select a weapon, you can use the bestweapon console command to tell Nexuiz how to select the best weapon with a single key.

Each weapon has a number associated with it. You use the weapon number in a list to tell Nexuiz what order of preference. That's great but your preference changes depending on the situation, right? So we just make multiple lists.

In the script below, I set up a list for close range weapons and sniper weapons. Then I set up a key to cycle through all weapons (like the mouse wheel does in Nexuiz's default setup). Finally, I set up a key for the laser, which needs to be quickly accessible for trick jumps.

You will probably want to customize most of the script to make your own lists with your own weapon orders. Also, set the key bindings to whatever is easiest for you. You might want to bind to a mouse button instead of the keyboard. My mouse driver is a little weird, so 3, 4 and 5 are actually mouse buttons for me. For most you would use MOUSE3, MOUSE4, MOUSE5 for mouse buttons.

Anyway, here is the script. Enjoy.

Code: Select all
/ switch weapons script based on favorite groupings
// my mouse outputs key presses: 3=left side btn, 4=middle btn, 5=right side btn
// Nexuiz impulse numbers: 9=rocket, 8=hagar, 7=nex, 6=crylink, 5=electro, 4=mortar, 3=machinegun, 2=shotgun, 1=laser

//best close weapon
bind "3" "bestweapon 7 3 2 9 8 6 5 4 1"
//best sniper weapon
bind "4" "bestweapon 7 3 9 8 6 5 4 2 1"
// best splash weapon
bind "r" "bestweapon 9 8 6 5 4 3 2 7 1"
// cycle
bind "f" "weapprev"
// laser
bind "5" "impulse 1"
Last edited by AceOfThumbs on Tue Sep 11, 2007 10:42 pm, edited 1 time in total.
AceOfThumbs
Alien
 
Posts: 158
Joined: Tue Sep 04, 2007 11:12 pm

Postby iSuck » Tue Sep 11, 2007 8:41 pm

I know this is a little off topic, but it relates to this. Is it actually possible to change weapon priority? I saw that you had a "bestweapon" command, could I apply that permanently so that for instance, my laser is above my shotgun?
iSuck
Alien
 
Posts: 150
Joined: Thu Apr 19, 2007 11:34 pm

Postby AceOfThumbs » Tue Sep 11, 2007 9:38 pm

I'm pretty sure that you can't change the order of weapon preference for the auto-swap or the order they show up in the menu.
AceOfThumbs
Alien
 
Posts: 158
Joined: Tue Sep 04, 2007 11:12 pm

Postby AceOfThumbs » Tue Sep 11, 2007 10:34 pm

Since bestweapon isn't reliable, I wrote a script that allows a similar function. This is not as good as the bestweapon feature but it works. You can group weapons and select from that group with a single key. I have a bunch of instructions, then the script is at the bottom.

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.

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

CUSTOMIZE IT
Please change the key binds to whatever works best for you. My mouse outputs key presses, so 4 means middle button. Most of you would use MOUSE3, MOUSE4 and MOUSE5 for your extra mouse buttons. 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 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: Select all
// AceOfThumbs weapon grouping script
// switch weapons based on groupings by type
// my mouse outputs key presses: 3=left side btn, 4=middle btn, 5=right side btn
// 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
// enemy close-shotgun and wide angle mode
bind "3" "impulse 2 "

// rocket
bind "r" "impulse 9"

//best sniper weapon
bind "4" "aot_nextws"

// best explosive weapon
bind "f" "aot_nextwp"

// laser
bind "5" "impulse 1"
AceOfThumbs
Alien
 
Posts: 158
Joined: Tue Sep 04, 2007 11:12 pm

Postby mand1nga » Tue Jun 24, 2008 1:58 am

Hello, I just found your post looking for feeling more comfortable while switching weapons. You had a nice idea, but it has a problem when doing combos. If you switch from i.e.: explosive to hitscan weapon you end using the 'next' hitscan weapon. So I've made this quick customization, I know is dirty but I won't spend more time with this, it just does the work for me. Maybe it can serve to keep improving the original script. So here it is:

Code: Select all
// best mortarish
alias "mortar_ws1" "alias mortar_ws mortar_ws2 ; impulse 6; alias mortar_now mortar_ws1 ; alias hitscan_ws hitscan_now ;"
alias "mortar_ws2" "alias mortar_ws mortar_ws3 ; impulse 4; alias mortar_now mortar_ws2 ; alias hitscan_ws hitscan_now ;"
alias "mortar_ws3" "alias mortar_ws mortar_ws4 ; impulse 5; alias mortar_now mortar_ws3 ; alias hitscan_ws hitscan_now ;"
alias "mortar_ws4" "alias mortar_ws mortar_ws1 ; impulse 8; alias mortar_now mortar_ws4 ; alias hitscan_ws hitscan_now ;"
alias "mortar_ws" "mortar_ws1"
alias mortar_now mortar_ws1
bind e "mortar_ws"

alias "mortar_ws" "mortar_ws1"

// best histcan
alias "hitscan_ws1" "alias hitscan_ws hitscan_ws2 ; impulse 7 ; alias hitscan_now hitscan_ws1 ; alias mortar_ws mortar_now ;"
alias "hitscan_ws2" "alias hitscan_ws hitscan_ws3 ; impulse 3 ; alias hitscan_now hitscan_ws2 ; alias mortar_ws mortar_now ;"
alias "hitscan_ws3" "alias hitscan_ws hitscan_ws1 ; impulse 2 ; alias hitscan_now hitscan_ws3 ; alias mortar_ws mortar_now ;"
alias "hitscan_ws" "hitscan_ws1"
alias hitscan_now hitscan_ws1
bind f "hitscan_ws"

alias w_laser " impulse 1 ; alias mortar_ws mortar_now ; alias hitscan_ws hitscan_now ;"
alias w_rocket " impulse 9 ; alias mortar_ws mortar_now ; alias hitscan_ws hitscan_now ;"
alias w_last "weaplast ; alias mortar_ws mortar_now ; alias hitscan_ws hitscan_now ;"

bind 1 w_laser
bind r w_rocket
bind q w_last
bind alt " alias hitscan_ws hitscan_ws1 ; alias mortar_ws mortar_ws1 ; alias mortar_now mortar_ws1 ; alias hitscan_now hitscan_ws1 ;"


I didn't found any better solution to this problem, so I'm sticking with this by now :)
Cheers,
mand1nga
Alien trapper
 
Posts: 321
Joined: Mon May 12, 2008 12:19 am

Postby AceOfThumbs » Tue Jun 24, 2008 3:52 am

I haven't updated this post in a while, but I have been using a new weapon switching script since 2.4 servers started appearing that takes advantage of a new command that lets you create one or more 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. You may want to change the weapons lists for your own preference.

Code: Select all
// 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 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"

// remove fix since most servers are 2.4+ now
// if you are playing on a 2.3 server, delete the line below
alias 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  "aot_bw; bestweapon 6 8 2 3 7 1 4 5 9; echo close range"

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

// far - sorted by speed then minimum spread then damage per sec
// for mg use alt fire for less spread, for crylink use primary
alias aot_w3  "aot_bw; bestweapon 7 3 6 1 8 4 5 2 9; echo long range"

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

// uncomment the lines below to
// restore Nexuiz's normal weapon menu
//in_bind 0 mwheelup "weapnext"
//in_bind 0 mwheeldown "weapprev"

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"

// start with medium range weapon
aot_weap2


If you read the comments, you'll see some commented code (lines that start with // are ignored) that offers a few options. If you won't need these options you can also just delete those lines and shorten the script.
Last edited by AceOfThumbs on Tue Jun 24, 2008 6:15 am, edited 1 time in total.
So much to do, so little time to do it
AceOfThumbs
Alien
 
Posts: 158
Joined: Tue Sep 04, 2007 11:12 pm

Postby AceOfThumbs » Tue Jun 24, 2008 6:14 am

I forgot to point out that this script uses the mouse wheel for changing weapons instead of using keys. There are 3 settings. You start off in the medium range. Scroll up to choose a weapon better for long range or down for close range weapons.

I think this feels more natural since the wheel is normally used to cycle through weapons, so many players will be used to using the wheel. Anyway try it out, but be aware that you can use keyboard binds if you prefer to hit a key to switch weapons.

There is some code below to handle special cases when you may want to choose a different explosive weapon than the one that is first in the medium range list. This is great for when your opponent is also using an explosive weapon. You need one that is faster or equally as fast so you can hit him faster or cause his own explosives to detonate near him. Hagar is the fastest. Electro and mortar are tied. Rocket is the slowest.

Also, the electro and mortar have useful secondary fire modes that let you bounce an explosive around a corner or leave a trail to hit someone following you.

If you add the code below, you'll have the R key bound to switch to an alternate medium range explosive weapon. So if you are holding any explosive weapon you can press R to cycle through the rocket launcher, electro, mortar and hagar.

Code: Select all
// cycle to next medium range weapon
bind R "cycleweapon 9 5 4 8"
So much to do, so little time to do it
AceOfThumbs
Alien
 
Posts: 158
Joined: Tue Sep 04, 2007 11:12 pm

Postby mand1nga » Tue Jun 24, 2008 12:28 pm

hey Ace thank you very much, I think your solution is better by the fact that it chooses weapons *with ammo* :)

I will try it when I get home

And thanks for the explosive vs explosive exception tip ;)

Cheers,
mand1nga
Alien trapper
 
Posts: 321
Joined: Mon May 12, 2008 12:19 am

Postby Oat » Tue Jun 24, 2008 7:04 pm

Okay erm... I tried out the script myself.

Tested it out on playing against BOT in maps. Ended up can't use laser AT ALL. When I press 1 for laser it says - The laser is NOT AVAILABLE on this map!

I tried other maps, removed the script and still can't use laser :S

but in a game on servers it works I think. So how to solve this please?
Oat
Advanced member
 
Posts: 74
Joined: Mon May 12, 2008 3:40 pm

Postby Dokujisan » Tue Jun 24, 2008 8:22 pm

try

bind 1 "impulse 1"
Dokujisan
Forum addon
 
Posts: 1199
Joined: Sat Oct 07, 2006 4:31 pm
Location: Louisville, Kentucky

Next

Return to Nexuiz - Gameplay

Who is online

Users browsing this forum: No registered users and 1 guest