|
|
|
Administrator 384 posts
Registered: Dec 2006
In ktpro rxr implemented some kind of call to an alias when a weapon in automatically selected by the server. This alias was f_x where x is the number of the weapon that was autoswitched. Typically this autoselection of weapons happens when you run out of ammo. So for example if you have sng and lg, and are shooting sng, if you run out of nails, the server automatically changes your weapon to LG and continues firing
Obviously, this sucks, because often you don't actually want to shoot the weapon that has been automatically selected for you. Ktpro's solution worked great, because you could effectively override the serverside weapon selection (in this case via the alias f_8 "impulse 5 3 2 4 8", which would switch to SSG when LG is automatically selected, since weapon 5 has no ammo).
For some reason this doesn't seem to work anymore in KTX. I can't be sure that it ever did (I've only really been playing regularly on KTX servers for about 7 months or so) so maybe something else has changed in my config. But in ktpro it definitely worked 100%.
Anyone else been using these f_ aliases? Anyone know if it should be supported in KTX?
Member 405 posts
Registered: Jan 2006
Unsupported, client have f_weaponchange alias however it maybe blocked with rulesets, whole scripting system maybe blocked/limited. Also I think instead of such aliases it whould be better tell server how to switch weapons at certain situations while connecting, this will make weapons scripts retarded and allow change such settings in client menu
Administrator 384 posts
Registered: Dec 2006
f_weaponchange won't do what I want because that executes the alias when you change weapon intentionally as well. Essentially what I need is some way to dictate what should happen when you run out of ammo. Maybe via CMD or similar when you connect to server as you suggest.
Surely other people must have this problem as well, it really sucks because like in EQL game I was stood at pent mega spamming SNG. Then I run out of ammo and it autoswitches to LG and continues firing. This is really bad because not only does it waste valuable cell ammo, it also alerts enemies to the fact that I have LG. Otherwise they might not perceive me to be a threat until it is too late.
This is of course a big surprise to me because the weapon alias I am using should NEVER fire LG since it isn't in the list of weapons for that shoot alias. The only reason LG is being fired is because the server autoswitches weapons when you run out of ammo, you should have the ability to set the priority for this yourself in the same way that you can set w_switch/b_switch for weapon/pack pickups.
Administrator 1864 posts
Registered: Feb 2006
You can actually use f_weaponchange, you just need to make a script that checks how much ammo you had for your previous weapon.
Member 485 posts
Registered: Feb 2006
You can actually use f_weaponchange, you just need to make a script that checks how much ammo you had for your previous weapon. You can't do weapon/impulse based on ammo with ruleset smackdown.
Administrator 384 posts
Registered: Dec 2006
Also it wouldn't be foolproof in any case, there could potentially be a situation where I want to shoot LG and have 0 ammo for previous weapon (e.g. I've just fired my last rocket, and while it's reloading I switch to firing LG).
The f_8 alias I used on ktpro servers was flawless.
Member 215 posts
Registered: Feb 2011
This is an old thread, but does anybody know if there's been a resolution? I've been trying to get my weapon script working "just right" but have been frustrated for a while now. I don't think what I'm trying to do is complicated, it just seems that ezquake/ktx doesn't like it. The bottom line is that if I switched to a weapon, it should never change to anything else unless I press a button to change it (unless I run out of ammo, then switch to SG). Don't change weapons if I pick up ammo, don't change if I pick up another weapon or pack. This sounds so simple but seems to be impossible. Of course, my b_switch and w_switch are set to 1. I am using these built-in commands: cl_weaponhide "2" cl_weaponpreselect "4" Everything should work perfectly well, BUT they cause this really annoying behavior: 1- I press 7 for "weapon 7 2", or some kind of bestweapon bind like "weapon 8 7 5 2", but I don't yet have an RL. I run around the map shooting my SG, and then at some point in the future, I pickup an RL or a pack with RL. At this point, my weapon automatically changes to RL and I will likely bore because I wasn't aware that my SG changed on its own. When I pressed my weapon bind, I wanted to switch to an RL IF I had one at the time. I don't want to switch to an RL any time I might pick one up in the future. It seems the client remembers the weapon list forever, which I don't want. I only want it to select from the weapon list at the time I press the bind. I found a workaround for this by binding to "weapon 7 2; weapon $weaponnum". This will try the weapons in order, pick the best one available, and then use the "$weaponnum" variable to set "weapon" to whatever weapon is now selected. That way, if in the future I pick up an RL, the client should think "weapon 2" and not "weapon 7 2", so it won't accidentally switch to an RL! Genius! 2- However, this workaround introduces another strange behavior (bug?) related to this thread. Pick up an LG but never select it. Also pick up an RL. Press the bind that is "weapon 7 2; weapon $weaponnum", and keep firing rockets until you have no ammo. Once you run out of ammo, you will switch to the LG and fire cells. WTF? Normally, without this workaround, it would switch to SG. This strange behavior is what brought me to this thread. 3- The other annoying behavior is that if I press "weapon 7 2; weapon $weaponnum", start firing rockets until I have no more, start firing SG, and then pick up rocket ammo, it will automatically switch back to RL. This is really annoying when I'm mentally in "shooting SG" mode. So, how can I have a simple weapon script that doesn't try to switch weapons for me and works in ruleset smackdown? I think I must be missing something super obvious because I don't see how nobody else is complaining. I tried lots of different things but no luck. Below is what I just came up with tonight, the stuff related to "wasfiring" and "fireornot" is a bonus attempt to have another key shoot a different weapon and switch back to the previous weapon, you can ignore it. // START WEAPONSCRIPT cl_weaponhide "2" cl_weaponpreselect "4" r_viewpreselgun "1"
bind MOUSE1 "+att" // Press to manually fire currently selected weapon bind RALT "+lg" // Press and hold to switch+fire lg/ng/sg, release to switch back to previous weapon for manual firing
set wasfiring "0" // Needed to support the +lg script so that we can keep firing after -lg and MOUSE1 is still held down
alias +att "+attack; set wasfiring 1" alias -att "-attack; set wasfiring 0"
bind 1 "weapon 1; weapon $weaponnum" // weapon $weaponnum is so that cl_weaponpreselect doesn't change weapons after e.g. you pressed 7 for rl but didn't have one at the time, and then picked one up bind 2 "weapon 2 1; weapon $weaponnum" bind 3 "weapon 3 2 1; weapon $weaponnum" bind 4 "weapon 5 4 2 1; weapon $weaponnum" bind 5 "weapon 5 4 6 2 1; weapon $weaponnum" bind 6 "weapon 6 2 1; weapon $weaponnum" bind 7 "weapon 7 2 1; weapon $weaponnum" bind 8 "weapon 8 2 1; weapon $weaponnum" bind / "weapon 8 7 6 5 3 2 1; weapon $weaponnum" // bestfire bind MOUSE4 "weapon 3 2 1; weapon $weaponnum" //safefire
alias "+lg" "set wp $weaponnum; weapon 8 5 2; +attack" alias "-lg" "-attack; weapon $wp; fireornot"
// This is so that if Mouse1 is held, and then Alt is held and let go while Mouse1 is still being held, Mouse1 continues to fire alias fireornot "if ($wasfiring = 1) then +attack"
Another summary of what I want is "exactly the same behavior as cl_weaponhide 0/cl_weaponpreselect 0 without dropping rl/lg packs" When those commands are set to 0, none of this weird behavior happens. With them set to 2 and 4 as I have, they shouldn't affect dmm3 at all but in fact they do still cause all these problems.
Member 124 posts
Registered: Apr 2012
AGREE 100% WITH BD
With modern clients and weapon scripts etc, there should be no reason for KTX to have this "feature" at all IMO.
As far as I can imagine, there's no way to properly work around this client-side without violating smackdown limitations.
Member 172 posts
Registered: Sep 2013
Are the smackdown limitations written down anywhere, or do we just trust the code inside of a client right now to be "the list of rules"? To me this sounds like a legitimate client bug. The server is just giving a somewhat logical fallback behavior because the client didn't specify what to do when it ran out of ammo for the current weapon. -- 1- I press 7 for "weapon 7 2", or some kind of bestweapon bind like "weapon 8 7 5 2", but I don't yet have an RL. I run around the map shooting my SG, and then at some point in the future, I pickup an RL or a pack with RL. At this point, my weapon automatically changes to RL...
It seems the client remembers the weapon list forever, which I don't want. I only want it to select from the weapon list at the time I press the bind. Yes, looking at ezQuake, using either `impulse` or `weapon` with multiple values ezQuake remembers this as its weapon list. That explains most of the behavior you are seeing. 2- However, this workaround introduces another strange behavior (bug?) related to this thread. Pick up an LG but never select it. Also pick up an RL. Press the bind that is "weapon 7 2; weapon $weaponnum", and keep firing rockets until you have no ammo. Once you run out of ammo, you will switch to the LG and fire cells. WTF? Normally, without this workaround, it would switch to SG. This strange behavior is what brought me to this thread. What I think is happening: (I'm just some newb glancing at the code) 1. You set `weapon 7` and `+attack` - ezQuake looks at the weapon list and selects the best with ammo. If none have ammo, it sends the best anyways (lolwhat?). So ezQuake sends 7 and attack? - source IN_Weapon, IN_AttackDown, and IN_BestWeapon 2. KTX receives impulse 7 and attack commands - handling +attack it checks ammo, sees you don't have ammo for that weapon, and automatically selects the best weapon for you with its own internal algorithm, and in this case (unless you were under water!!!) it would choose 8 - source W_Attack, W_CheckNoAmmo, W_BestWeapon I would not have expected the client to have chosen a weapon without ammo. But there don't seem to be rules on the client side here. 3- The other annoying behavior is that if I press "weapon 7 2; weapon $weaponnum", start firing rockets until I have no more, start firing SG, and then pick up rocket ammo, it will automatically switch back to RL. This is really annoying when I'm mentally in "shooting SG" mode. This is the exact same thing. But because ezQuake has still remembered your weapon list of `weapon 7`, it will always be trying to fire that. That is the way weapon lists are intended to work right now. The fact that you fired sg was probably again the server's choice too. -- It sounds like weapon list are not what you want: - If you set "weapon 7 2" and currently only have sg, but later get rl, you do not want the rl to fire. So you don't want a weapon list to be saved. You just wanted the best weapon right now. - If you set "weapon 7" and have no rockets, you expected sg to fire, but something else is, based on rules you haven't defined anywhere. You want to define those rules. You could imagine a number of ways a client could support this. Note: bestweapon would be `weapon # # #; weapon $weaponnum` Example one: // Trigger when you run out of ammo. // Triggers should never work in smackdown, so this doesn't help you. alias f_noammo "if $weaponnum == 8 weapon 5 4 2 1 else weapon 2 1" bind 7 "bestweapon 7 2 1" bind 8 "bestweapon 8 5 4 2 1" Example two: // Set an "always fallback to this weapon list" when the current weapon has no ammo and you are holding +attack. fallbackweapon 2 1 bind 7 "bestweapon 7 2 1" bind 8 "bestweapon 8 5 4 2 1" Example three: // Explicitly say what you want to fallback to when the current weapon runs out of ammo and you are holding +attack. // I kind of like this idea the most, you will never be surprised. fallbackweapon (2) 1 fallbackweapon (3) 2 1 fallbackweapon (4) 2 1 fallbackweapon (5) 8 2 1 // this is an interesting idea fallbackweapon (6) 2 1 fallbackweapon (7) 2 1 fallbackweapon (8) 5 4 2 1 bind 7 "bestweapon 7 2 1" bind 8 "bestweapon 8 5 4 2 1" These are examples of things a client could implement that let you decide what the client should do when every weapon in the weapon list has no ammo. I think this is something pretty basic a client should provide. What can you do now? Glancing at ezQuake, I see no way to select the weapon that fires when the current weapon in your `weapon` list runs out of ammo without some modification to the client. You could probably address most of (2) and (3) by re-running your bestweapon alias every time you pressed your +attack or +fire key, but I still think you would get unexpected behavior if you were holding +attack and ran out of ammo.
Member 124 posts
Registered: Apr 2012
@bogo: the problem might be detecting when you're out of ammo, though... I'm not really familiar with it and I haven't checked the code to see, but I imagine it like this:
1.) KTX obviously tracks your ammo on its side
2.) ezQuake either currently tracks it client-side as well, or will need to track it in order to do those things you suggested (and can not count on KTX's vision because of ping, where you'll be informed you're out of ammo -after- KTX has already decided you're swapped over from RL->LG)
The problem with that is that there's going to be a race condition here between KTX and ezQuake that might result in something like this:
1.) You're holding down +attack with RL, 2.) as you run out of ammo, 3.) KTX swaps you to LG and sends a packet to inform you that you're now firing LG 3.) ...just as ezQuake decides to swap you to SSG and sends a packet to inform the server 4.) So what weapon is actually being fired now?
Well, I could be wrong about how all of this works to begin with, but... Anyway, that might result in shooting some wayward cells or something if I'm guessing right.
What about if KTX and ezQuake both implemented some scheme where the client can just inform KTX about impulse lists? It would need to be something that can be compatible with old clients though, so that they can view newer MVD's, etc. It might be possible to use the same type of "variable" (I forget what they're called?) that w_switch and b_switch are, that are exposed to the server whenever they're changed by the client. Userinfo or something.
Edit:
Another solution is inspired from the OP! Re-implementing f_1, f_2, f_3, etc and letting KTX ask the client to trigger them when you're out of ammo. With one caveat: make ezQuake manage these aliases internally (and hide or write-protect them from the user) when you use impulse lists or the weapon command just to make it easy, and to preserve smackdown's "no triggers" deal. This idea might introduce a bit of delay between automatic switching when +attack is held down though.
Edit2:
In general, just a way to tell KTX "HERE is my preferred weapon order during this +attack session, please update it at your end too" is what I'm getting at.
Member 357 posts
Registered: Mar 2006
only newbs use weapon scripts c'mon its 15 years later jeez !
bind q "impulse 7 5 4 3 2 1"
bind e "impulse 8 5 4 3 2 1"
done.
Member 124 posts
Registered: Apr 2012
bind q "impulse 7 5 4 3 2 1"
bind e "impulse 8 5 4 3 2 1"
During a match: 1. pick up lg 2. pick up rl 3. press q and hold down +attack until rl is out of ammo 4. ...suddenly lg starts firing Nice fix................. :p
Administrator 384 posts
Registered: Dec 2006
All I can say is I never experienced any issues whatsoever with KTPro's implementation which must be about 10 years old now, so it's a shame an equivalent hasn't made its way into KTX yet.
Administrator 1025 posts
Registered: Apr 2006
Seems pretty easy to implement. Somebody must know somebody who's a programmer or has knowledge enough to implement.
Member 215 posts
Registered: Feb 2011
So I fixed 95% of my weapon switching issues with an elegant ( ) "1-line" fix ( patch here). Now the weapon order doesn't persist, which is exactly what I want. Once a bind has been selected such as "weapon 7 2 1", the client will change weapons based on the desired order and the weapons I have at that time, and then "overwrite" the first element of the order with the selected weapon. So, if you only have an SG and press that bind, you will not end up automatically switching to RL any time in the future just by picking up a pack or RL. If you did have RL, you will obviously switch to it as your selected weapon, and when you run out of ammo you will switch to SG and then Axe since that is what was defined as your preference. Also, picking up rox at this time still won't auto-switch you back to RL. Perfect behavior! This works for any value of cl_weaponpreselect and in fact always behaves just as if cl_weaponpreselect is set to 0 while keeping the weapon script functionality in place. Previously, I would get all sorts of weird behaviors with preselect enabled. The only thing still broken is related to ktx's behavior: if you hold down +attack while running out of ammo, the server will automatically switch your weapon for you and fire it. For example, if you have lg (and are not in the water) and run out of rockets, the server forces you to fire your lg even though your HUD shows you holding SG. The problematic code is at https://github.com/jite/ktx/blob/master/src/weapons.c#L1645. Note that the function is called W_BestWeapon() even though it doesn't really select your best weapon (rl and gl portions are commented out). The good news is that this only happens if you keep holding +attack while running out of ammo. If you let go of +attack, the situation gets automatically resolved. I can live with this. If someone wants to try out this build, you can find it here . None of the default client behavior is affected because you need to set a new variable called cl_weaponforgetorder for this change to take effect. My weapon script is now this: // START WEAPONSCRIPT cl_weaponhide "2" cl_weaponpreselect "4" cl_weaponforgetorder "1" r_viewpreselgun "1"
bind MOUSE1 "+att" // Press to manually fire currently selected weapon bind RALT "+lg" // Press and hold to switch+fire lg/ng/sg, release to switch back to previous weapon for manual firing
set wasfiring "0" // Needed to support the +lg script so that we can keep firing after -lg if MOUSE1 is still held down
alias +att "+attack; set wasfiring 1" alias -att "-attack; set wasfiring 0"
bind 1 "weapon 1" bind 2 "weapon 2 1" bind 3 "weapon 3 2 1" bind 4 "weapon 5 4 2 1" bind 5 "weapon 5 4 2 1" bind 6 "weapon 6 2 1" bind 7 "weapon 7 2 1" bind 8 "weapon 8 2 1" bind / "weapon 8 7 6 5 3 2 1" // bestfire bind MOUSE4 "weapon 3 2 1" //safefire
alias "+lg" "set wp $weaponnum; weapon 8 5 2; +attack" alias "-lg" "-attack; weapon $wp; fireornot"
// This is so that if Mouse1 is held, and then Alt is held and let go while Mouse1 is still being held, Mouse1 continues to fire alias fireornot "if ($wasfiring = 1) then +attack" Cheers, BD P.S. Thanks to bogojoker for helping to test! (Edited 2014-05-04, 02:50)
Member 142 posts
Registered: Jul 2013
So I fixed 95% of my weapon switching issues with an elegant ( ) "1-line" fix ( patch here). Now the weapon order doesn't persist, which is exactly what I want. Once a bind has been selected such as "weapon 7 2 1", the client will change weapons based on the desired order and the weapons I have at that time, and then "overwrite" the first element of the order with the selected weapon. So, if you only have an SG and press that bind, you will not end up automatically switching to RL any time in the future just by picking up a pack or RL. If you did have RL, you will obviously switch to it as your selected weapon, and when you run out you will switch to SG and then Axe. Perfect behavior! This works for any value of cl_weaponpreselect and in fact always behaves just as if cl_weaponpreselect is set to 0 while keeping the weapon script functionality in place. Previously, I would get all sorts of weird behaviors with preselect enabled. The only thing still broken is related to ktx's behavior: if you hold down +attack while running out of ammo, the server will automatically switch your weapon for you and fire it. For example, if you have lg (and are not in the water) and run out of rockets, the server forces you to fire your lg even though your HUD shows you holding SG. The problematic code is at https://github.com/jite/ktx/blob/master/src/weapons.c#L1645. Note that the function is called W_BestWeapon() even though it doesn't really select your best weapon (rl and gl portions are commented out). The good news is that this only happens if you keep holding +attack while running out of ammo. If you let go of +attack, the situation gets automatically resolved. I can live with this. If someone wants to try out this build, you can find it here . None of the default client behavior is affected because you need to set a new variable called cl_weaponforgetorder for this change to take effect. P.S. Thanks to bogojoker for helping to test! Do you go to MIT or something?
Member 37 posts
Registered: Jan 2007
I'm struggling with cl_weaponhide, cl_weaponpreselect and r_viewpreselgun variables...
Using cl_newhud 0 (ie oldschool/original hud) it doesn't shows the pre selected ammo, only the gun model (the sg/ssg ammo keep showing on the screen while the pre selected gun is there). With newhud 1 it's fine.
Is that a bug or am I missing something? a.k.a. doob/db/oldb | O Clă [6] member & founder | twitch.tv/oldb_qw
Administrator 887 posts
Registered: Jan 2006
bind SPACE "+shaft" bind e "bind mouse1 +fire7" bind q "bind mouse1 +fire6" bind 2 "bind mouse1 +fire2" bind o "say A HULI TUT!?!?" All I need. Join us on discord.quake.world
|
|
|
|