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

Making Normal Units Dissipate like Heroes

Status
Not open for further replies.
Level 30
Joined
Jan 31, 2010
Messages
3,551
I found a very nice map on DotA suggestions where normal units are converted to dissipate just like heroes. I was wondering, can someone make it MUI for me? I need to use it for my project (Signature) to apply it to only heroes that don't have dissipate animation. And, can someone adjust the turning angle and speed - to fit it similar to those heroes have in regular Wc3?
vJass, GUI, whatever you can do - just to make it easy to implement in my map and add heroes without dissipate animation to it. Testmap is required.

Thanks forward! ;)
 

Attachments

  • Dissipate.w3x
    28.6 KB · Views: 71
Level 37
Joined
Mar 6, 2006
Messages
9,240
Select the two Mountain Kings with drag-selection.

JASS:
// Dissipation system v1.06 by Maker                    //
//                                                      //
// When units die, they will slowly rise up in the air  //
// and fade.                                            //


library Dissipate initializer InitTrig_Dissipation

    globals
        // How often the dissipation height is updated
        private constant real LOOP_TIME = 0.03
        // How fast the units rise
        private constant real HEIGHT_SPEED = 7.5
        // How long the death animation plays before the unit begins to rise
        private constant real DEATH_DELAY = 2.5
        // How fast the units fade
        private constant integer FADE_SPEED = 5
        // How transparent the unit will be after dying
        private constant integer INITIAL_FADE = 177
        // How fast the units rotate
        private constant real ROTATION_SPEED = 5.
        // How high the units rise before vanishing completely
        private constant real HEIGHT_MAX = 500.
        // The visibility given by dissipating units
        private constant real VISIBILITY_RADIUS = 512.
        
        // RGB values for the dissipating units. Keep between 0 and 255
        private constant integer RED = 255
        private constant integer GREEN = 255
        private constant integer BLUE = 255
        
        // Raw code of the dummy
        private constant integer DUMMYCODE = 'h001'
        // Raw code of the dummy ability
        private constant integer BUFFCODE = 'B000'
        // Order code of the dummy ability
        private constant string ORDERCODE = "banish"

        
        // Does the dissipating unit provide visibility
        private constant boolean GIEF_VISIBILITY = true
        // Is the dissipating unit created for the owner of dying unit
        private constant boolean GHOST_FOR_OWNER = false
        // Do units rotate
        private constant boolean ROTATE = false
        
        
        // Don't tamper with the variables below //
        private constant integer array unitTypes
        
        private integer dissipates = 0
        hashtable dissipateHash = InitHashtable()
        private group dissipateGroup = CreateGroup()
        private timer dissipateTimer = CreateTimer()
    endglobals
    
    
    // Add all unit types you want the system to work with here
    private function initUnits takes nothing returns nothing
        set unitTypes[1] = 'Hblm'
        set unitTypes[2] = 'Hmkg'
    endfunction
    
    
    private function dissipateLoop takes nothing returns nothing
        local unit u = GetEnumUnit()
        local integer id = GetHandleId(u)
        local integer fade
        local real height
        local real delay = LoadReal( dissipateHash , id , 2 ) - LOOP_TIME
        
        if delay > 0. then
            call SaveReal( dissipateHash , id , 2 , delay )
        else
            set height = GetUnitFlyHeight(u)
            if LoadBoolean( dissipateHash , id , 5 ) != true then
                call SaveBoolean( dissipateHash , id , 5 , true )
                set bj_lastCreatedUnit = LoadUnitHandle( dissipateHash , id , 6 )
                if bj_lastCreatedUnit == null then 
                    set bj_lastCreatedUnit = CreateUnit( Player(15) , DUMMYCODE , GetUnitX(u) , GetUnitY(u) , 0. )
                    call SaveUnitHandle( dissipateHash , id , 6 , bj_lastCreatedUnit ) 
                endif
                call ShowUnit( bj_lastCreatedUnit , true )
                call SetUnitX(bj_lastCreatedUnit , GetUnitX(u) )
                call SetUnitY(bj_lastCreatedUnit , GetUnitY(u) )
                call IssueTargetOrder( bj_lastCreatedUnit , ORDERCODE , u )
            endif
            if height < HEIGHT_MAX then
                if ROTATE == true then
                    call SetUnitFacing( u , GetUnitFacing(u) + ROTATION_SPEED )
                endif
                call SetUnitFlyHeight( u , height + HEIGHT_SPEED , 0. )
            else
                if LoadBoolean( dissipateHash , id , 4 ) != true then
                    if GIEF_VISIBILITY == true then
                        call FogModifierStop( LoadFogModifierHandle( dissipateHash , id , 1 ) )
                    endif
                    call ShowUnit( LoadUnitHandle( dissipateHash , id , 6 ) , false )
                    call UnitRemoveAbility( u , BUFFCODE )
                    call SaveBoolean( dissipateHash , id , 4 , true )
                endif
                
                set fade = LoadInteger( dissipateHash , id , 3 ) - FADE_SPEED
                if fade > 0 then
                    call SetUnitVertexColor( u , RED , GREEN , BLUE , fade )
                    call SaveInteger( dissipateHash , id , 3 , fade )
                else
                    call GroupRemoveUnit( dissipateGroup , u )
                    call ShowUnit( u , false )
                    call SetUnitFlyHeight( u , 0. , 0. )
                    set dissipates = dissipates - 1
                    if dissipates == 0 then
                        call PauseTimer(dissipateTimer)
                    endif
                endif
            endif
        endif
        set u = null
    endfunction
    
    
    private function dissipateTimerExpire takes nothing returns nothing
        call ForGroup( dissipateGroup , function dissipateLoop )
    endfunction
    
    
    private function Actions takes nothing returns nothing
        local unit u = GetTriggerUnit()
        local integer id = GetHandleId(u)
        local integer id2
        local player p = GetOwningPlayer(u)
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        
        set bj_lastCreatedUnit = LoadUnitHandle( dissipateHash , id , 0 )
        
        if bj_lastCreatedUnit == null then
            if GHOST_FOR_OWNER == true then
                set bj_lastCreatedUnit = CreateUnit( p , GetUnitTypeId(u) , x , y , GetUnitFacing(u) )
            else
                set bj_lastCreatedUnit =  CreateUnit( Player(15) , GetUnitTypeId(u) , x , y , GetUnitFacing(u) )
                call SetUnitColor( bj_lastCreatedUnit , GetPlayerColor(p) )
            endif
            set id2 = GetHandleId(bj_lastCreatedUnit)
            call UnitAddAbility( bj_lastCreatedUnit , 'Arav' )
            call SaveUnitHandle( dissipateHash , id , 0 , bj_lastCreatedUnit )
            if GIEF_VISIBILITY == true then
                set bj_lastCreatedFogModifier = CreateFogModifierRadius( p , FOG_OF_WAR_VISIBLE , GetUnitX(bj_lastCreatedUnit) , GetUnitY(bj_lastCreatedUnit) , VISIBILITY_RADIUS , true , true )
                call SaveFogModifierHandle( dissipateHash , id2 , 1 , bj_lastCreatedFogModifier )
            endif
        else
            set id2 = GetHandleId(bj_lastCreatedUnit)
            call ShowUnit( bj_lastCreatedUnit , true )
            if GIEF_VISIBILITY == true then
                set bj_lastCreatedFogModifier = LoadFogModifierHandle( dissipateHash , id2 , 1 )
            endif
        endif
        
        call ShowUnit( u , false )
        call SetUnitX( bj_lastCreatedUnit , x )
        call SetUnitY( bj_lastCreatedUnit , y )
        call SetUnitVertexColor( bj_lastCreatedUnit , RED , GREEN , BLUE , 255 )
        call UnitAddAbility( bj_lastCreatedUnit , 'Aloc' )
        call UnitRemoveAbility( bj_lastCreatedUnit , 'Aloc' )
        call SetUnitAnimation( bj_lastCreatedUnit , "death" )
        call GroupAddUnit( dissipateGroup , bj_lastCreatedUnit )
        call SaveInteger( dissipateHash , id2 , 3 , INITIAL_FADE )
        call SaveReal( dissipateHash , id2 , 2 , DEATH_DELAY )
        call SaveBoolean( dissipateHash , id2 , 4 , false )
        call SaveBoolean( dissipateHash , id2 , 5 , false )
        
        if GIEF_VISIBILITY == true then
            call FogModifierStart(bj_lastCreatedFogModifier)
        endif
        
        set dissipates = dissipates + 1
        if dissipates == 1 then
            call TimerStart( dissipateTimer , LOOP_TIME , true , function dissipateTimerExpire )
        endif
        
        set u = null
        set p = null
    endfunction
    
    
    private function Condition takes nothing returns boolean
        local integer id = GetUnitTypeId(GetTriggerUnit())
        local integer i = 1
        loop
            if id == unitTypes[i] then
                return true
            endif
            set i = i + 1
            exitwhen unitTypes[i] == null
        endloop
        return false
    endfunction

    function InitTrig_Dissipation takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddAction( t , function Actions )
        call TriggerAddCondition( t , function Condition )
        call TriggerRegisterAnyUnitEventBJ( t , EVENT_PLAYER_UNIT_DEATH )
        call initUnits()
    endfunction
    
endlibrary
 

Attachments

  • Dissipate2.w3x
    23.6 KB · Views: 82
Status
Not open for further replies.
Top