Fixing up a Jass trigger.

Reaction score
149
Long time no see.

And here I return to world editor again, hoping for something to work as it is supposed to.

Yet, very first trigger that cannot be done in GUI seems to throw up more errors than I could ever imagine.

So here it goes again, ugly looking, non-optimizied triggers that vere freshly converted to JASS.

Anyone could explain me what's so wrong about it all?

JASS:

    local integer A

function Trig_SettingUp_Copy_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_SettingUp_Copy_Func010Func001C takes nothing returns boolean
    if ( not ( udg_Hero_AbilityType1[A] == 'A008' ) ) then
        return false
    endif
    if ( not ( GetUnitAbilityLevelSwapped(udg_Hero_Abilities[GetForLoopIndexA()], udg_tempHero) > 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_SettingUp_Copy_Actions takes nothing returns nothing
    set udg_tempHero = GetTriggerUnit()
    set A = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
    set udg_tempPlayerA[A] = GetOwningPlayer(udg_tempHero)
    set udg_checkHero[A] = true
    set udg_Hero[A] = udg_tempHero
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = udg_SaveLoad_Abilities_LastIndex
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if ( Trig_SettingUp_Copy_Func010Func001C() ) then
            set udg_Hero_AbilityType1[A] = udg_Hero_Abilities[GetForLoopIndexA()]
            set udg_Hero_AbilityLevel_I[A] = GetUnitAbilityLevelSwapped(udg_Hero_AbilityType1[A], udg_tempHero)
            call MultiboardDisplayBJ( false, udg_SkillBoard[A] )
            call MultiboardSetItemValueBJ( udg_SkillBoard[A], 2, 1, ( GetAbilityName(udg_Hero_AbilityType1[A]) + ":" ) )
            call MultiboardSetItemValueBJ( udg_SkillBoard[A], 3, 1, ( ( I2S(udg_Hero_AbilityExpierence_I[A]) + " / " ) + I2S(( udg_Hero_AbilityLevel_I[A] * 16 )) ) )
            if GetLocalPlayer() == udg_tempPlayerA[A] then
            call MultiboardDisplayBJ( true, udg_SkillBoard[A] )
            endif
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_SettingUp_JASS takes nothing returns nothing
    set gg_trg_SettingUp_JASS = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_SettingUp_JASS, GetPlayableMapRect() )
    call TriggerAddCondition( gg_trg_SettingUp_JASS, Condition( function Trig_SettingUp_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_SettingUp_JASS, function Trig_SettingUp_Copy_Actions )
endfunction


JASS:
function Trig_Casting_JASS_Func005Func002C takes nothing returns boolean
    if ( not ( udg_Hero_AbilityExpierence_I[A] >= ( udg_Hero_AbilityLevel_I[A] * 16 ) ) ) then
        return false
    endif
    return true
endfunction

function Trig_Casting_JASS_Func005C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped(udg_Hero_AbilityType1[A], GetTriggerUnit()) < 100 ) ) then
        return false
    endif
    if ( not ( GetSpellAbilityId() == udg_Hero_AbilityType1[A] ) ) then
        return false
    endif
    return true
endfunction

function Trig_Casting_JASS_Actions takes nothing returns nothing
    local integer A
    set A = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
    set udg_tempPlayerA[A] = GetOwningPlayer(udg_tempHero)
    set A = GetConvertedPlayerId(udg_tempPlayerA[A])
    if ( Trig_Casting_JASS_Func005C() ) then
        set udg_Hero_AbilityExpierence_I[A] = ( udg_Hero_AbilityExpierence_I[A] + ( ( 1 + udg_Hero_AbilityBonus ) + ( udg_Hero_AbilityLevel_I[A] / 7 ) ) )
        if ( Trig_Casting_JASS_Func005Func002C() ) then
            set udg_Hero_AbilityExpierence_I[A] = ( udg_Hero_AbilityExpierence_I[A] - ( 16 * GetUnitAbilityLevelSwapped(udg_Hero_AbilityType1[A], GetTriggerUnit()) ) )
            call SetUnitAbilityLevelSwapped( udg_Hero_AbilityType1[A], GetTriggerUnit(), ( GetUnitAbilityLevelSwapped(udg_Hero_AbilityType1[A], GetTriggerUnit()) + 1 ) )
            set udg_Hero_AbilityLevel_I[A] = GetUnitAbilityLevelSwapped(udg_Hero_AbilityType1[A], udg_Hero[A])
        else
        endif
        call MultiboardSetItemValueBJ( udg_SkillBoard[A], 3, 1, ( ( I2S(udg_Hero_AbilityExpierence_I[A]) + " / " ) + I2S(( udg_Hero_AbilityLevel_I[A] * 16 )) ) )
        call MultiboardDisplayBJ( false, udg_SkillBoard[A] )
        if GetLocalPlayer() == udg_tempPlayerA[A] then
        call MultiboardDisplayBJ( true, udg_SkillBoard[A] )
        endif
    else
    endif
endfunction

//===========================================================================
function InitTrig_Casting_JASS takes nothing returns nothing
    set gg_trg_Casting_JASS = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Casting_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Casting_JASS, function Trig_Casting_JASS_Actions )
endfunction
 

Cohadar

master of fugue
Reaction score
209
You cannot learn jass by converting old GUI code.
Maybe learn some tutorials?
 
Reaction score
149
I do not need to learn JASS.

I need only this trigger to work, as it causes server split when used in GUI - Globals used as locals.

Maybe I'll do learn JASS one day, but currently, all I need are these two triggers.
 
Reaction score
149
Code:
SettingUp
    Events
        Unit - A unit enters (Playable map area)
    Conditions
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Custom script:   local integer A
        Set tempHero = (Triggering unit)
        Custom script:   set A = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
        Custom script:   set udg_tempPlayerA[A] = GetOwningPlayer(udg_tempHero)
        Custom script:   set udg_tempInt = GetConvertedPlayerId(udg_tempPlayerA[A])
        Set checkHero[tempInt] = True
        Set Hero[tempInt] = tempHero
        For each (Integer A) from 1 to SaveLoad_Abilities_LastIndex, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Hero_AbilityType1[tempInt] Equal to Unselected Ability 
                        (Level of Hero_Abilities[(Integer A)] for tempHero) Greater than 0
                    Then - Actions
                        Set Hero_AbilityType1[tempInt] = Hero_Abilities[(Integer A)]
                        Set Hero_AbilityLevel_I[tempInt] = (Level of Hero_AbilityType1[tempInt] for tempHero)
                        Multiboard - Hide SkillBoard[tempInt]
                        Multiboard - Set the text for SkillBoard[tempInt] item in column 2, row 1 to ((Name of Hero_AbilityType1[tempInt]) + :)
                        Multiboard - Set the text for SkillBoard[tempInt] item in column 3, row 1 to (((String(Hero_AbilityExpierence_I[tempInt])) +  / ) + (String((Hero_AbilityLevel_I[tempInt] x 16))))
                        Custom script:   if GetLocalPlayer() == udg_tempPlayerA[A] then
                        Multiboard - Show SkillBoard[tempInt]
                        Custom script:   endif
                    Else - Actions
Code:
Casting
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
    Actions
        Custom script:   local integer A
        Custom script:   set A = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
        Custom script:   set udg_tempPlayerA[A] = GetOwningPlayer(udg_tempHero)
        Custom script:   set udg_tempInt = GetConvertedPlayerId(udg_tempPlayerA[A])
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of Hero_AbilityType1[tempInt] for (Triggering unit)) Less than 100
                (Ability being cast) Equal to Hero_AbilityType1[tempInt]
            Then - Actions
                Set Hero_AbilityExpierence_I[tempInt] = (Hero_AbilityExpierence_I[tempInt] + ((1 + Hero_AbilityBonus) + (Hero_AbilityLevel_I[tempInt] / 7)))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Hero_AbilityExpierence_I[tempInt] Greater than or equal to (Hero_AbilityLevel_I[tempInt] x 16)
                    Then - Actions
                        Set Hero_AbilityExpierence_I[tempInt] = (Hero_AbilityExpierence_I[tempInt] - (16 x (Level of Hero_AbilityType1[tempInt] for (Triggering unit))))
                        Unit - Set level of Hero_AbilityType1[tempInt] for (Triggering unit) to ((Level of Hero_AbilityType1[tempInt] for (Triggering unit)) + 1)
                        Set Hero_AbilityLevel_I[tempInt] = (Level of Hero_AbilityType1[tempInt] for Hero[tempInt])
                    Else - Actions
                Multiboard - Set the text for SkillBoard[tempInt] item in column 3, row 1 to (((String(Hero_AbilityExpierence_I[tempInt])) +  / ) + (String((Hero_AbilityLevel_I[tempInt] x 16))))
                Multiboard - Hide SkillBoard[tempInt]
                Custom script:   if GetLocalPlayer() == udg_tempPlayerA[A] then
                Multiboard - Show SkillBoard[tempInt]
                Custom script:   endif
            Else - Actions
 
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