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

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

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