• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Problem with moving dummies.

Status
Not open for further replies.
Level 14
Joined
Aug 8, 2010
Messages
1,022
Hello! I have a pretty major problem. I thought i will solve it easy at first, but then i realized that this will be one hell of a job...

In my leakless MUI spell (although if there is somewhere a leak - tell me please) i have a custom chain lightning. Everything works fine, it's MUI. But if the units affected by the lightnings are moving, the lightnings somehow stay in one place and don't move with the units, affected by the spell (it looks like the lightnings come up from nowhere). I know that this is because the dummies that cast the secondary lightnings (the bouncing lightnings) arn't moving. And the problem is in the way to make those dummies move with the unit, at which they are created. I tried many things, but i failed.

Triggers :
  • Chain Shock Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Chain Shock [Dummy]
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ChainID2 Equal to 0
        • Then - Actions
          • Trigger - Turn on Chain Shock Loop <gen>
        • Else - Actions
      • Set ChainID2 = (ChainID2 + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ChainID2 Greater than ChainIDMax
        • Then - Actions
          • Set ChainID[ChainID2] = ChainID2
          • Set ChainIDMax = ChainID2
        • Else - Actions
      • Set ChainArray = ChainID[ChainID2]
      • Set ChainBounceArray[ChainArray] = 0
      • Set ChainGroupCheck[ChainArray] = 0
      • Set ChainCaster[ChainArray] = (Triggering unit)
      • Set ChainBounceDelay = 0.80
      • Set ChainDelay[ChainArray] = ChainBounceDelay
      • Set ChainAbilityLevel[ChainArray] = (Level of Chain Shock [Dummy] for (Triggering unit))
      • Set ChainBounces[ChainArray] = (5 + (1 x ChainAbilityLevel[ChainArray]))
      • Set ChainTarget[ChainArray] = (Target unit of ability being cast)
      • Set ChainTargetPos[ChainArray] = (Position of ChainTarget[ChainArray])
      • Set ChainShockedUnit[ChainArray] = ChainTarget[ChainArray]
      • Set ChainBouncePoint[ChainArray] = ChainTargetPos[ChainArray]
      • Unit - Cause (Triggering unit) to damage ChainTarget[ChainArray], dealing (50.00 + (50.00 x (Real(ChainAbilityLevel[ChainArray])))) damage of attack type Spells and damage type Lightning
      • Custom script: call RemoveLocation(udg_ChainTargetPos[udg_ChainArray])
  • Chain Shock Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer ChainLoop) from 1 to ChainID2, do (Actions)
        • Loop - Actions
          • Set ChainArray = ChainID[ChainLoop]
          • Set ChainDelay[ChainArray] = (ChainDelay[ChainArray] - 0.03)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ChainBounces[ChainArray] Equal to 0
            • Then - Actions
              • Set ChainID[ChainLoop] = ChainID[ChainID2]
              • Set ChainID[ChainID2] = ChainArray
              • Set ChainID2 = (ChainID2 - 1)
              • Set ChainLoop = (ChainLoop - 1)
              • Game - Display to (All players) the text: End
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ChainDelay[ChainArray] Less than or equal to 0.00
            • Then - Actions
              • Set ChainBouncePoint[ChainArray] = (Position of ChainShockedUnit[ChainArray])
              • Set ChainUnitGroup[ChainArray] = (Units within 500.00 of ChainBouncePoint[ChainArray] matching ((((Matching unit) belongs to an ally of (Owner of ChainCaster[ChainArray])) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Not equal to Dummy))
              • Unit Group - Pick every unit in ChainUnitGroup[ChainArray] and do (Actions)
                • Loop - Actions
                  • Set ChainGroupCheck[ChainArray] = (ChainGroupCheck[ChainArray] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ChainGroupCheck[ChainArray] Less than or equal to 1
                • Then - Actions
                  • Set ChainID[ChainLoop] = ChainID[ChainID2]
                  • Set ChainID[ChainID2] = ChainArray
                  • Set ChainID2 = (ChainID2 - 1)
                  • Set ChainLoop = (ChainLoop - 1)
                  • Game - Display to (All players) the text: End
                  • Custom script: call DestroyGroup(udg_ChainUnitGroup[udg_ChainArray])
                  • Custom script: call RemoveLocation(udg_ChainBouncePoint[udg_ChainArray])
                  • Skip remaining actions
                • Else - Actions
                  • Set ChainGroupCheck[ChainArray] = 0
              • Unit Group - Remove ChainShockedUnit[ChainArray] from ChainUnitGroup[ChainArray]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (ChainUnitGroup[ChainArray] is empty) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (ChainShockedUnit[ChainArray] is alive) Equal to True
                    • Then - Actions
                      • Unit Group - Add ChainShockedUnit[ChainArray] to ChainUnitGroup[ChainArray]
                    • Else - Actions
                • Else - Actions
              • Set ChainShockedUnit[ChainArray] = (Random unit from ChainUnitGroup[ChainArray])
              • Unit - Create 1 Dummy for (Owner of ChainCaster[ChainArray]) at ChainBouncePoint[ChainArray] facing Default building facing degrees
              • Set ChainDummy[ChainArray] = (Last created unit)
              • Unit - Add a 0.40 second Generic expiration timer to ChainDummy[ChainArray]
              • Unit - Add Chain Shock Secondary [Dummy] to ChainDummy[ChainArray]
              • Unit - Order ChainDummy[ChainArray] to Special Archimonde - Finger Of Death ChainShockedUnit[ChainArray]
              • Unit - Cause ChainDummy[ChainArray] to damage ChainShockedUnit[ChainArray], dealing (25.00 + (25.00 x (Real(ChainAbilityLevel[ChainArray])))) damage of attack type Spells and damage type Lightning
              • Game - Display to (All players) the text: Daayum
              • Set ChainBounces[ChainArray] = (ChainBounces[ChainArray] - 1)
              • Set ChainDelay[ChainArray] = ChainBounceDelay
              • Custom script: call DestroyGroup(udg_ChainUnitGroup[udg_ChainArray])
              • Custom script: call RemoveLocation(udg_ChainBouncePoint[udg_ChainArray])
            • Else - Actions
Help will be appreciated with a +rep! Thanks in advance!

I will upload my spell, so you can see what is happening
 
Last edited:
Level 26
Joined
Aug 18, 2009
Messages
4,097
The test map does not include any try to move the dummy units. You would save the last target/caster and preferably set the dummy's position with SetUnitX/Y to not interrupt orders. Also your dummy should have Locust (Aloc) ability to ignore collisions, not be enumerated etc.
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
I didn't showed how i move the dummies because i wanted to show how awful it looks when the units are moving. Also, my dummies don't have Locust because i think that dummies with Locust can't cast spells. And finally - yes, my dummy has a speed of 0, but it moves, so that isn't the problem. I use the custom scripts to set the coordinates of the dummies to X and Y, but i still have problems. And that problem is that i can't capture the right point in a variable and then move the dummy to that variable.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Locusts can cast spells. Units with 0 move speed do not update their graphics when being moved by SetUnitX/Y. Do not know whether this influences such lightnings. You should not capture a point but the last striked unit (before picking a new one) and the caster should be the initial value.
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
Yes, that's what i tried before writing that thread and the problem is right there, you said it :
onNewTarget: set sourceUnit = target, then set target = whatever you pick as new

Because i clear "sourceUnit" every loop with a custom script, i need to set that "sourceUnit" variable in the trigger. I can't set it to "target" because after the spell bounces, the target changes, and the result is - the dummy above the unit that is under the effect of the bounce (the dummy is over the unit = no visible lightning). The whole thing works if i let a leak. :/

EDIT : @PurplePoot - one question : how? Can you show me, please? I have never heard of creating and updating lightning effects... o_O
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
In GUI, they're under the category "lightning". You still have to move them periodically via "Move Lightning Effect" to stay on top of the units they "hit", but it's easier than worrying about all the complications introduced by dummy units and doesn't contribute any complexity to counterbalance that.

One thing to note is that you'll want to fade them manually for it to look good, but since you already need to be periodically updating their position that shouldn't be too much of a hassle.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Avoid dummy units if at all possible; they introduce an unnecessary element of complexity to your code. In this case you could accomplish the same thing by creating and updating lightning effects.

Ability lightnings consider impact and outpact graphic values.

I can't set it to "target" because after the spell bounces, the target changes, and the result is - the dummy above the unit that is under the effect of the bounce

You know when the target changes because you wrote that line yourself. Before that line but in the same iteration, the variable contains the old target.

So first set lastTarget = target, afterwards target = <newTarget>

When setting lastTarget, you do not make a reference to the variable target but only read the current information behind it. lastTarget won't automatically change when you set target to <newTarget>.
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
@PurplePoot - i see, i see. I have checked that Lightning section in GUI. But i have to remake my spell if i am going to use this. I am lazy, this is the problem. :D I will have this in mind for future spells! Thanks! :)

EDIT : I was so close to success... damn. Thanks tough, to both of you! Everything is working perfect now!
 
Last edited:
Status
Not open for further replies.
Top