Warcraft III resources & community, 2003–2006 · archived

CreateUnitsInLine

not rated
Submitted by vjeuxFunctions0 downloads
Creates units in a line from (X1,Y1) to (X2,Y2), where Density specifies how close the units must be placed to each other.
typeId and who specifies the type of unit, and which player to create them for.

Source

function CreateUnitsInLine takes real X1, real Y1, real X2, real Y2, integer Density, integer typeId, player who returns nothing
    local real WaitX
    local real WaitY

    set WaitX = ( ( X1 + X2 ) / I2R(Density) )
    set WaitY = ( ( Y1 + Y2 ) / I2R(Density) )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = Density
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, typeId, who, Location(( X1 + ( WaitX * I2R(GetForLoopIndexA()) ) ), ( WaitY * I2R(GetForLoopIndexA()) )), bj_UNIT_FACING )
        call PauseUnitBJ( true, GetLastCreatedUnit() )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

Comments

1
cool snippet :)