Talk:Weapon scripts
From TF2 Wiki
I'm looking to use Shift Autoattack as automedigun with tap MOUSE1 to heal new target. I can't code it.
//Shift-Autoattack //========================== alias +primaryattack "-attack" alias -primaryattack "+attack; +jump" alias +primaryattackmodifier "alias -primaryattack +attack" alias -primaryattackmodifier "alias -primaryattack -attack" //========================== bind "MOUSE1" "+primaryattack" // Tap to select new heal target. bind "SHIFT" "+primaryattackmodifier"
This is a wild guess I haven't tested yet. I threw the +jump in there for the helluvit. I am also looking for a bunnyhop script and am checking if that'd work. Like, alias +bhop "-jump"
-bhop "+jump" or something. Although, I'd want it to bunny hop for as long as I hold the space bar.
- I'm not even going to bother with the bunny hop script, these have always been a nightmare to get the timings right, and I beleive bunny hopping has now been fixed (see Bunny hopping). The auto-attack doesn't look right to me though, I would have thought you would have to let go of the mousekey to fire as it stands, but I can't test it at the moment. I'll give an "off the cuff" response until I can check it, and I'm removing the +jump because it's confusing (add it back if you need to).
//Shift-Autoattack //========================== alias +primaryattack "+attack" alias -primaryattack "-attack" alias +primaryattackmodifier "alias -primaryattack +attack;alias +primaryattack -attack;+attack" alias -primaryattackmodifier "alias -primaryattack -attack;alias +primaryattack +attack" //========================== bind "MOUSE1" "+primaryattack" // Tap to select new heal target. bind "SHIFT" "+primaryattackmodifier"
- I have a fealing that the extra "alias +primaryattack -attack;+attack" would be needed to select a different target. As I said, it's "off the cuff" but I will check it tonight because I may steal the idea myself :) --Aurora 11:51, 19 December 2007 (CST)
- Thanks!
- What I put was incorrect, just tried it and I believe what you intended to happen works with the standard Shift-Autoattack originally posted, you just had the +/-attack the wrong way round.
//Shift-Autoattack //========================== alias +primaryattack "+attack" alias -primaryattack "-attack" alias +primaryattackmodifier "alias -primaryattack +attack" alias -primaryattackmodifier "alias -primaryattack -attack" //==========================
- Okay, what I requested was a mistake. What I actually want is Left Shift for autoattack, Left Shift again for new heal target. I don't understand 'alias -primaryattack +attack;alias +primaryattack -attack;+attack'. Aliases inside aliases confuses me, A LOT. Also, I want autoredisguise with Left Shift too. When I use Left Shift, it doesn't autoredisguise. Also, if I switch classes then switch back to spy, autoredisguise doesn't work with Left Mouse click. I had to use the double tap config class switcher and add this script to spy.cfg to fix it and tap numpad 9 twice to get autoredisguise again.
- Firstly aliases within aliases: Mainly used to re-assign an alias, if you look at the script above as an example - What the "primaryattackmodifier" is doing is re-assigning the "-primaryattack" command to act like a switch between +attack and -attack. Effectively this is a switch to leave the "attack" in a state of always on, or switched off; think of it as holding the MOUSE1 down or have it released. You have to do this to perform an on/off switch in HL2 scripting because there is no easy way to do this like assigning a value to a user defined variable like in other scripting languages (sadly - I'd love Valve to introduce user defined variables).
- Secondly you don't specify if the Left Shift should be held or not. It sort of implies that you don't from previous posts, which would cause a problem - When would the autoheal get turned off? I had the same issue when I setup my Medic script, I wanted to press the MOUSE3 once to autoheal, press it again to select a different target. Having done it and tested it I realised I couldn't do this because nothing was turning the +attack off, which means when you switch weapon it will autofire until you press MOUSE1. No way round this because the script was doing exactly what I told it to do, I just hadn't though about it enough. You need to have something turn it off , even if its a third press or when you switch weapon (much more complicated but what I ended up doing).
- So before I suggest any more scripts, can you write down what you want each key to do (including the release) and what disguise script you use as I don't know what commands to include, like this:-
- Left SHIFT - Hold = start autoheal, set disguise to Blue Sniper (using Essobie's "Spy Quick Disguise" script)
- Left SHIFT - Release = stop autoheal
- MOUSE1 - Press 1 = Reselect autoheal target (if holding Medigun)
- If you find it easier (I certainly would) find me in the TF2 Wiki Community on Steam and send me a message/scripts --Aurora 11:20, 3 January 2008 (CST)
- Shift = Toggle autofire ON. ARD (autoredisguise). Redisguise = lastdisguise.
Shift again = Toggle off then on quickly. A.K.A. select new heal target. MOUSE 1 = Attack + ARD + toggle autofire off.
Why use wait command?
For example in the script "Bind-Agnostic Version of Weapons Scroll":
//Alias-only Weapons Switching alias weaponSet "secondary" alias primary "slot1; wait; alias weaponSet secondary" alias secondary "slot2; wait; alias weaponSet primary" //Now bind whatever you like to weaponSet. For example, bind "MWHEELUP" "weaponSet" bind "MWHEELDOWN" "weaponSet"
If I take the wait commands out, it still works as expected. On some of the other weapon scripts, the wait command makes the function slightly unresponsive which make the unuseable for me. --Jabu2oz 08:09, 22 December 2007 (CST)
