• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Substitute GUI Move unit with custom script SetunitXY

Status
Not open for further replies.
Level 9
Joined
Sep 20, 2015
Messages
385
So, in this pages i found out that the function Set Unit X/Y is better and faster than Move unit, so i decided to use them in my map. There is a problem when is insert the custom scritps lines in the GUI trigger, it always say ''Expected end of the line'' error! I tried to convert in Jass and adjust some things but i messed it up even more... here is the trigger in JASS (original, not messed up more of course)



JASS:
function Trig_Leap_Dash_Loop_Func003C takes nothing returns boolean
    if ( not ( udg_Real[1] >= 0.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Leap_Dash_Loop_Actions takes nothing returns nothing
    set udg_Points[1] = GetUnitLoc(udg_LeapCaster)
    set udg_Points[2] = PolarProjectionBJ(udg_Points[1], 33.00, udg_Real[3])
    if ( Trig_Leap_Dash_Loop_Func003C() ) then
        set udg_Real[1] = ( udg_Real[1] - 33.00 )
        call SetUnitY(udg_LeapCaster), GetUnitY(udg_LeapCaster) + udg_Real[1] * Sin(bj_DEGTORAD * udg_Real[3]) ERROR!
        call SetUnitX(udg_LeapCaster), GetUnitX(udg_LeapCaster) + udg_Real[1] * Cos(bj_DEGTORAD * udg_Real[3]) ERROR!
    else
        call SetUnitPathing( udg_LeapCaster, true )
        call SetUnitFlyHeightBJ( udg_LeapCaster, GetUnitDefaultFlyHeight(udg_Caster), 0.00 )
        call CreateNUnitsAtLoc( 1, 'h009', GetOwningPlayer(udg_LeapCaster), udg_Points[2], bj_UNIT_FACING )
        call UnitApplyTimedLifeBJ( 0.50, 'BTLF', GetLastCreatedUnit() )
        call UnitAddAbilityBJ( 'A01N', GetLastCreatedUnit() )
        call SetUnitAbilityLevelSwapped( 'A01N', GetLastCreatedUnit(), 1 )
        call IssueImmediateOrderBJ( GetLastCreatedUnit(), "stomp" )
        call RemoveLocation(udg_Points[1])
        call RemoveLocation(udg_Points[2])
        call DisableTrigger( GetTriggeringTrigger() )
    endif
endfunction

//===========================================================================
function InitTrig_Leap_Dash_Loop takes nothing returns nothing
    set gg_trg_Leap_Dash_Loop = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Leap_Dash_Loop_Copia, 0.03 )
    call TriggerAddAction( gg_trg_Leap_Dash_Loop, function Trig_Leap_Dash_Loop_Actions )
endfunction


Those two lines with Error at the end are the problem. Thanks for the help
 
Last edited by a moderator:
Level 11
Joined
Jun 30, 2008
Messages
580
You are missing a parentheses on those lines.

JASS:
    SetUnitY(udg_LeapCaster, (GetUnitY(udg_LeapCaster) + udg_Real[1] * Sin(bj_DEGTORAD * udgReal[3]))
    SetUnitX(udg_LeapCaster, (GetUnitX(udg_LeapCaster) + udg_Real[1] * Cos(bj_DEGTORAD * udgReal[3]))

Also are you using JNGP? If you use the latest JNGP you can easily see where you need/remove them.

Edit: Here is the link! Jass NewGen Pack [Official]
 
Looking at the code given, you did not add another opening parenthesis before the variable:
(udg_LeapCaster). The solution is either to remove the closing parenthesis after the variable or add another opening parenthesis.

If you want to optimize your code in JASS, you can look below:

In the condition function, you can replace whatever's inside with this.
return udg_Real[1] >=0.00

In the actions function, you could declare a local unit variable somename. This will be the output

Code:
function Trig_Leap_Dash_Loop_Actions takes nothing returns boolean
    local real x = GetUnitX(udg_LeapCaster)
    local real y = GetUnitY(udg_LeapCaster)
    local real tx = x + udg_Real[1] * Sin(bi_DEGTORAD * udg_Real[3])
    local real ty = y + udg_Real[1] * Cos(bj_DEGTORAD * udg_Real[3])
    if udg_Real[1] >= 0.00 then
        set udg_Real[1] = ( udg_Real[1] - 33.00 )
        call SetUnitY(udg_LeapCaster, ty)
        call SetUnitX(udg_LeapCaster, tx)
    else
        call SetUnitPathing( udg_LeapCaster, true )
        call SetUnitFlyHeight( udg_LeapCaster, GetUnitDefaultFlyHeight(udg_Caster), 0.00 )
        set bj_lastCreatedUnit = CreateUnit('h009', GetOwningPlayer(udg_LeapCaster), tx, ty, bj_UNIT_FACING )
        call UnitApplyTimedLife( bj_lastCreatedUnit, 'BTLF', 0.50)
        call UnitAddAbility(bj_lastCreatedUnit, 'A01N')
        call SetUnitAbilityLevel( bj_lastCreatedUnit, 'A01N', 1 )
        call IssueImmediateOrder( bj_lastCreatedUnit, "stomp" )
        //  call IssueImmediateOrderById( bj_lastCreatedUnit, OrderId("stomp"))
        call DisableTrigger( GetTriggeringTrigger() )
    endif
    return false
endfunction

The code below is based from @Athur12A2
Code:
function InitTrig_Leap_Dash_Loop takes nothing returns nothing
    set gg_trg_Leap_Dash_Loop = CreateTrigger()
    call TriggerRegisterTimerEvent(gg_trg_Leap_Dash_Loop, 0.03, true)
    call TriggerAddCondition(gg_trg_Leap_Dash_Loop, Filter(function Trig_Leap_Dash_Actions))
endfunction
 
Last edited:
Level 10
Joined
Sep 16, 2016
Messages
269
So, in this pages i found out that the function Set Unit X/Y is better and faster than Move unit, so i decided to use them in my map. There is a problem when is insert the custom scritps lines in the GUI trigger, it always say ''Expected end of the line'' error! I tried to convert in Jass and adjust some things but i messed it up even more... here is the trigger in JASS (original, not messed up more of course)

Those two lines with Error at the end are the problem. Thanks for the help


JASS:
function Trig_Leap_Dash_Loop_Actions takes nothing returns boolean
    local unit u
    if udg_Real[1] >= 0.00 then
        set udg_Real[1] = ( udg_Real[1] - 33.00 )
        call SetUnitY(udg_LeapCaster, GetUnitY(udg_LeapCaster) + udg_Real[1] * SinBJ(udg_Real[3]) )
        call SetUnitX(udg_LeapCaster, GetUnitX(udg_LeapCaster) + udg_Real[1] * CosBJ(udg_Real[3]) )
    else
        call SetUnitPathing( udg_LeapCaster, true )
        call SetUnitFlyHeight( udg_LeapCaster, GetUnitDefaultFlyHeight(udg_LeapCaster), 0.00 )
        set u = CreateUnit( GetOwningPlayer(udg_LeapCaster),'h009', GetUnitX(udg_LeapCaster), GetUnitY(udg_LeapCaster), 0 )
        call UnitApplyTimedLife( u, 'BTLF', 1 )
        call UnitAddAbility( u, 'A01N' )
        call SetUnitAbilityLevel( u, 'A01N', 1 )
        call IssueImmediateOrder( u, "stomp" )
        call DisableTrigger( GetTriggeringTrigger() )
    set u = null
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Leap_Dash_Loop takes nothing returns nothing
    set gg_trg_Leap_Dash_Loop = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Leap_Dash_Loop, 0.03125 )
    call TriggerAddCondition( gg_trg_Leap_Dash_Loop, Condition( function Trig_Leap_Dash_Loop_Actions ) )
endfunction

EDIT: On second thought, You can keep the whole trigger in GUI and use customscript for 2 actions:
  • Custom script: call SetUnitY(udg_LeapCaster, GetUnitY(udg_LeapCaster) + udg_Real[1] * SinBJ(udg_Real[3]) )
  • Custom script: call SetUnitX(udg_LeapCaster, GetUnitX(udg_LeapCaster) + udg_Real[1] * CosBJ(udg_Real[3]) )
 
Last edited:
Level 9
Joined
Sep 20, 2015
Messages
385
You are missing a parentheses on those lines.

JASS:
    SetUnitY(udg_LeapCaster, (GetUnitY(udg_LeapCaster) + udg_Real[1] * Sin(bj_DEGTORAD * udgReal[3]))
    SetUnitX(udg_LeapCaster, (GetUnitX(udg_LeapCaster) + udg_Real[1] * Cos(bj_DEGTORAD * udgReal[3]))

Also are you using JNGP? If you use the latest JNGP you can easily see where you need/remove them.

Edit: Here is the link! Jass NewGen Pack [Official]

Thanks for the suggestion, im getting used to Jass after just now so i am an initiate, i added a parentesis but still get the error.

Looking at the code given, you did not add another opening parenthesis before the variable:
(udg_LeapCaster). The solution is either to remove the closing parenthesis after the variable or add another opening parenthesis.

If you want to optimize your code in JASS, you can look below:

In the condition function, you can replace whatever's inside with this.
return udg_Real[1] >=0.00

In the actions function, you could declare a local unit variable somename. This will be the output

Code:
function Trig_Leap_Dash_Loop_Actions
    local real x = GetUnitX(udg_LeapCaster)
    local real y = GetUnitY(udg_LeapCaster)
    local real tx = x + 33 * Sin(bi_DEGTORAD * udg_Real[3])
    ...

I'll continue the code later.

Thx but as stated before i'm new to Jass and i don't feel i can start to write directly with it.

JASS:
function Trig_Leap_Dash_Loop_Actions takes nothing returns boolean
    local unit u
    if udg_Real[1] >= 0.00 then
        set udg_Real[1] = ( udg_Real[1] - 33.00 )
        call SetUnitY(udg_LeapCaster, GetUnitY(udg_LeapCaster) + udg_Real[1] * SinBJ(udg_Real[3]) )
        call SetUnitX(udg_LeapCaster, GetUnitX(udg_LeapCaster) + udg_Real[1] * CosBJ(udg_Real[3]) )
    else
        call SetUnitPathing( udg_LeapCaster, true )
        call SetUnitFlyHeight( udg_LeapCaster, GetUnitDefaultFlyHeight(udg_LeapCaster), 0.00 )
        set u = CreateUnit( GetOwningPlayer(udg_LeapCaster),'h009', GetUnitX(udg_LeapCaster), GetUnitY(udg_LeapCaster), 0 )
        call UnitApplyTimedLife( u, 'BTLF', 1 )
        call UnitAddAbility( u, 'A01N' )
        call SetUnitAbilityLevel( u, 'A01N', 1 )
        call IssueImmediateOrder( u, "stomp" )
        call DisableTrigger( GetTriggeringTrigger() )
    set u = null
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Leap_Dash_Loop takes nothing returns nothing
    set gg_trg_Leap_Dash_Loop = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Leap_Dash_Loop, 0.03125 )
    call TriggerAddCondition( gg_trg_Leap_Dash_Loop, Condition( function Trig_Leap_Dash_Loop_Actions ) )
endfunction

EDIT: On second thought, You can keep the whole trigger in GUI and use customscript for 2 actions:
  • Custom script: call SetUnitY(udg_LeapCaster, GetUnitY(udg_LeapCaster) + udg_Real[1] * SinBJ(udg_Real[3]) )
  • Custom script: call SetUnitX(udg_LeapCaster, GetUnitX(udg_LeapCaster) + udg_Real[1] * CosBJ(udg_Real[3]) )

Thats what i've done in the beginning and i got the error. BTW if i remove the parentesis from udg:_LeapCaster i get the ''Expected a name'' error.

Thank you all for responses.
 
Level 10
Joined
Sep 16, 2016
Messages
269
Thats what i've done in the beginning and i got the error. BTW if i remove the parentesis from udg:_LeapCaster i get the ''Expected a name'' error.

Thank you all for responses.

You obviously didn't do the same as I, because my JNGP compiles my code with no error.
These are what make your Jasshelper reports errors:
sd.jpg
 
Level 9
Joined
Sep 20, 2015
Messages
385
You obviously didn't do the same as I, because my JNGP compiles my code with no error.
These are what make your Jasshelper reports errors:

I fixed the names on the variable and the trigger, but i still got the error in the SetUnitX/Y lines. I tried all possible combinations of deleting or addin parentesis, still get the error.....i think i'm gonna re-write the trigger from the beginning..

Thank you :)
 
Level 7
Joined
Jan 23, 2011
Messages
351
Look at the Init function

JASS:
call TriggerRegisterTimerEventPeriodic( gg_trg_Leap_Dash_Loop_Copia, 0.03 )
    call TriggerAddAction( gg_trg_Leap_Dash_Loop, function Trig_Leap_Dash_Loop_Actions )
endfunction

And then look at your func named

JASS:
function Trig_Leap_Dash_Loop_Func003C
,
JASS:
function Trig_Leap_Dash_Loop_Actions

Hopefully you now see the problem
 
This is quite a problem you have there. Seeing that you did what was previously suggested before, I would suggest looking for the udg_LeapCaster variable.

As to the script itself, you can improve it with some sort of parser. Try what @Athur12A2 has linked you: JNGP
This will add some readability to your code.

By the way, you can post in jass tags for your code instead of the code tag.
 
Level 7
Joined
Jan 23, 2011
Messages
351
JASS:
        call SetUnitY(udg_LeapCaster), GetUnitY(udg_LeapCaster) + udg_Real[1] * Sin(bj_DEGTORAD * udg_Real[3]) ERROR!
        call SetUnitX(udg_LeapCaster), GetUnitX(udg_LeapCaster) + udg_Real[1] * Cos(bj_DEGTORAD * udg_Real[3]) ERROR!

This to

JASS:
        call SetUnitY(udg_LeapCaster, GetUnitY(udg_LeapCaster) + udg_Real[1] * Sin(bj_DEGTORAD * udg_Real[3]))
       call SetUnitX(udg_LeapCaster, GetUnitX(udg_LeapCaster) + udg_Real[1] * Cos(bj_DEGTORAD * udg_Real[3]))

This
 
Level 9
Joined
Sep 20, 2015
Messages
385
So i wrote the code again from the beginning adn it's working now

JASS:
function Trig_LeapLoopJASS_Actions takes nothing returns nothing
    call SetUnitTimeScalePercent( gg_unit_O002_0005, 2.00 )
    set udg_Points[1] = GetUnitLoc(gg_unit_O002_0005)
    set udg_Points[2] = PolarProjectionBJ(udg_Points[1], 33.00, udg_Real[3])
    if ( Trig_LeapLoopJASS_Func004C() ) then
        set udg_Real[1] = ( udg_Real[1] - 33.00 )
        call SetUnitY(gg_unit_O002_0005, GetUnitY(gg_unit_O002_0005) + udg_Real[1] * Sin(bj_DEGTORAD * udg_Real[3]))
         call SetUnitX(gg_unit_O002_0005, GetUnitX(gg_unit_O002_0005) + udg_Real[1] * Cos(bj_DEGTORAD * udg_Real[3]))
    else
        call SetUnitPathing( gg_unit_O002_0005, true )
        call SetUnitAnimationByIndex (gg_unit_O002_0005, 6)
        call SetUnitTimeScalePercent( gg_unit_O002_0005, 300.00 )
        call CreateNUnitsAtLoc( 1, 'h009', GetOwningPlayer(gg_unit_O002_0005), udg_Points[2], bj_UNIT_FACING )
        call UnitApplyTimedLifeBJ( 0.50, 'BTLF', GetLastCreatedUnit() )
        call UnitAddAbilityBJ( 'A01N', GetLastCreatedUnit() )
        call SetUnitAbilityLevelSwapped( 'A01N', GetLastCreatedUnit(), 1 )
        call IssueImmediateOrderBJ( GetLastCreatedUnit(), "stomp" )
        call EnumDestructablesInCircleBJ( 250.00, udg_Points[1], function Trig_LeapLoopJASS_Func004Func015A )
        call RemoveLocation(udg_Points[1])
        call RemoveLocation(udg_Points[2])
        call DisableTrigger( GetTriggeringTrigger() )
        call TriggerSleepAction( 0.20 )
        set udg_LeapLoopAir = false
        if ( Trig_LeapLoopJASS_Func004Func022C() ) then
            call TriggerSleepAction( 0.01 )
            call SetUnitAnimationByIndex (gg_unit_O002_0005, 7)
            call SetUnitTimeScalePercent( gg_unit_O002_0005, 100.00 )
            call SetUnitFacingToFaceUnitTimed( gg_unit_O002_0005, udg_EparcAssorbTarget, 0 )
        else
            call SetUnitTimeScalePercent( gg_unit_O002_0005, 100.00 )
            call ResetUnitAnimation( gg_unit_O002_0005 )
        endif
    endif
endfunction

//===========================================================================
function InitTrig_LeapLoopJASS takes nothing returns nothing
    set gg_trg_LeapLoopJASS = CreateTrigger(  )
    call DisableTrigger( gg_trg_LeapLoopJASS )
    call TriggerRegisterTimerEventPeriodic( gg_trg_LeapLoopJASS, 0.03 )
    call TriggerAddAction( gg_trg_LeapLoopJASS, function Trig_LeapLoopJASS_Actions )
endfunction

Thank you all :)
 
So i wrote the code again from the beginning adn it's working now

JASS:
function Trig_LeapLoopJASS_Actions takes nothing returns nothing
    call SetUnitTimeScalePercent( gg_unit_O002_0005, 2.00 )
    set udg_Points[1] = GetUnitLoc(gg_unit_O002_0005)
    set udg_Points[2] = PolarProjectionBJ(udg_Points[1], 33.00, udg_Real[3])
    if ( Trig_LeapLoopJASS_Func004C() ) then
        set udg_Real[1] = ( udg_Real[1] - 33.00 )
        call SetUnitY(gg_unit_O002_0005, GetUnitY(gg_unit_O002_0005) + udg_Real[1] * Sin(bj_DEGTORAD * udg_Real[3]))
         call SetUnitX(gg_unit_O002_0005, GetUnitX(gg_unit_O002_0005) + udg_Real[1] * Cos(bj_DEGTORAD * udg_Real[3]))
    else
        call SetUnitPathing( gg_unit_O002_0005, true )
        call SetUnitAnimationByIndex (gg_unit_O002_0005, 6)
        call SetUnitTimeScalePercent( gg_unit_O002_0005, 300.00 )
        call CreateNUnitsAtLoc( 1, 'h009', GetOwningPlayer(gg_unit_O002_0005), udg_Points[2], bj_UNIT_FACING )
        call UnitApplyTimedLifeBJ( 0.50, 'BTLF', GetLastCreatedUnit() )
        call UnitAddAbilityBJ( 'A01N', GetLastCreatedUnit() )
        call SetUnitAbilityLevelSwapped( 'A01N', GetLastCreatedUnit(), 1 )
        call IssueImmediateOrderBJ( GetLastCreatedUnit(), "stomp" )
        call EnumDestructablesInCircleBJ( 250.00, udg_Points[1], function Trig_LeapLoopJASS_Func004Func015A )
        call RemoveLocation(udg_Points[1])
        call RemoveLocation(udg_Points[2])
        call DisableTrigger( GetTriggeringTrigger() )
        call TriggerSleepAction( 0.20 )
        set udg_LeapLoopAir = false
        if ( Trig_LeapLoopJASS_Func004Func022C() ) then
            call TriggerSleepAction( 0.01 )
            call SetUnitAnimationByIndex (gg_unit_O002_0005, 7)
            call SetUnitTimeScalePercent( gg_unit_O002_0005, 100.00 )
            call SetUnitFacingToFaceUnitTimed( gg_unit_O002_0005, udg_EparcAssorbTarget, 0 )
        else
            call SetUnitTimeScalePercent( gg_unit_O002_0005, 100.00 )
            call ResetUnitAnimation( gg_unit_O002_0005 )
        endif
    endif
endfunction

//===========================================================================
function InitTrig_LeapLoopJASS takes nothing returns nothing
    set gg_trg_LeapLoopJASS = CreateTrigger(  )
    call DisableTrigger( gg_trg_LeapLoopJASS )
    call TriggerRegisterTimerEventPeriodic( gg_trg_LeapLoopJASS, 0.03 )
    call TriggerAddAction( gg_trg_LeapLoopJASS, function Trig_LeapLoopJASS_Actions )
endfunction

Thank you all :)

I noticed that this was solved already, so may I post a bit more about the jass script that you used? I'll try optimizing it to the fullest in JASS.

By the by, is this going to be MUI? (Means that it can be cast by more than one caster per instance.)
 
Status
Not open for further replies.
Top