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

Lightning Issues

Status
Not open for further replies.
Level 11
Joined
Mar 18, 2009
Messages
788
So, I'm creating a trigger for a spell that I am currently making and the visual effect is multiply Lightning effects from the casting units position to his enemies position. The problem is that I cant manage to get the function MUI.
Here are the triggers I have done so far:

[trigger=Lightning]Lightning
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to EXSPELL
Actions
Set TempUnit = (Triggering unit)
Hashtable - Save 80 as (Key Handl) of 4 in Hash
Hashtable - Save Handle Of(Units within 500.00 of (Position of TempUnit) matching ((((Triggering player) is an enemy of (Owner of (Matching unit))) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Unit-type of (Matching unit)) is Mechanical) Not equal to True))) as (Key (Triggering unit)) of 1 in Hash
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in Group) Equal to 0
Then - Actions
Trigger - Turn on Lightning loop <gen>
Unit Group - Add TempUnit to Group
Else - Actions
Unit Group - Add TempUnit to Group[/trigger]

[trigger=Lightning Loop]Lightning loop
Events
Time - Every 0.05 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in Group and do (Actions)
Loop - Actions
Set TempUnit = (Picked unit)
Set Handle = (Picked unit)
Hashtable - Save Handle Of(Position of (Picked unit)) as (Key Handle) of 2 in Hash
Hashtable - Save ((Load (Key Handle) of 4 from Hash) - 1) as (Key Handle) of 4 in Hash
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Load (Key Handle) of 4 from Hash) Not equal to 0
Then - Actions
Unit Group - Pick every unit in (Load (Key Handle) of 1 in Hash) and do (Actions)
Loop - Actions
Hashtable - Save Handle Of(Position of (Picked unit)) as (Key (Picked unit)) of (Key Handle) in Hash
Set Lightning = (Load (Key (Picked unit)) of 3 in Hash)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Distance between (Load (Key (Picked unit)) of (Key Handle) in Hash) and (Load (Key Handle) of 2 in Hash)) Less than or equal to 500.00
((Picked unit) is alive) Equal to True
Then - Actions
Lightning - Destroy Lightning
Lightning - Create a Drain Life lightning effect from source (Load (Key (Picked unit)) of (Key Handle) in Hash) to target (Load (Key Handle) of 2 in Hash)
Hashtable - Save Handle Of(Last created lightning effect) as (Key (Picked unit)) of 3 in Hash
Else - Actions
Lightning - Destroy Lightning
Unit Group - Remove (Picked unit) from (Load (Key Handle) of 1 in Hash)
Else - Actions
Unit Group - Pick every unit in (Load (Key Handle) of 1 in Hash) and do (Actions)
Loop - Actions
Set Lightning = (Load (Key (Picked unit)) of 3 in Hash)
Lightning - Destroy Lightning
Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathCoil\DeathCoilSpecialArt.mdl
Special Effect - Destroy (Last created special effect)
Unit Group - Remove (Picked unit) from (Load (Key Handle) of 1 in Hash)
Unit Group - Remove TempUnit from Group
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in Group) Equal to 0
Then - Actions
Trigger - Turn off (This trigger)
Else - Actions[/trigger]

I removed all other function within these two triggers since they already work.
REP to those who help me out with this, some will be added to the credit list to. =)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
*The handle should be an integer
*Fixed leaks
*The handle integer should be the parent key
*You don't need to store the locations (if I understood the spell correctly)
*Remember to flush child hashtables

And a few other things I forgot.

The spell should now work as intended: However it is not fully MUI since you're keying the lightnings for the targets. When another caster cast the spell on units that already are affected by it, the lightnings will be overwritten.

I could have fixed that but I thought it would be a good learning opportunity for you to think of a way to make it MUI.

http://www.hiveworkshop.com/forums/pastebin.php?id=0k73ji
 
Last edited:
Level 11
Joined
Mar 18, 2009
Messages
788
Thanks a lot Maker :D

So only the Lightnings left? Well that will make it easier for me to find the solution. :)

EDIT: I solved it! :D
First I changed the keys in which the Lightning was stored in, then I added another Hashtable Integer to each affected unit that would count how many casting units that have him bound by the spell, if the Integer went down to 0 it cleared out all Child hash from the unit :grin:

First trigger:
  • Set SSUnitIndex[(Load 4 of (Key (Picked unit)) from SSHash)] = (SSUnitIndex[(Load 4 of (Key (Picked unit)) from SSHash)] + 1)
Loop trigger (from the part when the unit is removed from the spell):
  • Set SSUnitIndex[(Load 4 of (Key (Picked unit)) from SSHash)] = (SSUnitIndex[(Load 4 of (Key (Picked unit)) from SSHash)] - 1)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Load 4 of (Key (Picked unit)) from SSHash) Equal to 0
    • Then - Actions
      • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in SSHash
    • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top