• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Making a unit dissipate

Status
Not open for further replies.
I have a unit (not a hero) which can be revived at the altar. Works just fine.
The only problem is that I want it to dissipate like a hero.
It has a dissipate animation which I renamed to Decay Bone. I'm trying to have it fade out during the animation, but it's not working.

Here's my trigger:
JASS:
function Leader_Dissipate_Conditions takes nothing returns boolean
    return ( GetUnitTypeId(GetDecayingUnit()) == 'hfal' )
endfunction

function Leader_Dissipate_Actions takes nothing returns nothing
    local unit decayingUnit = GetDecayingUnit()
    local integer i = 0
    local integer opacity = 255
    local player localPlayer = GetLocalPlayer()
    local force playerAllies = CreateForce()
    
    call ForceEnumAllies(playerAllies, GetOwningPlayer(decayingUnit), null)
    
    if (IsPlayerInForce(localPlayer, playerAllies)) then
        call DisplayTextToPlayer(localPlayer, 0, 0, ( GetUnitName(decayingUnit) + " has fallen." ))
    endif
    
    loop
        exitwhen i >= 5
        call TriggerSleepAction( 0.29 )
        set opacity = ( opacity - 50)
        call SetUnitVertexColor( decayingUnit, 255, 255, 255, opacity )
        set i = i + 1
    endloop
    
    call RemoveUnit( decayingUnit )
endfunction

function Leader_Dissipate takes nothing returns nothing
    local trigger gg_trg_Dissipate = CreateTrigger(  )
    local integer index = 0

    loop
        call TriggerRegisterPlayerUnitEvent(gg_trg_Dissipate, Player(index), EVENT_PLAYER_UNIT_DECAY, null)

        set index = index + 1
        exitwhen index == 16
    endloop
    
    call TriggerAddCondition( gg_trg_Dissipate, Condition( function Leader_Dissipate_Conditions ) )
    call TriggerAddAction( gg_trg_Dissipate, function Leader_Dissipate_Actions )
endfunction

Everything works fine except for the fading out. I also tried attaching the dissipate effect, which also didn't work.
Any idea what could be causing this?
 
Last edited:
Using a hero is exactly what I'm trying to avoid :p The only hero-like behaviour I want is the ability to revive the unit. Although I'm considering using a hero instead. I could limit leveling to a minimum through triggers, and I can still give it the upgrades and abilities of a normal unit and remove hero inventory. I actually tried just changing the first letter of the unit's rawcode to a capital, and it achieved the best result while still being a hero.
Unless there's a way to hide the experience bar and/or int/agi/str from the unit UI.

--

I made a quick GUI trigger with a timer. Still no effect :(


  • Untitled Trigger 001
    • Events
      • Unit - A unit Decays
    • Conditions
      • (Unit-type of (Decaying unit)) Equal to Captain
    • Actions
      • Set u = (Decaying unit)
      • Countdown Timer - Start t as a One-shot timer that will expire in 0.29 seconds
  • Untitled Trigger 002
    • Events
      • Time - t expires
    • Conditions
      • i Less than 5
    • Actions
      • Countdown Timer - Start t as a One-shot timer that will expire in 0.29 seconds
      • Set Fade = (Fade + 20.00)
      • Animation - Change u's vertex coloring to (100.00%, 100.00%, 100.00%) with Fade% transparency
      • Set i = (i + 1)


Death type is set to decay. Everything else in the trigger on decay event works properly. Also the dissipate animation (renamed Decay Bone) plays properly.

Will try BJDebugMSG shortly. Thanks for your replies guys!

Setting transparency works BEFORE decaying starts. As soon as decaying starts, transparency is lost, probably along with all other effects.
Maybe I can remove the unit immediately and replace it with another one, and manually play the decay animation. Although I imagine there's a bunch of different problems that will be caused by that.

--> works but is anything but smooth


  • Untitled Trigger 001
    • Events
      • Unit - A unit Decays
    • Conditions
      • (Unit-type of (Decaying unit)) Equal to Captain
    • Actions
      • Set u = (Decaying unit)
      • Unit - Suspend corpse decay for u
      • Unit - Hide u
      • Unit - Create 1 (Unit-type of u) for (Owner of u) at (Position of u) facing (Facing of u) degrees
      • Unit - Remove u from the game
      • Set u = (Last created unit)
      • Unit - Change ownership of u to Neutral Passive and Retain color
      • Animation - Play u's Decay Bone animation
      • Countdown Timer - Start t as a One-shot timer that will expire in 0.29 seconds
  • Untitled Trigger 002
    • Events
      • Time - t expires
    • Conditions
      • Fade Less than 100.00
    • Actions
      • Countdown Timer - Start t as a One-shot timer that will expire in 0.29 seconds
      • Set Fade = (Fade + 20.00)
      • Animation - Change u's vertex coloring to (100.00%, 100.00%, 100.00%) with Fade% transparency
      • If (Fade Greater than or equal to 100.00) then do (Unit - Remove u from the game) else do (Do nothing)
 
Last edited:
Level 37
Joined
Jul 22, 2015
Messages
3,485
Why not have the trigger fire off the event of A unit Dies?

When that happens, you can create the same exact unit-type of the dying unit on its location, remove the original dying unit, and then change vertex coloring + height that way? I remember ILH attempting something like this, I will send him a message about this post and hopefully he can show you what he did.
 
The idea is to make an ability which will enable it, so that it can be added to any unit.
Well I just checked if that's possible, and I'll have to add a buff that only affects "self" in order to check for it :p

Trying your suggestion right now.

  • Actions
    • Unit - Add classification of A flying unit to u
    • Animation - Change u flying height to 200.00 at 0.50
Doesn't seem to do anything.


Aaaahh I think I'll just make it a hero with unit upgrades and without hero abilities and hidden hero icon. Maybe that's better :D
 
Last edited:
Level 37
Joined
Jul 22, 2015
Messages
3,485
  • Actions
    • Unit - Add classification of A flying unit to u
    • Animation - Change u flying height to 200.00 at 0.50

Giving the unit-type a flying unit classification isn't going to work. Add this custom script block before you change the flying height:
  • Custom script: if UnitAddAbility(udg_u,'Amrf') then
  • Custom script: call UnitRemoveAbility(udg_u,'Amrf')
  • Custom script: endif
 
Hmm, doesn't seem to be working.

Also tried changing height inside the if clause and an else clause.

Other than that, this seems to be working rather nicely:
JASS:
function LeaderDissipate_Conditions takes nothing returns boolean
    return ( GetUnitTypeId(GetDyingUnit()) == 'hcth' )
endfunction

function LeaderDissipate_Actions takes nothing returns nothing
    local unit dyingUnit = GetDyingUnit()
    local unit newUnit
    local integer opacity = 255
    
    set newUnit = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), GetUnitTypeId(dyingUnit), GetUnitLoc(dyingUnit), GetUnitFacing(dyingUnit))
    call SetUnitColor( newUnit, GetPlayerColor(GetOwningPlayer(dyingUnit)) )
    call RemoveUnit( dyingUnit )
    
    call SetUnitAnimation( newUnit, "Death" )
    call TriggerSleepAction( 3.00 )
    
    if UnitAddAbility(newUnit,'Amrf') then
        call UnitRemoveAbility(newUnit,'Amrf')
    endif
    
    call SetUnitFlyHeight(newUnit, 200, 0.5)
        
    loop
        exitwhen opacity < 15
        call TriggerSleepAction( 0.09 )
        set opacity = ( opacity - 15)
        call SetUnitVertexColor( newUnit, opacity, opacity, opacity, opacity )
    endloop

    call RemoveUnit(newUnit)
endfunction

//===========================================================================
function InitTrig_Leader_Dissipate takes nothing returns nothing
    local trigger Leader_Dissipate_Trigger = CreateTrigger(  )
    local integer index = bj_MAX_PLAYER_SLOTS

    loop
        set index = index - 1
        
        call TriggerRegisterPlayerUnitEvent(Leader_Dissipate_Trigger, Player(index), EVENT_PLAYER_UNIT_DEATH, null)

        exitwhen index == 0
    endloop
    
    call TriggerAddCondition( Leader_Dissipate_Trigger, Condition( function LeaderDissipate_Conditions ) )
    call TriggerAddAction( Leader_Dissipate_Trigger, function LeaderDissipate_Actions )
endfunction

Would be nice if I could make the unit unselectable too. Calling it a night now though :D

Edit: okay, apparently the rate value doesn't work the way I thought. I set it to 150 and now it works! This is very nice! :D
Tomorrow I'll try to figure out if I can make the unit unselectable and try to add the race-specific dissipate effect. Then I can create an ability to trigger this system, and it'll be pretty much done :D

Thanks again!
 
Last edited:
Hmm, I tried it but it doesn't seem to work.

JASS:
    call UnitAddAbility(newUnit,'AUls')
    call IssueImmediateOrder( newUnit, "locustswarm" )

tried without issuing order first

Edit: found a thread that said it's not Locust Swarm but just Locust, Aloc. Works now! Thanks!
Weird though, that ability isn't in the object editor.
 
Status
Not open for further replies.
Top