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

Fade System v1.3

Description
A fade system which uses hashtables for MUI-ness.
This is easy to implement and only contains few lines of codes.
This is made in GUI.

After lurking in hive for a couple of years, I finally decided to contribute and I don't know why. Give credits if used :wink:
How to use
1. Copy paste the triggers in the Fade System category into your map.
2. Copy/Recreate the associated variables.
3. The template for adding a unit for fading is in the "AddUnitTemplate" trigger.
Triggers
  • FadeSystemInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --------
      • -------- Add this to your map initialization --------
      • -------- It simply initializes the hashtable for the system --------
      • -------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --------
      • Hashtable - Create a hashtable
      • Set FadeSystemHash = (Last created hashtable)
  • FSMainLoop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • -------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --------
      • -------- This is the main loop. It's pretty basic as long as you know hashtables. --------
      • -------- There's no need to change anything here except the timer (if you wanna make it tick faster maybe) --------
      • -------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --------
      • Unit Group - Pick every unit in FadeSystemGroup and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • Custom script: set udg_FadeUnitKey = GetHandleId(udg_TempUnit)
          • Set TempBool = (Load FadeUnitKey of (Key FadeIn) from FadeSystemHash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempBool Equal to True
            • Then - Actions
              • Hashtable - Save ((Load FadeUnitKey of (Key FadeStart) from FadeSystemHash) - (Load FadeUnitKey of (Key FadeSpeed) from FadeSystemHash)) as FadeUnitKey of (Key FadeStart) in FadeSystemHash
            • Else - Actions
              • Hashtable - Save ((Load FadeUnitKey of (Key FadeStart) from FadeSystemHash) + (Load FadeUnitKey of (Key FadeSpeed) from FadeSystemHash)) as FadeUnitKey of (Key FadeStart) in FadeSystemHash
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load FadeUnitKey of (Key FadeTinted) from FadeSystemHash) Equal to True
            • Then - Actions
              • Animation - Change TempUnit's vertex coloring to ((Load FadeUnitKey of (Key FadeRed) from FadeSystemHash)%, (Load FadeUnitKey of (Key FadeGreen) from FadeSystemHash)%, (Load FadeUnitKey of (Key FadeBlue) from FadeSystemHash)%) with (Load FadeUnitKey of (Key FadeStart) from FadeSystemHash)% transparency
            • Else - Actions
              • Animation - Change TempUnit's vertex coloring to (100.00%, 100.00%, 100.00%) with (Load FadeUnitKey of (Key FadeStart) from FadeSystemHash)% transparency
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((TempBool Equal to True) and ((Load FadeUnitKey of (Key FadeStart) from FadeSystemHash) Less than or equal to (Load FadeUnitKey of (Key FadeEnd) from FadeSystemHash))) or ((TempBool Equal to False) and ((Load FadeUnitKey of (Key FadeStart) from FadeSystemHash) Greater than or equal to (Load FadeUnitKey of (Key FadeEnd) from FadeSystemHash)))
            • Then - Actions
              • Unit Group - Remove TempUnit from FadeSystemGroup
              • Hashtable - Clear all child hashtables of child FadeUnitKey in FadeSystemHash
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in FadeSystemGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
  • FSAddUnit
    • Events
    • Conditions
    • Actions
      • Custom script: set udg_FadeUnitKey = GetHandleId(udg_FSUnit)
      • Unit Group - Add FSUnit to FadeSystemGroup
      • Animation - Change FSUnit's vertex coloring to (FSRed%, FSGreen%, FSBlue%) with FSStart% transparency
      • Hashtable - Save FSStart as FadeUnitKey of (Key FadeStart) in FadeSystemHash
      • Hashtable - Save FSEnd as FadeUnitKey of (Key FadeEnd) in FadeSystemHash
      • Hashtable - Save FSSpeed as FadeUnitKey of (Key FadeSpeed) in FadeSystemHash
      • Hashtable - Save FSFadeIn as FadeUnitKey of (Key FadeIn) in FadeSystemHash
      • Hashtable - Save FSTinted as FadeUnitKey of (Key FadeTinted) in FadeSystemHash
      • Hashtable - Save FSRed as FadeUnitKey of (Key FadeRed) in FadeSystemHash
      • Hashtable - Save FSGreen as FadeUnitKey of (Key FadeGreen) in FadeSystemHash
      • Hashtable - Save FSBlue as FadeUnitKey of (Key FadeBlue) in FadeSystemHash
      • Trigger - Turn on FSMainLoop <gen>
      • -------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --------
      • -------- Clearing the variables --------
      • -------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --------
      • Set FSUnit = No unit
      • Set FSStart = 0.00
      • Set FSEnd = 0.00
      • Set FSSpeed = 0.00
      • Set FSFadeIn = False
      • Set FSTinted = False
      • Set FSRed = 0.00
      • Set FSGreen = 0.00
      • Set FSBlue = 0.00
To Use: Set the variables below from your trigger/spell and then call the AddUnit trigger. Most of the time, you'll only be needing to copy the first 5. The other 4 are optional and are used for tinted units. Dont forget add the last action "Run AddUnit"

  • Set FSUnit = (Triggering unit)
  • Set FSStart = 0.00
  • Set FSEnd = 100.00
  • Set FSSpeed = 5.00
  • Set FSFadeIn = False
  • Set FSTinted = False
  • Set FSRed = 0.00
  • Set FSGreen = 0.00
  • Set FSBlue = 0.00
  • Trigger - Run AddUnit <gen> (ignoring conditions)
The variables uses are as follows:
-- Unit FSUnit - The fading unit
-- Real FSStart - The starting opacity (100% = invisible)
-- Real FSEnd - The end opacity
-- Real FSSpeed - The amount of opacity gained/lost every tick (every 0.05 sec)
-- Boolean FSFadeIn - true = if fading in (turn VISIBLE), false = if fading out (turn INVISIBLE) Don't get mixed up on this one
The last value is needed for the system to know if it shall increment/decrement the opacity. (Even thought the start and end opacity is given)
IF your unit is tinted, then fill up the other values. If not, you don't have to put them
-- Boolean FSTinted - true = if the unit is tinted
-- Real FSRed - The amount of red 0-100%
-- Real FSGreen - The amount of green 0-100%
-- Real FSBlue - The amount of blue 0-100%
Note that the object editor requires integer values 0-255 while the trigger editor requires real values. To convert, just simply divide your tint value by 255 and multiply by 100. X/255 * 100.
Possible Uses
-- You can use it with your dummy projectiles to create a fading out effect.
-- You can make summons fade in.
-- You can make pseudo invi skills via fading.
-- You can set the start/end/speed of the fade. Ex: From 25%-90%
-- Anything really, because fading just adds that extra eye candy.
Changelog
- Renamed triggers to be not so "common"
- Added a new trigger to set the unit's initial opacity referenced from the FSStart variable.
- Adding a unit now use variables
- Recoded the handles to use variables instead (As suggested by Mag)
- Fixed couple of errors
- Added tint support
- Fixed the fadein/fadeout boolean. Fade In means turning visible and fade out is turning invisible
- Added an example for tinted units
Keywords:
Fade, System, GUI, MUI, MPI, Easy, Simple, Anti-Mage, Magina, Antimage, Hashtable, Ketchup
Contents

Fade System v1.3 (Map)

Reviews
18:49, 14th Sep 2012 Magtheridon96: Approved. This is a useful, robust system. Good job.

Moderator

M

Moderator

18:49, 14th Sep 2012
Magtheridon96:

Approved.
This is a useful, robust system.
Good job.
 
Level 17
Joined
Jul 17, 2011
Messages
1,863
triggers:
[trigger=initialization]Initialization
Events
Map initialization
Conditions
Actions
Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across (Entire map)
Player - Make Player 1 (Red) treat Player 2 (Blue) as an Ally with shared vision
Player - Make Player 2 (Blue) treat Player 1 (Red) as an Ally with shared vision
Trigger - Run AI1 <gen> (ignoring conditions)
[/trigger]
[trigger=AI1]AI1
Events
Conditions
Actions
Wait (Random real number between 0.00 and 1.00) seconds
Set TempPoint = (Random point in (Entire map))
Unit - Order Anti-Mage 0002 <gen> to Night Elf Warden - Blink TempPoint
Custom script: call RemoveLocation (udg_TempPoint)
Wait (Random real number between 0.00 and 1.00) seconds
Unit - Order Anti-Mage 0002 <gen> to Human Mountain King - Thunder Clap
Trigger - Run (This trigger) (ignoring conditions)
[/trigger]
[trigger=FadeInt]FadeInit
Events
Map initialization
Conditions
Actions
-------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --------
-------- Add this to your map initialization --------
-------- It simply initializes the hashtable for the system --------
-------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --------
Hashtable - Create a hashtable
Set FadeSystemHash = (Last created hashtable)
[/trigger]
[trigger=MainLoop]MainLoop
Events
Time - Every 0.05 seconds of game time
Conditions
Actions
-------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --------
-------- This is the main loop. It's pretty basic as long as you know hashtables. --------
-------- There's no need to change anything here except the timer (if you wanna make it tick faster maybe) --------
-------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --------
Unit Group - Pick every unit in FadeSystemGroup and do (Actions)
Loop - Actions
Set TempBool = (Load (Key (Picked unit)) of (Key FadeIn) from FadeSystemHash)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TempBool Equal to True
Then - Actions
Hashtable - Save ((Load (Key (Picked unit)) of (Key FadeStart) from FadeSystemHash) + (Load (Key (Picked unit)) of (Key FadeSpeed) from (Last created hashtable))) as (Key (Picked unit)) of (Key FadeStart) in FadeSystemHash
Else - Actions
Hashtable - Save ((Load (Key (Picked unit)) of (Key FadeStart) from FadeSystemHash) - (Load (Key (Picked unit)) of (Key FadeSpeed) from (Last created hashtable))) as (Key (Picked unit)) of (Key FadeStart) in FadeSystemHash
Animation - Change (Picked unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with (Load (Key (Picked unit)) of (Key FadeStart) from FadeSystemHash)% transparency
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((TempBool Equal to True) and ((Load (Key (Picked unit)) of (Key FadeStart) from FadeSystemHash) Greater than or equal to (Load (Key (Picked unit)) of (Key FadeEnd) from FadeSystemHash))) or ((TempBool Equal to False) and ((Load (Key (Picked unit)) of (Key FadeStart) from FadeSystemHash) Less than or equal to (Load (Key (Picked unit)) of (Key FadeEnd) from FadeSystemHash)))
Then - Actions
Unit Group - Remove (Picked unit) from FadeSystemGroup
Hashtable - Clear all child hashtables of child (Key (Picked unit)) in FadeSystemHash
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in FadeSystemGroup) Equal to 0
Then - Actions
Trigger - Turn off (This trigger)
Else - Actions
[/trigger]
 
Level 3
Joined
Nov 27, 2008
Messages
29
Yo seriously? This will remove tints on units!

Yea. Completely forgot aobut that. It's updated and now supports tinted units. An example is also present.
There is no way, though, to get the tint from the trigger editor so you have to manually save tinted units' tints in any way (hashtables etc) you want so you can reference them from the trigger editor.

Waits are inconcistent, use timers or MUI generated waits

:ogre_icwydt:
I only used waits for the AI. Kindly check the map and triggers first.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Maybe a system that hides/reveals units!
Why do you use VertexColoring if you can just Hide the unit using the ShowUnit function ?

Also, by pressing ALT bar, you can still see the "faded" unit, lol.
Not unless you disable the HP Bar of a unit.
And not to forget, dots on the minimap.

This system could be useful for making spells with "fade" effect.
 
Level 3
Joined
Nov 27, 2008
Messages
29
Your using Last Created Hashtable... Really

Must have missed that. Look, I was using the hashtable variable in the others so definitely that wasn't intended. Anyway fixed.

Regarding the other thing you said (and what Magtheridon said), I really have no idea. I thought that's actually faster that storing the picked/triggering unit to a variable or other ways. Sorry I really don't get what you are trying to say.

I can read and understand JASS but I can't/don't use it.
 
Last edited:
@crehym:

  • bla bla bla (Picked unit) bla bla bla
  • bla bla bla (Picked unit) bla bla bla
  • bla bla bla (Picked unit) bla bla bla
  • bla bla bla (Picked unit) bla bla bla
  • bla bla bla (Picked unit) bla bla bla
->

  • Set TempUnit = (Picked unit)
  • bla bla bla TempUnit bla bla bla
  • bla bla bla TempUnit bla bla bla
  • bla bla bla TempUnit bla bla bla
  • bla bla bla TempUnit bla bla bla
  • bla bla bla TempUnit bla bla bla
The second trigger is faster.
(Picked unit) calls a function to determine the picked unit.
It's not very efficient to keep redetermining the picked unit, obviously; It's better to store that unit into a variable so we can use the value directly without having to redetermine him in every action.

Not important:

(Of course, at the level of C++, it's just returning a value and doing nothing else, but function calls are slow, while variable lookups are way faster, and because optimizers have the ability to change variable names, they will be even faster in a finished-map. (The shorter the variable names, the faster the system)
Native function names can't be changed.
 
Level 3
Joined
Nov 27, 2008
Messages
29
Oh.

I thought that calling those functions were actually faster because I've read others saying use TriggeringUnit instead of others (now I know against "CastingUnit","AttackingUnit" etc). I also thought that saving up by not using variables save space etc plus you can't actually reference a variable from a hashtable. It doesn't really also show how much "faster" or "better" it became or it can become.

Updated anyway. Change handles and you now use variables to set up the settings.

Thanks for the lessons too :thumbs_up:
 
Last edited:
Level 3
Joined
Nov 27, 2008
Messages
29
Sorry for the double post but I have a legit reason to do it.

-You should fix things in the main loop trigger. You set the key, yet you aren't using it.

And now my nice thread about MUI ticks in. Even mag should notice that if I add a unit twice, it will break.

Actually I was using the key already, though I missed one line because I was rushing with the updates.
Fixed.

If you add a unit twice, it will simply override the previous settings. I didn't made it stack on a single unit because imagine if you added a fade in and a fade out effect, it will make the unit flicker which is ugly. It wasn't suppose to stack on a single unit but it is fully MUI.
 
Level 3
Joined
Nov 27, 2008
Messages
29
What if I have spell that fades units in and another one for the other way around.

Like what Adiktuz said.

Also, I didn't intend it to stack on a single unit.
I could've then saved a dummy as a handle for every instance of fading for it to be fully SUMI (like how you described it in your thread), but then again, it will look ugly and flicker esp if it is opposing fades.

So a second fade will override the first one.


Though it will be best to have options for both. I'm too lazeh though to do that atm.
 
Last edited:
Level 3
Joined
Nov 27, 2008
Messages
29
^ What?

Anyway updated.
-renamed triggers.
-added this line
  • Animation - Change FSUnit's vertex coloring to (FSRed%, FSGreen%, FSBlue%) with FSStart% transparency
so there is no need to set the initial opacity in your spell.
 
Top