[JASS & AI] Custom Night Elf wisp won't harvest from custom Entangled Mine

Level 4
Joined
Oct 31, 2024
Messages
16
Hello all!

So the go is that I'm working on custom AI for another project that has a custom Night Elf techtree.
I've got AI to work for the most part doing everything I need but the Night Elves won't harvest gold from the custom Entangled Mine I have.
This is for AI made in JASS set up as Campaign AI.
I've considered doing something like ordering the wisps to harvest/entangle the mine but that feels like a sloppy band-aid patch.

Something else to note, when playing the custom techtree, trying to harvest from the gold mine works however you get hit with a "Gold Mine is already entangled" message.
Besides that, it works as it should.

Any tips or work arounds anyone can share?
I'm working on a small test map to send for anyone needing to look into a map themselves.

EDIT: Here is the JASS function I have working to get the custom wisps into the custom Entangled Mine.
JASS:
//============================================================================
//  NightElfHarvestGold
//============================================================================
function NightElfHarvestGold takes integer town, integer wisps, integer maxPer returns nothing
    local unit wisp
    local unit mine
    local group wispsGroup = CreateGroup() // Get only owned Wisps
    local group minesGroup = GetPlayerUnitsOfType(legend_mine,ai_player) // Get only owned Entangled Mines
    local integer count = 0
    local group mineWisps = CreateGroup()
    
    
    // Find an entangled mine we own that has room
    loop
        set mine = FirstOfGroup(minesGroup)
        if mine == null then
        endif
        exitwhen mine == null
        
        if IsMineAvailable(mine, maxPer) then
            exitwhen true
        endif
    endloop
    
    if mine == null then
        call DestroyGroup(wispsGroup)
        call DestroyGroup(minesGroup)
        call DestroyGroup(mineWisps)
        return // No mine available
    endif
    
    set wispsGroup = GetPlayerUnitsOfType(legend_worker,ai_player)
    
    // Filter for idle Wisps
    loop
        set wisp = FirstOfGroup(wispsGroup)
        exitwhen wisp == null
        
        if IsUnitIdle(wisp) then
            call GroupAddUnit(mineWisps, wisp) // Add unit
        endif
        call GroupRemoveUnit(wispsGroup, wisp) // Remove unit
    endloop
    call DestroyGroup(wispsGroup)
    
    // Assign Wisps to the mine
    set count = 0
    loop
        set wisp = FirstOfGroup(mineWisps)
        exitwhen wisp == null or count >= wisps
        if mine != null and wisp != null then
        endif
        call IssueTargetOrder(mine, "load", wisp)
        call GroupRemoveUnit(mineWisps, wisp)
        set count = count + 1
        call Sleep(.1)
    endloop
    
    call DestroyGroup(minesGroup)
    call DestroyGroup(mineWisps)
endfunction
It could probably be better but it works at the moment and I'm too busy trying to perfect getting the correct town's mine.
 
Last edited:
I have had these same problems for many years, and so it is a little bit demoralizing that even the new leadership at Microsoft with Brad Chan does not fix this. I'm happy to post here and see if others follow up on the thread with better answers.
 
Level 4
Joined
Oct 31, 2024
Messages
16
I have had these same problems for many years, and so it is a little bit demoralizing that even the new leadership at Microsoft with Brad Chan does not fix this. I'm happy to post here and see if others follow up on the thread with better answers.
Hey Retera, big fan of your work!
I appreciate your message but if it helps you at all, I actually found a fix.
Not sure if I'm the first or anything but I made a function in JASS that orders the entangled mine to "load" the wisp.

Right now I've just got an issue with a loop somewhere so it only orders one but it's an easy fix. I just thought I'd update you and anyone else potentially interested that it's been fixed.

I'll upload the fully working function for everyone when it's finished.

EDIT: Alright so it also turns out that a wisp ordered to "board" a custom entangled gold mine also works. "board" will still attempt to send wisps into a full mine though.
Got them all to go in no problems both ways.
Problem now is I'm trying to find a Mine that has empty slots inside it specifically as a target, otherwise just return function.
I can't seem to find a way to check how many slots are used in the mine.

EDIT 2: That or I need a way to locate a town/town's mine. Location or Unit is good.
 
Last edited:
Top