- Joined
- Dec 13, 2018
- Messages
- 2,368
So I am taking upon me to finally learn MUI. A task I have been postponing for a long time, but now I can't postpone it anymore.
While some find it extremely simple to do it, I don't really understand the logic behind it completely just yet. If possible I would like to learn array MUI, preferably not hash tables.
I get the concept behind MUI and I am able to create some simple triggers, but when it comes to more advanced lightning systems is where logic really starts to elude me.
Here's a spell I have been trying to make work for some time now:
This trigger successfully creates a new instance of the lightning and it removes it in the same order that I cast it, just as I want it:
However I don't want the lightning to end from a timed wait, but rather when the affected unit dies so I tried doing this:
Needless to say this didn't work as I hoped it would as the units doesn't necessarily die in the order they were affected by the spell.
And then comes the part that really gets me. Actually moving every single instance of lightning to their respective units. This is what I tried:
I am well aware that the reason this isn't working is because it will only move the most recent instance of MIL[udg_MIC] to the caster, leaving the old lightnings stuck on the ground. I have tried thinking out some way to successfully reference the correct lightnings with a simple periodic trigger but I just can't wrap my head around how to do it.
Any help is appreciated.
While some find it extremely simple to do it, I don't really understand the logic behind it completely just yet. If possible I would like to learn array MUI, preferably not hash tables.
I get the concept behind MUI and I am able to create some simple triggers, but when it comes to more advanced lightning systems is where logic really starts to elude me.
Here's a spell I have been trying to make work for some time now:
This trigger successfully creates a new instance of the lightning and it removes it in the same order that I cast it, just as I want it:
-
MIL
-
Events
-
Unit - A unit Starts the effect of an ability
-
-
Conditions
-
(Ability being cast) Equal to Inner Fire
-
-
Actions
-
Unit Group - Add (Target unit of ability being cast) to MI_Group
-
Set MIC = (MIC + 1)
-
Set MC[MIC] = (Triggering unit)
-
Set MT[MIC] = (Target unit of ability being cast)
-
Set MP1[MIC] = (Position of MC[MIC])
-
Set MP2[MIC] = (Position of MT[MIC])
-
Custom script: set udg_MIL[udg_MIC] = AddLightningEx("DRAL", true , GetLocationX(udg_MP1[udg_MIC]), GetLocationY(udg_MP1[udg_MIC]), GetLocationZ(udg_MP1[udg_MIC]) + 70, GetLocationX(udg_MP2[udg_MIC]), GetLocationY(udg_MP2[udg_MIC]), GetLocationZ(udg_MP2[udg_MIC]) + 70)
-
Set LightningCount = (LightningCount + 1)
-
Custom script: call RemoveLocation (udg_MP1[udg_MIC])
-
Custom script: call RemoveLocation (udg_MP2[udg_MIC])
-
Wait 10.00 seconds
-
Set MIT = (MIT + 1)
-
Lightning - Destroy MIL[MIT]
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MIC Equal to MIT
-
-
Then - Actions
-
Set MIC = 0
-
Set MIT = 0
-
-
Else - Actions
-
-
-
However I don't want the lightning to end from a timed wait, but rather when the affected unit dies so I tried doing this:
-
MIL
-
Events
-
Unit - A unit Starts the effect of an ability
-
-
Conditions
-
(Ability being cast) Equal to Inner Fire
-
-
Actions
-
Unit Group - Add (Target unit of ability being cast) to MI_Group
-
Set MIC = (MIC + 1)
-
Set MC[MIC] = (Triggering unit)
-
Set MT[MIC] = (Target unit of ability being cast)
-
Set MP1[MIC] = (Position of MC[MIC])
-
Set MP2[MIC] = (Position of MT[MIC])
-
Custom script: set udg_MIL[udg_MIC] = AddLightningEx("DRAL", true , GetLocationX(udg_MP1[udg_MIC]), GetLocationY(udg_MP1[udg_MIC]), GetLocationZ(udg_MP1[udg_MIC]) + 70, GetLocationX(udg_MP2[udg_MIC]), GetLocationY(udg_MP2[udg_MIC]), GetLocationZ(udg_MP2[udg_MIC]) + 70)
-
Set LightningCount = (LightningCount + 1)
-
Custom script: call RemoveLocation (udg_MP1[udg_MIC])
-
Custom script: call RemoveLocation (udg_MP2[udg_MIC])
-
-
-
MIL Target dies
-
Events
-
Unit - A unit Dies
-
-
Conditions
-
((Triggering unit) is in MI_Group) Equal to True
-
-
Actions
-
Unit Group - Remove (Triggering unit) from MI_Group
-
Set MIT = (MIT + 1)
-
Lightning - Destroy MIL[MIT]
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MIC Equal to MIT
-
-
Then - Actions
-
Set MIC = 0
-
Set MIT = 0
-
-
Else - Actions
-
-
-
Needless to say this didn't work as I hoped it would as the units doesn't necessarily die in the order they were affected by the spell.
And then comes the part that really gets me. Actually moving every single instance of lightning to their respective units. This is what I tried:
-
MIL Periodic
-
Events
-
Time - Every 0.03 seconds of game time
-
-
Conditions
-
(Number of units in MI_Group) Greater than 0
-
-
Actions
-
Set MP1[MIC] = (Position of MC[MIC])
-
Set MP2[MIC] = (Position of MT[MIC])
-
Custom script: call MoveLightningEx(udg_MIL[udg_MIC], true , GetLocationX(udg_MP1[udg_MIC]), GetLocationY(udg_MP1[udg_MIC]), GetLocationZ(udg_MP1[udg_MIC]) + 70, GetLocationX(udg_MP2[udg_MIC]), GetLocationY(udg_MP2[udg_MIC]), GetLocationZ(udg_MP2[udg_MIC]) + 70)
-
Custom script: call RemoveLocation (udg_MP1[udg_MIC])
-
Custom script: call RemoveLocation (udg_MP2[udg_MIC])
-
-
I am well aware that the reason this isn't working is because it will only move the most recent instance of MIL[udg_MIC] to the caster, leaving the old lightnings stuck on the ground. I have tried thinking out some way to successfully reference the correct lightnings with a simple periodic trigger but I just can't wrap my head around how to do it.
Any help is appreciated.