Function MeleePlayerIsOpponent

Line
9099
Location
blizzard.j
Constant?
no
Type
function
Arguments
integer playerIndex, integer opponentIndex
Returns
boolean
9099
function MeleePlayerIsOpponent takes integer playerIndex, integer opponentIndex returns boolean
9100
    local player thePlayer = Player(playerIndex)
9101
    local player theOpponent = Player(opponentIndex)
9102
9103
    // The player himself is not an opponent.
9104
    if (playerIndex == opponentIndex) then
9105
        return false
9106
    endif
9107
9108
    // Unused player slots are not opponents.
9109
    if (GetPlayerSlotState(theOpponent) != PLAYER_SLOT_STATE_PLAYING) then
9110
        return false
9111
    endif
9112
9113
    // Players who are already defeated are not opponents.
9114
    if (bj_meleeDefeated[opponentIndex]) then
9115
        return false
9116
    endif
9117
9118
    // Allied players with allied victory set are not opponents.
9119
    if GetPlayerAlliance(thePlayer, theOpponent, ALLIANCE_PASSIVE) then
9120
        if GetPlayerAlliance(theOpponent, thePlayer, ALLIANCE_PASSIVE) then
9121
            if (GetPlayerState(thePlayer, PLAYER_STATE_ALLIED_VICTORY) == 1) then
9122
                if (GetPlayerState(theOpponent, PLAYER_STATE_ALLIED_VICTORY) == 1) then
9123
                    return false
9124
                endif
9125
            endif
9126
        endif
9127
    endif
9128
9129
    return true
9130
endfunction