Staredit Network > Forums > SC1 UMS Theory and Ideas > Topic: Using EUD for custom AI
Using EUD for custom AI
Dec 14 2017, 4:59 pm
By: jncraton  

Dec 14 2017, 4:59 pm jncraton Post #1

I know almost nothing about UMS map making, and until the recent SCR patch, I had never looked at EUD in any detail. However, I have been working on an improved melee map AI for over a decade off and on:

My AI uses the older and much more limited method of patching the internal AI scripts rather than just hooking into the game externally as BWAPI does. I like this method as it is very simple to get up and running.

Currently, using my AI in SCR requires overwriting patch_rt.mpq. I'm curious if it might be possible to build this directly into a UMS map by making use of EUD. I found this list of offsets posted recently:

It lists these offsets:

0x0068C104 0x0068C108 backed by code hAIScript
0x0068C108 0x0068C10C backed by code hBWScript

It sounds like those are pointers to the start of aiscript.bin and bwscript.bin. Does anyone know if that is correct? In theory, could I write custom scripts to some scratch memory somewhere and update these pointers to point to them?

I haven't looked at how AI scripts are actually executed by SC in tremendous detail, but my assumption is that it has a program counter of some sort that points to the next AI instruction to execute. It seems probable that I'd need to be able to overwrite this address to get this working unless the PC is relative to the start of AIScript.bin. Is this offset known and accessible via the new EUD rules?

I'd love to see any work that others have done on this if there is anything available. Thanks!

Dec 14 2017, 11:19 pm trgk Post #2



Dec 15 2017, 12:17 pm Heinermann Post #3

SDE, BWAPI owner, hacker.

Curious, can the pointer just be modified to point to a section in the map's CHK file? Or does the data need to be overwritten entirely by triggers?

Dec 15 2017, 2:07 pm trgk Post #4

Quote from Heinermann
Curious, can the pointer just be modified to point to a section in the map's CHK file? Or does the data need to be overwritten entirely by triggers?

Some requires data copy. Some only requires pointer modification (ex: iScript).
Here we use NPA, which generates triggers that overwrite existing AIScript memory.


Dec 16 2017, 3:38 pm jncraton Post #5

This is very helpful. Thanks! It looks like at minimum this was possible in 1.16 and may be possible in SCR.

Here's what I've done so far:

- Created a basic EUD map in SCMDraft to prove to myself that I understood the basics of what this technique allows. I simply altered the game speed.

- Created a map that alters the two offsets that I mentioned in my first post. I confirmed that the alterations took place using Cheat Engine, but there was no effect on AI behavior.

I'm not entirely sure where to go from here. I wasn't able to make sense of the Korean language tools for doing this. It sounds like I will actually need to use EUD triggers to overwrite the content of aiscript.bin. This makes sense, but I'm not sure how to determine the offset to write to. Also, does anyone know if this offset is even accessible in the SCR EUD emulation?

Dec 16 2017, 3:52 pm Nekron Post #6

This is slightly off-topic, but I'm not really sure if confining yourself to EUD maps has any real benefits over using a Samase remastered .exe with AIscript/BWscript; a custom .exe is arguably as easy to run as downloading separate maps, as long as you intend for something to be single-player.

Dec 16 2017, 4:46 pm jncraton Post #7

That's a good point. The benefits of this aren't huge. Basically:

1. You could play against different AIs without restarting StarCraft
2. You could play multiplayer online against custom AIs very easily
3. You could be confident that Blizzard wouldn't ban your account

However, I'm becoming less confident that this is possible in SCR. The memory address for the aiscript.bin data appears to change between games, and doesn't seem to be relative to the death table data, so I don't think I have a way to modify it from inside the game.

Dec 16 2017, 11:48 pm Heinermann Post #8

SDE, BWAPI owner, hacker.

You could use whatever current player trick is being used by some people. You have access to the AIScript pointer, so you use the CP trick to binary copy the pointer value into the current trigger player (as value/4 - deaths_base/4) and then use deaths of terran marine for current player to write to it.

Dec 21 2017, 3:37 pm jncraton Post #9


I'm not sure I fully understand at this point, but it sounds like you are referring to this trick:

I don't understand how it works just yet, but it sounds like in principle it should allow me to write to an offset relative to the AIScript pointer.

Dec 22 2017, 10:07 pm jncraton Post #10

Thanks for all of your help!

I've been able to successfully embed my custom aiscript.bin in a set of EUD triggers. Here are the maps if you'd like to try them out and/or see exactly how they work.

Post has been edited 1 time(s), last time on Dec 22 2017, 10:29 pm by jncraton.

Dec 26 2017, 5:25 pm Nekron Post #11

This should perhaps have been mentioned earlier, but using UMS causes all scripts to be campaing scripts instead of melee ones :P
That shouldn't be a big deal for your scripts, but it will cause differences in attack patterns and some opcode usage changes + will fix the issue where non-campaign protosss AIs (almost?) never build archons

The attacking issue (random regions instead of safest/nearest regions) is the biggest concern here since it makes lots of the attacks disorganised on maps that are not properly designed, from the AI's viewpoint

Also, was there anything more than what's already in this thread you needed to make EUD work? It could be actually pretty useful accessibility-wise for me, if I'd be able to use it on my future campaign maps

Dec 29 2017, 5:38 am jncraton Post #12

Thanks for the information. I'll definitely have to look into the melee and campaign script differences to see if this may be causing issues.

I didn't need much information other than what was in this thread. I wasn't able to find a working tool that would write the appropriate triggers for me, but I was able to get the pointer math working and scripted the large number of triggers that actually write the individual words of aiscript.bin. Here's the trigger template that I use:

Let me know if you run into problems getting this working. I don't think it will be too difficult if you already understand EUD triggers. That was the most challenging part for me.

Jan 29 2018, 3:06 pm Nekron Post #13

Correction re:archons: Melee AI seems to train them properly under some circumstances? Using a sample script that was basically only build tech, train archons the AI merged them without a delay. Psionic storm seems to disrupt the merging, S O M E T I M E S

The conditions for military high templars to merge are (courtesy of Neiv) having 75+ energy and being in region state 4 / 5 / 8 / 9, but there's also something that lets them merge even if they're below 75 energy.

Still can't get blizzard default AIs to ever train them and haven't seen any in non-UMS JNC protoss, though - maybe just bad luck?

Aug 20 2019, 4:22 pm psyhotechnica Post #14

Quote from trgk

Where do you find NPA 5?


  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:59 am]
UndeadStar -- Wow, that Johnseena adbot, 4 topics in a row, not gonna give it the pleasure to open them all, probably obvious enough without a report
[2022-1-20. : 11:46 pm]
O)FaRTy1billion[MM] -- firegraft is for making mods for starcraft, if you're trying to do stuff like that for a single map then EUD Editor is probably what you are looking for
[2022-1-20. : 11:45 pm]
O)FaRTy1billion[MM] -- fusiongtxo0
fusiongtxo0 shouted: my computer says the download of firegraft has a virus
ya, for some reason AVs like to say it's some infected browser extension or something
[2022-1-20. : 5:37 pm]
fusiongtxo0 -- like in gods tower defense
[2022-1-20. : 5:37 pm]
fusiongtxo0 -- will firegraft allow me to make a tiger able to attack
[2022-1-20. : 5:11 pm]
NudeRaider -- that's normal for modding tools. All it means is that your virus scanner hasn't seen the file often.
[2022-1-20. : 4:56 pm]
fusiongtxo0 -- this is bullshit lol
[2022-1-20. : 4:56 pm]
fusiongtxo0 -- my computer says the download of firegraft has a virus
[2022-1-20. : 4:42 pm]
fusiongtxo0 -- so can you guys answer my question in ums assistance for sc1
[2022-1-20. : 2:57 am]
Ahli -- KrayZee
KrayZee shouted: When Kotick leaves, I'd say this.
too bad that he will leave with an additional f*ckton of money after the acquisition will be completed :(
Please log in to shout.

Members Online: Zergy, NudeRaider, Voyager7456, C(a)HeK, jun3hong