• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

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

Status
Not open for further replies.
Level 22
Joined
Mar 16, 2008
Messages
981
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