Moderator
M
Moderator
18:49, 14th Sep 2012
Magtheridon96:
Approved.
This is a useful, robust system.
Good job.
Magtheridon96:
Approved.
This is a useful, robust system.
Good job.
DescriptionA 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
How to use1. 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.
TriggersTo 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"
- 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
The variables uses are as follows:
- 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)
-- 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