• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Changing AI

Status
Not open for further replies.
Level 1
Joined
Jun 11, 2016
Messages
2
Hey, all! Long time lurker, first time poster. I was inspired by the Warcraft movie to create a custom map containing Orcs vs Humans. I only know how to use the WC3 World Editor.

The Orc Hero is Gul'dan, and I want it to be played by a custom AI (As it is a custom hero with altered Orc units, using custom abilities which the regular AI would not use). There are three players, one is the Alliance (Computer - Player 1), the Horde (Computer - Player 7) and the Hero (User - Player 4).

The Alliance (Computer) has no modifications to it, and I want it to use the melee AI. I created a custom AI for the Horde, which seems to work perfectly. I have a trigger that (at map initialization) that starts my custom AI for Player 7 (Green - Horde), however this conflicts with "Map initialization - Melee Game - Run melee AI scripts (for computer players)".

If I remove "Map initialization - Melee Game - Run melee AI scripts (for computer players)", then my trigger (Map initialization) successfully activates my custom script for Player 7, however Player 1 has no AI to control it. I created a custom AI that was completely unchanged from the template Blizzard has provided, and duplicated my trigger for Player 7, except it affiliates the new, unaltered AI to Player 1. For some reason, this didn't work and Player 1 continues to send Peasants to mine gold and make no further actions.

As I mentioned, if I have "Map initialization - Melee Game - Run melee AI scripts (for computer players)" initialized, then Player 7 makes no actions (Other than make Peons mine gold). If I remove it, Player 7 works but Player 1 becomes malfunctional.

I attempted to create a trigger that (after elapsed game time is X seconds) starts my custom Horde AI for Player 7, but this did not work. I was hoping if anyone has any solution to my issue, they'll help me out. :)

P.S. I'm sorry, I don't know how to link snippets of World Editor triggers, but I've attached screenshots.
 

Attachments

  • WC3 map 0.jpg
    WC3 map 0.jpg
    99.9 KB · Views: 310
  • WC3 map 1.jpg
    WC3 map 1.jpg
    54.9 KB · Views: 330
Level 4
Joined
Sep 13, 2014
Messages
106
This is the code that gets run when you run the melee AI scripts. (Starting with the second function)

Code:
function PickMeleeAI takes player num, string s1, string s2, string s3 returns nothing
    local integer pick

    // easy difficulty never uses any custom AI scripts
    // that are designed to be a bit more challenging
    //
    if GetAIDifficulty(num) == AI_DIFFICULTY_NEWBIE then
        call StartMeleeAI(num,s1)
        return
    endif

    if s2 == null then
        set pick = 1
    elseif s3 == null then
        set pick = GetRandomInt(1,2)
    else
        set pick = GetRandomInt(1,3)
    endif

    if pick == 1 then
        call StartMeleeAI(num,s1)
    elseif pick == 2 then
        call StartMeleeAI(num,s2)
    else
        call StartMeleeAI(num,s3)
    endif
endfunction

//===========================================================================
function MeleeStartingAI takes nothing returns nothing
    local integer index
    local player  indexPlayer
    local race    indexRace

    set index = 0
    loop
        set indexPlayer = Player(index)
        if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
            set indexRace = GetPlayerRace(indexPlayer)
            if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
                // Run a race-specific melee AI script.
                if (indexRace == RACE_HUMAN) then
                    call PickMeleeAI(indexPlayer, "human.ai", null, null)
                elseif (indexRace == RACE_ORC) then
                    call PickMeleeAI(indexPlayer, "orc.ai", null, null)
                elseif (indexRace == RACE_UNDEAD) then
                    call PickMeleeAI(indexPlayer, "undead.ai", null, null)
                    call RecycleGuardPosition(bj_ghoul[index])
                elseif (indexRace == RACE_NIGHTELF) then
                    call PickMeleeAI(indexPlayer, "elf.ai", null, null)
                else
                    // Unrecognized race.
                endif
                call ShareEverythingWithTeamAI(indexPlayer)
            endif
        endif

        set index = index + 1
        exitwhen index == bj_MAX_PLAYERS
    endloop
endfunction

This is what you do: Remove the melee starting AI function and add the following using the Custom script action:

Custom script: call PickMeleeAI(Player(0), "human.ai", null, null)

If you want your AI to "share vision and advanced unit control with all AI players of its allies." (which is the default for melee AI), you need to:

Custom script: call ShareEverythingWithTeamAI(Player(0))

Replace Player(0) with Player(1), 2 , 3 etc if you want other AIs to run the melee AI.
 
Last edited:
Status
Not open for further replies.
Top