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. Hey guys, we've posted the Results for the 30th Modeling Contest. Check them out!
    Dismiss Notice
  4. The 15th Mini-Mapping Contest came to an end. The Secrets of Warcraft 3 are soon to be revealed! Come and vote in the public poll for your favorite maps.
    Dismiss Notice
  5. The 12th incarnation of the Music Contest is LIVE! The theme is Synthwave. Knight Rider needs a song to listen to on his journey. You should definitely have some fun with this theme!
    Dismiss Notice
  6. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  7. 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

Submitted by Chaosy
This bundle is marked as approved. It works and satisfies the submission rules.
Simple fade system written in wurst.
Fades a unit in/out over X seconds.
Intended for cinematic use, but could be used when a unit dies in a TD for example.

API:


yourUnit.fadeOut(duration)
yourUnit.fadeIn(duration)​

[​IMG]

Code (WurstScript):

package Fade

import TimerUtils
import LinkedListModule

timer t

public enum fadetype
    IN
    OUT

public function unit.fade(fadetype ft, real duration)
    new Fade(this, ft, duration)

public function unit.fadeOut(real duration)
    this.fade(fadetype.OUT, duration)

public function unit.fadeIn(real duration)
    this.fade(fadetype.IN, duration)

function unit.setFade(integer raw)
    this.setVertexColor(colorA(255,255,255, raw))

public class Fade
    use LinkedListModule
    unit fader
    real changeSpeed
    real fadeState
    construct(unit u, fadetype ft, real duration)
        changeSpeed = (255 / duration) * 0.03

        if(ft == fadetype.IN)
            changeSpeed *= -1
            fadeState = 0
        else
            fadeState = 255

        fader = u

function onLoop()
    Fade current = Fade.first
    while(current != null)
        current.fadeState -= current.changeSpeed
        current.fader.setFade(R2I(current.fadeState))
        if(current.fadeState >= 255 or current.fadeState <= 0)
            Fade next = current.next
            destroy current
            current = next
        else
            current = current.next

init
    t = getTimer()
    t.startPeriodic(0.03, function onLoop)
Code (WurstScript):

package Demo

import Fade
import TimerUtils

boolean tracker = false
unit test
real speed = 1

init
test = createUnit(players[0], 'Hpal', vec2(0, 0), angle(0))

test.fadeOut(speed)

getTimer()
..startPeriodic(speed, () -> begin
if(tracker)
test.fadeOut(speed)
tracker = false
else
test.fadeIn(speed)
tracker = true
end)
 
Contents

Fade System (Map)

Reviews
MyPad
Nitpicks: Since there are quite some Fade Systems already made for users here, it would affect the overall rating. A bit of documentation goes a long way. Notes: None Quirks: I like how short this system is, compared to other Fade systems....
  1. stan0033

    stan0033

    Joined:
    Jun 27, 2010
    Messages:
    1,612
    Resources:
    14
    Models:
    4
    Packs:
    1
    Skins:
    2
    Maps:
    6
    Spells:
    1
    Resources:
    14
    Dude your map is empty.
     
  2. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,574
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    1. Wurst code is injected directly into the map which is why there are no triggers.
    2. There is no DEMO code to showcase the system since it is one function with one argument
     
  3. stan0033

    stan0033

    Joined:
    Jun 27, 2010
    Messages:
    1,612
    Resources:
    14
    Models:
    4
    Packs:
    1
    Skins:
    2
    Maps:
    6
    Spells:
    1
    Resources:
    14
    If it is injected then how are users supposed to use it?
     
  4. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,574
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    Wurst is not really compatible with jass and vjass, but if you already use wurst in your project you just copy the code from the main post.
    The wurst workflow takes care of the rest.
     
  5. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,574
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    Added demo triggers + preview gif.
     
  6. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,861
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    I should really write an Easings library
     
  7. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,259
    Resources:
    6
    Models:
    1
    Icons:
    1
    Spells:
    3
    JASS:
    1
    Resources:
    6

    Nitpicks:


    • Since there are quite some Fade Systems already made for users here, it would affect the overall rating.
    • A bit of documentation goes a long way.

    Notes:


    • None

    Quirks:


    • I like how short this system is, compared to other Fade systems.
    • Since there are no Wurst equivalents of Fade Systems as far as I know, this could affect my rating.

    Status:



    This resource has been Approved.
     
  8. trebla ratilla

    trebla ratilla

    Joined:
    Oct 20, 2016
    Messages:
    349
    Resources:
    2
    Maps:
    2
    Resources:
    2
    hmm.. interesting spell :aht:
     
  9. omidh

    omidh

    Joined:
    Apr 30, 2009
    Messages:
    42
    Resources:
    0
    Resources:
    0
    Nice!