1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  5. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  6. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  7. The results are out! Check them out.
    Dismiss Notice
  8. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  9. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Fade System v1.3

Submitted by crehym
This bundle is marked as approved. It works and satisfies the submission rules.
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
Main 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"
Adding a unit

  • 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
v1.3
- Renamed triggers to be not so "common"
- Added a new trigger to set the unit's initial opacity referenced from the FSStart variable.
v1.2
- Adding a unit now use variables
- Recoded the handles to use variables instead (As suggested by Mag)
v1.1
- 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
Moderator
18:49, 14th Sep 2012 Magtheridon96: Approved. This is a useful, robust system. Good job.
  1. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,269
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    This thread is either full of sarcasm or do people really like this....?

    WAIIIT SERIOUSLY?!
    I just looked at the triggers. This is the definition of redundant and retarded.
    Your using Last Created Hashtable... Really?
    You spam functions like Picked Unit, Triggering Unit... ugh
    This "system" is ludacris.
     
  2. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,978
    Resources:
    17
    Spells:
    17
    Resources:
    17
    Just wait for Magtheridon to say on behalf of me.
     
  3. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    I don't understand what all the fuss is about :l

    Simple systems are not bad.

    But there's a catch:
    If you choose to submit a simple system, it must be perfect.
    More complex systems sometimes get away with a couple of things.
     
  4. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    me is perfect
     
  5. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,978
    Resources:
    17
    Spells:
    17
    Resources:
    17
    There you go, Mag has said on behalf of me.
     
  6. crehym

    crehym

    Joined:
    Nov 27, 2008
    Messages:
    28
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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: May 3, 2013
  7. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    Variable look-up executes faster than function calls so its better to save things [like triggering unit etc] first into a variable if ur gonna use them multiple times...
     
  8. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    @crehym:

    Explanation
    • 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.
     
  9. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,978
    Resources:
    17
    Spells:
    17
    Resources:
    17
    Also Mag, you should state another technique when to actually use a variable.
    Like,

    • Set U = (Triggering unit)
    • Unit - Kill U


    Should be,
    • Unit - Kill (Triggering unit)
     
  10. crehym

    crehym

    Joined:
    Nov 27, 2008
    Messages:
    28
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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: May 3, 2013
  11. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    Non-arrayed variables are fine. However, arrayed variables... just bad behaviour using those for simple tasks.
     
  12. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    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.
     
  13. crehym

    crehym

    Joined:
    Nov 27, 2008
    Messages:
    28
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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.
     
  14. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    I agree that overwriting previous fades on the same unit will be much better than making it stack... Unless you're trying to make a Christmas light...
     
  15. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    What if I have spell that fades units in and another one for the other way around.
     
  16. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    no matter how you look at it, if you cast them at the same unit it will be christmas lights...
     
  17. crehym

    crehym

    Joined:
    Nov 27, 2008
    Messages:
    28
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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: May 3, 2013
  18. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    Maybe you should have a real variable that sets the current alpha of the unit so it wont hack like it does now...
     
  19. crehym

    crehym

    Joined:
    Nov 27, 2008
    Messages:
    28
    Resources:
    1
    Spells:
    1
    Resources:
    1
    ^ 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.
     
  20. FRENGERS

    FRENGERS

    Joined:
    Aug 4, 2012
    Messages:
    971
    Resources:
    4
    Icons:
    3
    Maps:
    1
    Resources:
    4
    Huraay it's cool now @.@