Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Absolute noob guide to modifying SC AI (no mods)
Absolute noob guide to modifying SC AI (no mods)
Feb 12 2021, 7:13 pm
By: Fruitdispenser  

Feb 12 2021, 7:13 pm Fruitdispenser Post #1



I created this guide because as a noob, I expent like 6 hours asking someone to explain me how to make certain units to start with 100% energy and 100% hangar. I someone helped me, I have to give something back. We all help eachother


After I finished the campaigns I thought that some missions could have been a little harder. I started reading on how to modify AI's, and everywhere I went, people said you needed mods. How could I play with friends or upload maps if everyone needed to download stuff. BUT, this guy
https://github.com/jncraton/BWMetaAI
discovered that you don't need to. He converted the ai scripts file, aptly named aiscript.bin, to triggers.

The trick is using EUD's. We don't need to know too much about it, but in short, Set Deaths trigger action allows you access parts of the runtime game memory so we can modify it. However, because Windows and Mac SC versions use different memory addresses, this won't work on Mac. Unless in the future, someone manages to find the Mac AIScript pointer


As the following scripts will apply to player one, player one needs to be present. It can be Computer, Neutral, Rescuable or Human. Doesn't matter, but it needs to be present. So, remember to place a Starting position for player 1.

First thing, first. Wee need tools to modify the AI.
The tool we are gonna use is the PyAI module of the PyMS modding suite. You can download PyMS here
Press on Code and select 'Download ZIP'.


To run PyMS you need to have installed python 2.7.x (download here) and PIL [download here(remember to download PIL compatible with python 2.7)]

For people who has Python >3.x installed, python 2to3 doesn't work translating it and I found out that the faster way to proceed was to install a Windows XP virtual machine and install Python 2.7.9 there. Why 2.7.9? Because it's the latest version able to run on XP
I suggest Oracle Virtual box, because it allows you to copy-and-paste AND drag-and-drop to and from guest to host



So, we have already installed PyMS. We open PyAI and it should look like this



We open the default scripts.




What script should we modify?. How about purple Zerg in SC Protoss last mission, 'Eye of the Storm'? I have prepared a two player version, so you can play with friends.

Looking trought the triggers, we see that purple uses 'Protoss 10 - Overmind defenders'

We open it and start modifying it.



For example, we can add more ultralisk to defense, so instead of
Code
    defensebuild_gg(1, Zerg Ultralisk)
    defenseuse_gg(1, Zerg Ultralisk)


we can change it to
Code
    defensebuild_gg(3, Zerg Ultralisk)
    defenseuse_gg(3, Zerg Ultralisk)



If we move down a little bit, we can see we can research techs
Code
    tech(Plague, 30)
    tech(Spawn Broodling, 30)



The basis of an attack is
Code
    attack_add(24, Zerg Zergling)
    attack_prepare()
    wait(500)

    attack_do()
    attack_clear()


We add units to an attack, we prepare, we wait a little bit, we do the attack and we clear the attack, so we can prepare the next one

Now, if we want to cycle attacks, we can do the following
Code
        --P10o 0000--
//place your attacks here
    goto(P10o 0000)

That will cycle forever.


This is a list of all AI functions


Now that we are done, we save and overwrite the script


And save the aiscript bin files to desktop or wherever you want.



Now is where the magic begins. We need to transform this aiscript.bin files to triggers.

We extract the attached jncraton-tool files to the same folder in which the AI bin file exist and we run the 'eud_gen_trigs' file. If we had modified a BW script, we should have run the 'eud_gen_trigs_bw file'.



A 'trigs.txt' (or 'trigs_bw.txt') file will be created. If you open it, it has a lot of triggers.



Because there are so many triggers, I suggest only modifying vanilla AI (aiscript.bin) files or only BW AI (bwscript.bin) files. It seems that aiscript.bin scripts are unable to train/research/upgrade BW stuff, which makes sense. In the same vein, because there are so many triggers to run, 'Run AI' triggers should run after a few seconds


Now, copy all the contents of the recently generated 'trigs.txt' file and paste it. But where?


Assuming you already have SCMDraft 2, you need to install TrigEditPlus. Donwload that, and place the 'TrigEditPlus.sdp' file in the plugins folder of your SCMDraft 2 folder.

Open SCMDraft, go to the Triggers tab and BEFORE opening TrigEdit++, open 'Trigger Editor' and compile. Why? Sometimes there are syntax errors that will prevent us from compiling the triggers we will be pasting in TrigEdit++.





So, spoiler, we need to paste the contents of 'trigs.txt' to TrigEdit++ and well see something like this
Before pasting


After pasting




We'll press F5 to compile, we save and we are done.




However, wanna do something a little bit cooler? Let's say we want to make red player train Hunter Killers instead of Hydras? You'll need EUD 3 and to run that, you'll also need euddraft
As of 12-Feb-2021, for latest version of EUD 3, euddraft 0.9.0.9 is the recommended version.



Now, let's go back to our aiscript.bin file and modify 'Protoss 10 - Mini-Town Master'


Note: the <0> and the following words are automatically written once you save and quit the script. You only need to write Hunter Killer. The same for every unit that has a parenthesis in the 'Units' file in jncraton-tool.


We again, save the script, save the file, run eud_gen_trigs, open trigs.txt, copy, paste in TrigEdit++.
IT'S SUPER IMPORTANT YOU DELETE ALL THE PREVIOUS TRIGGERS RELATED TO THE PREVIOUS AISCRIPT.BIN ITERATION.
PRESERVE THE SCENARIO TRIGGERS (defeat conditions, initial resources, dialogs, even the Run AI script triggers), DELETE THE aiscript.bin RELATED TRIGGERS.

Do this everytime you modify the relevant scripts of the scenario file you are working.


So, we already told the AI to build Hunter Killers. We now need to tell the game that Hunter Killers is a perfectly breasonable unit to train.
EUD 3 does a lot of stuff under the hood. It inyects from an scenario A to an empty scenario B. But it needs a favor from us. It needs we create an empty scenario file to inyect all the stuff we'll do. I just copied and pasted the scenario, though. It doesn't matter.






Anyway, we open the dat editor.





Search for Hydralisk.



Select Zerg Hydralisk, go to Requirements, select User Custom, right click over a Requirement and select Copy


go to Hunter Killer, go to Requirements, select User Custom

right-click on the white window

and paste


We do that again with the other requirements. PRESERVE THE ORDER OF THE REQUIREMENTS.For terran units that require add-ons is important. We can drag the requirements inside the white panel.


We'll also modify the Hunter Killer AI order section to be the same as the Hydralisk,
Hydra AI order


Stock Hunter Killer AI order


Modified Hunter Killer AI order



and the required supply, in the Default tab.
Hydra supply


Stock Hunter Killer supply


Modified HK supply


Otherwise, the AI will train like 40 Hunter Killers, even when we told it to train just a few. We save the proyect

and build.



Everything should be allright now. Now, when you go over the internet, you create a game using the Inyected scenario, not the base one.

Attachments:
jncraton-tool.zip
Hits: 8 Size: 4.73kb
(2)Eye of the Storm extreme_base.scx
Hits: 4 Size: 6563.45kb

Post has been edited 3 time(s), last time on Feb 27 2021, 2:07 pm by Fruitdispenser.




Feb 12 2021, 11:24 pm Nekron Post #2



This is a pretty nice & succinct guide, I'm sure it'll be useful in all sorts of EUD maps :)




Feb 19 2021, 1:54 pm Fruitdispenser Post #3



Quote from Nekron
This is a pretty nice & succinct guide, I'm sure it'll be useful in all sorts of EUD maps :)


I'm glad you thing is nice. It's my very first tutorial ever, so if you or anyone who reads this posts has comments on it, they are more than welcome (welcomer?)



None.

Feb 25 2021, 2:38 pm IlyaSnopchenko Post #4

The Curious

Am I the only one who is seeing it so that the majority of the screenshots are really the same? (Basic unit properties sheet).



Trial and error... mostly error.

Feb 26 2021, 5:02 pm Fruitdispenser Post #5



Quote from IlyaSnopchenko
Am I the only one who is seeing it so that the majority of the screenshots are really the same? (Basic unit properties sheet).
Yes. You are right. I'll fix that as soon as I can. Thanks for noticing

Edit: fixed. For some reason, image url codes were wrong. It's weird because I just copied and pasted. Whatever.

Post has been edited 1 time(s), last time on Feb 27 2021, 2:10 pm by Fruitdispenser.



None.

Oct 9 2021, 3:06 am Gidoza Post #6



Hey there Fruitdispenser,

I'm just wondering is there a way for the AI to simply run two races simultaneously? It sometimes works on a map, but not consistently, and I have no idea why - and I feel like this is beyond my ability. :/



None.

Oct 9 2021, 11:17 pm Fruitdispenser Post #7



Quote from Gidoza
Hey there Fruitdispenser,

I'm just wondering is there a way for the AI to simply run two races simultaneously? It sometimes works on a map, but not consistently, and I have no idea why - and I feel like this is beyond my ability. :/
Hey!
Did you recently post in the official Starcraft forums?
I don't remember too well, but some Episode VI missions had players that controlled both Terran and Zerg building and units. I suggest taking a look at those.

Something to note, if you have a Terran base and a Protoss expansion and you use Terran AI and Protoss expansion AI, it works well.
Also, if you have a Terran base and a Protoss base and run AI's for those two bases, probes and SCV's get a little confused at first, but eventually they start working and build stuff.

Have you tried using two different players and changing the colors of said players?



None.

Oct 10 2021, 9:47 am Nekron Post #8



The easiest way to do this without modding (which I'll assume you don't wanna do based on the forum posts) is to slap a Protoss campaign script on with a Zerg attacking areatown, like the ones used in xT8 or xP8.

The issue you're seeing where the AI sometimes gets stuck on random stuff is because Remastered AI has priority bugs(example: when Protoss Campaign Insane builds up, it will get stuck for several minutes trying to get a shuttle before it even has a robo facility), it won't be able to build from scratch as well as it did. It works way better if you place bases for it (and of course, don't disable any units it wants to use)




Oct 12 2021, 2:10 am Luigi Post #9

In God I trust.

Quote from Nekron
The easiest way to do this without modding (which I'll assume you don't wanna do based on the forum posts) is to slap a Protoss campaign script on with a Zerg attacking areatown, like the ones used in xT8 or xP8.
TB8C is the only one I've found to do that. Unless start_areatown() is not needed.
Areatowns PB8B, PB8D and PB8F are just for mining.

I guess that a Protoss attacking areatown could work with ZB8A as well, but I would need to write it...

Note: I have installed Python after a lot of struggle with my computer. Then I had a lot of issues with PIP, and installing the right version of PILLOW after getting PIP (I think my computer is allergic to Python). Then I tried to run PyAI, but the window closes right after it opens (nothing from PyMS works for me). However, Veeq's version of PyAI works fine for me.



I'm the creator of StarCraft Adventures.
For Spanish version "Aventuras de StarCraft":
Aventuras de StarCraft (blog)

Oct 12 2021, 10:04 am Nekron Post #10



The attack scripts from xP8 are labeled P5-something, I think it's PB5A and PB5B. They're not areatowns, but they run a pretty consistent attack loop by themselves

To complement that you'll need a zerg areatown that actually builds something, or a zerg main town and a protoss areatown that attacks and upgrades (that one actually exists iirc somewhere in Vanilla, maybe Zerg 10 or Protoss 7?) but all in all it's going to be really messy unless you actually mod a new script in




Oct 14 2021, 2:31 am Luigi Post #11

In God I trust.

Quote from Nekron
The attack scripts from xP8 are labeled P5-something, I think it's PB5A and PB5B. They're not areatowns, but they run a pretty consistent attack loop by themselves
Yes, I looked for those scripts and found them. PB5B for orange Zerg and PB5A for brown Zerg in xProtoss 8.


Quote from Nekron
To complement that you'll need a zerg areatown that actually builds something, or a zerg main town and a protoss areatown that attacks and upgrades (that one actually exists iirc somewhere in Vanilla, maybe Zerg 10 or Protoss 7?) but all in all it's going to be really messy unless you actually mod a new script in
Pro7: Protoss 7 - Left Protoss Town (only researches Psionic Storm and Stasis Field).
Pro8 on the other hand... This areatown makes upgrades and attacks, while Pr8B is main town but only builds 1 Nexus and 4 Probes.
Pro8 and Pr8B are purple Protoss' scripts for the left and right base, respectively.

So I guess a decent thing to try would be PB8E + PB5B + Pro8.



I'm the creator of StarCraft Adventures.
For Spanish version "Aventuras de StarCraft":
Aventuras de StarCraft (blog)

Oct 16 2021, 12:46 am Gidoza Post #12



Quote from Fruitdispenser
Quote from Gidoza
Hey there Fruitdispenser,

I'm just wondering is there a way for the AI to simply run two races simultaneously? It sometimes works on a map, but not consistently, and I have no idea why - and I feel like this is beyond my ability. :/
Hey!
Did you recently post in the official Starcraft forums?
I don't remember too well, but some Episode VI missions had players that controlled both Terran and Zerg building and units. I suggest taking a look at those.

Something to note, if you have a Terran base and a Protoss expansion and you use Terran AI and Protoss expansion AI, it works well.
Also, if you have a Terran base and a Protoss base and run AI's for those two bases, probes and SCV's get a little confused at first, but eventually they start working and build stuff.

Have you tried using two different players and changing the colors of said players?

I did post on the SC General forums first indeed - someone referred me here. While I'm sure many are benefitting from your guide, for me it's just a headache. :/ That's a reflection of my own ability, not yours.


For the map in question I have 3 AIs that I want to run Protoss and Zerg bases simultaneously. I started with a test map first (before building the real map) to make sure it would work - and it did; all three worked fine. But then when I built the map I wanted, they mysteriously just chose not to work.

I've tried doing Protoss-Zerg AI, then Zerg-Protoss, setting each player to various particular combinations of starting race - everything. Nothing works. It simply works on one map and not the other.


Quote from Nekron
The easiest way to do this without modding (which I'll assume you don't wanna do based on the forum posts) is to slap a Protoss campaign script on with a Zerg attacking areatown, like the ones used in xT8 or xP8.

The issue you're seeing where the AI sometimes gets stuck on random stuff is because Remastered AI has priority bugs(example: when Protoss Campaign Insane builds up, it will get stuck for several minutes trying to get a shuttle before it even has a robo facility), it won't be able to build from scratch as well as it did. It works way better if you place bases for it (and of course, don't disable any units it wants to use)


Can you elaborate on this? What is a Zerg attacking areatown? Does it use all units, do all upgrades? Use big armies like Campaign Insane would?



None.

Oct 16 2021, 9:38 am Nekron Post #13



Luigi above listed a few of the good ones, but they're pretty tame in general. P5A/B attack frequently but with small stuff, though I guess you could stack them.
Areatowns are towns you can use alongside a main script that assign to themselves all buildings in the location they're used in, a few of them in the campaigns also happen to research some upgrades and/or attack. The one in To Chain the Beast in particular researches a lot and has decently-sized attacks, but also waits a super long time in between each attack.

If you're using EUDs it would be easier just to write the scripts, tl;dr




Oct 16 2021, 3:33 pm Gidoza Post #14



Quote from Nekron
Luigi above listed a few of the good ones, but they're pretty tame in general. P5A/B attack frequently but with small stuff, though I guess you could stack them.
Areatowns are towns you can use alongside a main script that assign to themselves all buildings in the location they're used in, a few of them in the campaigns also happen to research some upgrades and/or attack. The one in To Chain the Beast in particular researches a lot and has decently-sized attacks, but also waits a super long time in between each attack.

If you're using EUDs it would be easier just to write the scripts, tl;dr


Any way to copy-paste the Zerg Insane AI script into the Protoss Insane AI script so it just does both?



None.

Oct 17 2021, 9:03 am Nekron Post #15



Sure, if you can edit the scripts you should be able to multirun the second script without headers and it'll mostly work. Town will be very ugly though, and it will be very likely to fail at expanding into new locations (AI doesnt differentiate between which worker type to use for new towns)

Also at that point (if you're already editing the scripts) it really really really would be easier to just do sth custom lol




Oct 18 2021, 4:29 pm Gidoza Post #16



Quote from Nekron
Sure, if you can edit the scripts you should be able to multirun the second script without headers and it'll mostly work. Town will be very ugly though, and it will be very likely to fail at expanding into new locations (AI doesnt differentiate between which worker type to use for new towns)

Also at that point (if you're already editing the scripts) it really really really would be easier to just do sth custom lol

It depends. Insane Expansion AI seems not to need to expand anyways because 1. It get free money when it's low on cash anyways (making expansions superfluous), and 2. I could be wrong, but when buildings are pre-placed for the AI, it doesn't necessarily build new ones at all. So if the base was pre-designed, would it be ugly after all?



None.

Oct 18 2021, 7:12 pm Fruitdispenser Post #17



Quote from Gidoza
[quote=name:Nekron]I could be wrong, but when buildings are pre-placed for the AI, it doesn't necessarily build new ones at all.
Even if it's just one Command Center/Hatchery/Nexus?
In that case, maybe you can place buildings and units of other players and then change ownership



None.

Oct 19 2021, 1:43 am Gidoza Post #18



Quote from Fruitdispenser
Quote from Gidoza
[quote=name:Nekron]I could be wrong, but when buildings are pre-placed for the AI, it doesn't necessarily build new ones at all.
Even if it's just one Command Center/Hatchery/Nexus?
In that case, maybe you can place buildings and units of other players and then change ownership

No I meant to imply that it won't build buildings if they already pre-exist as part of it's strategy (e.g. if it requires 3 stargates and 2 are pre-placed, then it will build 1).



None.

Oct 19 2021, 12:51 pm Nekron Post #19



Quote from Gidoza
Quote from Fruitdispenser
Quote from Gidoza
[quote=name:Nekron]I could be wrong, but when buildings are pre-placed for the AI, it doesn't necessarily build new ones at all.
Even if it's just one Command Center/Hatchery/Nexus?
In that case, maybe you can place buildings and units of other players and then change ownership

No I meant to imply that it won't build buildings if they already pre-exist as part of it's strategy (e.g. if it requires 3 stargates and 2 are pre-placed, then it will build 1).
Yes, "build (n) (building) (priority)" requests up to (n) buildings at a priority. So your example is correct, and you could preplace a good looking base (thought it would be best to have some space for Pylons still)

Oh, thats another thing - AI will only manage primary race supply, so the second one has to have supply building requests, or some triggers for that.

Insane AI does get free money through the give_money (if below 2k, give up to 2k) opcode, but it could run out between refreshments (but that doesnt matter much since you can either edit the wait or use triggers or whatever, if thats not acceptable for whatever reason)




Nov 13 2021, 6:57 pm Hoangquan123 Post #20



Quote from Nekron
Sure, if you can edit the scripts you should be able to multirun the second script without headers and it'll mostly work. Town will be very ugly though, and it will be very likely to fail at expanding into new locations (AI doesnt differentiate between which worker type to use for new towns)

Also at that point (if you're already editing the scripts) it really really really would be easier to just do sth custom lol

Can you help me?, I don't know how to make for AI Protoss, I want Zealots attack Terran Supply Depot first.

I always prevent them to not attack my building by build Terran Supply Depot each gate and I build Marines standing after Supply Depot, then Zealots can't attack Marine because Zealots is prevented by Supply Depot. So, to difficult, I want make for AI Protoss attack Terran Supply Depot first. Do you know how to make it ? Thanks

Attachments:
image_2021-11-14_015708.png
Hits: 3 Size: 552.28kb



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[01:39 am]
Ultraviolet -- no u elky skeleton guy, I'll use em better
[10:50 pm]
Vrael -- Ultraviolet
Ultraviolet shouted: How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
hey cut it out I'm getting all the minerals
[10:11 pm]
Ultraviolet -- :P
[10:11 pm]
Ultraviolet -- How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
[2024-4-17. : 11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
[2024-4-17. : 3:26 am]
O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
[2024-4-17. : 1:53 am]
Vrael -- bet u'll ask for my minerals first and then just send me some lousy vespene gas instead
[2024-4-17. : 1:52 am]
Vrael -- hah do you think I was born yesterday?
Please log in to shout.


Members Online: Roy