• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

I wrote a simple savegame loader

Status
Not open for further replies.
Level 1
Joined
Sep 29, 2015
Messages
1
So, Gaias Retaliation is probably in the top 3, if not the best warcraft map ever made. Thanks for your hard work and dedication, guys, and so should Blizzard; if it weren't for people like you, the game would've been long dead.

Anyway, I love how the load code gets written to the WC3 folder, which makes it a breeze to play short sessions without spending half the time typing the key. As I play solo a lot, I figured I could shorten the (already short) time it takes to load a hero, so I wrote a script in python to extract the key from the latest savegame and copy it to the clipboard, change focus to the Warcraft III window and Enter, paste load command, Enter.

I used pyinstaller to create a one-file executable with all the dependencies, and I've added it to the quick launch bar so I can load the map, alt+tab, click the icon and start playing.

Here's how you use it:

1. Download the zip file containing load.exe
2. Extract load.exe to your save folder (<WC3-folder>\GaiasRetaliation\<yournick>), you can make a shortcut to it for convenience.
3. Load the Gaias Retaliation ORPG map and press any key to enter game.
4. Press alt+tab and launch load.exe.

The WC3 window will be restored and your hero will get loaded.

Here's the code:

Code:
from os import path
from glob import iglob
from pyperclip import copy
import win32com.client
from win32gui import GetWindowText, GetForegroundWindow

# Get's most recently modified file
newest = max(iglob('*.txt'), key=path.getctime)
print("Newest savegame: ", newest)

# Extracts the load command from the file
with open (newest, "r") as myfile:
    data=myfile.readlines()
length = len(data[4])
command = data[4][4:(length - 5)]
print("Save code: ", command)

# Adds the command to windows' clipboard using pyperclip
copy(command)
print("Save code copied to clipboard.")

# Uses win32com to set the focus to WC3 window, then presses
# enter key to activate it as it wasn't working when in fullscreen
shell = win32com.client.Dispatch("WScript.Shell")
test = shell.AppActivate('Warcraft III')
shell.SendKeys('{ENTER}')

# Makes sure you're in the WC3 window before pasting the command
if GetWindowText(GetForegroundWindow()) == "Warcraft III":
	shell.SendKeys('^{V}')
	shell.SendKeys('{ENTER}')

It has only been tested on Win10 x64 for now, but there shouldn't be any reasons for it not to work on other Windows releases. If you guys like it, I can spend some time improving it to make it more convenient, as this is just a quick script I threw together. The file size is due to it containing the python3.5 runtime and other modules to keep it self-sustained, the win32gui dependencies alone ramp up to 3.5MiB.
 

Attachments

  • load.zip
    7 MB · Views: 128
Level 8
Joined
Oct 2, 2011
Messages
551
Good job. Unfortunately people here don't seem to be interested in load scripts, even though it's so undeniably convenient. I've made various scripts for all rpgs I've played (haven't needed to copy-paste codes in years) and pretty much nobody has bothered trying them.

I like your program because it's self-sufficient, hopefully others will see how easy it is to use then try it out. The only problem I see is that it's an exe file which are pretty dangerous to download and use off the interwebz (though even an online anti-virus service would be able to quickly verify a file this small)
 
The problem with these loaders is usually, that you still need to alt+tab the game to load, which makes it... not that much more convenient over just opening the txt and manually copying the code. For example, I put a link to the GaiasRetaliation folder directly on my desktop, so I don't even have to browse the filesystem anymore if I want to get a specific .txt.

Great work though! It's good to see people still make 3rd party tools for wc3!
 
Level 8
Joined
Oct 2, 2011
Messages
551
I use ahk scripts. So basically I will just type something like "loadbrd" in the war3 chat line and my bard will promptly load. Never a need for me to alt-tab or browse the file system in any way. This is how most war3 code loaders are (ahk is immensely popular for war3 in general) so I'm not sure why you would think alt-tabbing is an issue with loaders.

Also, even in this case making an ahk script to start this .exe with just a key like CTRL+L (or adding a similar function to the program itself) would be really simple.
 
Level 8
Joined
Oct 2, 2011
Messages
551
The folder name doesn't matter, it would theoretically work as long as the program is placed in the folder where your save texts are.
 
Status
Not open for further replies.
Top