Staredit Network > Forums > Modding Discussion > Topic: Defining AI commands and functions
Defining AI commands and functions
Jun 21 2017, 8:49 pm
By: Pr0nogo
Pages: < 1 2 3 4 5 >
 

Jul 23 2017, 9:14 am Neiv Post #41



You place it after attack_add, so it will multiply the attack force you've already defined.



None.

Aug 11 2017, 1:54 pm Nekron Post #42



Edit: Last 3 commands

wait_secure - Either does nothing (it's honestly hard to tell since the way to test it seems to be running a multirun that builds defense structures) or waits until all (?) regions are defended with static defense structures. Works for all races. Ignores build_bunkers/turrets execution if it's being run while there are already enough defences, so I figure it's unrelated.

implode - Seems to act as "placeguard_clear" - guard units aren't being rebuilt after calling it. Might be wrong, as this was the result I was expecting, so I'm really biased.

region_size (byte) (block) -
Jump to block %2 if the map's region tile count is below 32 times %1. Can be used to check for map size.

Post has been edited 2 time(s), last time on Aug 23 2017, 4:33 pm by Nekron.




Aug 23 2017, 11:06 pm Pr0nogo Post #43



Updated the OP with a link to Nekron's documentation for AI commands in google doc form. Also updated the collapsable boxes with some additional info, but refer to the google doc for more in-depth and complete information.

Does `expand` get delayed by other loops/commands, or does the number value that comes after it relate to priority as opposed to number of towns?

In this script, the zerg AI is given the following orders in a multirun:

Code
allies_watch(2, TB5D 0011)
wait(900)
try_townpoint(1, TB5D 0009)
stop()

Shortly afterwards, this occurs in the main script (not a multirun):

Code
try_townpoint(1, TB5D 0010)
expand(1, TB5D 0011)
goto(TB5D 0012)

0010 leads to the following:

Code
expand(2, TB5D 0011)

This is 0011 (the block called by all these expand/allies_watch functions):

Code
start_town()
build(1, Zerg Hatchery, 80)
wait_build(1, Zerg Hatchery)

However, only the allies_watch code seems to function properly. Expand(1; 2; 3; etc) don't do anything. Expand(99, 0011) works properly to make the AI expand several times. Is this a syntax error or is something else in the code the culprit?

Post has been edited 1 time(s), last time on Aug 23 2017, 11:57 pm by Pr0nogo.




Aug 24 2017, 6:28 pm Pandut Post #44

I'm just a fish

Wow, these are great. Thank you so much for the doc, I've always wanted to get back into AI scripting haha. Awesome that you're making a reference for script terms :).

Also dumb question here, how does one actually get an AIscript to work with SCR? Do I drop it in the patch_rt file or?



None.

Aug 24 2017, 6:52 pm Nekron Post #45



Yes, you can use them with SCR, and since Blizz never bothered touching them they're still in patch_rt. The Blizzard app scans your gamefiles after every time you close the game, so you'd need to make a .bat file or w/e for this to be convenient at all (if you won't swap files/change names somehow immediately after the process closes, your changed patch_rt will get deleted). Maybe you can avoid this by launching SC with the -launch parameter, but I haven't gotten around to testing this yet
Edit: Launch the Starcraft.exe through a shortcut with the parameter -launch, and you can avoid using the Blizz client for a month - and thus, rechecking files. You have to log in once a month to prove to Blizz you still have an internet connection or something, idk, or else you lose RM graphics until you re-log.

Post has been edited 1 time(s), last time on Aug 24 2017, 8:25 pm by Nekron.




Aug 29 2017, 11:55 pm Pandut Post #46

I'm just a fish

Yarr, that did it. Been fiddling around with AI scripts all day now, thanks! :)



None.

Sep 24 2017, 10:10 am Nekron Post #47



Last two missing commands added to the doc, courtesy of Neiv

implode (takes no parameter) -
Quote from Neiv
Implode changes the state of ai regions: Any region which has state 0,1,2 or 3, and at least two of its neighbouring regions also have state < 4, the regions state is changed to 4. (So depending which regions are checked first the regions which change to 4 differ)

(more or less accurate list of region states)
0x0 Nothing,
0x1 = Attack?,
0x2 = Attacking,
0x3 = Town under attack and can't defend? Or just enemy seen there, Can't repair,
0x4 = Near main building? Future town?,
0x5 = Town? Also with Value area higher script,
0x6 = Defending,
0x7 = Chase away?,
0x8 = Moving to attack?,
0x9 = Moving to attack 2?

After some testing, it's hard to really find any uses for this one. It's basically something somewhat similar to capt_expand, but it's more "aggressive", while also being way more inconsistent

wait_secure (takes no parameter)-
Quote from Neiv
wait_secure seems to have the script wait until AI trains defense, but it's a global thing so it may be difficult to use. And if the AI doesn't have to train defense, the script seems to hang? Maybe it's meant to use in a child thread which starts to do something once there's a reason to train def?
Seems completely useless, the condition's either inconsistent or really easy to achieve, so it basically always forwards the script execution seamlessly. And if it doesn't, it will probably hang your script xD




Sep 26 2017, 1:52 am Heinermann Post #48

SDE, BWAPI owner, hacker.

Where did I write that post? Was it on the BroodwarAI forum?




Sep 26 2017, 6:59 am Nekron Post #49



Nope, it were the StarcraftAI forums.
Thread
BroodwarAI forums were down already when I started looking for more commands, I think 5? or 4 years ago




Oct 2 2017, 5:47 pm Pandut Post #50

I'm just a fish

How does region_size work? Like, example-wise. Mostly, I'd like to include a script in my AI code that's jumped to when the map size is 64x64/96x96/small. Don't know how it works, tho.



None.

Oct 2 2017, 7:16 pm Nekron Post #51



Edit: See post below

Post has been edited 1 time(s), last time on Oct 3 2017, 5:58 pm by Nekron.




Oct 3 2017, 4:33 am Heinermann Post #52

SDE, BWAPI owner, hacker.

Here's region_size: https://pastebin.com/9uYVz9p2

Basically, if the walkable tiles for all the town's pathable areas is below 32*value, it jumps to block.

Some use cases:
- Determine the rough size of the map. Larger value means you may need to execute a more long distance strategy.
- Determine the size of an island that an expansion is on. If it is a small island, there may be certain structures you don't want to build.

Also, groundmap_jump will check if any opponent structure is accessible from where the script was run. You can call it multiple times, for example to determine whether the player has lifted and moved to an island.

region_size can also be used to determine if you're on an island, and may be preferable in some cases because it is town-based, and groundmap is script-based.


Quote from Neiv
- `allies_watch`. The first argument is a index of the base location (I don't think there are any tools to determine the index), and second is a script position. If the base location has resources remaining, *something* happens.
Looks like it expands (calls AI_ExpandAt), using the block for the new expansion.


if_diff
I'm not sure what it does *takes a look*. So it isn't really useful. The only values assigned to it are:
0 = AI script town was not started
1 = AI town was started (start_town or start_areatown)

It gets compared to 2 somewhere in the code but it doesn't actually get set to 2 anywhere.

easy_attack
If the if_diff value is 0, meaning the AI script town was not started, then it calls AttackAdd with %1 count of %2 unit.

Post has been edited 2 time(s), last time on Oct 3 2017, 6:18 am by Heinermann.




Oct 21 2017, 1:45 pm Nekron Post #53



A few requests/questions if anybody would have the time to answer them:

Normal priority:
- a clarification of clear_combatdata's function - does it only remove units from attacks, or maybe it doesn't even do that? Are the units properly reutilised if it does?
- accurate description of wait_secure's condition - obviously pretty relevant if the command were to ever be used, since without an accurate description it's hard to predict when will the script continue
- does check_transports literally only affect the number of transports the AI keeps around? Mostly asked because I've seen it used in zerg-only scripts

Low priority:
- confirmation whether harass_location has no actual in-game functions, not even obscure
- double check to see whether wait_bunkers and wait_turrets do in fact wait for build_bunkers/turrets to end, and do nothing more both commands do nothing
- a confirmation of capt_expand's functions: since every bit of knowledge on it is currently based solely on in-game observations.
List of presumed functions (for campaign scripts) right now:
* If default_min is greater than 0: Keeps first defensebuild_gg and _aa units as guards (?) in locations along the edges of defended regions
* Expands the area it defends, more with every next use of capt_expand
* Enables the usage of defensebuild_ga and defenseuse_ga commands
usage confirmed and mostly documented

Really low priority:
- a confirmation whether target_expansion flag has no effects on campaign scripts (used by Blizz in a campaign script once) (presumably requires going through attack logic?) long testing did not show any attack-related changes
- a check to see when exactly does panic crash the game: seems to happen most often when empty (start locations sans resources) resareas exist on the map
- accurate list of things affected by set_randomseed (since they supposedly do exist) randomseeds seem to not work properly outside of replays?
- a description of default_min force distribution (clearly not actually (byte) per every region, ignores some regions) and an exact description of AI's defense mechanism, including special cases (such as the 700-800 max_force regions in the town center) researched and documented in the doc
- why was kill_thread supposed to "never by used" according to old SCAI threads? does it cause any performance hits/crashes? can cause request log issues, needs more testing

Post has been edited 2 time(s), last time on Nov 5 2017, 2:56 pm by Nekron.




Oct 30 2017, 10:35 pm Pandut Post #54

I'm just a fish

Honestly, in all instances I've used wait_turrets/bunkers, I've never seen the AI wait. I usually just have to put in a wait(whatevertime) and just go from there. Maybe it has function in Campaign scripts, but certainly not Skirmish scripts.



None.

Oct 31 2017, 11:39 am Nekron Post #55



Yeah, it could be the case. I can't decompile commands myself, so I can't really tell whether something has a start_campaign caveat: Also, I don't think I've tested these too accurately, to be honest D:

Otherwise, I added lots of new info to the doc that can probably be of use to you, especially the region stuff.

I tried writing two melee scripts recently, and my biggest problem seems to be that it's hard to make a non-linear script that doesn't get absolutely retarded because of requests: I frequently end up with 60 + unit requests to fill which murders the AI completely :I Also being limited to 21->12 workers/base on Fighting Spirit (12 after expanding) is pretty annoying




Jan 29 2019, 8:02 am IlyaSnopchenko Post #56

The Curious

Wow, this is mindboggling. On a way higher level than anything I've ever done with AI Scripts. :) Thank you people for your tireless research.



Trial and error... mostly error.

Jan 29 2019, 12:48 pm Nekron Post #57



it's on a way higher level than what anyone before 2017 did with AIscripts (with the notable exception of JNCraton, though his stuff is pretty simple command-usage wise)




Feb 25 2019, 5:32 pm IlyaSnopchenko Post #58

The Curious

A couple little questions here.

One: do I have to finish blocks invoked by multirun opcode in stop(), or does goto() work too to bring it back into the main flow of the script? I'm asking because I'm not sure the AI is going to respect all the settings done in a multiran block which then gets terminated, like nuke_rate(). Or am I just paranoid?

Two: how do I best order units to do commands that require no target through issue_orders()? I mean, orders like Stop, Cloak or Decloak. Do I specify the target unit/location as "Any"/"Anywhere", or rather "self"/"location where that unit is supposed to be"? Say, I want to order a Ghost hero like Duran to cloak / decloak when I need them to. How do I do this in a most efficient way, if it works that way at all?



Trial and error... mostly error.

Feb 25 2019, 6:46 pm Nekron Post #59



Quote
One: do I have to finish blocks invoked by multirun opcode in stop(), or does goto() work too to bring it back into the main flow of the script? I'm asking because I'm not sure the AI is going to respect all the settings done in a multiran block which then gets terminated, like nuke_rate(). Or am I just paranoid?
The way you presented it goto would be extremely dumb, if youre multirunning a one-time thing its alright to stop it when it ends. Everything set in the multiran block will be remembered if its requests or flags.

Quote
Two: how do I best order units to do commands that require no target through issue_orders()? I mean, orders like Stop, Cloak or Decloak. Do I specify the target unit/location as "Any"/"Anywhere", or rather "self"/"location where that unit is supposed to be"? Say, I want to order a Ghost hero like Duran to cloak / decloak when I need them to. How do I do this in a most efficient way, if it works that way at all?

I think some orders need to target themselves(cloak), others just take any target and ignore it, but im not 100% sure




Feb 25 2019, 7:27 pm IlyaSnopchenko Post #60

The Curious

Thanks. Never hurts to be sure.



Trial and error... mostly error.

Options
Pages: < 1 2 3 4 5 >
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[05:00 pm]
lil-Inferno -- benis
[10:41 am]
v9bettel -- Nice
[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
Please log in to shout.


Members Online: DarkenedFantasies, Roy