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

[Trigger] Help making spell MUI/Leakless in GUI

Status
Not open for further replies.
Level 8
Joined
Feb 3, 2013
Messages
277
Hi all, I've been having headaches trying to understand how to make a spell MUI/Leakless in GUI

This is just for fun so I know these spells wont lag me, but I want to know just for good practice and learning - how I can make these spells MUI. I've read lots of tutorials on them, but I still don't understand how to do so... Can someone walk me through on this one?
Spell 1
  • Surge Step Go
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Surge Step
    • Actions
      • Custom script: local unit u
      • Custom script: local effect p
      • Set ShadeEnd = ((Position of (Triggering unit)) offset by 500.00 towards (Facing of (Triggering unit)) degrees)
      • Set ShadeTransparency = 25.00
      • Set ShadeCaster = (Triggering unit)
      • Set ShadePoint = ((Position of ShadeCaster) offset by 250.00 towards (Facing of ShadeCaster) degrees)
      • Set ShadeLoc[0] = (Position of ShadeCaster)
      • Unit - Create 1 Shade for (Owner of (Triggering unit)) at ShadePoint facing (Facing of ShadeCaster) degrees
      • Set ShadeDummy = (Last created unit)
      • Custom script: set u = udg_ShadeDummy
      • Custom script: set udg_ShadeDummy = u
      • Special Effect - Create a special effect attached to the weapon of ShadeDummy using Abilities\Spells\Other\HealingSpray\HealBottleMissile.mdl
      • Set ShadeEffects[0] = (Last created special effect)
      • Custom script: set p = udg_ShadeEffects[0]
      • Custom script: set udg_ShadeEffects[0] = p
      • Special Effect - Create a special effect at ShadeLoc[0] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • Animation - Play ShadeDummy's attack animation
      • Animation - Change ShadeDummy's vertex coloring to (0.00%, 0.00%, 0.00%) with ShadeTransparency% transparency
      • Set ShadeGroup[0] = (Units within 300.00 of (Position of ShadeDummy) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of ShadeCaster)) Equal to True)))
      • Unit Group - Pick every unit in ShadeGroup[0] and do (Actions)
        • Loop - Actions
          • Unit - Cause ShadeDummy to damage (Picked unit), dealing 250.00 damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Other\Transmute\PileofGold.mdl
          • Special Effect - Destroy (Last created special effect)
      • Set ShadeGroup[1] = (Units within 250.00 of (Position of ShadeCaster) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of ShadeCaster)) Equal to True)))
      • Unit Group - Pick every unit in ShadeGroup[1] and do (Actions)
        • Loop - Actions
          • Unit - Cause ShadeDummy to damage (Picked unit), dealing 100.00 damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Other\Transmute\PileofGold.mdl
          • Special Effect - Destroy (Last created special effect)
      • Custom script: call SetUnitX( udg_ShadeCaster, GetLocationX(udg_ShadeEnd) )
      • Custom script: call SetUnitY( udg_ShadeCaster, GetLocationY(udg_ShadeEnd) )
      • Countdown Timer - Start ShadeTimer[0] as a Repeating timer that will expire in 0.02 seconds
      • Wait 1.50 seconds
      • Custom script: call PauseTimer(udg_ShadeTimer[0])
      • Custom script: call RemoveLocation(udg_ShadeLoc[0])
      • Custom script: call RemoveLocation(udg_ShadePoint)
      • Custom script: call RemoveLocation(udg_ShadeEnd)
      • Custom script: call DestroyGroup (udg_ShadeGroup[0])
      • Custom script: call DestroyGroup (udg_ShadeGroup[1])
      • Custom script: call DestroyEffect (p)
      • Custom script: call RemoveUnit (u)
      • Custom script: set u = null
      • Custom script: set p = null
  • Surge Step Clean
    • Events
      • Time - ShadeTimer[0] expires
    • Conditions
    • Actions
      • Set ShadeTransparency = (ShadeTransparency + 1.00)
      • Animation - Change ShadeDummy's vertex coloring to (0.00%, 0.00%, 0.00%) with ShadeTransparency% transparency
This first spell basically blinks your caster a distance forward and creates an effect inbetween.



Spell 2
  • Spin Go
  • Events - Specific Unit takes damage,
  • Conditions
  • (Level of Assault Strike for (Damage source)) Greater than 0
  • Actions
  • Set SpinNer = (Damage source)
  • Set SpinTarget = (Triggering unit)
  • Set SpinPoint[0] = (Position of SpinNer)
  • Set SpinPoint[1] = ((Position of SpinTarget) offset by 100.00 towards (Random real number between 0.00 and 360.00) degrees)
  • Set SpinAOE = (Units within 225.00 of (Position of SpinTarget) matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of SpinNer)) Equal to True) and ((Matching unit) Not equal to SpinTarget))))
  • Unit Group - Pick every unit in SpinAOE and do (Actions)
  • Loop - Actions
  • Set SpinAOEPicked = (Picked unit)
  • Unit - Cause SpinDummy to damage SpinAOEPicked, dealing (0.15 x (Damage taken)) damage of attack type Chaos and damage type Normal
  • Special Effect - Create a special effect attached to the chest of SpinAOEPicked using Abilities\Spells\Orc\Disenchant\DisenchantSpecialArt.mdl
  • Set SpinEffects[0] = (Last created special effect)
  • Special Effect - Create a special effect at SpinPoint[0] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
  • Special Effect - Destroy (Last created special effect)
  • Special Effect - Create a special effect attached to the chest of SpinTarget using Abilities\Spells\Orc\Disenchant\DisenchantSpecialArt.mdl
  • Set SpinEffects[1] = (Last created special effect)
  • Custom script: call SetUnitX( udg_SpinNer, GetLocationX(udg_SpinPoint[1]) )
  • Custom script: call SetUnitY( udg_SpinNer, GetLocationY(udg_SpinPoint[1]) )
  • Custom script: call RemoveLocation(udg_SpinPoint[0])
  • Custom script: call RemoveLocation(udg_SpinPoint[1])
  • Custom script: call DestroyGroup(udg_SpinAOE)
  • Unit - Set life of SpinNer to ((Life of SpinNer) + 0.00)
  • Special Effect - Create a special effect attached to the head of SpinNer using Abilities\Spells\Undead\VampiricAura\VampiricAuraTarget.mdl
  • Special Effect - Destroy (Last created special effect)
  • Wait 0.70 seconds
  • Special Effect - Destroy SpinEffects[0]
  • Special Effect - Destroy SpinEffects[1]

This second spell is basically an built in blink, cleave attack, lifesteal into a regular units attack.

I've done what i can to try and cover up the leaks, but i still need help - on top of that I have no idea how to make them Multi Unit Instanceable. T-T can someone help me please?
 
Level 7
Joined
Nov 15, 2009
Messages
225
Hey,
hive contains lots of tutorials for mui spells.
You should check them out, they tell you anything you need to know.

Example: http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/

I made a very very basic mui trigger. And converted it to Jass.
Personally I think this is the easiest way to make a spell mui.

I did only changed the mui aspects of the trigger. Nothing else.
This is not a 'perfect' jass code (I want you to know what is important for mui and what not).

+ You have a new message, if you need further help just feel free to answer me.


And to your map: Sorry but don't want to rewrite anything of it.. :p



1. Gui trigger
  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Blizzard
        • Then - Actions
          • Wait 1.00 seconds
          • Game - Display to (All players) the text: (Caster: + (String((Unit-type of (Triggering unit)))))
          • Game - Display to (All players) the text: (Mana (before): + (String((Mana of (Triggering unit)))))
          • Unit - Set mana of (Triggering unit) to 100.00%
          • Game - Display to (All players) the text: (Mana (after): + (String((Mana of (Triggering unit)))))
        • Else - Actions
2. Converted custom text
JASS:
function Trig_Converted_Spell_Func001C takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'AHbz' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Converted_Spell_Actions takes nothing returns nothing
    if ( Trig_Converted_Spell_Func001C() ) then
        call TriggerSleepAction( 1.00 )
        call DisplayTextToForce( GetPlayersAll(), ( "Caster: " + UnitId2StringBJ(GetUnitTypeId(GetTriggerUnit())) ) )
        call DisplayTextToForce( GetPlayersAll(), ( "Mana (before): " + R2S(GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit())) ) )
        call SetUnitManaPercentBJ( GetTriggerUnit(), 100 )
        call DisplayTextToForce( GetPlayersAll(), ( "Mana (after): " + R2S(GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit())) ) )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Converted_Spell takes nothing returns nothing
    set gg_trg_Converted_Spell = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Converted_Spell, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Converted_Spell, function Trig_Converted_Spell_Actions )
endfunction
3. Edited custom script to make it mui using locals
JASS:
function Trig_Jass_Spell_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    if (GetSpellAbilityId() == 'AHbz') then
        call TriggerSleepAction(1.00)
        call DisplayTextToForce(GetPlayersAll(), ("Caster: " + UnitId2StringBJ(GetUnitTypeId(u))))
        call DisplayTextToForce(GetPlayersAll(), ("Mana (before): " + R2S(GetUnitStateSwap(UNIT_STATE_MANA, u))))
        call SetUnitManaPercentBJ(u, 100)
        call DisplayTextToForce(GetPlayersAll(), ("Mana (after): " + R2S(GetUnitStateSwap(UNIT_STATE_MANA, u))))
    else
    endif
    set u = null
endfunction

function InitTrig_Jass_Spell takes nothing returns nothing
    set gg_trg_Jass_Spell = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Jass_Spell, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction(gg_trg_Jass_Spell, function Trig_Jass_Spell_Actions)
endfunction
 

Attachments

  • Mui.w3x
    16.9 KB · Views: 53
Last edited:
Level 23
Joined
Apr 16, 2012
Messages
4,041
the else block there is useless
you should change the trigger in init to local too unless you want to use it in other triggers too

and no your first spell is not mui because you use index 0 all the time so if I cast it second time while first instance is sleeped, I will overwrite thr old data with new, which means the trigger has high pottention of leaking
also the second custom script with set in it is useless
you should either use hashtable(you can learn about them from link provided by SeriousEnemy) or some sort of indexing

I didnt check the second spell because it is hard to see where the loop ends
 
Level 8
Joined
Feb 3, 2013
Messages
277
thanks for ur response serious;

I've actually read that tutorial before, but I didn't understand why hashtables allow for MUI. Won't the data stored in the keys override just like variables do everytime a trigger runs?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
if you use the right keys they wont
dor instance if you use Key(triggering unit) it will be unique value for all triggering units
its called handle id by the way and the magic is that no 2 handles share same handle id
 
Status
Not open for further replies.
Top