• 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.

MUI Jass Help!

Status
Not open for further replies.
Level 21
Joined
May 16, 2012
Messages
644
I'm trying to move from GUI to Jass, because lets be honest, GUI is easy and all, but it ties my hands, especially when i'm trying to make things MUI, and i started taking old GUI triggers that I've made and turned them into Jass, but instead of using Global variables i switch to local ones, so the whole thing becomes MUI (Right?). I've read some tutorials here on hive on how to do this and just want to be sure that its correct.

It's a realy simple code, it checks if the attacked unit have a specific item and do its think. So is it MUI? If not, Why, and what need to be changed to become MUI.

JASS:
function Lucky_Shield_Conditions takes nothing returns boolean
    if ( not ( UnitHasItemOfTypeBJ(GetAttackedUnitBJ(), 'I04M') == true ) ) then
        return false
    endif
    return true
endfunction

function Lucky_Shield_Chance takes nothing returns boolean
    if ( not ( GetRandomInt(1, 100) <= 10 ) ) then
        return false
    endif
    return true
endfunction

function Lucky_Shield_Actions takes nothing returns nothing
local unit u

    if ( Lucky_Shield_Chance() ) then
        set u = GetAttackedUnitBJ()
        call DestroyEffectBJ(AddSpecialEffectTargetUnitBJ( "chest", u, "war3mapImported\\WarpHolyCaster.mdx" ))
        call SetUnitLifePercentBJ( u, ( GetUnitLifePercent(u) + 10.00 ) )
    endif
set u = null
endfunction

//===========================================================================
function InitTrig_LS_1_JASS_TEST takes nothing returns nothing
    local trigger t
    set t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( t, Condition( function Lucky_Shield_Conditions ) )
    call TriggerAddAction( t, function Lucky_Shield_Actions )
endfunction

And why i need to put InitTrig_... before every trigger name? There's any way to make my trigger work without it, because recently I've had an error where, when saving my game the jasshelper gave me this weird error of "Memory Exhausted", and i think its related to the amount of triggers in my map.
 
Last edited:
Level 8
Joined
Jan 28, 2016
Messages
486
What you got there is MUI. There's this recent thread that explains the need for the "InitTrig_" prefix. This isn't exactly related to your MUI question but if you want to post your Jass code with highlighted text, just wrap it in [code=jass][/code] tags like so:

JASS:
function Lucky_Shield_Conditions takes nothing returns boolean
    if ( not ( UnitHasItemOfTypeBJ(GetAttackedUnitBJ(), 'I04M') == true ) ) then
        return false
    endif
    return true
endfunction

function Lucky_Shield_Chance takes nothing returns boolean
    if ( not ( GetRandomInt(1, 100) <= 10 ) ) then
        return false
    endif
    return true
endfunction

function Lucky_Shield_Actions takes nothing returns nothing
    local unit u
    if ( Lucky_Shield_Chance() ) then
        set u = GetAttackedUnitBJ()
        call DestroyEffectBJ(AddSpecialEffectTargetUnitBJ( "chest", u, "war3mapImported\\WarpHolyCaster.mdx" ))
        call SetUnitLifePercentBJ( u, ( GetUnitLifePercent(u) + 10.00 ) )
    endif
    set u = null
endfunction

//===========================================================================
function InitTrig_LS_1_JASS_TEST takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( t, Condition( function Lucky_Shield_Conditions ) )
    call TriggerAddAction( t, function Lucky_Shield_Actions )
    set t = null
endfunction
 
Level 21
Joined
May 16, 2012
Messages
644
What you got there is MUI. There's this recent thread that explains the need for the "InitTrig_" prefix. This isn't exactly related to your MUI question but if you want to post your Jass code with highlighted text, just wrap it in [code=jass][/code] tags like so:

JASS:
function Lucky_Shield_Conditions takes nothing returns boolean
    if ( not ( UnitHasItemOfTypeBJ(GetAttackedUnitBJ(), 'I04M') == true ) ) then
        return false
    endif
    return true
endfunction

function Lucky_Shield_Chance takes nothing returns boolean
    if ( not ( GetRandomInt(1, 100) <= 10 ) ) then
        return false
    endif
    return true
endfunction

function Lucky_Shield_Actions takes nothing returns nothing
    local unit u
    if ( Lucky_Shield_Chance() ) then
        set u = GetAttackedUnitBJ()
        call DestroyEffectBJ(AddSpecialEffectTargetUnitBJ( "chest", u, "war3mapImported\\WarpHolyCaster.mdx" ))
        call SetUnitLifePercentBJ( u, ( GetUnitLifePercent(u) + 10.00 ) )
    endif
    set u = null
endfunction

//===========================================================================
function InitTrig_LS_1_JASS_TEST takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( t, Condition( function Lucky_Shield_Conditions ) )
    call TriggerAddAction( t, function Lucky_Shield_Actions )
    set t = null
endfunction

Oh, thx a lot man!
 
Status
Not open for further replies.
Top