X/Y's mess up code?

D.V.D

Make a wish
Reaction score
73
I tryed adding X/Y's into my code but now, my trigger ccreates units but, always at the same spot, even when the locs are set in the loop and, the unitgroup acions don't work. Code:
JASS:
function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Check1 takes nothing returns boolean
    return GetOwningPlayer(GetEnumUnit()) == GetOwningPlayer(GetTriggerUnit())
endfunction

function Check2 takes nothing returns boolean
    return GetOwningPlayer(GetEnumUnit()) != GetOwningPlayer(GetTriggerUnit())
endfunction

function UnitGroupActions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local integer array dh
    set dh[1] = 30
    set dh[2] = 60
    set dh[3] = 130
    set dh[4] = 200
    set dh[5] = 375
    set dh[6] = 560
    set dh[7] = 1250
    set dh[8] = 4675
    set dh[9] = 6780
    set dh[10] = 8000
    if ( Check1() ) then
        call SetWidgetLife(GetEnumUnit(), GetWidgetLife(GetEnumUnit()) + I2R(dh[GetUnitAbilityLevel(Caster, 'A001')]))
    else
    endif
    if ( Check2() ) then
        call UnitDamageTargetBJ( Caster, GetEnumUnit(), I2R(dh[GetUnitAbilityLevel(Caster, 'A001')]), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
        //call UnitDamageTarget( Caster, GetEnumUnit(), I2R(dh[GetUnitAbilityLevel(Caster,'A001')]), ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
    else
    endif
endfunction

function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local unit dummy
    local location p0 = GetUnitLoc(Caster)
    local location p1
    local location p2
    local integer array i
    local integer t = 0
    local group unitgroup = CreateGroup()
    local real x
    local real y
    set i[1] = 8
    set i[2] = 10
    set i[3] = 12
    set i[4] = 13
    set i[5] = 15
    set i[6] = 17
    set i[7] = 18
    set i[8] = 20
    set i[9] = 24
    set i[10] = 30
    call PolledWait(0.40)
    loop
        exitwhen t > i[GetUnitAbilityLevel(Caster, 'A001')]
        set x = GetUnitX(Caster) + GetRandomReal(250.00, 550.00) * Cos(GetRandomReal(0.00, 360.00 * 6.283185))
        set y = GetUnitY(Caster) + GetRandomReal(250.00, 550.00) * Sin(GetRandomReal(0.00, 360.00 * 6.283185))
        set p1 = PolarProjectionBJ(p0, GetRandomReal(250.00, 550.00), GetRandomDirectionDeg())
        //call CreateUnitAtLoc(GetOwningPlayer(Caster), 'h001', p1, GetUnitFacing(Caster))
        call CreateUnit(GetOwningPlayer(Caster),'h001',x,y,GetRandomReal(0.00, 360.00))
        set dummy = GetLastCreatedUnit()
        call PauseUnit(dummy,true)
        set p2 = GetUnitLoc(dummy)
        set unitgroup = GetUnitsInRangeOfLocAll(( I2R(GetUnitAbilityLevel(Caster, 'A001')) * 100.00 ), p2)
        call UnitApplyTimedLife( dummy,'BTLF',1.00 )
        call PolledWait( 0.20 )
        call ForGroup( unitgroup, function UnitGroupActions )
        set t = t + 1
    endloop
    call RemoveLocation( p0 )
    call RemoveLocation( p1 )
    call RemoveLocation( p2 )
    call DestroyGroup( unitgroup )
    set Caster = null
    set dummy = null
endfunction

//===========================================================================
function InitTrig_Holy_Light takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
endfunction
 

Strilanc

Veteran Scripter
Reaction score
42
The reason the point is the same everytime is because you aren't changing the distance or angle each iteration of the loop. Of course you're going to get the same x/y again with the same distance/angle.
 

D.V.D

Make a wish
Reaction score
73
The unitgroup worked before. Why won't it work now? Also, with the X/Y's Ive noticed my angles were done wrong but, the distance is a random real from 250 and 550 and its in the loop making it different every time. So why doesn't it work?

Edit: Updated code. The creation works, but the Pause Unit doesn't. Gonna try CreateGroup to see if it will work.

Tested, doesn't work.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top