Unit group variable :3

Emu.Man00

New Member
Reaction score
41
JASS:

function getTargetAngle takes nothing returns boolean
    local real angleTarget = ( AngleBetweenPoints(GetUnitLoc(udg_DummyFC), GetUnitLoc(GetFilterUnit())) )
    local real facing = (GetUnitFacing(udg_Commander))
    local real targetRange = 45 / 2
    local real angleTargetMin = facing - targetRange
    local real angleTargetMax = facing + targetRange
    return(angleTarget > angleTargetMin) and (angleTarget < angleTargetMax)
endfunction

function targetAttack takes nothing returns nothing
    call IssueTargetOrderBJ( udg_DummyFC, "chainlightning", GroupPickRandomUnit(udg_RAGroup[GetConvertedPlayerId(GetOwningPlayer(udg_DummyFC))]) )
endfunction

function pickRandom takes nothing returns nothing
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(700.00, GetUnitLoc(udg_DummyFC), Condition(function getTargetAngle)), function targetAttack )
endfunction

function pickTargetGroup takes nothing returns nothing
    call ForGroupBJ( GetUnitsInRangeOfLocAll(700.00, GetUnitLoc(udg_DummyFC)), function pickRandom )
endfunction

function testFacing takes real facing returns nothing
    call DisplayTextToForce(GetPlayersAll(), "ANGLE: "+R2S(facing))
endfunction
//===========================================================================
function InitTrig_Range takes nothing returns nothing
    set gg_trg_Range = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic(gg_trg_Range, 0.50)
    call TriggerAddAction( gg_trg_Range, function pickTargetGroup )
endfunction


function pickTargetGroup makes a unit group. I want to set this made unit group to "udg_RAGroup"

How do i do that? :3 Sorry, I'm just learning JASS, and if you see any other things wrong with the code please point them out.
 

RaiJin

New Member
Reaction score
40
JASS:
function getTargetAngle takes nothing returns boolean
    local location l = GetUnitLoc(udg_DummyFC)
    local location l2 = GetUnitLoc(GetFilterUnit())
    local real angleTarget = ( AngleBetweenPoints(l, l2))
    local real facing = (GetUnitFacing(udg_Commander))
    local real targetRange = 45 / 2
    local real angleTargetMin = facing - targetRange
    local real angleTargetMax = facing + targetRange
    call RemoveLocation(l)
    call RemoveLocation(l2)
    set l = null
    set l2 = null
    return(angleTarget > angleTargetMin) and (angleTarget < angleTargetMax)
endfunction

function targetAttack takes nothing returns nothing
    call IssueTargetOrderBJ( udg_DummyFC, "chainlightning", GroupPickRandomUnit(udg_RAGroup[GetConvertedPlayerId(GetOwningPlayer(udg_DummyFC))]) )
endfunction

function pickRandom takes nothing returns nothing
    local location l = GetUnitLoc(udg_DummyFC)
    call ForGroup( GetUnitsInRangeOfLocMatching(700.00, l, Condition(function getTargetAngle)), function targetAttack )
    call RemoveLocation(l)
    set l = null
endfunction

function pickTargetGroup takes nothing returns nothing
    local location l = GetUnitLoc(udg_DummyFC)
    set udg_RAGroup = GetUnitsInRangeOfLocAll(700.00, l)
    call ForGroup(udg_RAGroup, function pickRandom)
    call RemoveLocation(l)
    set l = null
endfunction

function testFacing takes real facing returns nothing
    call DisplayTextToForce(GetPlayersAll(), "ANGLE: "+R2S(facing))
endfunction
//===========================================================================
function InitTrig_Range takes nothing returns nothing
    local timer t = CreateTimer()
    call TimerStart(t, 0.50, true, function pickTargetGroup)
endfunction


fixed it up for u
 

Emu.Man00

New Member
Reaction score
41
Tyvm repped both, helping very much :3

But for the loop.. I want it to do something like if a boolean is false for a specific unit, it's removed from the group, can you show me how to do that? :D
 

RaiJin

New Member
Reaction score
40
you would have to set the unit a custom value.. and then manipulate that in arrays as shown below


JASS:
globals
    integer index
    boolean array Boolean
endglobals

function Booleas takes nothing returns nothing
    local integer UnitIndex = GetUnitUserData(GetEnumUnit())
    set Boolean[UnitIndex] = false
endfunction

function example2 takes nothing returns nothing
    set index = index + 1
    call SetUnitUserData(GetEnumUnit(), index)
endfunction

function example takes nothing returns nothing
    local group g = CreateGroup()
    local group g2 = CreateGroup()
    call ForGroup(g, function example2)
    call ForGroup(g2, function Booleas)
    set g=null
    set g2=null
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top