[JASS] Are theese triggers MUI?

Status
Not open for further replies.
Level 8
Joined
Dec 16, 2007
Messages
252
Are theese triggers MUI and Leakless?

JASS:
function Trig_Ion_Cannon_Channel_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A005'
endfunction

function Trig_Ion_Cannon_Channel_Actions takes nothing returns nothing
    local location p = GetUnitLoc(GetTriggerUnit())
    local location r = GetSpellTargetLoc()
    local unit u = GetTriggerUnit()
    local integer pui = GetUnitIndex(u)
    local location q = PolarProjectionBJ(p, 105.00, AngleBetweenPoints(p, r) )
    local unit dummy
    local integer i
    set dummy = CreateUnitAtLoc(GetOwningPlayer(u) , 'u000', q, AngleBetweenPoints(p, r) )
    call SetUnitLifeBJ( dummy, I2R(GetUnitAbilityLevelSwapped('A005', u) ))
    call SetUnitUserData( dummy, GetUnitUserData(u) )
    set udg_s_BlazeDummy[GetUnitUserData(dummy)] = dummy
    set i = 1
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 5
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set i = i + 1 
        call SetUnitScalePercent( dummy, ( 100.00 + ( 20.00 * I2R(GetForLoopIndexA()) ) ), ( 100.00 + ( 20.00 * I2R(GetForLoopIndexA()) ) ), ( 100.00 + ( 20.00 + I2R(GetForLoopIndexA()) ) ) )
        call TriggerSleepAction( 1 )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call RemoveLocation(p)
    call RemoveLocation(r)
    call RemoveLocation(q)   
    set dummy = null
    set u = null
    set i = 0
endfunction

//===========================================================================
function InitTrig_Ion_Cannon_Channel takes nothing returns nothing
    set gg_trg_Ion_Cannon_Channel = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Ion_Cannon_Channel, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Ion_Cannon_Channel, Condition( function Trig_Ion_Cannon_Channel_Conditions ) )
    call TriggerAddAction( gg_trg_Ion_Cannon_Channel, function Trig_Ion_Cannon_Channel_Actions )
endfunction

  • Ion Cannon Cast
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to Blaze
    • Actions
      • Set s_BlazeLoc[1] = (Position of s_BlazeDummy[(Custom value of (Triggering unit))])
      • Set s_BlazeLoc[2] = (s_BlazeLoc[1] offset by 100.00 towards (Facing of s_BlazeDummy[(Custom value of (Triggering unit))]) degrees)
      • Unit - Add Blaze Damage to s_BlazeDummy[(Custom value of (Triggering unit))]
      • Unit - Set level of Blaze Damage for s_BlazeDummy[(Custom value of (Triggering unit))] to (Integer((Life of s_BlazeDummy[(Custom value of (Triggering unit))])))
      • Unit - Order s_BlazeDummy[(Custom value of (Triggering unit))] to Orc Tauren Chieftain - Shockwave s_BlazeLoc[2]
      • Unit - Add a 0.10 second Generic expiration timer to s_BlazeDummy[(Custom value of (Triggering unit))]
      • Custom script: call RemoveLocation(udg_s_BlazeLoc[1])
      • Custom script: call RemoveLocation(udg_s_BlazeLoc[2])
 
Level 19
Joined
Nov 16, 2006
Messages
2,165
The script is MUI, however I don't know about the GUI.
In my opinion, everything variable used with GUI makes it not MUI (there is always a small chance that heroes cast a spell at the same time. Even if that chance is 1 or 5%, it is there).

Your script/triggers aren't leaking but you should work out the BJ's, like Teelo said use an integer for your loop and optimize your script.
For example:
JASS:
  local unit u = GetTriggerUnit()
  local location p = GetUnitLoc(u)

Also, you don't need to set i = 0 at the end.

p.s. I only watched fast over it.
 
Last edited:
Level 8
Joined
Aug 6, 2008
Messages
451
I dont get it.. Why people post converted GUI as Jass codes?

Anyways, you cant cast 2 spells at the same time. It is not possible.
So if there is no waits or timer usage in your code, you can use globals and it is still MUI.

Just remember that events interrupt stuff, example if we call testscope_Action:

JASS:
scope testscope initializer init
globals
    private unit TestUnit // This is just some unit
endglobals

public function Action takes nothing returns nothing
    // we damage target
    call UnitDamageTarget(TestUnit, TestUnit, 10., false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,null)
    // what happened?
    // test unit is null now, so this fails:
    call SetUnitX(TestUnit,0.0)
endfunction

private function DamageActions takes nothing returns boolean
    set TestUnit=null
    return false
endfunction

private function init takes nothing returns nothing
    local trigger t=CreateTrigger()
    set TestUnit = // ...
    call TriggerRegisterUnitEvent(t,TestUnit,EVENT_UNIT_DAMAGED)
    call TriggerAddCondition(t,Condition(function DamageActions))
endfunction
endscope
 
Level 6
Joined
Aug 19, 2006
Messages
187
Are theese triggers MUI and Leakless?

JASS:
function Trig_Ion_Cannon_Channel_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A005'
endfunction

function Trig_Ion_Cannon_Channel_Actions takes nothing returns nothing
    local location p = GetUnitLoc(GetTriggerUnit())
    local location r = GetSpellTargetLoc()
    local unit u = GetTriggerUnit()
    local integer pui = GetUnitIndex(u)
    local location q = PolarProjectionBJ(p, 105.00, AngleBetweenPoints(p, r) )
    local unit dummy = CreateUnitAtLoc(GetOwningPlayer(u) , 'u000', q, AngleBetweenPoints(p, r) )
    local integer i = 2
    call SetUnitLifeBJ( dummy, I2R(GetUnitAbilityLevelSwapped('A005', u) ))
    call SetUnitUserData( dummy, GetUnitUserData(u) )
    set udg_s_BlazeDummy[GetUnitUserData(dummy)] = dummy
    loop
        exitwhen i > 5
        call SetUnitScalePercent( dummy, ( 100.00 + ( 20.00 * I2R(i)) ) ), ( 100.00 + ( 20.00 * I2R(i)) ) ), ( 100.00 + ( 20.00 + I2R(i) ) ) )
        call TriggerSleepAction( 1 )
        set i = i + 1
    endloop
    call RemoveLocation(p)
    call RemoveLocation(r)
    call RemoveLocation(q)   
    set dummy = null
    set u = null
endfunction

//===========================================================================
function InitTrig_Ion_Cannon_Channel takes nothing returns nothing
    local integer i = 0
    set gg_trg_Ion_Cannon_Channel = CreateTrigger(  )
    loop
    exitwhen i == <number of possible players>
    call TriggerRegisterPlayerUnitEvent( gg_trg_Ion_Cannon_Channel, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null )
    set i = i+1
    endloop
    call TriggerAddCondition( gg_trg_Ion_Cannon_Channel, Condition( function Trig_Ion_Cannon_Channel_Conditions ) )
    call TriggerAddAction( gg_trg_Ion_Cannon_Channel, function Trig_Ion_Cannon_Channel_Actions )
endfunction
[...]

i added some example code improvements. new jess gen shows blizzard functions with red text and they can be replaced buy the "real function".
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Try to avoid using BJ's,, use a program as Jasscraft to look up those functions and you might see some BJ's that do nothing but switch the position of the Parameters, others might have a little more actions in it, but still you can better use no BJ's,, at least that is what they taught me,,
this is the function of SetUnitLifeBJ:
JASS:
function SetUnitLifeBJ takes unit whichUnit, real newValue returns nothing
    call SetUnitState(whichUnit, UNIT_STATE_LIFE, RMaxBJ(0,newValue))
endfunction
You can see that it only calls one function, and uses a function for 1 parameter, but that one is totaly unnecesary, because it will always return the parameter 'newValue' , only not if 'newValue == 0' then it will return the other 0, but 0 == 0 so whatever,,
I think you can better use SetUnitState, since it is a native, which are THA BEST to use, i think,,

EDIT: Example of a useless BJ function, one even without any Parameters:
JASS:
function GetClickedButtonBJ takes nothing returns button
    return GetClickedButton()
endfunction
You get what i mean right?
 
Status
Not open for further replies.
Top