MUI Help

Tawnttoo

New Member
Reaction score
36
I recently started to try my hand at making MUI spells. Could you tell me if this is MUI?

Trigger:
  • DoT Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to DoT (Neutral Hostile)
    • Actions
      • Set DoT_Integer = (DoT_Integer + 1)
      • Set DoT_Caster[DoT_Integer] = (Triggering unit)
      • Set DoT_Target[DoT_Integer] = (Target unit of ability being cast)
      • Set DoT_Duration[DoT_Integer] = 15.00
      • Set DoT_Damage[DoT_Integer] = (Life of DoT_Caster[DoT_Integer])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DoT_Integer Equal to 5000
        • Then - Actions
          • Set DoT_Integer = 1
        • Else - Actions


Trigger:
  • DoT Damage
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer DoT_Number) from 1 to DoT_Integer, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DoT_Duration[DoT_Number] Greater than 0.00
            • Then - Actions
              • Unit - Cause DoT_Caster[DoT_Number] to damage DoT_Target[DoT_Number], dealing (DoT_Damage[DoT_Number] / 15.00) damage of attack type Spells and damage type Normal
              • Set DoT_Duration[DoT_Number] = (DoT_Duration[DoT_Number] - 1.00)
            • Else - Actions
              • Set DoT_Integer = (DoT_Integer - 1)


Also, any suggestions to improve the code?
 

Laiev

Hey Listen!!
Reaction score
188
test? :p

but i think i'll bug in some time..

Set DoT_Integer = (DoT_Integer - 1)

lets think in an example...

I cast the spell... DoT_Integer = 1 now...
Then You cast the spell too before my spell over...
DoT_Integer = 2 now

when my spell over, the DoT_Integer will be 1 again and the Your spell still running but with the id 1 which is mine..
 

vonDarkmoor

New Member
Reaction score
9
If you Use a pre-Set amount of damage and dont care about where the damage comes from you can use:

Trigger:
  • Initiate DOT
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to DOT
    • Actions
      • Set Pre_Set_Damage = 100
      • Unit Group - Add (Target unit of ability being cast) to DOT_Unit_Group
      • Unit - Set the custom value of (Target unit of ability being cast) to 15
      • Unit Group - Add (Target unit of ability being cast) to DOT_Unit_Group


with

Trigger:
  • Run DOT
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in DOT_Unit_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked unit)) Greater than 0
            • Then - Actions
              • Unit - Set the custom value of (Picked unit) to ((Custom value of (Picked unit)) - 1)
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (Real(Pre_Set_Damage)))
            • Else - Actions
              • Unit Group - Remove (Picked unit) from DOT_Unit_Group
      • For each (Integer A) from 1 to (Number of units in DOT_Unit_Group), do (Actions)
        • Loop - Actions



Else, as far as i can tell, in order to keep track of Target, Caster, Duration,and Custom-per-unit Damage you will need to use a Hashtable to keep the trigger from overlapping itself.
 

Tawnttoo

New Member
Reaction score
36
Since I'm already using custom values for something else, could you tell me how would I go about using hashtables? I haven't really used them before.
 

NoobImbaPro

You can change this now in User CP.
Reaction score
60
at the second trigger at the last line
"Set DoT_Integer = (DoT_Integer - 1)" why are you doing that?
I can't understand
 

Tawnttoo

New Member
Reaction score
36
Sadly, that tutorial doesn't tell me how to deal the damage (from a source) but only heals and pushbacks are handled in it. I'm using these:
Trigger:
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set DoT_Hash = (Last created hashtable)


Trigger:
  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to DoT (Neutral Hostile)
    • Actions
      • Hashtable - Save (Life of (Triggering unit)) as 0 of (Key (Target unit of ability being cast)) in DoT_Hash
      • Hashtable - Save 15.00 as 1 of (Key (Target unit of ability being cast)) in DoT_Hash
      • Hashtable - Save Handle Of(Triggering unit) as 2 of (Key (Triggering unit)) in DoT_Hash
      • Unit Group - Add (Target unit of ability being cast) to DoT_Targets


Trigger:
  • DoT
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in DoT_Targets and do (Actions)
        • Loop - Actions
          • Set DoT_Duration = (Load 0 of (Key (Picked unit)) from DoT_Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DoT_Duration Greater than 0.00
            • Then - Actions
              • Set DoT_Damage = (Load 0 of (Key (Picked unit)) from DoT_Hash)
              • Set DoT_Source = (Load 2 of (Key (Triggering unit)) in DoT_Hash)
              • Unit - Cause DoT_Source to damage (Picked unit), dealing DoT_Damage damage of attack type Spells and damage type Normal
            • Else - Actions


And I know the unit storing doesn't work. But how should it be done?
 

vonDarkmoor

New Member
Reaction score
9
SUCCESS! i hope lol. i think i got your spell trigger figured out with the hashtable. Ill post the triggers, and upload the map so you can see it in action.
I have this ability set up so it does damage equal to the casters HP every second for 10/15/20 seconds. Duration is dependent upon lvl of ability. For an ability with a lot of levels you might wanna consider using a "For each integer A from 1 to X(amount of levels)" Function. in the (Start D O T) Trigger
Trigger:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
      • Hashtable - Create a hashtable
      • Set DOT_HashTable = (Last created hashtable)


Trigger:
  • Start D O T
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to D O T
    • Actions
      • Set Damage = (Life of (Triggering unit))
      • Set Caster = (Triggering unit)
      • Unit Group - Add (Target unit of ability being cast) to DOT_Group
      • Hashtable - Save Handle OfCaster as (Key caster) of (Key (Target unit of ability being cast)) in DOT_HashTable
      • Hashtable - Save Damage as (Key damage) of (Key (Triggering unit)) in DOT_HashTable
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of D O T for (Triggering unit)) Equal to 1
        • Then - Actions
          • Set Duration = 10
          • Hashtable - Save Duration as (Key duration) of (Key (Target unit of ability being cast)) in DOT_HashTable
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of D O T for (Triggering unit)) Equal to 2
            • Then - Actions
              • Set Duration = 15
              • Hashtable - Save Duration as (Key duration) of (Key (Target unit of ability being cast)) in DOT_HashTable
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of D O T for (Triggering unit)) Equal to 3
                • Then - Actions
                  • Set Duration = 20
                  • Hashtable - Save Duration as (Key duration) of (Key (Target unit of ability being cast)) in DOT_HashTable
                • Else - Actions


Trigger:
  • Run D O T
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in DOT_Group and do (Actions)
        • Loop - Actions
          • Set Remaining_Time = (Load (Key duration) of (Key (Picked unit)) from DOT_HashTable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Remaining_Time Greater than 0
            • Then - Actions
              • Unit - Cause (Load (Key caster) of (Key (Picked unit)) in DOT_HashTable) to damage (Picked unit), dealing (Load (Key damage) of (Key (Load (Key caster) of (Key (Picked unit)) in DOT_HashTable)) from DOT_HashTable) damage of attack type Spells and damage type Normal
              • Hashtable - Save (Remaining_Time - 1) as (Key duration) of (Key (Picked unit)) in DOT_HashTable
            • Else - Actions
              • Unit Group - Remove (Picked unit) from DOT_Group
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in DOT_HashTable


I think there is a memory leak with the unit Group that would require custom script to remove it, not sure, but if so i dont remember the custom script to remove it. The custom script should be easy to search for ive seen the issue come up a lot.

Hope this helps.

:EDIT: I just saw that i forgot to incorporate the fact that you want the caster to deal the damage to the unit, ill see bout fixing that ...
::EDIT:: Fixed it so that the caster deals the damage and updated the above code, also re-uploaded the map so its up to date as well.
 

Attachments

  • HashTable.w3x
    19.8 KB · Views: 167

Tawnttoo

New Member
Reaction score
36
Firstly, I disagree with
there is a memory leak with the unit Group that would require custom script to remove it
because after dealing with the unit inside the group, it is removed from it. Also, the group is never again being created.

Secondly, I wonder why my spell doesn't work. I believe I made everything just like in your example. Could you check it out for me?
 

Attachments

  • Hash DoT.w3x
    17.8 KB · Views: 179

vonDarkmoor

New Member
Reaction score
9
was messin around with this part of your code:

Trigger:
  • Unit - Cause (Load (Key caster) of (Key (Picked unit)) in DoT_Hash) to damage (Picked unit), dealing (Load (Key damage) of (Key (Load (Key caster) of (Key (Picked unit)) in DoT_Hash)) from DoT_Hash) damage of attack type Spells and damage type Normal


Ended up with this:
Not sure whats different lol but it worked.

Trigger:
  • Unit - Cause (Load (Key caster) of (Key (Picked unit)) in DoT_Hash) to damage (Picked unit), dealing (Load (Key damage) of (Key (Load (Key caster) of (Key (Picked unit)) in DoT_Hash)) from DoT_Hash) damage of attack type Spells and damage type Normal


I might have changed somethin else without remembering but im gonna upload the map so you can see if anything else is different.
 

Attachments

  • Hash DoT.w3x
    17.7 KB · Views: 198

Tawnttoo

New Member
Reaction score
36
I'm confused. The trigger code is identical. There is nothing different in my code compared to yours. Yet, it doesn't work. I don't get it.

EDIT: Odd. I could make it work by simply recreating the 'Unit - Damage Target' line. Why it didn't work the first time around beats me. I wish to thank you very much, vonDarkmoor, for your effort in helping me. I now understand at least the basics of hashtables. Its +rep for sure.
 

Tawnttoo

New Member
Reaction score
36
One more question: instead of having the damage dealt at 'Every 1.00 seconds', how could it be set to be so that the first tick of damage takes place one second after cast and continues from there every second = each cast has its own timer?
 

vypur85

Hibernate
Reaction score
803
> damage takes place one second after cast....

If you don't mind, you can probably try this:

Code:
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to DoT (Neutral Hostile)
    Actions
        Custom script:   local unit udg_TARGET
        Custom script:   local integer i = 0
        Set TARGET = (Target unit of ability being cast)
        Custom script:   loop
        Custom script:   exitwhen i >14 or ( GetWidgetLife(udg_TARGET) < 0.405 )
        Custom script:   set i = i +1
        Unit - Cause (Triggering unit) to damage TARGET, dealing ((Life of (Triggering unit)) / 15.00) damage of attack type Spells and damage type Normal
        Wait 1.00 game-time seconds
        Custom script:   endloop
        Set TARGET = No unit

Simpler, I'd say. But then, if you're attempting to learn how to code MUI purely via GUI, then this is not the one for you.
 

vonDarkmoor

New Member
Reaction score
9
One more question: instead of having the damage dealt at 'Every 1.00 seconds', how could it be set to be so that the first tick of damage takes place one second after cast and continues from there every second = each cast has its own timer?

hmmm, im not too sure bout that lol.
 

Tawnttoo

New Member
Reaction score
36
I suppose each cast should have a timer of its own. But I can't figure out the events to the damage-dealing trigger. I reckon adding an event each time the spell is cast will leak an event.
 

Ashlebede

New Member
Reaction score
43
You could do something along these lines :

Trigger:
  • //Hand-written
    • Actions
      • Set MySpellTargetUnit[(Custom value of (Triggering unit))] = (Target unit of ability being cast)
      • For each Integer LoopCounter[(Custom value of (Triggering unit))] from 1 to 14 do actions
        • Loop - Actions
          • If (All conditions are true) then do (Then actions) else do (Else actions)
            • If - Conditions
              • (MySpellTargetUnit[(Custom value of (Triggering unit))] Is dead) Equal to False
            • Then - Actions
              • -------- Whatever goes here --------
              • Wait 1.00 game-time seconds
            • Else - Actions


Personally, I find this alternative is not optimal at all and is really inaccurate. But that is as seen from a Jasser's eye.
 

Inflicted

Currently inactive
Reaction score
63
i know you probably don't want to hear this, but wouldn't it be simpler just to use locals and a loop? then it would be alot shorter, i don't know how it will look, i havent tryed anything of this type with locals in GUI. but it seems obvious enough.

just a suggestion.
 

Tawnttoo

New Member
Reaction score
36
Like vypur85 suggested? Is there, by any chance, anything wrong in the code? It's my first time using hashtables and without questioning vonDarkmoor's skills with them, I want to ensure its all good.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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