[AI] function to figure out what user slot is running AI script and how to reference it

Status
Not open for further replies.
Level 21
Joined
Mar 16, 2008
Messages
955
I'm trying to make some AI attack "suicide" target for this scirpt but I don't know enough about JASS, maybe someone can explain.

I want it to say something like if player is red then target blue, teal, or purple depending on a random roll.

my main question is will "GetAiPlayer() ==" give the user slot of the computer player that is running the script? in the condition?

here's how far i got:
JASS:
function RushAttack takes nothing returns nothing
    local integer roll = GetRandomInt(1,3)
    local integer player_slot
    local integer target
    if (GetAiPlayer() == 0) then
        if (roll == 1) then
            call SuicideOnPlayer (240, Player(1))
        elseif (roll == 2) then
            call SuicideOnPlayer (240, Player(2))
        elseif (roll == 3) then
            call SuicideOnPlayer (240, Player(3))
        endif
    elseif (GetAiPlayer() == 1) then
        if (roll == 1) then
            call SuicideOnPlayer (240, Player(2))
        elseif (roll == 2) then
            call SuicideOnPlayer (240, Player(3))
        elseif (roll == 3) then
            call SuicideOnPlayer (240, Player(0))
        endif
    elseif (GetAiPlayer() == 2) then
        if (roll == 1) then
            call SuicideOnPlayer (240, Player(3))
        elseif (roll == 2) then
            call SuicideOnPlayer (240, Player(0))
        elseif (roll == 3) then
            call SuicideOnPlayer (240, Player(1))
        endif
    elseif (GetAiPlayer() == 3) then
        if (roll == 1) then
            call SuicideOnPlayer (240, Player(0))
        elseif (roll == 2) then
            call SuicideOnPlayer (240, Player(1))
        elseif (roll == 3) then
            call SuicideOnPlayer (240, Player(2))
        endif                   
    endif
endfunction
 
Last edited:
Status
Not open for further replies.
Top