• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

MUI Jass Help!

Status
Not open for further replies.
Level 20
Joined
May 16, 2012
Messages
635
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 20
Joined
May 16, 2012
Messages
635
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