• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Condition question

Status
Not open for further replies.
Level 7
Joined
Nov 15, 2009
Messages
225
Hey!
I wanted to start converting an old jass passive code into a better code.
Removing BJ's, removing condition triggers and so on.

But some of them always give me error messages if I try to make it better.

For example this code:
JASS:
set g1 = GetUnitsOfPlayerMatching(GetOwningPlayer(u), Condition(function Trig_14))

function Trig_12 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'n00D' )
endfunction

function Trig_13 takes nothing returns boolean
    return ( GetUnitUserData(GetFilterUnit()) < 10 )
endfunction

function Trig_14 takes nothing returns boolean
    return GetBooleanAnd( Trig_12(), Trig_13() )
endfunction
How to remove the condition triggers and add the conditions as text?
For example:
JASS:
set g1 = GetUnitsOfPlayerMatching(GetOwningPlayer(u), GetUnitTypeId(GetFilterUnit()) == 'n00D' and ( GetUnitUserData(GetFilterUnit()) < 10 ))

JASS:
function Trig_1 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'n00D' )
endfunction

function Trig_2 takes nothing returns boolean
    return ( GetUnitUserData(GetFilterUnit()) < 10 )
endfunction

function Trig_3 takes nothing returns boolean
    return GetBooleanAnd( Trig_1(), Trig_2() )
endfunction

function Trig_4 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'n00E' )
endfunction

function Trig_5 takes nothing returns boolean
    return ( GetUnitUserData(GetFilterUnit()) < 20 )
endfunction

function Trig_6 takes nothing returns boolean
    return GetBooleanAnd( Trig_4(), Trig_5() )
endfunction

function Trig_7 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'n00C' )
endfunction

function Trig_8 takes nothing returns boolean
    return ( GetUnitUserData(GetFilterUnit()) < 30 )
endfunction

function Trig_9 takes nothing returns boolean
    return GetBooleanAnd( Trig_7(), Trig_8() )
endfunction

function Trig_12 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'n00D' )
endfunction

function Trig_13 takes nothing returns boolean
    return ( GetUnitUserData(GetFilterUnit()) < 10 )
endfunction

function Trig_14 takes nothing returns boolean
    return GetBooleanAnd( Trig_12(), Trig_13() )
endfunction

function Trig_15 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'n00E' )
endfunction

function Trig_16 takes nothing returns boolean
    return ( GetUnitUserData(GetFilterUnit()) < 20 )
endfunction

function Trig_17 takes nothing returns boolean
    return GetBooleanAnd( Trig_15(), Trig_16() )
endfunction

function Trig_20 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'n00D' )
endfunction

function Trig_21 takes nothing returns boolean
    return ( GetUnitUserData(GetFilterUnit()) < 10 )
endfunction

function Trig_22 takes nothing returns boolean
    return GetBooleanAnd( Trig_20(), Trig_21() )
endfunction


function Trig_27 takes nothing returns nothing
    if ( udg_RuneLureLoopAllow == true ) then
        set udg_RuneLureLoopAllow = false
        call SetUnitUserData( GetEnumUnit(), ( GetUnitUserData(GetEnumUnit()) + 1 ) )
        call SetUnitAbilityLevelSwapped( 'A00F', GetEnumUnit(), ( GetUnitUserData(GetEnumUnit()) + 1 ) )
        if ( GetUnitTypeId(GetEnumUnit()) == 'n00D' ) then
            call SetUnitAbilityLevelSwapped( 'A00I', GetEnumUnit(), ( GetUnitUserData(GetEnumUnit()) + 1 ) )
        else
            if ( GetUnitTypeId(GetEnumUnit()) == 'n00E' ) then
                call SetUnitAbilityLevelSwapped( 'A00G', GetEnumUnit(), ( GetUnitUserData(GetEnumUnit()) + 1 ) )
            else
                call SetUnitAbilityLevelSwapped( 'A00H', GetEnumUnit(), ( GetUnitUserData(GetEnumUnit()) + 1 ) )
            endif
        endif
    else
    endif
endfunction

function Trig_Misc_RuneLureAbility_Actions takes nothing returns nothing
    local unit u = GetKillingUnit()
    local group g1 = CreateGroup()
    local group g2 = CreateGroup()
    local group g3 = CreateGroup()
    local group g4 = CreateGroup()
    set udg_RuneLureLoopAllow = true
    if ( GetUnitTypeId(u) == 'n00D' ) then
        if ( GetUnitUserData(u) < 10 ) then
            call SetUnitUserData( u, ( GetUnitUserData(u) + 1 ) )
            call SetUnitAbilityLevelSwapped( 'A00F', u, ( GetUnitUserData(u) + 1 ) )
            call SetUnitAbilityLevelSwapped( 'A00I', u, ( GetUnitUserData(u) + 1 ) )
        else
            set g1 = GetUnitsOfPlayerMatching(GetOwningPlayer(u), Condition(function Trig_22))
        endif
    else
        if ( GetUnitTypeId(u) == 'n00E' ) then
            if ( GetUnitUserData(u) < 20 ) then
                call SetUnitUserData( u, ( GetUnitUserData(u) + 1 ) )
                call SetUnitAbilityLevelSwapped( 'A00F', u, ( GetUnitUserData(u) + 1 ) )
                call SetUnitAbilityLevelSwapped( 'A00G', u, ( GetUnitUserData(u) + 1 ) )
            else
                set g1 = GetUnitsOfPlayerMatching(GetOwningPlayer(u), Condition(function Trig_14))
                set g2 = GetUnitsOfPlayerMatching(GetOwningPlayer(u), Condition(function Trig_17))
                call GroupAddGroup( g2, g1 )
            endif
        else
            if ( GetUnitTypeId(u) == 'n00C' ) then
                if ( GetUnitUserData(u) < 30 ) then
                    call SetUnitUserData( u, ( GetUnitUserData(u) + 1 ) )
                    call SetUnitAbilityLevelSwapped( 'A00F', u, ( GetUnitUserData(u) + 1 ) )
                    call SetUnitAbilityLevelSwapped( 'A00H', u, ( GetUnitUserData(u) + 1 ) )
                else
                    set g1 = GetUnitsOfPlayerMatching(GetOwningPlayer(u), Condition(function Trig_3))
                    set g2 = GetUnitsOfPlayerMatching(GetOwningPlayer(u), Condition(function Trig_6))
                    set g3 = GetUnitsOfPlayerMatching(GetOwningPlayer(u), Condition(function Trig_9))
                    call GroupAddGroup( g2, g1 )
                    call GroupAddGroup( g3, g1 )
                endif
            else
            endif
        endif
    endif
    call ForGroupBJ( g1, function Trig_27 )
    call DestroyGroup( g1 )
    call DestroyGroup( g2 )
    call DestroyGroup( g3 )
    call DestroyGroup( g4 )
    set g1 = null
    set g2 = null
    set g3 = null
    set g4 = null
    set u = null
endfunction

function InitTrig_Misc_RuneLureAbility takes nothing returns nothing
    set gg_trg_Misc_RuneLureAbility = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Misc_RuneLureAbility, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Misc_RuneLureAbility, function Trig_Misc_RuneLureAbility_Actions )
endfunction


Everytime the Rune Lure kills a unit the rune charges some of the energy of the unit inside.
If the Rune Lure reaches max. Damage, Rune Lures with the same or with lower level get the damage increasion!
The damage will be increased by 2.


Thank you for your time!
 
Status
Not open for further replies.
Top