• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] My Undead AI is not working

Level 8
Joined
May 12, 2018
Messages
106
Hello readers,
I want to make an AI of classical Undead that builds a base slowly from the beginning. (Like RoC NE Final chapter's Undead in Jaina and Thrall's base)

But my AI is causing problems from the testing stage. It doesn't work at all.
Undead AI doesn't build any haunted gold mine and necropolis, and etc builds and just keep sleeping forever.
I'm calmly testing one by one while reading Nowow's JASS AI tutorial, but I have no idea where the problem is. The Demo Jass Syntax Checker prints there is no problem.
this is my sample map and AI.
JASS:
globals
    player user = Player(1)
    integer Tier1 = 1
    
    constant integer UNIT_UNDEAD_WORKER = 'naco'
    constant integer UNIT_UNDEAD_GHOUL = 'ugho'
    constant integer UNIT_UNDEAD_FIEND = 'ucry'
    constant integer UNIT_UNDEAD_GARGOYLE = 'ugar'
    constant integer UNIT_UNDEAD_WAGON = 'umtw'
    constant integer UNIT_UNDEAD_ABOMINATION = 'uabo'
    constant integer UNIT_UNDEAD_NECRO = 'unec'
    constant integer UNIT_UNDEAD_BANSHEE = 'uban'
    constant integer UNIT_UNDEAD_OBSIDIAN = 'uobs'
    constant integer UNIT_UNDEAD_DESTROYER = 'ubsp'
    constant integer UNIT_UNDEAD_FROSTWYRM = 'ufro'
    constant integer UNIT_UNDEAD_SHADE = 'ushd'
    
    constant integer HERO_UNDEAD_DEATHKNIGHT = 'Udea'
    
    constant integer SUMMONED_UNDEAD_SKELETON = 'u010'
    constant integer SUMMONED_UNDEAD_SKELETALMAGE = 'uskm'
    
    constant integer BUILD_UNDEAD_GOLD = 'ugol'
    constant integer BUILD_UNDEAD_HALL1 = 'unpl'
    constant integer BUILD_UNDEAD_HALL2 = 'unp1'
    constant integer BUILD_UNDEAD_HALL3 = 'unp2'
    constant integer BUILD_UNDEAD_ALTAR = 'uaod'
    constant integer BUILD_UNDEAD_FARM = 'uzig'
    constant integer BUILD_UNDEAD_FARMTOWER = 'uzg1'
    constant integer BUILD_UNDEAD_FARMTOWERFROST = 'uzg2'
    constant integer BUILD_UNDEAD_BARRACKS = 'usep'
    constant integer BUILD_UNDEAD_BLACKSMITH = 'ugrv'
    constant integer BUILD_UNDEAD_SLAUGHTERHOUSE = 'uslh'
    constant integer BUILD_UNDEAD_TEMPLE = 'utod'
    constant integer BUILD_UNDEAD_SACPIT = 'usap'
    constant integer BUILD_UNDEAD_BONEYARD = 'ubon'
    constant integer BUILD_UNDEAD_SHOP = 'utom'
    
    constant integer UPG_UNDEAD_PACK = 'Rupm'
    
    constant integer UPG_UNDEAD_ARMOR_STRUCTURE = 'R00A'
    constant integer UPG_UNDEAD_WEAPON_CASTER = 'R00B'
    constant integer UPG_UNDEAD_WEAPON_MELEE = 'Rume'
    constant integer UPG_UNDEAD_ARMOR_MELEE = 'Ruar'
    constant integer UPG_UNDEAD_WEAPON_RANGE = 'Rura'
    constant integer UPG_UNDEAD_ARMOR_RANGE = 'Rucr'
    
    constant integer UPG_UNDEAD_CANNIBALIZE = 'Ruac'
    constant integer UPG_UNDEAD_GHOUL_FRENZY = 'Rugf'
    constant integer UPG_UNDEAD_FIEND_BURROW = 'Rubu'
    constant integer UPG_UNDEAD_FIEND_WEB = 'Ruwb'
    constant integer UPG_UNDEAD_GARGOYLE_FORM = 'Rusf'
    constant integer UPG_UNDEAD_WAGON_CORPSE = 'Ruex'
    constant integer UPG_UNDEAD_WAGON_BLIGHT = 'R02L'
    constant integer UPG_UNDEAD_DISEASECLOUD = 'Rupc'
    constant integer UPG_UNDEAD_ABOMINATION_FLESH = 'R600'
    constant integer UPG_UNDEAD_TRAIN_NECRO = 'Rune'
    constant integer UPG_UNDEAD_TRAIN_BANSHEE = 'Ruba'
    constant integer UPG_UNDEAD_OBSIDIAN_MANA = 'R025'
    constant integer UPG_UNDEAD_OBSIDIAN_FORM = 'Rusp'
    constant integer UPG_UNDEAD_NECRO_MASTERY = 'Rusm'
    constant integer UPG_UNDEAD_FROSTWYRM_ATTACK = 'Rufb'
endglobals

function BuildOrder takes nothing returns nothing
    call SetBuildUnitEx( 1,1,1, UNIT_UNDEAD_WORKER)
    call SetBuildUnitEx( 1, 1, 1, BUILD_UNDEAD_GOLD)
    call SetBuildUnitEx( 1, 1, 1, BUILD_UNDEAD_HALL1)
    call SetBuildUnitEx( 1, 1, 1, BUILD_UNDEAD_FARM)
    call SetBuildUnitEx( 1, 1, 1, BUILD_UNDEAD_BARRACKS)
    call SetBuildUnitEx( 1, 1, 1, BUILD_UNDEAD_ALTAR)
    call SetBuildUnitEx( 1, 1, 1, BUILD_UNDEAD_BLACKSMITH)
    call SetBuildUnitEx( 1, 1, 1, BUILD_UNDEAD_SHOP)
    call SetBuildUnitEx( 4, 4, 4, BUILD_UNDEAD_FARM)
    call SetBuildUnitEx( 6, 6, 6, UNIT_UNDEAD_WORKER)
    call SetBuildUnitEx( 4, 4, 4, UNIT_UNDEAD_GHOUL)
endfunction

function main takes nothing returns nothing
    call CampaignAI(BUILD_UNDEAD_FARM, null)
    call DoCampaignFarms(false)
    call SetPeonsRepair(true)
    
    set campaign_wood_peons = 8
    call BuildOrder()
endfunction
 

Attachments

  • TEST.AI
    3.5 KB · Views: 3
  • AITEST.w3x
    14.3 KB · Views: 2
Last edited:
Level 27
Joined
Nov 25, 2021
Messages
480
Maybe a late af reply, but I think it's because you wrote:

JASS:
constant integer UNIT_UNDEAD_WORKER = 'naco'

Instead of:

JASS:
constant integer UNIT_UNDEAD_WORKER = 'uaco'

And then you have this at the top of your build order:

JASS:
    call SetBuildUnitEx( 1,1,1, UNIT_UNDEAD_WORKER)

Which halts the A.I until it finishes training the 'naco' unit instead of an Acolyte.

Although, in the future, I suggest not declaring Global for unit who already has their own integer (GHOUL for Ghouls, ACOLYTE for Acolytes and such) to not confuse the JASS Syntax Checker. You can refer to this for all of the already-declared Integers: JASS Manual: API Browser - common.ai.

As an example, the BuildOrder function can be written like this for simplicity's sake:

JASS:
function BuildOrder takes nothing returns nothing
    call SetBuildUnitEx( 1,1,1, ACOLYTE)
    call SetBuildUnitEx( 1, 1, 1, UNDEAD_MINE)
    call SetBuildUnitEx( 1, 1, 1, NECROPOLIS_1)
    call SetBuildUnitEx( 1, 1, 1, ZIGGURAT_1)
    call SetBuildUnitEx( 1, 1, 1, CRYPT)
    call SetBuildUnitEx( 1, 1, 1, UNDEAD_ALTAR)
    call SetBuildUnitEx( 1, 1, 1, GRAVEYARD)
    call SetBuildUnitEx( 1, 1, 1, TOMB_OF_RELICS)
    call SetBuildUnitEx( 4, 4, 4, ZIGGURAT_1)
    call SetBuildUnitEx( 6, 6, 6, ACOLYTE)
    call SetBuildUnitEx( 4, 4, 4, GHOUL)
endfunction
 
Level 8
Joined
May 12, 2018
Messages
106
Maybe a late af reply, but I think it's because you wrote:

JASS:
constant integer UNIT_UNDEAD_WORKER = 'naco'

Instead of:

JASS:
constant integer UNIT_UNDEAD_WORKER = 'uaco'

And then you have this at the top of your build order:

JASS:
    call SetBuildUnitEx( 1,1,1, UNIT_UNDEAD_WORKER)

Which halts the A.I until it finishes training the 'naco' unit instead of an Acolyte.

Although, in the future, I suggest not declaring Global for unit who already has their own integer (GHOUL for Ghouls, ACOLYTE for Acolytes and such) to not confuse the JASS Syntax Checker. You can refer to this for all of the already-declared Integers: JASS Manual: API Browser - common.ai.

As an example, the BuildOrder function can be written like this for simplicity's sake:

JASS:
function BuildOrder takes nothing returns nothing
    call SetBuildUnitEx( 1,1,1, ACOLYTE)
    call SetBuildUnitEx( 1, 1, 1, UNDEAD_MINE)
    call SetBuildUnitEx( 1, 1, 1, NECROPOLIS_1)
    call SetBuildUnitEx( 1, 1, 1, ZIGGURAT_1)
    call SetBuildUnitEx( 1, 1, 1, CRYPT)
    call SetBuildUnitEx( 1, 1, 1, UNDEAD_ALTAR)
    call SetBuildUnitEx( 1, 1, 1, GRAVEYARD)
    call SetBuildUnitEx( 1, 1, 1, TOMB_OF_RELICS)
    call SetBuildUnitEx( 4, 4, 4, ZIGGURAT_1)
    call SetBuildUnitEx( 6, 6, 6, ACOLYTE)
    call SetBuildUnitEx( 4, 4, 4, GHOUL)
endfunction
Thank you for answer. However, I've created lots of custom races and I'm not familiar with the names declared already on common.ai, so I'll have to practice modifying and overwriting the common.ai file, referring to the common_v2.ai code of InsaneMonster.
I recognized the problem about having to declare the Hall tiers of custom races separately and write related functions in common.ai.
 
Level 18
Joined
Mar 16, 2008
Messages
721
1) if it's not working at all it's a syntax error, as nchp1903 mentioned above,
2) if you declare anything already listed in common.ai, it won't run at all.

so i suspect you are having one of these problems.

edit/update: haven't 100% check but seems very likely you are experiencing problem #2 that i listed in this post. you only want to declare custom units. you are pretty much forced into using either the code of the unit or Blizzard's common.ai JASS variable name for the unit.

default units are done in all lower case typically 'hpea' or something like that.
 
Last edited:
Top