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

Disabling Melee AI for certain computer players.

Status
Not open for further replies.
Level 4
Joined
Aug 11, 2013
Messages
65
Hey everyone,

I have a quick query, I want to disable the melee AI for players 10, 11 and 12. But keep them on for players 1 through 9.

As far as i can see theres only that melee game trigger which enables melee AI for ALL of the computers, but i dont want that.

Any help is appreciated.
 
Hey everyone,

I have a quick query, I want to disable the melee AI for players 10, 11 and 12. But keep them on for players 1 through 9.

As far as i can see theres only that melee game trigger which enables melee AI for ALL of the computers, but i dont want that.

Any help is appreciated.

I'm not sure if there any more efficient ways (ai editor, object data) to do this, but maybe;

  • Player - Make Neutral Hostile treat Player 1 (Red) as an Ally
or is that completely different from what you want?
 
Level 4
Joined
Aug 11, 2013
Messages
65
No sorry thats not what i want, i just want to make it so a few of the computers dont have their Melee AI enabled, which makes them do nothing in game as oppose to attacking and building things and shit.
 
Level 4
Joined
Aug 11, 2013
Messages
65
Ok, cant i disable the melee AI for the entire game, and then force start the melee AI for certain players using the trigger: AI - Start melee AI script?
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Ok, cant i disable the melee AI for the entire game, and then force start the melee AI for certain players using the trigger: AI - Start melee AI script?


This is the usual melee GUI action that you know as "Melee Game - Run AI"

The noteworthy part is exitwhen index == bj_MAX_PLAYERS
This is the highest player number that will be checked for AI.
Thus, you just have to replace bj_MAX_PLAYERS with 8(player 9, because players start from 0 in JASS)

Make a separate trigger and convert it to custom text. Then copy everything from here, except the first and last line.
Paste it into the actions function and voila.
JASS:
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
What it should look like(Triggername is the name of the trigger that this function is inside)
JASS:
function Triggername_Actions 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 == 8
    endloop
endfunction
 
Level 4
Joined
Aug 11, 2013
Messages
65
I've never used jass before. From what i can see, it looks like it loops through all the players from 0 to 8, and force starts the melee AI if they are controlled by the computer?

If i understand this correctly, then thank you very much i will try it out soon as i get a chance.
 
Status
Not open for further replies.
Top