How to MUI my spell

master maste

New Member
Reaction score
32
OK well I have this spell but its not MUI (actually got 8 spells based on the same thing (just different dummy units)

JASS:
function Trig_Ion_Shield_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Trig_Ion takes nothing returns nothing
    set udg_ShieldCasterLoc = GetUnitLoc(udg_ShieldCaster)
    call SetUnitPositionLoc(udg_Dummy[1], udg_ShieldCasterLoc)
endfunction

function Trig_Ion_Shield_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    set udg_ShieldCaster = GetSpellAbilityUnit()
    set udg_ShieldCasterLoc = GetUnitLoc(udg_ShieldCaster)

    call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "|cffffcc00YOU HAVE ENABLED ION SHIELD|r." )
    
    call RemoveUnit( GetLastCreatedUnit() )
    call CreateNUnitsAtLoc( 1, 'h001', GetTriggerPlayer(), udg_ShieldCasterLoc, GetUnitFacing(GetTriggerUnit()) )
    
    set udg_Dummy[1] = GetLastCreatedUnit()
    
    call TimerStart(t,0.03,true,function Trig_Ion)
endfunction


//===========================================================================
function InitTrig_Ion_Shield takes nothing returns nothing
    set gg_trg_Ion_Shield = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Ion_Shield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Ion_Shield, Condition( function Trig_Ion_Shield_Conditions ) )
    call TriggerAddAction( gg_trg_Ion_Shield, function Trig_Ion_Shield_Actions )
endfunction


I've been looking at this code for days but my JASS skills have gone downhill in the last couple of months, so if anyone here could help me I would greatly appreciate it.
 

Arkan

Nobody rides for free
Reaction score
92
Use local variables instead of global variables to achieve MUI.
You are however using a timer, and local variables need to be passed to that timer function, this can be done with gamecache or structs.
 

master maste

New Member
Reaction score
32
Is it completely necessary for me to import a system? Because it would be more beneficial if it were not.
 

SFilip

Gone but not forgotten
Reaction score
634
Yeah, you need some sort of attachment system to make local timer/local trigger based spells completely MUI.
However if you want to avoid that then you can probably just make it so that every player can cast one instance at time (as opposed to one unit being able to which is called MUI).
 

SFilip

Gone but not forgotten
Reaction score
634
If only one unit per player is going to use this spell then you can just have an array and put the player number of owner of triggering unit as the index.
 

Tom Jones

N/A
Reaction score
437
JASS:
//Create these variables
globals
    unit array udg_ShieldCaster
    unit array udg_ShieldDummies
endglobals

//Copy/Paste from here.
function Trig_Ion_Shield_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Trig_Ion takes nothing returns nothing
    local integer i = GetTriggerExecCount(GetTriggeringTrigger())
    local real x = GetUnitX(udg_ShieldCaster<i>)
    local real y = GetUnitY(udg_ShieldCaster<i>)

    call SetUnitPosition(udg_ShieldDummies<i>,x,y)
endfunction

function Trig_Ion_Shield_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local integer i = GetTriggerExecCount(GetTriggeringTrigger())
    set udg_ShieldCaster<i> = GetSpellAbilityUnit()

    call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), &quot;|cffffcc00YOU HAVE ENABLED ION SHIELD|r.&quot; )
    
    call RemoveUnit( GetLastCreatedUnit() )
    call CreateNUnitsAtLoc( 1, &#039;h001&#039;, GetTriggerPlayer(), udg_ShieldCasterLoc, GetUnitFacing(GetTriggerUnit()) )
    
    set udg_ShieldDummies<i> = GetLastCreatedUnit()
    
    call TimerStart(t,0.03,true,function Trig_Ion)
endfunction


//===========================================================================
function InitTrig_Ion_Shield takes nothing returns nothing
    set gg_trg_Ion_Shield = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Ion_Shield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Ion_Shield, Condition( function Trig_Ion_Shield_Conditions ) )
    call TriggerAddAction( gg_trg_Ion_Shield, function Trig_Ion_Shield_Actions )
endfunction</i></i></i></i></i>
 

master maste

New Member
Reaction score
32
Thanks for the help guys, I'll try what you guys said tomorrow as its midnight now. :)

and it is only being used by 1 unit for each player, so I might try that out as a backup.
 

master maste

New Member
Reaction score
32
I tried Tom Jones trigger and I get a tonne of errors.

any reasons?

edit: Nvm forgot how clocks work, sorry for the double post.
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Quite nice, Tom.

Master Maste - You see the part between the global tags?

JASS:
globals
    unit array udg_ShieldCaster
    unit array udg_ShieldDummies
endglobals


Remove it. Press Ctrl + B (variables' table) and create the following 2 variables.

1) Unit (array) call ShieldCaster
2) Unit (array) ShieldDummies

Copy the rest of Tom's code to your trigger (must be named Ion Shield).

By the way, here is my own little fix to the trigger (Modulos added to make it cycle) :

JASS:

globals
    unit array udg_ShieldCaster
    unit array udg_ShieldDummies
endglobals

function Trig_Ion_Shield_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == &#039;A001&#039;
endfunction

function Trig_Ion takes nothing returns nothing
    local integer i = ModuloInteger(GetTriggerExecCount(), 8192)
    local real x = GetUnitX(udg_ShieldCaster<i>)
    local real y = GetUnitY(udg_ShieldCaster<i>)

    call SetUnitPosition(udg_ShieldDummies<i>,x,y)
endfunction

function Trig_Ion_Shield_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local integer i = ModuloInteger(GetTriggerExecCount(), 8192)
    set udg_ShieldCaster<i> = GetSpellAbilityUnit()

    call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), &quot;|cffffcc00YOU HAVE ENABLED ION SHIELD|r.&quot; )
    
    call RemoveUnit( GetLastCreatedUnit() )
    call CreateNUnitsAtLoc( 1, &#039;h001&#039;, GetTriggerPlayer(), udg_ShieldCasterLoc, GetUnitFacing(GetTriggerUnit()) )
    
    set udg_ShieldDummies<i> = GetLastCreatedUnit()
    
    call TimerStart(t,0.03,true,function Trig_Ion)
endfunction


//===========================================================================
function InitTrig_Ion_Shield takes nothing returns nothing
    set gg_trg_Ion_Shield = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Ion_Shield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Ion_Shield, Condition( function Trig_Ion_Shield_Conditions ) )
    call TriggerAddAction( gg_trg_Ion_Shield, function Trig_Ion_Shield_Actions )
endfunction 
</i></i></i></i></i>
 

master maste

New Member
Reaction score
32
I have those variables and the trigger is named "Ion Shield" but its not liking it, I'll try again then edit this post with a reply.

Also what do the modulos things do?

still got errors, what am I doing wrong?
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
> Also what do the modulos things do?

Cycle through numbers - if you get over the number given you start from the start.

Mod(3,5) = 3
Mod(5,5) = 5
Mod(6,5) = 0, we passed 5 so we start from the beggining
Mod(7,5) = 1
Mod(11,5) = 0 we passed 5 the second time, so we again start over.

etc...
 

SFilip

Gone but not forgotten
Reaction score
634
Which line is the one with the first error?
 

master maste

New Member
Reaction score
32
Its in the bold part :)

Code:
function Trig_Ion_Shield_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Trig_Ion takes nothing returns nothing
    [B]local integer i = ModuloInteger(GetTriggerExecCount(), 8192)[/B]
    local real x = GetUnitX(udg_ShieldCaster[i])
    local real y = GetUnitY(udg_ShieldCaster[i])

    call SetUnitPosition(udg_ShieldDummies[i],x,y)
endfunction

function Trig_Ion_Shield_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local integer i = ModuloInteger(GetTriggerExecCount(), 8192)
    set udg_ShieldCaster[i] = GetSpellAbilityUnit()

    call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "|cffffcc00YOU HAVE ENABLED ION SHIELD|r." )
    
    call RemoveUnit( GetLastCreatedUnit() )
    call CreateNUnitsAtLoc( 1, 'h001', GetTriggerPlayer(), udg_ShieldCasterLoc, GetUnitFacing(GetTriggerUnit()) )
    
    set udg_ShieldDummies[i] = GetLastCreatedUnit()
    
    call TimerStart(t,0.03,true,function Trig_Ion)
endfunction


//===========================================================================
function InitTrig_Ion_Shield takes nothing returns nothing
    set gg_trg_Ion_Shield = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Ion_Shield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Ion_Shield, Condition( function Trig_Ion_Shield_Conditions ) )
    call TriggerAddAction( gg_trg_Ion_Shield, function Trig_Ion_Shield_Actions )
endfunction

edit: . . . anyone?

edit2: anyone at all?
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Bah, the function needs to take a trigger, thus:

JASS:

function Trig_Ion_Shield_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == &#039;A001&#039;
endfunction

function Trig_Ion takes nothing returns nothing
    local integer i = ModuloInteger(GetTriggerExecCount(GetTriggeringTrigger()), 8192)
    local real x = GetUnitX(udg_ShieldCaster<i>)
    local real y = GetUnitY(udg_ShieldCaster<i>)

    call SetUnitPosition(udg_ShieldDummies<i>,x,y)
endfunction

function Trig_Ion_Shield_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local integer i = ModuloInteger(GetTriggerExecCount(GetTriggeringTrigger()), 8192)
    set udg_ShieldCaster<i> = GetSpellAbilityUnit()

    call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), &quot;|cffffcc00YOU HAVE ENABLED ION SHIELD|r.&quot; )
    
    call RemoveUnit( GetLastCreatedUnit() )
    call CreateNUnitsAtLoc( 1, &#039;h001&#039;, GetTriggerPlayer(), udg_ShieldCasterLoc, GetUnitFacing(GetTriggerUnit()) )
    
    set udg_ShieldDummies<i> = GetLastCreatedUnit()
    
    call TimerStart(t,0.03,true,function Trig_Ion)
endfunction


//===========================================================================
function InitTrig_Ion_Shield takes nothing returns nothing
    set gg_trg_Ion_Shield = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Ion_Shield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Ion_Shield, Condition( function Trig_Ion_Shield_Conditions ) )
    call TriggerAddAction
</i></i></i></i></i>
 

master maste

New Member
Reaction score
32
What was that? Also I copy and pasted that last code and got errors again. :p seems to not like me.

edit: sorry it took so long for me to reply, I was refreshing the same page over and over again with out realising that it had gone to another page (I dont know why I always do that :p)
 

Tom Jones

N/A
Reaction score
437
Sorry that was my mistake, I actually forgot to add GetTriggeringTrigger()
Did you know that ResetTrigger(SomeTrigger()) sets the execution and evaluation count to 0?

*Edit*
I updated the code in my first post, it should work :)
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Just note that if the spell is casted over 8192, it will be wierd, if you think the spell might be casted so many times (doubtful) use Modulo.
 

master maste

New Member
Reaction score
32
Tried both Tom Jones' new code and Rheias Code (then used Toms new code and the modulos parts of Rheias' code in another test)

and none of them worked, they now save which is great but they dont work, it does however display the text I want it to show but it is not showing the dummy units. . .

Any ideas?
 
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