Staredit Network > Forums > Modding Assistance > Topic: Zerg AI will not train specific unit
Zerg AI will not train specific unit
Jul 26 2019, 6:17 am
By: Pandut  

Jul 26 2019, 6:17 am Pandut Post #1

I'm just a fish

I'm working on a custom AI script for my mod, atm it's just an extremely basic script simply for testing purposes as I add things in. My modded Zerg faction allows the Hydralisk to morph into a Lurker-type unit in the Hunter Killer<0>Hydralisk slot. Thing is, the AI refuses to train this unit to the point where it locks up the script. I've made all necessary changes in Firegraft; button set and unit requirements, etc. I've also made all the necessary dat changes. It works perfectly fine in-game but for some reason it's stumping the AI.

All dat entries effectively make the Hunter Killer a copy of the Lurker. Reason I chose Hunter Killer is because the base Lurker has weird hardcoded nonsense I can't get around. Here is what I've tried:

-Changed button sets and unit requirements to Larva instead of Hydralisk, no change.
-Removed ALL requirements so the AI can train Hunter Killers at the start of the game from Larva, no change.
-Removed ALL requirements so the AI can train Hunter Killers at the start of the game from Hydras, no change.
-Using wait_train, do_morph, defaultbuild has no change.

Here's my script:
Code
# stat_txt.tbl entry 1344: Zerg Expansion Custom Level<0>
ZMCx(1344, 101, aiscript):
    start_town()
    transports_off()
    farms_notiming()
    defaultbuild_off()
    define_max(30, Zerg Drone)
    define_max(24, Zerg Zergling)
    define_max(12, Zerg Hydralisk)
    define_max(6, Hunter Killer<0>Hydralisk)
    define_max(255, Zerg Lurker)
    define_max(8, Zerg Mutalisk)
    define_max(12, Zerg Scourge)
    define_max(3, Zerg Queen)
    define_max(4, Zerg Defiler)
    define_max(4, Zerg Guardian)
    define_max(4, Zerg Devourer)
    define_max(6, Zerg Ultralisk)
    build(1, Zerg Hatchery, 150)
    wait_buildstart(1, Zerg Hatchery)
    build(1, Zerg Overlord, 150)
    wait_buildstart(1, Zerg Overlord)
    build(4, Zerg Drone, 150)
    wait_buildstart(4, Zerg Drone)
    build(8, Zerg Drone, 150)
    wait_build(8, Zerg Drone)
    build(2, Zerg Hatchery, 150)
    build(2, Zerg Overlord, 150)
    build(12, Zerg Drone, 150)
    wait(100)

    multirun(GiveMoney)
    build(3, Zerg Overlord, 150)
    wait_build(3, Zerg Overlord)
    farms_timing()
    build(1, Zerg Spawning Pool, 150)
    build(3, Zerg Creep Colony, 90)
    train(8, Zerg Zergling)
    defensebuild_gg(2, Zerg Zergling)
    defenseuse_gg(2, Zerg Zergling)
    wait_build(1, Zerg Spawning Pool)
    build(1, Zerg Extractor, 150)
    train(12, Zerg Zergling)
    build(3, Zerg Sunken Colony, 90)
    wait_build(1, Zerg Extractor)
    multirun(PoolUpgrades)
    train(6, Zerg Hydralisk)
    defensebuild_gg(1, Zerg Hydralisk)
    defenseuse_gg(1, Zerg Hydralisk)
    defensebuild_ag(2, Zerg Hydralisk)
    defenseuse_ag(2, Zerg Hydralisk)
    expand(1, ZergTown)
    build(3, Zerg Hatchery, 150)
    expand(2, ZergTown)
    build(5, Zerg Creep Colony, 90)
    build(1, Zerg Evolution Chamber, 150)
    train(8, Zerg Hydralisk)
    train(16, Zerg Zergling)
    wait_build(1, Zerg Evolution Chamber)
    train(4, Hunter Killer<0>Hydralisk)
    build(5, Zerg Sunken Colony, 90)
    train(2, Zerg Defiler)
    multirun(EvoUpgrades)
    wait(100)

    attack_add(14, Zerg Zergling)
    attack_add(8, Zerg Hydralisk)
    attack_add(2, Zerg Defiler)
    attack_add(4, Hunter Killer<0>Hydralisk)
    attack_prepare()
    attack_do()
    attack_clear()
    build(7, Zerg Creep Colony, 90)
    train(1, Zerg Defiler)
    train(8, Zerg Hydralisk)
    train(12, Zerg Zergling)
    train(2, Zerg Defiler)
    attack_add(16, Zerg Zergling)
    attack_add(8, Zerg Hydralisk)
    attack_add(2, Zerg Defiler)
    attack_prepare()
    attack_do()
    attack_clear()
    wait(100)

    build(1, Zerg Spire, 150)
    expand(3, ZergTown)
    wait_build(1, Zerg Spire)
    multirun(SpireUpgrades)
    train(4, Zerg Mutalisk)
    defensebuild_aa(2, Zerg Mutalisk)
    defenseuse_aa(2, Zerg Mutalisk)
    defensebuild_ag(2, Zerg Mutalisk)
    defenseuse_ag(2, Zerg Mutalisk)
    train(12, Zerg Scourge)
    defensebuild_aa(4, Zerg Scourge)
    defenseuse_aa(4, Zerg Scourge)
    build(1, Zerg Queen's Nest, 150)
    attack_add(24, Zerg Zergling)
    attack_add(8, Zerg Mutalisk)
    attack_prepare()
    attack_do()
    attack_clear()
    wait_build(1, Zerg Queen's Nest)
    train(1, Zerg Queen)
    train(8, Zerg Mutalisk)
    train(2, Zerg Guardian)
    train(2, Zerg Devourer)
    train(4, Zerg Ultralisk)
    defensebuild_gg(1, Zerg Ultralisk)
    defenseuse_gg(1, Zerg Ultralisk)
    multirun(NestUpgrades)
    build(2, Zerg Spore Colony, 90)
    build(11, Zerg Creep Colony, 90)
    wait_build(11, Zerg Creep Colony)
    build(7, Zerg Sunken Colony, 90)
    build(3, Zerg Spore Colony, 90)
    wait(100)

    attack_add(6, Zerg Ultralisk)
    attack_add(12, Zerg Hydralisk)
    attack_add(3, Zerg Guardian)
    attack_add(2, Zerg Devourer)
    attack_add(3, Zerg Defiler)
    attack_prepare()
    attack_do()
    attack_clear()
    train(2, Zerg Queen)
    wait(100)

    goto(EndPhase)


        --EndPhase--
    expand(99, ZergTown)
    train(1, Zerg Zergling)
    train(1, Zerg Hydralisk)
    train(1, Zerg Defiler)
    train(1, Zerg Mutalisk)
    train(1, Zerg Scourge)
    train(1, Zerg Ultralisk)
    train(1, Zerg Guardian)
    train(1, Zerg Devourer)
    train(1, Zerg Queen)
    wait(1000)

    attack_add(8, Zerg Mutalisk)
    attack_add(8, Zerg Scourge)
    attack_add(4, Zerg Devourer)
    attack_prepare()
    attack_do()
    attack_clear()
    wait(1000)

    attack_add(24, Zerg Zergling)
    attack_add(10, Zerg Hydralisk)
    attack_add(3, Zerg Defiler)
    attack_add(6, Zerg Ultralisk)
    attack_add(4, Zerg Guardian)
    attack_prepare()
    attack_do()
    attack_clear()
    wait(1000)

    goto(EndPhase)


        --GiveMoney--
    give_money()
    wait(1000)

    goto(GiveMoney)


        --ZergTown--
    start_town()
    build(1, Zerg Hatchery, 150)
    wait_build(1, Zerg Hatchery)
    creep(4)
    get_oldpeons(4)
    build(6, Zerg Drone, 150)
    wait(2500)

    build(2, Zerg Hatchery, 150)
    build(3, Zerg Creep Colony, 100)
    wait_build(3, Zerg Creep Colony)
    build(3, Zerg Sunken Colony, 100)
    wait(100)

    stop()


        --PoolUpgrades--
    upgrade(1, Metabolic Boost, 80)
    wait(250)

    upgrade(1, Grooved Spines, 80)
    stop()


        --EvoUpgrades--
    tech(Lurker Aspect, 200)
    wait(250)

    upgrade(1, Zerg Melee Attacks, 80)
    wait(250)

    upgrade(1, Zerg Missile Attacks, 80)
    wait(250)

    upgrade(1, Zerg Carapace, 70)
    wait(250)

    wait_build(1, Zerg Queen's Nest)
    upgrade(2, Zerg Melee Attacks, 80)
    wait(250)

    upgrade(2, Zerg Missile Attacks, 80)
    wait(250)

    upgrade(2, Zerg Carapace, 70)
    wait(250)

    upgrade(3, Zerg Melee Attacks, 80)
    wait(250)

    upgrade(3, Zerg Missile Attacks, 80)
    wait(250)

    upgrade(3, Zerg Carapace, 70)
    stop()


        --SpireUpgrades--
    upgrade(1, Pneumatized Carapace, 80)
    wait(250)

    upgrade(1, Ventral Sacs, 80)
    wait(250)

    upgrade(1, Zerg Flyer Attacks, 80)
    wait(250)

    upgrade(1, Zerg Flyer Carapace, 70)
    wait(250)

    wait_build(1, Zerg Queen's Nest)
    upgrade(2, Zerg Flyer Attacks, 80)
    wait(250)

    upgrade(2, Zerg Flyer Carapace, 70)
    wait(250)

    upgrade(3, Zerg Flyer Attacks, 80)
    wait(250)

    upgrade(3, Zerg Flyer Carapace, 70)
    wait(250)

    stop()


        --NestUpgrades--
    upgrade(1, Chitinous Plating, 70)
    wait(250)

    upgrade(1, Gamete Meiosis, 80)
    wait(250)

    upgrade(1, Metasynaptic Node, 80)
    wait(250)

    tech(Spawn Broodling, 80)
    wait(250)

    tech(Irradiate, 80)
    wait(250)

    tech(Plague, 80)
    wait(250)

    tech(Consume, 80)
    wait(250)

    stop()



AI works normal until it reaches attack_add(4, Hunter Killer<0>Hydralisk) and then it just stops because it won't train Hunter Killers. I've been trying to troubleshoot this for the last 3 days and I'm kinda going insane :bye1:.



None.

Jul 26 2019, 12:23 pm Pr0nogo Post #2



Unit morphs are generally hardcoded. You'll need to download GPTP, open it in visual studio 2010, and edit the function '' in unit_morph.cpp. Here's an example that lets Hydralisks morph to Hunter Killers. Someone more well-versed in GPTP may point out that more functions need to be edited but I'd start there, compile the plugin, and add it to your exe with firegraft.




Jul 27 2019, 1:17 am Pandut Post #3

I'm just a fish

Oof that seems like a hassle just to get the AI to train one unit. Luckily, I'm reusing the Infested Command Center as a secondary training building for niche units so I decided to just 'cheat' a little by letting the AI train Hunter Killers from the infested command center while players have to morph them from Hydras. It's a little wonky but it works. I'll keep this morphing hardcoded stuff in mind for the future though.



None.

Jul 27 2019, 10:40 am Pr0nogo Post #4



Players can't morph them either without these changes from my experience. GPTP is essential for 1.16.1 mods, you'll need to familiarize yourself with it to at least some degree eventually.




Jul 30 2019, 7:25 pm Pandut Post #5

I'm just a fish

I've made the Firegraft edits to change Lurker morph permissions to Hunter Killer instead. But yeah, I imagine eventually I'll have to suck it up and learn GPTP aha. It just looks so much like the time I tried to learn C++ and had to stop because it was making my head hurt too much.



None.

Aug 11 2019, 8:54 am Lagi Post #6



there is 2x unit_morph.cpp , both have same name, the one you want is in source/subfolders files in Framework GTPT.

Maybe it save someone from wasting time :D



None.

Aug 11 2019, 2:28 pm Pr0nogo Post #7



Good shout, iquare fixed it recently so I'll try to upload an improved version of the code later this week.




Aug 11 2019, 3:37 pm Lagi Post #8



there is 2x unit_morph.cpp (I call one : tech (where you create new transformations) and second : orders (zergBirth & Morph1)

if I save tech (unit_morph.cpp) the GPTP will come with failed build. BUT its enough to change 1 letter in any comments in orders (unit_morph.cpp) to receive successful build.

====
I follow this one https://www.moddb.com/tutorials/unit-morph-for-all-units
still can not change zerg morphing in anything.
been trying to change Hydralisk to morph in just anything else without success. is this tutor from moddb is still valid with Framework 1.12?



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[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?
[2024-4-17. : 1:08 am]
O)FaRTy1billion[MM] -- i'll trade you mineral counts
[2024-4-16. : 5:05 pm]
Vrael -- Its simple, just send all minerals to Vrael until you have 0 minerals then your account is gone
[2024-4-16. : 4:31 pm]
Zoan -- where's the option to delete my account
[2024-4-16. : 4:30 pm]
Zoan -- goodbye forever
Please log in to shout.


Members Online: Ultraviolet, Roy, NudeRaider