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
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top