jooonior / tf2-loadouts-script

Loadout specific settings and a resup bind that knows which loadout you're on.
32 stars 2 forks source link

More than 4 loadouts? #5

Closed gabrielwoj closed 3 years ago

gabrielwoj commented 3 years ago

Hi, is it possible to make the script load more than 4 loadouts? I have implemented a funciton where the game loads a 5th loadout by using the script, it replaces the load_itemprest 3 (as an example) with something else, but uses another "slot" hidden on the script.

I'm okay if loadout E loads load_itempreset 3 with a different set of items, I just would like more loadouts so I can wear different weapons and cosmetics. If anything, I can simply remove the "Loadouts A-D" buttons on my HUD, to avoid confusion, and rely on hotkeys only.

So I can do something like... F1-F4 are loadouts based around Stock, and serious gameplay, using the load_itempreset 0 F5-F8 are for other types of loadout, using load_itempreset 1 F9-F12 are for MVM-related loadouts, using load_itempreset 2 N and M is for Medieval-related loadouts, using load_itempreset 3

The part I'm most confused is this one:

alias loadouts.load.A"alias loadouts.load.A;alias loadouts.load.B echo l1B;alias loadouts.load.C echo l1C;alias loadouts.load.D echo l1D; alias loadouts.load.E echo l1E" alias loadouts.load.B"alias loadouts.load.A echo l1A;alias loadouts.load.B;alias loadouts.load.C echo l1C;alias loadouts.load.D echo l1D; alias loadouts.load.E echo 11E" alias loadouts.load.C"alias loadouts.load.A echo l1A;alias loadouts.load.B echo l1B;alias loadouts.load.C;alias loadouts.load.D echo l1D; alias loadouts.load.E echo 11E" alias loadouts.load.D"alias loadouts.load.A echo l1A;alias loadouts.load.B echo l1B;alias loadouts.load.C echo l1C;alias loadouts.load.D; alias loadouts.load.E acho 11E" alias loadouts.load.E"alias loadouts.load.A echo l1A;alias loadouts.load.B echo l1B;alias loadouts.load.C echo l1C;alias loadouts.load.D; alias loadouts.load.E acho 11E" loadouts.old.scout loadouts.restore.scout

I honestly have no idea what's going on here. I'm mostly sure this is the part that is causing errors. I will indent the code later for easier management, but this is how it looks right now.

The game did recognize the loadout E, and the console printed the correct stuff, but when I'm trying to switch loadouts around, the loadout E uses the previous loadout I selected.

I have added the "5th loadout" functionality like this:

load.cfg: alias loadouts.A"load_itempreset 0;loadouts.load.A" alias loadouts.B"load_itempreset 1;loadouts.load.B" alias loadouts.C"load_itempreset 2;loadouts.load.C" alias loadouts.D"load_itempreset 3;loadouts.load.D" alias loadouts.E"load_itempreset 3;loadouts.load.E" ... alias loadouts.scout"alias loadouts.class.A l1A;alias loadouts.class.B l1B;alias loadouts.class.C l1C;alias loadouts.class.D l1D;alias loadouts.class.E l1E;loadouts.restore.scout;echo [Loadouts] Scout loadout restored."

restart.cfg alias loadouts.load.A"alias loadouts.resup load_itempreset 0;loadouts.class.A;loadouts.cfg.A;echo [Loadouts] Active loadout: A" alias loadouts.load.B"alias loadouts.resup load_itempreset 1;loadouts.class.B;loadouts.cfg.B;echo [Loadouts] Active loadout: B" alias loadouts.load.C"alias loadouts.resup load_itempreset 2;loadouts.class.C;loadouts.cfg.C;echo [Loadouts] Active loadout: C" alias loadouts.load.D"alias loadouts.resup load_itempreset 3;loadouts.class.D;loadouts.cfg.D;echo [Loadouts] Active loadout: D" alias loadouts.load.E"alias loadouts.resup load_itempreset 3;loadouts.class.E;loadouts.cfg.E;echo [Loadouts] Active loadout: E"

save.cfg alias l1A alias loadouts.old.scout loadouts.load.A alias l1B alias loadouts.old.scout loadouts.load.B alias l1C alias loadouts.old.scout loadouts.load.C alias l1D alias loadouts.old.scout loadouts.load.D alias l1E alias loadouts.old.scout loadouts.load.E ... l1A;l2A;l3A;l4A;l5A;l6A;l7A;l8A;l9A con_logfile cfg/saved_loadouts.txt alias loadouts.load.A"alias loadouts.load.A;alias loadouts.load.B echo l1B;alias loadouts.load.C echo l1C;alias loadouts.load.D echo l1D; alias loadouts.load.E echo l1E" alias loadouts.load.B"alias loadouts.load.A echo l1A;alias loadouts.load.B;alias loadouts.load.C echo l1C;alias loadouts.load.D echo l1D; alias loadouts.load.E echo 11E" alias loadouts.load.C"alias loadouts.load.A echo l1A;alias loadouts.load.B echo l1B;alias loadouts.load.C;alias loadouts.load.D echo l1D; alias loadouts.load.E echo 11E" alias loadouts.load.D"alias loadouts.load.A echo l1A;alias loadouts.load.B echo l1B;alias loadouts.load.C echo l1C;alias loadouts.load.D; alias loadouts.load.E acho 11E" alias loadouts.load.E"alias loadouts.load.A echo l1A;alias loadouts.load.B echo l1B;alias loadouts.load.C echo l1C;alias loadouts.load.D; alias loadouts.load.E acho 11E" loadouts.old.scout loadouts.restore.scout

Upon closing the game, It did add 11E to my saved_loadouts.txt just fine.

I have extracted the .vpk to be able to customize the script, and the original .vpk is not on my custom folder.

Thanks.

jooonior commented 3 years ago

is it possible to make the script load more than 4 loadouts?

The script can be extended to track any amount of arbitrary loadouts, but there's no command to change which items you have equipped, so you're stuck with the four load_itempreset sets. What it could do is execute different commands for each arbitrary loadout, even if they share the same itempreset, but I don't think that's what you were hoping for.

I know some community servers have plugins where you can say !equip or !item (or something) in chat to equip different weapons, but where's no way to do this in vanilla TF2 I'm afraid.

I have extracted the .vpk to be able to customize the script

Take the "source code" from the repo instead (here). It has comments and proper formatting, which are not in the release VPK to make it's file size a bit smaller.

The part I'm most confused

You should be able to make sense of it from the source code.

I have added the "5th loadout" functionality like this

Yeah you're doing it right, just add E wherever you see ABDC and it should work.

gabrielwoj commented 3 years ago

Thanks for the response, but yeah, that's sadly not what I'm looking for. I think I'll have to rely on a custom AutoHotkey script which moves the mouse around and do specific clicks in specific locations, so I can make a little script that always chooses the correct items. The "Search: " bar when choosing an item will definetely come in handy.

It will take some time for the script choose each item and let the menus load themselves, but I'm not really a serious TF2 player, so it's alright. I could try using +quickswitch as well, that could work even faster. But unlike the standard loadout menu, +quickswitch does not allow you to search, and the script may not work anymore if I own any extra items after making such script.

I can also make the script only work if hl2.exe is running. So... if I press, for example, F1 in Windows, the mouse won't move around in the screen.

A regular AutoHotKey script does not hook on hl2.exe's process, so it's not considered a cheat. I have been using other AutoHotKey scripts while running TF2 for some years now, but these scripts weren't related to TF2 (mostly window management on Windows, as well one script that auto-moved my mouse cursor every couple of seconds when it remained completely stand still, due to a crashing issue I had with my PC years ago which would crash if remained idle, for some reason...). I have even used AutoHotKey while running Overwatch, which has a more sophisticated anti-cheat detection (though, they are both totally different engines).