• 🏆 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!

Night Elf AI doesn't use normal gold mines

Status
Not open for further replies.
I've given the NE a human town hall and peasant, which is fine, but the AI doesn't recognize the gold mine unless it's entangled.
The only solution I've found is replacing regular gold mines with entangled mines which have the regular Gold Mine Ability instead of the Entangled Gold Mine Ability (and changing the art etc.).
The biggest annoyance with that is that I'd have to do it at map init, and every time a NE AI player builds a town hall, and probably change it back if a town hall gets destroyed.

Is there any way to make the AI just use regular mines?

Edit: easiest solution is replacing ALL gold mines with entangled mines with regular Gold Mine Ability etc. Other AI doesn't seem to have a problem using entangled unit types.
 
Last edited:
Level 8
Joined
May 21, 2019
Messages
435
I'm gonna skip the question of why an NE player has to be able to use human mining, and assume that there's a good reason.

Said reason is probably that this NE player needs to be able to do a variety of things that aren't regular melee.

In this case, I'd say that it may be time to start thinking outside the box, and make some manual AI assistance. You could run a periodic event that assigns "gold miner" peasants to any given gold mine, and then manually orders them to harvest gold. This way, you could get them to use proper human goldmining, without having them do a reskinned version of the NE gold farming. You'd have to be sure of how this interacts with the AI assigning workers to construction and such, and I am nowhere near enough of a melee buff to know how it goes about doing that.

What I would do, is basically add a newly constructed town hall (and the first town hall on map init) to a group of town halls, that are connected to the closest gold mine by hashtable. Then you periodically check the amount of peasants mining gold from the mines using a different value in the same hashtable, and order the computer player to take steps to bring this to a desired level.
 
Some good ideas, but it's way easier to just replace all 'ngol' gold mines with 'egol' gold mines changed to be exactly like regular ones. This way NE AI is able to use them (it apparently checks on the basis of unit type when assigning workers to gold mines), and other race AIs can use 'egol' mines without a problem.

The reason is that I'm only using human and orc races, and I've replaced night elf and undead with human and orc respectively, so Random still works as expected. So it's a pretty straight-forward case.
Undead doesn't have the same issue with haunted gold mines, fortunately.

JASS:
    private function ReplaceMinesEnum takes nothing returns boolean
        local unit mine = GetFilterUnit()
        local real x = GetUnitX(mine)
        local real y = GetUnitY(mine)
        local integer gold = GetResourceAmount(mine)
       
        call RemoveUnit(mine)
           
        set mine = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'egol', x, y, bj_UNIT_FACING)
        call SetResourceAmount(mine, gold)
       
        if GetUnitX(mine) != x or GetUnitY(mine) != y then
            call UnitSetUsesAltIcon(mine, false)
            call ShowUnit(mine, false)
            call SetUnitX(mine, x)
            call SetUnitY(mine, y)
            call ShowUnit(mine, true)
            call UnitSetUsesAltIcon(mine, true)
        endif
       
        set mine = null
       
        return false
    endfunction
   
    function ReplaceMines takes nothing returns nothing
        local group mines = CreateGroup()
       
        call GroupEnumUnitsOfType(mines, "goldmine", function ReplaceMinesEnum)
        call DestroyGroup(mines)
        set mines = null
    endfunction
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
This might need a custom AI. The melee AI cannot deal with unexpected buildings or units very well. A melee Night Elf AI has no idea what to do with a Human Town Hall or Peasants.

One could make a custom AI that can cope with such a situation. It might operate separate stock queues for each playable race that get turned on and ordered when they own the appropriate buildings.
 
Status
Not open for further replies.
Top