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

First ''MUI'' Approach

Status
Not open for further replies.
Level 18
Joined
May 11, 2012
Messages
2,103
Well something here is clearly wrong which I can't see whole day....

  • Drap Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Drap
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MaxIndexDrap1 Equal to 0
        • Then - Actions
          • Trigger - Turn on Drap Loop <gen>
        • Else - Actions
      • Set MaxIndexDrap1 = (MaxIndexDrap1 + 1)
      • Set MaxIndexDrap2 = (MaxIndexDrap2 + 1)
      • Set Drap_TrigUnitIndex[MaxIndexDrap1] = (Triggering unit)
      • Set Drap_TrigUnitPointIndex[MaxIndexDrap1] = (Position of Drap_TrigUnitIndex[MaxIndexDrap1])
      • Set Drap_TargetUnitIndex[MaxIndexDrap1] = (Target unit of ability being cast)
      • Set Drap_TargetUnitPointIndex[MaxIndexDrap1] = (Position of Drap_TargetUnitIndex[MaxIndexDrap1])
      • Unit - Create 1 Dummy Drap for (Owner of Drap_TrigUnitIndex[MaxIndexDrap1]) at Drap_TrigUnitPointIndex[MaxIndexDrap1] facing Drap_TargetUnitPointIndex[MaxIndexDrap1]
      • Set Drap_DummyUnitIndex[MaxIndexDrap1] = (Last created unit)
      • Custom script: call RemoveLocation(udg_Drap_TrigUnitPointIndex[udg_MaxIndexDrap1])
      • Custom script: set udg_Drap_TrigUnitPointIndex[udg_MaxIndexDrap1] = null
      • Custom script: call RemoveLocation(udg_Drap_TargetUnitPointIndex[udg_MaxIndexDrap1])
      • Custom script: set udg_Drap_TargetUnitPointIndex[udg_MaxIndexDrap1] = null
  • Drap Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Drap_CurrentIndex) from 1 to MaxIndexDrap1, do (Actions)
        • Loop - Actions
          • Set Drap_TargetUnitPointIndex[Drap_CurrentIndex] = (Position of Drap_TargetUnitIndex[Drap_CurrentIndex])
          • Set Drap_DummyUnitPointIndex[Drap_CurrentIndex] = (Position of Drap_DummyUnitIndex[Drap_CurrentIndex])
          • Set Drap_AngleIndex[Drap_CurrentIndex] = (Angle from Drap_DummyUnitPointIndex[Drap_CurrentIndex] to Drap_TargetUnitPointIndex[Drap_CurrentIndex])
          • Set Drap_DummyUnitMoveIndex[Drap_CurrentIndex] = (Drap_DummyUnitPointIndex[Drap_CurrentIndex] offset by 20.00 towards Drap_AngleIndex[Drap_CurrentIndex] degrees)
          • Unit - Move Drap_DummyUnitIndex[Drap_CurrentIndex] instantly to Drap_DummyUnitMoveIndex[Drap_CurrentIndex], facing Drap_AngleIndex[Drap_CurrentIndex] degrees
          • Environment - Create a 0.30 second Temporary crater deformation at Drap_DummyUnitPointIndex[Drap_CurrentIndex] with radius 125.00 and depth 10.00
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Drap_DummyUnitPointIndex[Drap_CurrentIndex] and Drap_TargetUnitPointIndex[Drap_CurrentIndex]) Less than or equal to 75.00
            • Then - Actions
              • Unit - Kill Drap_DummyUnitIndex[Drap_CurrentIndex]
              • Unit - Remove Drap_DummyUnitIndex[Drap_CurrentIndex] from the game
              • Unit - Cause Drap_TrigUnitIndex[Drap_CurrentIndex] to damage Drap_TargetUnitIndex[Drap_CurrentIndex], dealing 200.00 damage of attack type Spells and damage type Normal
              • Special Effect - Create a special effect at Drap_TargetUnitPointIndex[Drap_CurrentIndex] using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set Drap_TrigUnitIndex[Drap_CurrentIndex] = Drap_TrigUnitIndex[MaxIndexDrap1]
              • Set Drap_TrigUnitIndex[MaxIndexDrap1] = No unit
              • Set Drap_TargetUnitIndex[Drap_CurrentIndex] = Drap_TargetUnitIndex[MaxIndexDrap1]
              • Set Drap_TargetUnitIndex[MaxIndexDrap1] = No unit
              • Set Drap_DummyUnitIndex[Drap_CurrentIndex] = Drap_DummyUnitIndex[MaxIndexDrap1]
              • Set Drap_DummyUnitIndex[MaxIndexDrap1] = No unit
              • Set MaxIndexDrap2 = (MaxIndexDrap2 - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MaxIndexDrap2 Equal to 0
                • Then - Actions
                  • Set MaxIndexDrap1 = 0
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Drap_TargetUnitPointIndex[udg_Drap_CurrentIndex])
          • Custom script: set udg_Drap_TargetUnitPointIndex[udg_Drap_CurrentIndex] = null
          • Custom script: call RemoveLocation(udg_Drap_DummyUnitPointIndex[udg_Drap_CurrentIndex])
          • Custom script: set udg_Drap_DummyUnitPointIndex[udg_Drap_CurrentIndex] = null
          • Custom script: call RemoveLocation(udg_Drap_DummyUnitMoveIndex[udg_Drap_CurrentIndex])
          • Custom script: set udg_Drap_DummyUnitMoveIndex[udg_Drap_CurrentIndex] = null
Making my first MUI spell, and the problem is in here: When I cast it few times in a row, the dummies move normally towards target, but when the first missile reaches the target, all of the missiles suddenly stop and don't move anymore....
Why?
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Get rid of MaxIndexDrap2 and change all actions and conditions related to MaxIndexDrap2 to MaxINdexDrap1.

Also, you should learn the usefulness of temp variables, because you "store" points and angles in array variables when all you would need are temp variables (this may end up with the same result, but the difference is that temporal variables can be used in all spells, while the one you use technically can't)

  • Environment - Create a 0.30 second Temporary crater deformation at Drap_DummyUnitPointIndex[Drap_CurrentIndex] with radius 125.00 and depth 10.00
Doesn't this lag your pc? You create terrain deformation every 0,03 second for each drap dummy in game. I would really leave that one out imo.

A side note - it is always better to simplify names if possible, so they still give you the idea what they are related to, but are not 16 letters long.
For example instead of "Drap_TrigUnitIndex" I would name it Drap_Caster and "Drap_TargetUnitIndex" to "Drap_Tar"
It's not bad the way you have it, but it's far harder to understand what you want and those names you use are very similar (and with the added index variable, it's even longer). Worst case you can get lost in them yourself and make silly mistake :)

You also don't need a unique integer variable for loops. You only need them to be different if you have loop inside another loop.
 
Level 18
Joined
May 11, 2012
Messages
2,103
Get rid of MaxIndexDrap2 and change all actions and conditions related to MaxIndexDrap2 to MaxINdexDrap1.

Also, you should learn the usefulness of temp variables, because you "store" points and angles in array variables when all you would need are temp variables (this may end up with the same result, but the difference is that temporal variables can be used in all spells, while the one you use technically can't)

  • Environment - Create a 0.30 second Temporary crater deformation at Drap_DummyUnitPointIndex[Drap_CurrentIndex] with radius 125.00 and depth 10.00
Doesn't this lag your pc? You create terrain deformation every 0,03 second for each drap dummy in game. I would really leave that one out imo.

A side note - it is always better to simplify names if possible, so they still give you the idea what they are related to, but are not 16 letters long.
For example instead of "Drap_TrigUnitIndex" I would name it Drap_Caster and "Drap_TargetUnitIndex" to "Drap_Tar"
It's not bad the way you have it, but it's far harder to understand what you want and those names you use are very similar (and with the added index variable, it's even longer). Worst case you can get lost in them yourself and make silly mistake :)

You also don't need a unique integer variable for loops. You only need them to be different if you have loop inside another loop.

Already did that, but it's still screwing up -.-
Nope, no lag with deformations and it looks nice with it :D

Names aren't the problems
Unique variable: I know that, this isn't in my map yet and I use TempInt for loop variable.

and yes, TempPoint I'm also using, but here I just wanted to be sure to be MUI, I use TempPoint in my map in cases where the effect is instant like locations and shits...

Death - I was making it following your Chapter 12 - How to Index so this is your way. Or it isn't?
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
I recreated the spell (with slight modifications), but encountered no problems.

Triggers I used:
  • Drap Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Drap
    • Actions
      • Set Drap_Max = (Drap_Max + 1)
      • Set Drap_Caster[Drap_Max] = (Triggering unit)
      • Set Drap_Tar[Drap_Max] = (Target unit of ability being cast)
      • Set p1 = (Position of Drap_Caster[Drap_Max])
      • Set p2 = (Position of Drap_Tar[Drap_Max])
      • Unit - Create 1 Drap Dummy for (Owner of Drap_Caster[Drap_Max]) at p1 facing p2
      • Set Drap_Dummy[Drap_Max] = (Last created unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Drap_Max Equal to 1
        • Then - Actions
          • Trigger - Turn on Drap Loop <gen>
        • Else - Actions
      • Custom script: call RemoveLocation(udg_p1)
      • Custom script: call RemoveLocation(udg_p2)
      • Custom script: set udg_p1 = null
      • Custom script: set udg_p2 = null
  • Drap Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopInteger) from 1 to Drap_Max, do (Actions)
        • Loop - Actions
          • Set p1 = (Position of Drap_Dummy[LoopInteger])
          • Set p2 = (Position of Drap_Tar[LoopInteger])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between p1 and p2) Less than or equal to 75.00
            • Then - Actions
              • Unit - Kill Drap_Dummy[LoopInteger]
              • Unit - Cause Drap_Caster[LoopInteger] to damage Drap_Tar[LoopInteger], dealing 200.00 damage of attack type Spells and damage type Normal
              • Special Effect - Create a special effect at p2 using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
              • Special Effect - Destroy (Last created special effect)
              • -------- ------------------------------------------------------------ --------
              • Set Drap_Caster[LoopInteger] = Drap_Caster[Drap_Max]
              • Set Drap_Tar[LoopInteger] = Drap_Tar[Drap_Max]
              • Set Drap_Dummy[LoopInteger] = Drap_Dummy[Drap_Max]
              • -------- ------------------------------------------------------------ --------
              • Set Drap_Caster[Drap_Max] = No unit
              • Set Drap_Tar[Drap_Max] = No unit
              • Set Drap_Dummy[Drap_Max] = No unit
              • -------- ------------------------------------------------------------ --------
              • Set Drap_Max = (Drap_Max - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Drap_Max Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • Set p3 = (p1 offset by 10.00 towards (Angle from p1 to p2) degrees)
              • Unit - Move Drap_Dummy[LoopInteger] instantly to p3
              • Environment - Create a 0.30 second Temporary crater deformation at p3 with radius 125.00 and depth 10.00
              • Custom script: call RemoveLocation(udg_p3)
          • Custom script: call RemoveLocation(udg_p1)
          • Custom script: call RemoveLocation(udg_p2)
In case you wanted to look at it in WE, I attached the map to this post as well.
 

Attachments

  • Drap Spell.w3x
    19.4 KB · Views: 37
Level 28
Joined
Sep 26, 2009
Messages
2,520
Well, the only problem I see is that you use MaxIndexDrap2 to check how many instances of that spell are currently active, and MaxIndexDrap1 to index and deindex. But when one instance ended, they both had different values, which may ended up doing the problem.

Using only MaxIndexDrap1 for everything should solve the problem.

Death - uh yeah, sorry xD
 
Well, the only problem I see is that you use MaxIndexDrap2 to check how many instances of that spell are currently active, and MaxIndexDrap1 to index and deindex. But when one instance ended, they both had different values, which may ended up doing the problem.

Using only MaxIndexDrap1 for everything should solve the problem.

Death - uh yeah, sorry xD

np lol its easy to miss
 
yes. that reduces the loop integer. the reason u reduce it is u just ran the index that was at that index but u then de-indexed. what that means is u move everything from the maxIndex ( last index indexed). the problem w that is that u dont run that index because it was moved after the iondex was looped. So to gain back that index that wasnt run u just reduce the loop integer. that makes it so that index that wouldve been skipped is now covered accordingly.
 
Level 18
Joined
May 11, 2012
Messages
2,103
yes. that reduces the loop integer. the reason u reduce it is u just ran the index that was at that index but u then de-indexed. what that means is u move everything from the maxIndex ( last index indexed). the problem w that is that u dont run that index because it was moved after the iondex was looped. So to gain back that index that wasnt run u just reduce the loop integer. that makes it so that index that wouldve been skipped is now covered accordingly.

wow :D
 
ok to try to simplify

u have 1, 2, 3, 4, 5 indexed and running in a loop

for some reason number 3 ends.
so we remove it
now we have this
1, 2, , 4, 5
a blank spot.
now we de-index and have this and reduce the maxIndex variable
1, 2, 5, 4
the problem is the loop integer is 3 and will be 4 the next time it goes to the top of the loop.

this will make it so number 5 never ran this time period.
so we reduce the integer. now number 5 which is in the 3rd indexed spot will now run. just like it was meant to this time period
 
Level 18
Joined
May 11, 2012
Messages
2,103
Hey, here I made another spell Storm Hammer
Hope now it's all ok? Because ingame it works flawlessly :D

  • Storm Hammer Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Storm Hammer
    • Actions
      • Set MaxIndexStormHammer = (MaxIndexStormHammer + 1)
      • Set StormHammer_TrigUnit[MaxIndexStormHammer] = (Triggering unit)
      • Set StormHammer_TargetUnit[MaxIndexStormHammer] = (Target unit of ability being cast)
      • Set TempPoint = (Position of StormHammer_TrigUnit[MaxIndexStormHammer])
      • Set TempPoint2 = (Position of StormHammer_TargetUnit[MaxIndexStormHammer])
      • Unit - Create 1 Dummy Storm Hammer for (Owner of StormHammer_TrigUnit[MaxIndexStormHammer]) at TempPoint facing TempPoint2
      • Set StormHammer_Dummy[MaxIndexStormHammer] = (Last created unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MaxIndexStormHammer Equal to 1
        • Then - Actions
          • Trigger - Turn on Storm Hammer Loop <gen>
        • Else - Actions
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call RemoveLocation(udg_TempPoint2)
  • Storm Hammer Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer TempInt) from 1 to MaxIndexStormHammer, do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of StormHammer_Dummy[TempInt])
          • Set TempPoint2 = (Position of StormHammer_TargetUnit[TempInt])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between TempPoint and TempPoint2) Less than or equal to 75.00
            • Then - Actions
              • Unit - Kill StormHammer_Dummy[TempInt]
              • Unit - Remove StormHammer_Dummy[TempInt] from the game
              • Set TempUnitGroup = (Units within 350.00 of TempPoint2 matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is dead) Equal to False)) and (((Matching unit) belongs to an enemy of (Owner of StormHammer_TrigUnit[TempInt])) Equal to True)))
              • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
                • Loop - Actions
                  • Unit - Create 1 Dummy Stunner for (Owner of StormHammer_TrigUnit[TempInt]) at TempPoint2 facing (Facing of (Picked unit)) degrees
                  • Set TempDummyUnit = (Last created unit)
                  • Unit - Add a 0.50 second Generic expiration timer to TempDummyUnit
                  • Unit - Add Dummy Storm Hammer to TempDummyUnit
                  • Unit - Set level of Dummy Storm Hammer for TempDummyUnit to (Level of Storm Hammer for StormHammer_TrigUnit[TempInt])
                  • Unit - Order TempDummyUnit to Human Mountain King - Storm Bolt (Picked unit)
              • Custom script: call DestroyGroup(udg_TempUnitGroup)
              • Set StormHammer_TrigUnit[TempInt] = StormHammer_TrigUnit[MaxIndexStormHammer]
              • Set StormHammer_TrigUnit[MaxIndexStormHammer] = No unit
              • Set StormHammer_TargetUnit[TempInt] = StormHammer_TargetUnit[MaxIndexStormHammer]
              • Set StormHammer_TargetUnit[MaxIndexStormHammer] = No unit
              • Set StormHammer_Dummy[TempInt] = StormHammer_Dummy[MaxIndexStormHammer]
              • Set StormHammer_Dummy[MaxIndexStormHammer] = No unit
              • Set MaxIndexStormHammer = (MaxIndexStormHammer - 1)
            • Else - Actions
              • Set TempPoint3 = (TempPoint offset by 25.00 towards (Angle from TempPoint to TempPoint2) degrees)
              • Unit - Move StormHammer_Dummy[TempInt] instantly to TempPoint3, facing (Angle from TempPoint to TempPoint2) degrees
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MaxIndexStormHammer Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
              • Custom script: call RemoveLocation(udg_TempPoint3)
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint2)
 
Status
Not open for further replies.
Top