Converted the spell to MUI, now... Help!

MrApples

Ultra Cool Member
Reaction score
78
Ok I just converted this trigger
Code:
Blink StrikeBU
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Blink Strike [NEW]
    Actions
        Set CastingUnit = (Casting unit)
        Set TempPoint = (Position of (Target unit of ability being cast))
        Set BlinkStrikeTarget = (Target unit of ability being cast)
        Unit - Move CastingUnit instantly to TempPoint2
        Unit - Make CastingUnit face BlinkStrikeTarget over 0.00 seconds
        Animation - Play CastingUnit's attack animation
        Unit - Cause CastingUnit to damage BlinkStrikeTarget, dealing (175.00 + (150.00 x ((Real((Level of Blink Strike [NEW] for CastingUnit))) - 1.00))) damage of attack type Hero and damage type Normal
        Custom script:   call RemoveLocation(udg_TempPoint)
        Set BlinkStrikeTarget = No unit
        For each (Integer A) from 1 to ((Level of Blink Strike [NEW] for (Casting unit)) x 2), do (Actions)
            Loop - Actions
                Set TempPoint = (Position of CastingUnit)
                Set TempGroup = (Units within 512.00 of TempPoint matching (((((Matching unit) is alive) Equal to True) and (((Matching unit) is in TempGroup2) Equal to False)) and (((Matching unit) belongs to an enemy of (Owner of CastingUnit)) Equal to True)))
                Set BlinkStrikeTarget = (Random unit from TempGroup)
                Set TempPoint2 = (Position of BlinkStrikeTarget)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        BlinkStrikeTarget Equal to No unit
                    Then - Actions
                        Custom script:   exitwhen true
                    Else - Actions
                        Lightning - Create a Magic Leash lightning effect from source TempPoint to target TempPoint2
                        Unit - Move CastingUnit instantly to TempPoint2
                        Unit - Make CastingUnit face BlinkStrikeTarget over 0.00 seconds
                        Animation - Play CastingUnit's attack animation
                        Unit - Cause CastingUnit to damage BlinkStrikeTarget, dealing (150.00 + (200.00 x ((Real((Level of Blink Strike [NEW] for CastingUnit))) - 1.00))) damage of attack type Hero and damage type Normal
                        Wait 0.25 game-time seconds
                        Lightning - Destroy (Last created lightning effect)
                        Unit Group - Add BlinkStrikeTarget to TempGroup2
                        Set BlinkStrikeTarget = No unit
                Custom script:   call RemoveLocation(udg_TempPoint)
                Custom script:   call RemoveLocation(udg_TempPoint2)
                Custom script:   call DestroyGroup(udg_TempGroup)
        Custom script:   call DestroyGroup(udg_TempGroup2)
        Custom script:   set udg_TempPoint = null
        Custom script:   set udg_TempPoint2 = null
        Custom script:   set udg_TempGroup = null
        Custom script:   set udg_TempGroup2 = null
To Jass and set all the variables to locals
Code:
function Trig_Blink_Strike_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A085' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Blink_Strike_Func010Func002002003001001 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Blink_Strike_Func010Func002002003001002 takes nothing returns boolean
    return ( IsUnitInGroup(GetFilterUnit(), TempGroup2) == false )
endfunction

function Trig_Blink_Strike_Func010Func002002003001 takes nothing returns boolean
    return GetBooleanAnd( Trig_Blink_Strike_Func010Func002002003001001(), Trig_Blink_Strike_Func010Func002002003001002() )
endfunction

function Trig_Blink_Strike_Func010Func002002003002 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(CastingUnit)) == true )
endfunction

function Trig_Blink_Strike_Func010Func002002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Blink_Strike_Func010Func002002003001(), Trig_Blink_Strike_Func010Func002002003002() )
endfunction

function Trig_Blink_Strike_Func010Func005C takes nothing returns boolean
    if ( not ( BlinkStrikeTarget == null ) ) then
        return false
    endif
    return true
endfunction

function Trig_Blink_Strike_Actions takes nothing returns nothing
    set local unit CastingUnit = GetSpellAbilityUnit()
    set local point TempPoint = GetUnitLoc(GetSpellTargetUnit())
    set local unit BlinkStrikeTarget = GetSpellTargetUnit()
    call SetUnitPositionLoc( CastingUnit, TempPoint2 )
    call SetUnitFacingToFaceUnitTimed( CastingUnit, BlinkStrikeTarget, 0 )
    call SetUnitAnimation( CastingUnit, "attack" )
    call UnitDamageTargetBJ( CastingUnit, BlinkStrikeTarget, ( 175.00 + ( 150.00 * ( I2R(GetUnitAbilityLevelSwapped('A085', CastingUnit)) - 1 ) ) ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
    call RemoveLocation(TempPoint)
    set BlinkStrikeTarget = null
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = ( GetUnitAbilityLevelSwapped('A085', GetSpellAbilityUnit()) * 2 )
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set local point TempPoint = GetUnitLoc(CastingUnit)
        set local group TempGroup = GetUnitsInRangeOfLocMatching(512, TempPoint, Condition(function Trig_Blink_Strike_Func010Func002002003))
        set local unit BlinkStrikeTarget = GroupPickRandomUnit(TempGroup)
        set local point TempPoint2 = GetUnitLoc(BlinkStrikeTarget)
        if ( Trig_Blink_Strike_Func010Func005C() ) then
            exitwhen true
        else
            call AddLightningLoc( "LEAS", TempPoint, TempPoint2 )
            call SetUnitPositionLoc( CastingUnit, TempPoint2 )
            call SetUnitFacingToFaceUnitTimed( CastingUnit, BlinkStrikeTarget, 0 )
            call SetUnitAnimation( CastingUnit, "attack" )
            call UnitDamageTargetBJ( CastingUnit, BlinkStrikeTarget, ( 150.00 + ( 200.00 * ( I2R(GetUnitAbilityLevelSwapped('A085', CastingUnit)) - 1 ) ) ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
            call PolledWait( 0.25 )
            call DestroyLightningBJ( GetLastCreatedLightningBJ() )
            call GroupAddUnitSimple( BlinkStrikeTarget, TempGroup2 )
            set BlinkStrikeTarget = null
        endif
        call RemoveLocation(TempPoint)
        call RemoveLocation(TempPoint2)
        call DestroyGroup(TempGroup)
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call DestroyGroup(udg_TempGroup2)
    set TempPoint = null
    set TempPoint2 = null
    set TempGroup = null
    set TempGroup2 = null
endfunction

//===========================================================================
function InitTrig_Blink_Strike takes nothing returns nothing
    set gg_trg_Blink_Strike = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Blink_Strike, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Blink_Strike, Condition( function Trig_Blink_Strike_Conditions ) )
    call TriggerAddAction( gg_trg_Blink_Strike, function Trig_Blink_Strike_Actions )
endfunction

And now theres 49 compiled errors!

Also theres so many functions, thats laggy, anyway I can improve?
 

Sim

Forum Administrator
Staff member
Reaction score
534
49 ?!! ouch !

Well what you could do first is removing Useless function calls and setting the condition directly in the action, and hum..

Why do you have "set local..."

It is

"local unit blablabla..."

Remove the set.

Also, you should improve your loops and stop using bj_integerA. Use your own local integer variable.
 
D

dArKzEr0

Guest
All locals must be defined at the start of your function, "TempPoint2" isn't defined. Also, once a local is defined, you don't need to call it "local" anymore, and you don't need to specify what type of variable it is.

e.g.
Code:
function ShowMrApplesHowVariablesWork takes nothing returns string
    local string myText
    set myText = "This is how you set already initialized variables"
    return myText
endfunction

There's also a bunch of other mistakes. I was going to rewrite it for you to show you how it's properly done (this is wayyy easier than your setup corner/teams trigger) but I didn't know what to initialize TempPoint2 to.

-darkz
 

SFilip

Gone but not forgotten
Reaction score
633
or, well you can also define them
Code:
    local string myText
    set myText = "This is how you set already initialized variables"
this way
Code:
    local string myText = "This is how you set already initialized variables"

and btw you dont need these
Code:
        Custom script:   set udg_TempPoint = null
        Custom script:   set udg_TempPoint2 = null
        Custom script:   set udg_TempGroup = null
        Custom script:   set udg_TempGroup2 = null
they are already destroyed aren't they? you only need to set local variables to null in order to prevent leaks, not globals.
 

emjlr3

Change can be a good thing
Reaction score
395
to create locals

its just

local unit blah

locals are local for that function only, you can not move them around the other functions liek you tried to do

then when u want to update locals, its just

set blah = blah

try re reading some tuts., you seem to be getting the very basics wrong
 

MrApples

Ultra Cool Member
Reaction score
78
Oh, I thought you created and set at the same time....

Locals are better then using globals right?

Whats this?
Code:
    return myText
Never seen it before...

>Well what you could do first is removing Useless function calls and setting the condition directly in the action, and hum..

I have no idea what you mean...


Update: It now looks like this
Code:
function Trig_Blink_Strike_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A085' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Blink_Strike_Func010Func002002003001001 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Blink_Strike_Func010Func002002003001002 takes nothing returns boolean
    return ( IsUnitInGroup(GetFilterUnit(), TempGroup2) == false )
endfunction

function Trig_Blink_Strike_Func010Func002002003001 takes nothing returns boolean
    return GetBooleanAnd( Trig_Blink_Strike_Func010Func002002003001001(), Trig_Blink_Strike_Func010Func002002003001002() )
endfunction

function Trig_Blink_Strike_Func010Func002002003002 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(CastingUnit)) == true )
endfunction

function Trig_Blink_Strike_Func010Func002002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Blink_Strike_Func010Func002002003001(), Trig_Blink_Strike_Func010Func002002003002() )
endfunction

function Trig_Blink_Strike_Func010Func005C takes nothing returns boolean
    if ( not ( BlinkStrikeTarget == null ) ) then
        return false
    endif
    return true
endfunction

function Trig_Blink_Strike_Actions takes nothing returns nothing
    local unit CastingUnit
    local unit BlinkStrikeTarget
    local point TempPoint
    local point TempPoint2
    local group TempGroup
    local group TempGroup2
    set CastingUnit = GetSpellAbilityUnit()
    set TempPoint = GetUnitLoc(GetSpellTargetUnit())
    set BlinkStrikeTarget = GetSpellTargetUnit()
    call SetUnitPositionLoc( CastingUnit, TempPoint2 )
    call SetUnitFacingToFaceUnitTimed( CastingUnit, BlinkStrikeTarget, 0 )
    call SetUnitAnimation( CastingUnit, "attack" )
    call UnitDamageTargetBJ( CastingUnit, BlinkStrikeTarget, ( 175.00 + ( 150.00 * ( I2R(GetUnitAbilityLevelSwapped('A085', CastingUnit)) - 1 ) ) ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
    call RemoveLocation(TempPoint)
    set BlinkStrikeTarget = null
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = ( GetUnitAbilityLevelSwapped('A085', GetSpellAbilityUnit()) * 2 )
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set TempPoint = GetUnitLoc(CastingUnit)
        set TempGroup = GetUnitsInRangeOfLocMatching(512, TempPoint, Condition(function Trig_Blink_Strike_Func010Func002002003))
        set BlinkStrikeTarget = GroupPickRandomUnit(TempGroup)
        set TempPoint2 = GetUnitLoc(BlinkStrikeTarget)
        if ( Trig_Blink_Strike_Func010Func005C() ) then
            exitwhen true
        else
            call AddLightningLoc( "LEAS", TempPoint, TempPoint2 )
            call SetUnitPositionLoc( CastingUnit, TempPoint2 )
            call SetUnitFacingToFaceUnitTimed( CastingUnit, BlinkStrikeTarget, 0 )
            call SetUnitAnimation( CastingUnit, "attack" )
            call UnitDamageTargetBJ( CastingUnit, BlinkStrikeTarget, ( 150.00 + ( 200.00 * ( I2R(GetUnitAbilityLevelSwapped('A085', CastingUnit)) - 1 ) ) ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
            call PolledWait( 0.25 )
            call DestroyLightningBJ( GetLastCreatedLightningBJ() )
            call GroupAddUnitSimple( BlinkStrikeTarget, TempGroup2 )
            set BlinkStrikeTarget = null
        endif
        call RemoveLocation(TempPoint)
        call RemoveLocation(TempPoint2)
        call DestroyGroup(TempGroup)
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call DestroyGroup(udg_TempGroup2)
    set TempPoint = null
    set TempPoint2 = null
    set TempGroup = null
    set TempGroup2 = null
endfunction

//===========================================================================
function InitTrig_Blink_Strike takes nothing returns nothing
    set gg_trg_Blink_Strike = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Blink_Strike, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Blink_Strike, Condition( function Trig_Blink_Strike_Conditions ) )
    call TriggerAddAction( gg_trg_Blink_Strike, function Trig_Blink_Strike_Actions )
endfunction
But theres 54 compiled errors now...

I should null locals before setting them again right? Do they need to be destroyed?
 
D

Dino.pl

Guest
> Whats this? [return myText] Never seen it before...
Your function can return something to the calling function, for example:
Code:
function oneMore takes integer i returns integer
    return i + 1
endfunction

function someFunction takes nothing returns nothing
    local integer int = oneMore(5) //now int==6
endfunction
> > Well what you could do first is removing Useless function calls and setting the condition directly in the action, and hum..
> I have no idea what you mean...
For example, you can replace this
Code:
if ( Trig_Blink_Strike_Func010Func005C() ) then
with this
Code:
if (BlinkStrikeTarget == null) then
and remove function Trig_Blink_Strike_Func010Func005C

> I should null locals before setting them again right?
No.
You don't need to nullify them before every use.
Just nullify them at the end of your function.

> Do they need to be destroyed?
It depends...
Everything about memory leaks and what you need to destroy is in the tutorials.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Ok, I just stuck it into JassCraft, and it says there are 7 things wrong with it...

First, there is no such thing as a point in Jass. They are called locations, so change the variable types from point to location. (First 2 things wrong with it).

Second, when you try to destroy the TempGroup2, you use an udg_ before it. You changed the name of the variable to just TempGroup2, so you don't need it anymore. (Third thing wrong with it).

Then next things wrong with it are a little more complex... local variables can only be used in one function. Unless you call the other functions, with the unit.

For example when a function "takes" something, that means you have to call that function with a variable of that type.

EX:
Code:
function something takes [B]real[/B] MyRealsName returns nothing
    set MyRealsName = 2.25
endfunction

that means you can not just do this:

call something()

Instead you have to do this:

call something(ThisIsMyLocalReal)

Otherwise there is no real for the function to use.

This is what is wrong with the rest of your trigger.
Code:
function Trig_Blink_Strike_Func010Func002002003001002 takes nothing returns boolean
    return ( IsUnitInGroup(GetFilterUnit(), TempGroup2) == false )
endfunction

This one is the first thing wrong with it.

That means that you need to change this function so it takes a group.

So it will be like this instead:

function Trig_Blink_Strike_Func010Func002002003001002 takes group TempGroup2 returns boolean

Also, you will have to find all of the times that this function is called, and inside the (), you will have to put a group so that the function can use it. Your function/condition is used inside ANOTHER condition, so you will have to do the same thing with that function, until you get to the actions, in which case you change it, so that it gives the functions/conditions the correct local group.

This is why I usually won't start out with GUI if I am going to have to make something MUI. :eek:
 

Sim

Forum Administrator
Staff member
Reaction score
534
Darthfett said:
This is why I usually won't start out with GUI if I am going to have to make something MUI.

This is why I will actually learn JASS better :)

It looks so complicated and gay but is in reality sooo better than GUI!

But still for short & fast & Easy triggers sometimes using GUI doesn't hurt.

EDIT: The reason why you got 54 compile errors is because every time you use your "point" variables (which are locations) it adds one error to the list. Since you have two point variables and you use them often, it adds up fast ! :D
 

MrApples

Ultra Cool Member
Reaction score
78
Ok how am I to put all those functions into the action, i don't know how (and) matching conditions are setup.

WHy doesn't the game automatically just put it in the action...
 

MrApples

Ultra Cool Member
Reaction score
78
I changed it over to location, and now theres 55 compiled.....
Code:
function Trig_Blink_Strike_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A085' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Blink_Strike_Func010Func002002003001001 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Blink_Strike_Func010Func002002003001002 takes nothing returns boolean
    return ( IsUnitInGroup(GetFilterUnit(), TempGroup2) == false )
endfunction

function Trig_Blink_Strike_Func010Func002002003001 takes nothing returns boolean
    return GetBooleanAnd( Trig_Blink_Strike_Func010Func002002003001001(), Trig_Blink_Strike_Func010Func002002003001002() )
endfunction

function Trig_Blink_Strike_Func010Func002002003002 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(CastingUnit)) == true )
endfunction

function Trig_Blink_Strike_Func010Func002002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Blink_Strike_Func010Func002002003001(), Trig_Blink_Strike_Func010Func002002003002() )
endfunction

function Trig_Blink_Strike_Actions takes nothing returns nothing
    local unit CastingUnit
    local unit BlinkStrikeTarget
    local location TempPoint
    local location TempPoint2
    local group TempGroup
    local group TempGroup2
    set CastingUnit = GetSpellAbilityUnit()
    set TempPoint = GetUnitLoc(GetSpellTargetUnit())
    set BlinkStrikeTarget = GetSpellTargetUnit()
    call SetUnitPositionLoc( CastingUnit, TempPoint2 )
    call SetUnitFacingToFaceUnitTimed( CastingUnit, BlinkStrikeTarget, 0 )
    call SetUnitAnimation( CastingUnit, "attack" )
    call UnitDamageTargetBJ( CastingUnit, BlinkStrikeTarget, ( 175.00 + ( 150.00 * ( I2R(GetUnitAbilityLevelSwapped('A085', CastingUnit)) - 1 ) ) ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
    call RemoveLocation(TempPoint)
    set BlinkStrikeTarget = null
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = ( GetUnitAbilityLevelSwapped('A085', GetSpellAbilityUnit()) * 2 )
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set TempPoint = GetUnitLoc(BlinkStrikeTarget)
        set TempGroup = GetUnitsInRangeOfLocMatching(512, TempPoint, Condition(function Trig_Blink_Strike_Func010Func002002003))
        set BlinkStrikeTarget = GroupPickRandomUnit(TempGroup)
        set TempPoint2 = GetUnitLoc(BlinkStriketarget)
        if ( BlinkStrikeTarget == null ) then
            exitwhen true
        else
            call AddLightningLoc( "LEAS", TempPoint, TempPoint2 )
            call SetUnitPositionLoc( CastingUnit, TempPoint2 )
            call SetUnitFacingToFaceUnitTimed( CastingUnit, BlinkStrikeTarget, 0 )
            call SetUnitAnimation( CastingUnit, "attack" )
            call UnitDamageTargetBJ( CastingUnit, BlinkStrikeTarget, ( 150.00 + ( 200.00 * ( I2R(GetUnitAbilityLevelSwapped('A085', CastingUnit)) - 1 ) ) ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
            call PolledWait( 0.25 )
            call DestroyLightningBJ( GetLastCreatedLightningBJ() )
            call GroupAddUnitSimple( BlinkStrikeTarget, TempGroup2 )
            set BlinkStrikeTarget = null
        endif
        call RemoveLocation(TempPoint)
        call RemoveLocation(TempPoint2)
        call DestroyGroup(TempGroup)
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call DestroyGroup(udg_TempGroup2)
    set TempPoint = null
    set TempPoint2 = null
    set TempGroup = null
    set TempGroup2 = null
endfunction

//===========================================================================
function InitTrig_Blink_Strike takes nothing returns nothing
    set gg_trg_Blink_Strike = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Blink_Strike, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Blink_Strike, Condition( function Trig_Blink_Strike_Conditions ) )
    call TriggerAddAction( gg_trg_Blink_Strike, function Trig_Blink_Strike_Actions )
endfunction

How can I put the function's conditions into the action, how is the AND condition setup.
 

MrApples

Ultra Cool Member
Reaction score
78
Welll now its been 2 days since last reply.

I just need to know how to remove the rest of the functions, they are AND conditions 'This Condition and This Condition And This condition' and I don't know how to write 'and' conditions in jass.

I understand the whole takes variabletype variable part but I want to avoid the functions all-together


Also, what would be put for this function?
Code:
function Trig_Blink_Strike2_Func009Func002002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Blink_Strike2_Func009Func002002003001(), Trig_Blink_Strike2_Func009Func002002003002() )
endfunction

Since its like a reroute to the other functions.

EDIT: After redoing the convert and putting the takes Variable thing I have 104 compiled errors.
Code:
function Trig_Blink_Strike2_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A085' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Blink_Strike2_Func009Func002002003001001 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Blink_Strike2_Func009Func002002003001002 takes group TempGroup2 returns boolean
    return ( IsUnitInGroup(GetFilterUnit(), TempGroup2) == false )
endfunction

function Trig_Blink_Strike2_Func009Func002002003001 takes nothing returns boolean
    return GetBooleanAnd( Trig_Blink_Strike2_Func009Func002002003001001(), Trig_Blink_Strike2_Func009Func002002003001002() )
endfunction

function Trig_Blink_Strike2_Func009Func002002003002 takes unit CastingUnit returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(CastingUnit)) == true )
endfunction

function Trig_Blink_Strike2_Func009Func002002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Blink_Strike2_Func009Func002002003001(), Trig_Blink_Strike2_Func009Func002002003002() )
endfunction

function Trig_Blink_Strike2_Actions takes nothing returns nothing
    local unit CastingUnit
    local unit BlinkStrikeTarget
    local location TempPoint
    local location TempPoint2
    local group TempGroup
    local group TempGroup2
    set CastingUnit = GetSpellAbilityUnit()
    set TempPoint = GetUnitLoc(GetSpellTargetUnit())
    set BlinkStrikeTarget = GetSpellTargetUnit()
    call SetUnitPositionLoc( CastingUnit, TempPoint2 )
    call SetUnitFacingToFaceUnitTimed( udg_CastingUnit, udg_BlinkStrikeTarget, 0 )
    call SetUnitAnimation( CastingUnit, "attack" )
    call UnitDamageTargetBJ( CastingUnit, BlinkStrikeTarget, ( 175.00 + ( 150.00 * ( I2R(GetUnitAbilityLevelSwapped('A085', CastingUnit)) - 1 ) ) ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
    call RemoveLocation(TempPoint)
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = ( GetUnitAbilityLevelSwapped('A085', GetSpellAbilityUnit()) * 2 )
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set TempPoint = GetUnitLoc(udg_BlinkStrikeTarget)
        set TempGroup = GetUnitsInRangeOfLocMatching(512, udg_TempPoint, Condition(function Trig_Blink_Strike2_Func009Func002002003))
        set BlinkStrikeTarget = GroupPickRandomUnit(TempGroup)
        set TempPoint2 = GetUnitLoc(BlinkStrikeTarget)
        if ( BlinkStrikeTarget == null ) then
            exitwhen true
        else
            call AddLightningLoc( "LEAS", TempPoint, TempPoint2 )
            call SetUnitPositionLoc( CastingUnit, TempPoint2 )
            call SetUnitFacingToFaceUnitTimed( CastingUnit, BlinkStrikeTarget, 0 )
            call SetUnitAnimation( udg_CastingUnit, "attack" )
            call UnitDamageTargetBJ( CastingUnit, BlinkStrikeTarget, ( 150.00 + ( 200.00 * ( I2R(GetUnitAbilityLevelSwapped('A085', CastingUnit)) - 1 ) ) ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
            call PolledWait( 0.25 )
            call DestroyLightningBJ( GetLastCreatedLightningBJ() )
            call GroupAddUnitSimple( BlinkStrikeTarget, TempGroup2 )
            set udg_BlinkStrikeTarget = null
        endif
        call RemoveLocation(TempPoint)
        call RemoveLocation(TempPoint2)
        call DestroyGroup(TempGroup)
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call DestroyGroup(TempGroup2)
    set TempPoint = null
    set TempPoint2 = null
    set TempGroup = null
    set TempGroup2 = null
endfunction

//===========================================================================
function InitTrig_Blink_Strike2 takes nothing returns nothing
    set gg_trg_Blink_Strike2 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Blink_Strike2, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Blink_Strike2, Condition( function Trig_Blink_Strike2_Conditions ) )
    call TriggerAddAction( gg_trg_Blink_Strike2, function Trig_Blink_Strike2_Actions )
endfunction
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
OK, I just put your new ones back in. It seems you just forgot to remove some of the udg_ from the variables, and one other thing. (They are not globals anymore, they're locals, so you don't need it anymore).

Line 39
call SetUnitFacingToFaceUnitTimed( udg_CastingUnit, udg_BlinkStrikeTarget, 0 )

Line 48
set TempGroup = GetUnitsInRangeOfLocMatching(512, udg_TempPoint, Condition(function Trig_Blink_Strike2_Func009Func002002003))

And the other errors were that in this function:
Code:
function Trig_Blink_Strike2_Func009Func002002003001 takes nothing returns boolean
    return GetBooleanAnd( Trig_Blink_Strike2_Func009Func002002003001001(), [B]Trig_Blink_Strike2_Func009Func002002003001002()[/B] )
endfunction

When you call the 2 functions, you don't put in the group from the second function. It takes a group, so you need this condition to take a group, so that it can give it to the OTHER condition.
 

MrApples

Ultra Cool Member
Reaction score
78
I removed the udgs, this time using Find, now theres only 48 compiled errors.

Also I don't want to use the functions, I want to put them directly into the trigger, but I don't know how to set up "Condition AND Condition". Could you explain how to do this and how come the code doesn't put the functions automatically into the actions if its so much slower?

Also that one functions needs to take both a unit variable and a group variable, how would I do that even so.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
>>Also I don't want to use the functions, I want to put them directly into the trigger, but I don't know how to set up "Condition AND Condition".

Well I don't think you can put them directly in the trigger (I've never dealt with the Condition(code func) before. I think you HAVE to use a seperate function. But I do know that instead of it calling the Function that checks to see if both functions are true, that you can combine the two functions into one, using a simple And.

>>and how come the code doesn't put the functions automatically into the actions if its so much slower?

It's GUI, GUI == Stupid. :p

>>Also that one functions needs to take both a unit variable and a group variable, how would I do that even so.

Instead of
Code:
function something takes group MYGROUP returns nothing
endfunction

it would be
Code:
function something takes group MYGROUP, unit MYUNIT returns nothing
endfunction

Also, I couldn't help but notice another stupid thing the GUI did.

Code:
function Trig_Blink_Strike_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A085' ) ) then
        return false
    endif
    return true
endfunction

can be this:

Code:
function Trig_Blink_Strike_Conditions takes nothing returns boolean
    if (GetSpellAbilityId() == 'A085' ) then
        return true
    else
        return false
    endif
endfunction
 

corvusHaunt

New Member
Reaction score
96
Darthfett said:
Also, I couldn't help but notice another stupid thing the GUI did.

Code:
function Trig_Blink_Strike_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A085' ) ) then
        return false
    endif
    return true
endfunction

can be this:

Code:
function Trig_Blink_Strike_Conditions takes nothing returns boolean
    if (GetSpellAbilityId() == 'A085' ) then
        return true
    else
        return false
    endif
endfunction
What's wrong with what the GUI did?
 
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