Triggered lightning shield graphic

averes

New Member
Reaction score
17
If this should go in the JASS forum then sorry about that, but regardless, I'm trying to make a "lightning shield graphic" where the orbs rotate through triggers so that I can increase/decrease the speed of rotation. I know how to make a single object rotate around something, but I'm drawing a blank as to how to get 3 objects rotate around a unit that make it look like a lightning shield (even distance, ect)
 

noworries

New Member
Reaction score
4
Alright, I didn't know if you wanted this multi unit, or multi player, or what, so what I wrote up I believe is multi-player instanced, meaning each player can use it at the same time. At least, it works in single player!

So, two triggers total, 5 variables.

First Trigger.

Code:
Start Cast
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Slam (Neutral Hostile)
    Actions
        Set unit_RotateAround[(Player number of (Owner of (Casting unit)))] = (Casting unit)
        Set LightningShieldOn[(Player number of (Owner of (Casting unit)))] = True
        Set tempPoint = (Position of (Casting unit))
        Unit - Create 1 Wisp for (Owner of (Casting unit)) at (tempPoint offset by 50.00 towards 0.00 degrees) facing Default building facing degrees
        Unit - Add a 30.00 second Generic expiration timer to (Last created unit)
        Set unit_WispRotation[((Player number of (Owner of (Casting unit))) + 12)] = (Last created unit)
        Set real_WispRotation[((Player number of (Owner of (Casting unit))) + 12)] = 1.00
        Unit - Create 1 Wisp for (Owner of (Casting unit)) at (tempPoint offset by 50.00 towards 120.00 degrees) facing Default building facing degrees
        Unit - Add a 30.00 second Generic expiration timer to (Last created unit)
        Set unit_WispRotation[((Player number of (Owner of (Casting unit))) + 25)] = (Last created unit)
        Set real_WispRotation[((Player number of (Owner of (Casting unit))) + 25)] = 121.00
        Unit - Create 1 Wisp for (Owner of (Casting unit)) at (tempPoint offset by 50.00 towards 240.00 degrees) facing Default building facing degrees
        Unit - Add a 30.00 second Generic expiration timer to (Last created unit)
        Set unit_WispRotation[((Player number of (Owner of (Casting unit))) + 37)] = (Last created unit)
        Set real_WispRotation[((Player number of (Owner of (Casting unit))) + 37)] = 241.00
        Custom script:   call RemoveLocation( udg_tempPoint )

I chose to use wisps to rotate around, I saved them as the player number + 12/25/37 because those numbers can't be repeated with adding player numbers to them(i think.) Also, they start out at 0/120/240 because thats the same as 120/240/360(which is 360 divided by 3)

Next trigger..

Code:
Rotation
    Events
        Time - Every 0.03 seconds of game time
    Conditions
        (Number of units in (Units of type Wisp)) Greater than 0
    Actions
        For each (Integer A) from 1 to 12, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        LightningShieldOn[(Integer A)] Equal to True
                    Then - Actions
                        Set tempPoint = (Position of unit_RotateAround[(Integer A)])
                        Unit - Move unit_WispRotation[((Integer A) + 12)] instantly to (tempPoint offset by 50.00 towards real_WispRotation[((Integer A) + 12)] degrees), facing Default building facing degrees
                        Set real_WispRotation[((Integer A) + 12)] = (real_WispRotation[((Integer A) + 12)] + 3.00)
                        Unit - Move unit_WispRotation[((Integer A) + 25)] instantly to (tempPoint offset by 50.00 towards real_WispRotation[((Integer A) + 25)] degrees), facing Default building facing degrees
                        Set real_WispRotation[((Integer A) + 25)] = (real_WispRotation[((Integer A) + 13)] + 3.00)
                        Unit - Move unit_WispRotation[((Integer A) + 37)] instantly to (tempPoint offset by 50.00 towards real_WispRotation[((Integer A) + 37)] degrees), facing Default building facing degrees
                        Set real_WispRotation[((Integer A) + 37)] = (real_WispRotation[((Integer A) + 37)] + 3.00)
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                real_WispRotation[((Integer A) + 12)] Greater than or equal to 359.00
                            Then - Actions
                                Set real_WispRotation[((Integer A) + 12)] = 0.00
                            Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                real_WispRotation[((Integer A) + 25)] Greater than or equal to 359.00
                            Then - Actions
                                Set real_WispRotation[((Integer A) + 25)] = 0.00
                            Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                real_WispRotation[((Integer A) + 37)] Greater than or equal to 359.00
                            Then - Actions
                                Set real_WispRotation[((Integer A) + 37)] = 0.00
                            Else - Actions
                        Custom script:   call RemoveLocation( udg_tempPoint )
                    Else - Actions

Condition to check if at least 1 wisp exists, no reason for it to run when no one is using the ability.

Int 1-12 is for the player numbers, if their boolean is set to true, it will run, basically moves the wisps with Integer A +12/25/37 to their position around the hero +3(you can change.)

If their position becomes greater than 359, its reset to 0.

hope this helps.
 

averes

New Member
Reaction score
17
This helps alot! Thanks! My only question is how could I go about changing the speed at which the wisps move?
 

Flare

Stops copies me!
Reaction score
662
Code:
                        Set real_WispRotation[((Integer A) + 37)] = (real_WispRotation[((Integer A) + 37)] + 3.00)

Change the 3.00. 360*0.03 would give you a full revolution every second.

Also, noworries' trigger leaks locations (point offset by X towards Y takes 1 location (source location) and gives back the end location. noworries only set source location to a variable and cleared it)
 

averes

New Member
Reaction score
17
Code:
                        Set real_WispRotation[((Integer A) + 37)] = (real_WispRotation[((Integer A) + 37)] + 3.00)

Change the 3.00. 360*0.03 would give you a full revolution every second.

Also, noworries' trigger leaks locations (point offset by X towards Y takes 1 location (source location) and gives back the end location. noworries only set source location to a variable and cleared it)

But wouldn't doing that make it only possible to change the speed at the creation of it? What if I wanted it to speed up/slow down after being created.
 

averes

New Member
Reaction score
17
Isn't the .03 periodic timer what states how fast it moves? Are you able to change a trigger event on the fly?
 

averes

New Member
Reaction score
17
Effectively as in not possible? Or just difficult. The main point is being able to speed up or slow down the spinning while its up, otherwise I'd just use a normal lightning shield graphic :/.
 

noworries

New Member
Reaction score
4
You can change the speed to make it go slower, or faster, as he said, by changing the value in that line.

The only problem is making it look natural, once you get over a certain value of the number, it will be look unnatural.

With 3 units spaced out 120 degrees apart, it still looks natural and fast if you set the numbers to 20.

However, if you were to set it to 70, you'd get images from where the units would be, and if you did 120 the units wouldn't appear to rotate at all.


If you want your speed to go up/down after creation, simply replace the amount that is added with a variable. Rather than it being 3, or 20, or whatever, just have it so its.


Set real_WispRotation[((Integer A) + 37)] = (real_WispRotation[((Integer A) + 37)] + RotateAmount)

or something. Then, when you change the RotateAmount, the period trigger will update and move faster or slower.
 

averes

New Member
Reaction score
17
Alright, thanks! Last question is could this be modified to work with many units per player? Such as if each player had X of these? I can just store the rotation speed of each wisp in there custom value but currently it seems this would be setup for multiple players, but only 1 use per player.
 

noworries

New Member
Reaction score
4
Well, I went ahead and tried to make it MUI, which I suppose it is. Up to 999 units using it, I think, which isn't technically MUI, since hypothetically there could be more than 999 units who could use an ability, but it recycles the unused ones, so if slot 3 becomes available but you're at 55, it will use 3 instead of going up to 56, so, I think it should be enough, and you could even come down if you wanted. As for custom speeds, you'll have to come up with that yourself.

Code:
Start Cast Copy
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Slam (Neutral Hostile)
    Actions
        Set LightningShieldOn = True
        For each (Integer A) from 1 to int_CurrentRotations, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        LightningShieldOn Equal to True
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                unit_RotateAround[(Integer A)] Equal to No unit
                            Then - Actions
                                Set LightningShieldOn = False
                                Set unit_RotateAround[(Integer A)] = (Casting unit)
                                Set tempPoint = (Position of (Casting unit))
                                Set tempPoint2 = (tempPoint offset by 50.00 towards 0.00 degrees)
                                Unit - Create 1 Wisp for (Owner of (Casting unit)) at tempPoint2 facing Default building facing degrees
                                Custom script:   call RemoveLocation( udg_tempPoint2 )
                                Unit - Add a 30.00 second Generic expiration timer to (Last created unit)
                                Unit - Set the custom value of (Last created unit) to (Integer A)
                                Set unit_WispRotation[(Integer A)] = (Last created unit)
                                Set real_WispRotation[(Integer A)] = 1.00
                                Set tempPoint2 = (tempPoint offset by 50.00 towards 120.00 degrees)
                                Unit - Create 1 Wisp for (Owner of (Casting unit)) at tempPoint2 facing Default building facing degrees
                                Custom script:   call RemoveLocation( udg_tempPoint2 )
                                Unit - Add a 30.00 second Generic expiration timer to (Last created unit)
                                Set unit_WispRotation[((Integer A) + 1000)] = (Last created unit)
                                Set real_WispRotation[((Integer A) + 1000)] = 121.00
                                Set tempPoint2 = (tempPoint offset by 50.00 towards 240.00 degrees)
                                Unit - Create 1 Wisp for (Owner of (Casting unit)) at tempPoint2 facing Default building facing degrees
                                Custom script:   call RemoveLocation( udg_tempPoint2 )
                                Unit - Add a 30.00 second Generic expiration timer to (Last created unit)
                                Set unit_WispRotation[((Integer A) + 2000)] = (Last created unit)
                                Set real_WispRotation[((Integer A) + 2000)] = 241.00
                                Custom script:   call RemoveLocation( udg_tempPoint )
                            Else - Actions
                    Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                LightningShieldOn Equal to True
            Then - Actions
                Set LightningShieldOn = False
                Set int_CurrentRotations = (int_CurrentRotations + 1)
                Set unit_RotateAround[int_CurrentRotations] = (Casting unit)
                Set tempPoint = (Position of (Casting unit))
                Set tempPoint2 = (tempPoint offset by 50.00 towards 0.00 degrees)
                Unit - Create 1 Wisp for (Owner of (Casting unit)) at (tempPoint offset by 50.00 towards 0.00 degrees) facing Default building facing degrees
                Custom script:   call RemoveLocation( udg_tempPoint2 )
                Unit - Add a 30.00 second Generic expiration timer to (Last created unit)
                Unit - Set the custom value of (Last created unit) to int_CurrentRotations
                Set unit_WispRotation[int_CurrentRotations] = (Last created unit)
                Set real_WispRotation[int_CurrentRotations] = 1.00
                Set tempPoint2 = (tempPoint offset by 50.00 towards 120.00 degrees)
                Unit - Create 1 Wisp for (Owner of (Casting unit)) at (tempPoint offset by 50.00 towards 120.00 degrees) facing Default building facing degrees
                Custom script:   call RemoveLocation( udg_tempPoint2 )
                Unit - Add a 30.00 second Generic expiration timer to (Last created unit)
                Set unit_WispRotation[(int_CurrentRotations + 1000)] = (Last created unit)
                Set real_WispRotation[(int_CurrentRotations + 1000)] = 121.00
                Set tempPoint2 = (tempPoint offset by 50.00 towards 240.00 degrees)
                Unit - Create 1 Wisp for (Owner of (Casting unit)) at (tempPoint offset by 50.00 towards 240.00 degrees) facing Default building facing degrees
                Custom script:   call RemoveLocation( udg_tempPoint2 )
                Unit - Add a 30.00 second Generic expiration timer to (Last created unit)
                Set unit_WispRotation[(int_CurrentRotations + 2000)] = (Last created unit)
                Set real_WispRotation[(int_CurrentRotations + 2000)] = 241.00
                Custom script:   call RemoveLocation( udg_tempPoint )
            Else - Actions

Basically, it sets a boolean to true, which will determine if anything can be created, this is needed because the For Integer A would run multiple times without it, the integer A checks to the maximum count of rotations running, and assigns it to the first one that is free, sets the variable to off, which stops the next part from running. If none are free, variable stays true, and it creates the unit while adding 1 to the counter.

Code:
Rotation Copy
    Events
        Time - Every 0.03 seconds of game time
    Conditions
        (Number of units in (Units of type Wisp)) Greater than 0
    Actions
        For each (Integer A) from 1 to int_CurrentRotations, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        unit_RotateAround[(Integer A)] Not equal to No unit
                    Then - Actions
                        Set tempPoint = (Position of unit_RotateAround[(Integer A)])
                        Set tempPoint2 = (tempPoint offset by 50.00 towards real_WispRotation[(Integer A)] degrees)
                        Unit - Move unit_WispRotation[(Integer A)] instantly to tempPoint2, facing Default building facing degrees
                        Custom script:   call RemoveLocation( udg_tempPoint2 )
                        Set real_WispRotation[(Integer A)] = (real_WispRotation[(Integer A)] + 3.00)
                        Set tempPoint2 = (tempPoint offset by 50.00 towards real_WispRotation[((Integer A) + 1000)] degrees)
                        Unit - Move unit_WispRotation[((Integer A) + 1000)] instantly to tempPoint2, facing Default building facing degrees
                        Custom script:   call RemoveLocation( udg_tempPoint2 )
                        Set real_WispRotation[((Integer A) + 1000)] = (real_WispRotation[((Integer A) + 1000)] + 3.00)
                        Set tempPoint2 = (tempPoint offset by 50.00 towards real_WispRotation[((Integer A) + 2000)] degrees)
                        Unit - Move unit_WispRotation[((Integer A) + 2000)] instantly to (tempPoint offset by 50.00 towards real_WispRotation[((Integer A) + 2000)] degrees), facing Default building facing degrees
                        Custom script:   call RemoveLocation( udg_tempPoint2 )
                        Set real_WispRotation[((Integer A) + 2000)] = (real_WispRotation[((Integer A) + 2000)] + 3.00)
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                real_WispRotation[(Integer A)] Greater than or equal to 359.00
                            Then - Actions
                                Set real_WispRotation[(Integer A)] = 0.00
                            Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                real_WispRotation[((Integer A) + 1000)] Greater than or equal to 359.00
                            Then - Actions
                                Set real_WispRotation[((Integer A) + 1000)] = 0.00
                            Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                real_WispRotation[((Integer A) + 2000)] Greater than or equal to 359.00
                            Then - Actions
                                Set real_WispRotation[((Integer A) + 2000)] = 0.00
                            Else - Actions
                        Custom script:   call RemoveLocation( udg_tempPoint )
                    Else - Actions

The same as before, just integer A's are changed.

Code:
Subtraction
    Events
        Unit - A unit Dies
    Conditions
        (Unit-type of (Dying unit)) Equal to Wisp
    Actions
        Set unit_RotateAround[(Custom value of (Dying unit))] = No unit
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Custom value of (Dying unit)) Equal to int_CurrentRotations
            Then - Actions
                Set int_CurrentRotations = (int_CurrentRotations - 1)
            Else - Actions

This is where the removal happens. It only checks for the first wisp since the first wisp created for every unit is the only one given a custom value. It also checks if the custom value is the max of int_CurrentRotations, and if so it sets the max - 1.


This should work, I've been testing it out, and its working fine for me, but if you need help understanding anything else, lemme know.
 

averes

New Member
Reaction score
17
Im able to make it circle around one unit, however when I have 2 units (both are owned by player 1) on the map, only the first one circles. I removed the experation timers and never added the removal trigger as the orbs are never actually going to go away, any idea why this might happen?

EDIT: Nvm got it working. Thanks!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top