• 🏆 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!

Wc3 lightning Effects

Status
Not open for further replies.
Level 4
Joined
Oct 6, 2009
Messages
85
hi i got a problem of lightning effects ok here is the trigger


  • problem
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to I dont know
    • Actions
      • Set ang = 0.00
      • Set dist = 500.00
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Lightning - Create a Chain Lightning - Primary lightning effect from source (Position of (Triggering unit)) to target ((Position of (Triggering unit)) offset by dist towards ang degrees)
          • Unit - Create 1 Column Uryuu for Neutral Passive at ((Position of (Triggering unit)) offset by dist towards ang degrees) facing (Angle from (Position of (Last created unit)) to (Position of (Triggering unit))) degrees
          • Unit - Add a 2.10 second Generic expiration timer to (Last created unit)
          • Set ang = (ang + 32.00)
      • Unit Group - Pick every unit in (Units within 400.00 of (Position of Caster_Unit) matching (((Matching unit) belongs to an enemy of (Owner of Caster_Unit)) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit - Cause Caster_Unit to damage (Picked unit), dealing 5000.00 damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
          • Special Effect - Destroy (Last created special effect)
      • Unit - Create 1 Explozion for Neutral Passive at (Position of Caster_Unit) facing Default building facing degrees
      • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
      • Set Caster_Unit = No unit
      • Set ang = 0.00
what i want is after a 3 seconds to remove the created lightning effects but i tried removing lightning effect but only removes 1 si i realy need your help tnx in advance
 
Level 4
Joined
Oct 6, 2009
Messages
85
oh never mind i already got it

i did is

  • For each (Integer A) from 1 to 11, do (Actions)
    • Loop - Actions
      • Lightning - Create a Chain Lightning - Primary lightning effect from source (Position of (Triggering unit)) to target ((Position of (Triggering unit)) offset by dist towards ang degrees)
      • Set LightningEffect[((Integer A) + 1)] = (Last created lightning effect)
      • Unit - Create 1 Column Uryuu for Neutral Passive at ((Position of (Triggering unit)) offset by dist towards ang degrees) facing (Angle from (Position of (Last created unit)) to (Position of (Triggering unit))) degrees
      • Unit - Add a 2.10 second Generic expiration timer to (Last created unit)
      • Set ang = (ang + 32.00)
  • Wait 2.00 seconds
  • For each (Integer A) from 1 to 11, do (Actions)
    • Loop - Actions
      • Lightning - Destroy LightningEffect[((Integer A) + 1)]

Correct me if somethings wrong but it worked nice for me
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
You want this done the good or the bad way?

The bad (easy) way would be:

  • Set lightningEffect[(Integer A)] = (Last created lightning effect)
Put this behind the create lightning-action.


  • Wait 3.00 game-time seconds
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • Lightning - Destroy lightningEffect[(Integer A)]
Put this at the end of the trigger.

Why is this bad? Because it's not MUI (not even MPI), so if you cast it more than once at the same time, it will bug.


The good way involves timers and either hashtable or indexing. Or you could abuse local variables.


Edit: Seems like you got it before me, but why "integer A + 1"? Why not just "Integer A"?
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Read post above, however if you do not wish this to be MUi there is also one leak:
  • Unit - Create 1 Column Uryuu for Neutral Passive at ((Position of (Triggering unit)) offset by dist towards ang degrees) facing (Angle from (Position of (Last created unit)) to (Position of (Triggering unit))) degrees
Position of Triggering unit/last created unit leaks, set them as variables and after using use custom script call RemoveLocation (udg_your_loc).
 
Level 4
Joined
Oct 6, 2009
Messages
85
ok tnx but i dont get cause im a total noob so can you make screeny for me and yeah the unit already fixed it :ogre_hurrhurr:
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
I neither understand you.
If you talk about locations as leaks (first you should read about leaks as whole to get better understanding of what they are) refering to Position of X orders to automaticaly create given point and save it in memory. Remember that after your action is done this position is useless and because you didnt set it to variable it will remain there for the rest of the game (WHICH is bad, with high amount of leaks you get spikes/lag).

Solution:
Instead of Position of X - you use action: Set Variable and choose your_pointvariable (type of variable: point) you created before (you have to, to be able to choose it here). Use it in place of Postion of X within action about creating units.
Immidiately after using your variable, call action that gets rid of this leak. It's Custom Script (at the begining of actions list), and write this line: call RemoveLocation(udg_yourvariable), press enter.
 
Level 4
Joined
Oct 6, 2009
Messages
85
ohhh yeah i know that but what i mean is the lightning effect that apocalyps said about hashtables how do you do that plzz tell me how ^^ to avoid bugs
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Hmh, okay.

You probably already have a trigger with the event "map initialization".
Add these two actions to it:
  • Hashtable - Create a hashtable
  • Set skillTable = (Last created hashtable)
Then add this action to the top of your ability-trigger:
  • Set handleId = (Key (Triggering unit))
Still in your ability-trigger, add this right below creating the lightning effects (inside the loop):
  • Hashtable - Save Handle Of(Last created lightning effect) as (Integer A) of handleId in skillTable
And right behind the loop, add these actions:
  • Hashtable - Save 2.00 as 0 of handleId in skillTable
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • skillCount Equal to 0
    • Then - Actions
      • Trigger - Turn on Loop <gen>
    • Else - Actions
  • Set skillCount = (skillCount + 1)
  • Unit Group - Add (Triggering unit) to skillGroup
Note: the "2.00" in here is the time before the effects get removed!

Now you have to create a new initially disabled trigger (as seen in the previous actions, I called it "Loop").
It goes like this:

  • Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in skillGroup and do (Actions)
        • Loop - Actions
          • Set handleId = (Key (Picked unit))
          • Set tempReal = ((Load 0 of handleId from skillTable) - 0.05)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • tempReal Less than or equal to 0.00
            • Then - Actions
              • For each (Integer A) from 1 to 10, do (Actions)
                • Loop - Actions
                  • Lightning - Destroy (Load (Integer A) of handleId in skillTable)
              • Unit Group - Remove (Picked unit) from skillGroup
              • Set skillCount = (skillCount - 1)
              • Hashtable - Clear all child hashtables of child handleId in skillTable
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • skillCount Less than or equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • Hashtable - Save tempReal as 0 of handleId in skillTable

That's what it takes to create a bug-free spell. And this was rather easy (all I had to do was count down a variable from 2 to 0).
 
Status
Not open for further replies.
Top