User panel stuff on forum
  3 posts on 1 page  1
General Discussion
2018-03-11, 07:18
Member
215 posts

Registered:
Feb 2011
TL/DR: Read this essay to find out about a cool feature in KTX you probably didn't know about, but which needs a bit of loving to make it more usable.

Background

Some of us experience a very annoying problem at high ping, where you try to switch to a weapon you just picked up, press +attack, but unfortunately an SG shot comes out instead of what you intended to fire. This happens because the server didn't have time to acknowledge that you picked up the weapon that you say you fired, so it makes you fire an SG instead.

As an easy proof of concept, bind a key as follows:
bind x "weapon 7 2; +attack; -attack"

or equivalently,
bind x "+fire 7 2"

then connect to a server with low ping. Before picking up anything, pressing 'x' will fire an SG, as expected. Next, quickly pickup an RL and immediately press 'x'. You'll fire a rocket, as expected.

Finally, disconnect from the server, type '/cl_delay_packet 150', then reconnect and repeat the same experiment. You'll probably notice that more often than not, an SG comes out instead of a rocket. Disastrous!

This, BTW, is why I hate playing DM4 with high ping. A huge part of the map is attacking and defending the middle area, but it's almost impossible to attack when a shotgun is fired instead of the LG right after picking up the LG. You end up dying before any cells are fired, so regaining control of the middle is basically impossible. But I digress!

Wishlist

I use a different key to select each weapon, and a single key to fire what I previously selected.

Here's how I like my weapons to behave:

1a- No SG script enabled for dmm3. This means I drop the weapon I'm holding in 1on1 and 2on2, which I prefer strategically.
1b- SG script enabled for dmm1. This means I don't drop the weapon I'm holding in 4on4 unless I'm firing, which is the only way to play.

The above 2 requirements are satisfied with a combination of /cl_weaponhide "2" and /cl_weaponpreselect "4".

2- I want to see the weapon I'm holding that I will be firing next, even in dmm1 (where technically you are running around with a shotgun even if you preselected the RL to be fired next).

The above requirement is satisfied with /r_viewpreselgun "1".

3- I don't want my weapon selection to be remembered, I want it to be immediate. For example, bind two keys as follows:
bind x "weapon 8 7 2"
bind MOUSE1 +attack

Then pickup an RL, press 'x' to select it, then press MOUSE1 to fire it. So far so good. Next, pickup the LG (or an LG pack) and press MOUSE1 again. You'd think you should keep firing the RL as that's you've been doing, but you will instead switch to the LG and fire that instead. That's because the client remembers the complete weapon preference list at the time you pressed 'x', so it will always try to fire the best weapon from that list. Horrible behavior for any kind of competitive play; any kind of automatic weapon switching that you didn't ask for right now is a big no no. This happens even if you set /w_switch 2 and /b_switch 2.

The above behavior was a problem for a long time, and it's the reason I ended up adding the /cl_weaponforgetorder CVAR (see https://www.quakeworld.nu/forum/topic/4534/97237/#97172 for an informative thread about weird weapon behavior both from the client and from KTX).

So, the above requirement is now satisifed with /cl_weaponforgetorder 1. Instead of remembering the preference forever and changing weapons for you at any time in the future, it only selects from the weapons you're holding right now and then forgets about the preference. Note that this was never a problem for those of you who use a different key to fire each weapon, because you are explicitly specifying the weapon you want to fire with each +attack.

4- Finally, I don't want the server to ever change weapons for me.

All you need to demonstrate that this happens is:
bind x weapon "7 2"
bind MOUSE1 +attack

Pickup an LG, an SNG and an RL, press x to select RL, then keep holding down MOUSE1 to fire rockets without letting go. When you run out of rocket ammo, KTX will "helpfully" automatically switch you to firing the LG (unless you're in water), and when you're out of cells, it will then automatically switch you to SNG and fire nails. This happens even though your config has nothing at all about an LG or SNG. How helpful... The workaround is to let go of +attack and then press it again, at which time you will stop firing the weapon that KTX selected for you, and instead you will fire the SG as you specified.

I don't think this is possible to workaround without changing KTX. It was also discussed in the above thread, and Bogo's post links to the problematic KTX code.

5- Bonus: There's a problem where if you are firing RL, die, spawn, +attack (SG is fired because that's all you have), then pickup an RL (or backpack with RL), then press +attack again, a rocket is fired. This is because dying didn't reset your weapon choice to SG, it still thinks you want to fire the last weapon you were holding before you died. You can resolve this with something like
alias f_death "weapon 2"
or
alias f_respawn "weapon 2"
but unfortunately these triggers don't work with common rulesets like smackdown...

Anyway, with the above settings I'm able to get a simple weapon configuration that meets all my requirements (except #4 and #5). It works fine at low ping, but as discussed earlier, it doesn't work so well at high ping and leads to lots of frustration.

Weapon switching at high ping

Not many people know that KTPro had a feature - which KTX inherited - that is meant to resolve this high ping problem. See https://pastebin.com/WWCUvQu2 for the documentation.

Essentially, instead of letting the client handle your weapon changing, you tell the server what you want it to do for you. If you use a different key to select+fire each weapon, it's pretty simple and you can just follow the documentation. If instead (like me) you use different keys to select each weapon, and a single key to fire, things are more complicated as usual (even though that's the oldschool quake configuration, shame on you all for ignoring your roots...).

First thing is to register your preferences:
// Register weapon preferences with KTX
cmd wreg a 1 // Axe
cmd wreg b 21 // SG
cmd wreg c 321 // SSG
//cmd wreg d 5421 // NG (redundant with SNG bind)
cmd wreg e 5421 // SNG
cmd wreg f 621 // GL
cmd wreg g 721 // RL
cmd wreg h 821 // LG
cmd wreg i 8765321 // Bestweapon
cmd wreg j 321 // SSG/SG
cmd wreg k 8652 // LG/GL/SNG
cmd wreg x + // Fire weapon
if ($deathmatch = 3) then cmd wreg z - else cmd wreg z -21 // If dmm1, switch to sg/axe after firing (-21), otherwise just stop firing but don't switch weapons (-)

Then, instead of doing something like "bind x weapon 1" to select the axe, you would do "bind x cmd a", because "cmd a" is registered with KTX as an instruction to select the axe for you.

Note that 'x' is assigned to '+', which is the equivalent of +attack. The last line is my attempt to enable sg script for dmm1 (assign '-21' to z, which is the equivalent of -attack then weapon 2 1), but no SG script for dmm3 (assign just '-' to z, which is the equivalent of just -attack).

Also note that as per the documentation, these commands need to be registered on every map load. So, you can add something like "alias on_enter "exec wreg.cfg" ", which will get executed on every map load.

Side Note:I've noticed that the server warns me about being a command flooder (3 warnings to kick) if I execute the above cfg, unless I execute it very shortly after the map is loaded. It seems the limit is 10 cmds in a short period of time, except for a few seconds after map load. You can confirm which commands were successfully registered with "cmd wreg".

Next, you need to bind your keys to select the weapons:
// Binds to select weapon.
// "cmd [x]" is required, otherwise client won't show which weapon you selected until after you start firing.
// "set weaponreg [x]" is required for dmm1, otherwise +att alias will only fire selected weapon until releasing key. After that, it will fire SG because "cmd z" (from -att) swithes back to SG...
bind 1 "cmd a; set weaponreg a"
bind 2 "cmd b; set weaponreg b"
bind 3 "cmd c; set weaponreg c"
bind 4 "cmd e; set weaponreg e"
bind 5 "cmd e; set weaponreg e"
bind 6 "cmd f; set weaponreg f"
bind 7 "cmd g; set weaponreg g"
bind 8 "cmd h; set weaponreg h"
bind / "cmd i; set weaponreg i" // bestfire
bind MOUSE4 "cmd j; set weaponreg j" // ssg/sg fire

There are 2 parts to each bind, and the reason they're both needed is explained in the comments just above.

Finally, we setup the attack key:
bind MOUSE1 "+att" // Press to manually fire currently selected weapon

alias +att "cmd $weaponreg; cmd x"
alias -att "cmd z"

The above config resolves the high ping switching problem, which is quite miraculous. You can repeat the test at the very top of this post and you'll see the weapon switching behavior at high ping works well.

HOWEVER, there are still a few gaps to meet all of my requirements:

1- cl_weaponpreselect "4" only ever shows SG ammo count in your HUD, no matter what you're currently firing or selected to fire in the future. The weapon you're holding in your hand also never changes. So, you have to use cl_weaponpreselect "0".

2- cl_weaponpreselect "0" works fine in dmm3 (where cmd z is assigned to just '-'), but in dmm1 (where cmd z is assigned to '-21'), you only see SG ammo count in HUD except while you are firing another weapon. It would be nice to get the client-side behavior of cl_weaponpreselect "4", which is to show the ammo count of the weapon you're going to fire the next time you press MOUSE1. I don't care to see the SG ammo count if I'm going to fire an RL. I also don't care to see an SG in my hands if I'm going to fire an RL (which is solved on the client-side with r_viewpreselgun, if you use a client-side weapon configuration).

3- Requirement #3 from the previous section is now a problem again. This means that for example if you press '/' to select your best available weapon, and you have everything except the LG at this time, you will be firing the RL (as expected). Unfortunately, any time in the future you pickup an LG, the server will switch you to the LG and you will fire that instead. This is very disorienting and is the whole reason cl_weaponforgetorder was implemented. Unfortunately, I don't think there's a KTX-side equivalent to this client-side CVAR.

4- Requirement #4 from the previous section is still a problem.
5- Requirement #5 from the previous section is still a problem.

#4 and #5 aren't dealbreakers because they exist for client-side weapon handling too, but it would be nice if they were eventually addressed. Unfortunately, #3 is a deal breaker because it means I can't benefit from this miraculous high-ping feature. The tradeoff of unexpectedly having my weapon changed for me while I'm firing something else is too big.

Conclusion

In principle, my requirements are extremely simple: Only switch weapons at the time I ask for it, never in the future without my express authorization. Show me the weapon I'm going to fire in the future when I press +attack, and its ammo count. Optionally, use an SG script in dmm1 so I don't drop packs. When I die, reset any past weapon selections to just the SG. That's it! Should be extremely simple in theory, but in practice I don't think all of those things are possible at the same time, either with client-side or server-side weapon handling.

Any thoughts about how to modify the "wreg" (high ping) config to fix issue #3, without screwing up any of the other behavior, would be much appreciated!

Anyway, if you got this far, I hope some of you learned about this KTX feature and that you will benefit from it if you play with high ping.

Cheers,
BD
2018-03-11, 15:15
Administrator
284 posts

Registered:
Sep 2015
#4 was fixed 2 years ago, and shipped in KTX 1.37. "/setinfo w_rank 21" will pick shotgun first and fallback to axe if you're out of shells, for example.

I'll look into adding server-side weapon selection as a protocol extension, but will need to think about forgetweaponorder option... the client sends 821 for instance, server knows you have LG but client doesn't... what happens the next time you press fire? Can't send no selection to the server, because your 'hide weapon' script will have kicked in so you'll be carrying shotgun. Need to think about it some more.
2018-03-11, 16:19
Member
215 posts

Registered:
Feb 2011
Just tested the w_rank stuff and it does indeed seem to fix #4, thanks Meag! Ciscon had mentioned it to me but for whatever reason it wasn't working when I tried it, I must have done something wrong.

If we can figure out a fix for #3, that would be fabulous.
  3 posts on 1 page  1