Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Two weapons on each key?

#1
Hi
How can I bind two weapons on each key? I would like to fix two weapons on eg. Q.
Can it be done in the cfg?
Thank you
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#2
Is this still actual? Is this the only way?

Source:

Weapon Hook

When you change your active weapon, the game calls the alias cl_hook_activeweapon with a parameter that is the name of the selected weapon. Here's what I do with it:
set bx_weapon "shotgun" // default value
alias cl_hook_activeweapon "bx_weapon ${1}; bx_on_weapon_change" // now we have the current weapon name in a variable, and can execute an action, too!
alias bx_on_weapon_change "hud_panel_physics 3; bx_if_eq ${bx_weapon} laser hud_panel_physics 2" // show speed HUD panel only when laser is selected
I will show one more way to use this variable in the next section.

Weapon Switching

Don't you think that the current way to switch weapons – one, sometimes two per key – is somewhat inefficient? Well, there's a better way. Go to the console and type search cl_weapon* right now.
So, the cl_weaponpriorityN cvars can hold individual weapon cycling lists, to be used by impulse 20N, impulse 21N and impulse 22N. I'll just leave my binds here.

cl_weaponpriority1 "crylink shotgun"; cl_weaponpriority2 "hagar uzi hlac"; cl_weaponpriority3 "rocketlauncher electro grenadelauncher"; cl_weaponpriority4 "minstanex nex rifle"; cl_weaponpriority5 "fireball seeker minelayer porto"; cl_weaponpriority0 "laser hook"
bind 1 "impulse 221"; bind 2 "impulse 222"; bind 3 "impulse 223"; bind 4 "impulse 224"; bind 5 "impulse 225"; bind 6 "impulse 226"
bind Q "bx_if_not_eq ${bx_weapon} laser impulse 220; bx_if_eq ${bx_weapon} laser weaplast" // if not laser, switch to laser, else switch to previous weapon

Weapon Combos

Yes, weaplast command (Q button by default) is useful, but imagine this situation: you have a 2-weapon combo, you keep switching between those weapons, shoot your opponent... but then you need to use the laser, so your 'combo' is broken: now it is one of the weapons and laser. Well, I made a similar bx_invprev command that does just the same, but excludes laser! You can use the laser and then the command can switch back to your combo of 2 weapons.

alias bx_on_weapon_change "bx_save_last_weapon_ ${bx_weapon}" // save new weapon selection
set bx_last_weapons "" //this variable will hold 2 last weapons, separated with space
alias bx_save_last_weapon_ "rpn /bx_last_weapons_temp_ /${1} bx_last_weapons union /shotgun union \"/laser none\" difference =; // save ($1$bx_last_weaponsshotgun)–(lasernone)
····························bx_save_last_weapon_step2_"
alias bx_save_last_weapon_step2_ "bx_save_last_weapon_step3_ ${bx_last_weapons_temp_}" // a relay so we can cut off all arguments except the first 2
alias bx_save_last_weapon_step3_ "bx_last_weapons \"${1 ?} ${2 ?}\""·················· // save the first 2 weapons from the 'set'

alias bx_invprev "bx_switch_weapon2_ ${bx_last_weapons} shotgun shotgun" // shotgun is added in case the variable is empty
alias bx_switch_weapon2_ "weapon_${2}" // many arguments are passed, but we take only the 2nd
bind E "bx_invprev" // it is probably more usual to put Q here, but I use it for laser


FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#3
I can think of a much simpler solution which switches the bind everytime you press the key.

Into console enter(open shift+esc; you can ctrl+c/v):
Code:
alias weap2 "weapon_blaster; bind <KEY> weap1";
alias weap1 "weapon_devastator; bind <KEY> weap2";
weap1;

you can also cycle with more:

Code:
alias weap3 "weapon_vortex; bind <KEY> weap2";
alias weap2 "weapon_blaster; bind <KEY> weap1";
alias weap1 "weapon_devastator; bind <KEY> weap3";
weap1;

Replace <KEY> with what you want.

Example:
Code:
alias weap2 "weapon_blaster; bind c weap1";
alias weap1 "weapon_devastator; bind c weap2";
weap1;
Reply

#4
Thank you very very much for your answer.

Is this persistent?
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#5
(08-16-2019, 01:11 AM)FAF Wrote: Thank you very very much for your answer.

Is this persistent?

It is not! I have put them in an autoexec.cfg

I now have multiple weapons on different keys, thank you...now I need to practice Smile

What a joy that it could be this simple.
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#6
Anyway to use this per game-type, like only to use on CA?
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#7
I guess this might work:
Code:
alias cl_hook_gamestart_ca "aliasname1; aliasname2"

You can add as many aliases as you wish with semicolons.
"ca" can be any gamemode.
Reply

#8
(08-16-2019, 06:06 AM)Mirio Wrote: I guess this might work:
Code:
alias cl_hook_gamestart_ca "aliasname1; aliasname2"

You can add as many aliases as you wish with semicolons.
"ca" can be any gamemode.

Thank you, but how do I load the alias without exposing it to dm? How can I call it?

The "alias weap2 "weapon_vortex; bind <key> weap1";" loads up in whatever game-type as it's exposed in autoexec.cfg.

I really need basic instructions as I have not done this before.
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#9
OK. I have now made different cfg files for the different game-types which are called by "alias cl_hook_gamestart_ca "exec ca_exec.cfg". That works, but I loose my default keys when I again join a "dm" game.

Is there a way to reset to default keys in cfg? Like "alias cl_hook_gamestart_dm "exec reset_keys"?


Thank you for helping this noob here Smile
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#10
You can use cl_hook_gamestart_all for resetting to defaults - it runs each time before the gametype-specific hook. You still need to have an explicit list of keys to reset, there is no built-in reset_keys.
[Image: 30381.jpg]

<packer> when i see martin-t's name my blood pressure increases

<[BOT]Hоtdоg> anyone here lives near martin?
<[BOT]Hоtdоg> will pay monies for shooting him
Reply

#11
Thx Martin. I will type in an explicit list of keys to reset...was thinking that I had to but hoped not.
Thx again to all.
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#12
Is there a list, database, or dictionary, with all the different commands that I can use? I have some ideas of what I want, but if I fly in the dark its hard.
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#13
Yes. Not everything is documented properly. Not everything can be because shit's badly designed. Aliases can't have descriptions. There are also examples in the data repo like a brainfuck interpreter. The config/console lang is turing complete. Additionally the forum has a search feature.
[Image: 30381.jpg]

<packer> when i see martin-t's name my blood pressure increases

<[BOT]Hоtdоg> anyone here lives near martin?
<[BOT]Hоtdоg> will pay monies for shooting him
Reply

#14
Thank you, yes found some here and there.
Have been messing with this: unbindall; cvar_resettodefaults_all; exec default.cfg;
... but I resolved to manually entering the binds in the cfg. Works ok.
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#15
Is there a way to set weapon priority to the switch? If there is a priority it does not work.
Code:
alias weap2 "weapon_blaster; bind <KEY> weap1";
alias weap1 "weapon_devastator; bind <KEY> weap2";
weap1;
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#16
I don't know there used to be a command like "wait <time>" or something to delay commands.That way you could make it switch back after some time.
But else this is cheap weapon switching where you have to remember the weapon that you get with the binds.

As it works it switches a bind which is saved. So the weapon switching is saved across sessions. To cope with that you could include into the autoexec.cfg a line with "weap1" to make it reset to the right bind on startup.

Other solution would be a reset bind: alias reset_bind "weap1; weapX; weapY"
Where neither weapX nor weapY would be weap2 in that case but the initial bind of other weapon switches.

Then just bind <key> reset_bind and/or put it into the autoexec.cfg.
Reply

#17
Thank you. As it is now, I have put the binds into different exec files, which are loaded from autoexec.cfg.
The only one I really need in quick combat situations is the vortex, so I should probably put than on a key of its own.
Maybe this dual-key setup is not optimal in the long run, but it makes my life easier right now.
Thank you again for your help.
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#18
(08-28-2019, 02:55 AM)FAF Wrote: Is there a way to set weapon priority to the switch? If there is a priority it does not work.
Code:
alias weap2 "weapon_blaster; bind <KEY> weap1";
alias weap1 "weapon_devastator; bind <KEY> weap2";
weap1;

Hi again. Since the last update to 0.8.5 ab on the server and client, this seems no longer to work? Do you know what changed? The "weapon_vortex" calls a FLAC is not available in game?

"weapon_vortex" is now called what? Ty
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply

#19
(07-02-2022, 01:44 PM)FAF Wrote:
(08-28-2019, 02:55 AM)FAF Wrote: Is there a way to set weapon priority to the switch? If there is a priority it does not work.
Code:
alias weap2 "weapon_blaster; bind <KEY> weap1";
alias weap1 "weapon_devastator; bind <KEY> weap2";
weap1;

Hi again. Since the last update to 0.8.5 ab on the server and client, this seems no longer to work? Do you know what changed? The "weapon_vortex" calls a FLAC is not available in game?

"weapon_vortex" is now called what? Ty

weapon_vortex is still not working in release, but you can call it with weapon_group_7.
It is fixed in autobuild.
FAF - FERIS - COPENHAGEN - DENMARK - GNU/Linux  Heart
Homepage: https://feris-xonotic.net
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Sad [META] Xonotic stats: two me? Delusion 153 153,650 04-23-2024, 11:48 PM
Last Post: UrbaLox
  [BUG] Rebound "R" key, still occasionally does "team say" anyways Cynical 2 2,031 06-27-2019, 08:54 AM
Last Post: Cynical
  [NEED HELP] Custom Weapons 3agle427 2 2,825 01-26-2019, 11:19 PM
Last Post: 3agle427
  Chat key bind problem BuddyFriendGuy 4 3,400 01-26-2019, 11:12 PM
Last Post: BuddyFriendGuy
  [NEED HELP] Custom Weapons 3agle427 0 1,670 01-15-2019, 09:55 PM
Last Post: 3agle427
  [NEED HELP] Custom Weapons 3agle427 0 1,905 12-30-2018, 01:39 PM
Last Post: 3agle427
  [SOLVED] Weird key hold issue with official version Bloodthorn 9 5,820 05-21-2018, 07:56 AM
Last Post: Bloodthorn
  [NEED HELP] Weapons always sway Kriss7475 8 4,909 01-19-2018, 01:24 PM
Last Post: Kriss7475
  [BUG] Grappling hook breaks if no new key is pressed while it is midair (new since 8.2) reth 2 3,242 05-13-2017, 06:52 AM
Last Post: reth
  [NEED HELP] console send key or calling menus BuddyFriendGuy 3 4,744 05-07-2017, 09:17 AM
Last Post: -z-

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-