PyMS and ProTRG developer
That script does not compile without warnings for me, and I don't see any way to not get warnings for it. If you can provide more details on how to get it to not show warnings, I can look into that. And no, I have not hardcoding an exception for those scripts, that makes no sense lol
So let's make an important distinction here. Warning=/=Variable error. Typing "build(1, infested_terran, 80) gives you a variable error and you can't save the script. Typing "defensebuild_gg(1, sunken_colony)" gives you a variable error and you can't save the script. Checking TSW3 (And other TSW scripts with "build caster") gives you a warning and you can save the script succesfully, should you decide to edit it. You wrote above that defensebuild sunken gives you a warning, but that's not true. I have the newest PyAI and it gives you a variable error (expected military, got building)
Yes there is some confusion caused by this
When you use "sunken_colony" from the built in unitdef.txt, it is typed as "military", if you just use the unit id "146" or the name from stat_txt "Zerg Sunken Colony", it will be untyped. You will get errors for using variables as parameters of the wrong type because they are explicitly typed. Now when decompiling scripts, PyAI tries to find variables with the correct type to decompile to, and if it can't it will use the stat_txt name or just the ID. So if you notice when TSW3 gets decompiled, it generates "build(x, Zerg Queen, y)" instead of "build(x, queen, y)", because the "build" command has a "building" parameter and the variable "queen" is defined as a military type. So yeah if you really wanted to you could do "defensebuild_gg(1, Zerg Sunken Colony)" or "defensebuild_gg(1, 146)" and you would only get warnings.
The defensebuild_xx and defenseuse_xx commands are specific to defending against ground or air units, so it checks that the units you chose to defend with have a valid attack for the type they are defending against. Generic attacks don't have that requirement, so it doesn't do those checks.
You maybe misunderstood me? When I say non-attacking spellcasters I don't mean "spellcasting units that don't have an attack" - I mean "spellcasting units that don't execute attack orders properly" - all spellcasters except the three mentioned get stuck in the grouping area, and don't follow the attack party once it is ready to go. That is improper execution, so it seems warning-worthy to me. Seeing that Neiv found them listed by IDs somewhere it has to be distinguishable somehow, if not just listed on a case by case basis.
The four spellcasters which stay in the attack preparation region are hardcoded, but otherwise any unit should be fine to use in attacks. If they can't do anything they'll just hang around, but they should move correctly with rest of the attack force and not break the AI in any way.
Yeah I could add this as a warning. Would you happen to have those 4 hardcoded ID's?
What is that check though? If someone can give a way to detect units that can damage other units outside of normal attacks from the files in the mpq, in a way that supports mods, I can look into it. But i'm pretty sure there is no good way.
Just from Firegraft it looks like every unit has a spellcasting behaviour assigned, where one of the behaviours is no behaviour at all, obviously used for most units in the game - so the check is whether or not the unit ID has a spellcaster behaviour (other than the blank one) assigned. This should be a mod-happy solution since I imagine you'd want to assign a spellcaster behaviour to your new spellcasters in a mod. It also lets you make use of hero units, well, if they're already supported in PyAi anyway.
FireGraft edits hardcoded values in the starcraft exe, it does not use files from the mpq's, it is not something that can be done in PyMS. I was thinking about this last night though, what I could do is add another directive or something that can be placed in your scripts or in unitdef.txt, like "@spellcaster(x)". That way I can define the vanilla ones in unitdef.txt, and mod authors can make their own definitions.
`build` only works on buildings, workers and overlords. Anything else just causes AI waste a bit of time trying to build something it can not.
Do you know why overlords and workers included in this? Do you also have the specific logic used for these checks? Like is it checking units.dat special ability flags for building and workers (or hardcoded ID's for workers), and overlord is hardcoded unit ID? Right now I believe my overlord check is not based on unit id but on if its not a building && provides supply, which could be wrong.
The military opcodes should accept any non-building unit.
Yep.
If the AI's defensebuild_xy list only has units whose air/ground strength is 0 (e.g it has no weapon), then the game will freeze due to an infinite loop in the reinforcing code. Otherwise it should just make AI train defense units even if they cannot attack the enemy, and I could see using defensebuild to make AI build more casters being reasonable. `defensebuild_xy` on static defense doesn't make any sense though.
Hmm, I could look into adding a warning for that freeze, though it wouldn't be perfect. Otherwise sounds good to me.
I also tried the 64-bit branch. MPQs seemed to work fine, but the registry accessing code throws the error `OpenKey() takes no keyword arguments` in python 2.7.13. I don't have a 32-bit installation to check if anything broke on that side though.
Nice, thanks man! You're awesome! I have fixed that error if you have a chance to retest it.
Thanks!