[Import] vJASS: Unit Dissipate Issue

Status
Not open for further replies.
Level 2
Joined
Apr 25, 2018
Messages
13
So I found a thread about making a unit get a dissipate effect with the Banish ability as the dummy spell, I downloaded a map (made by Maker) and for some reason, the vJASS trigger can't be enabled and I can't test it out nor save it while I try to get it enabled. It comes up with a compile syntax error:

"Unknown compile error (syntax error, line 62)"

"library Dissipate initializer InitTrig_Dissipation"

Code:
// 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 = 'B005'
        // 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


If I delete it, more errors come up, and then everything turns into a mess... (just wanted to try things if that changed anything but it's just the same)

Then, the trigger works fine in it's original test map, but if changes are made and I save that map, it just won't work anymore, as the same thing comes up again, and I just simply don't know what to do to import this vJASS trigger (nor any vJASS spell actually) on my custom maps.

Aaaand... no, I have zero knowledge about JASS or vJASS, but I really need this effect to make some non-hero units to disappear when they die with the ghostly effect, otherwise I don't like the result.

Btw, I use World Editor Extended (WEX).

Here you have the map for testing it out (again, this isn't my map, it's Maker's):
https://www.hiveworkshop.com/attachments/dissipate2-w3x.95096/
 

Attachments

  • issue.PNG
    issue.PNG
    14.5 KB · Views: 107
  • Dissipate2.w3x
    Dissipate2.w3x
    21.9 KB · Views: 78
That code has no issues. I can save that library into a new map with no errors. Also using WEX and 1.29.something. Delete the library and the trigger, save your map, close it, open it, create a new trigger, and paste the code again, and save it. If that doesn't work who knows.

My best guess is your copy of the code has a hidden character in it somewhere from copying/pasting across locales that pjass doesn't know how to process.
 
How should I import JASS or vJASS codes then? I just copy-paste them like GUI triggers, but unlike them, this happens... Uughh

Edit: Could you please give me your version of WEX (1.29) or where can I get it? Just for testing purposes (I'm using the latest version from the SharpCraft Bundle).

I dunno if you can see any issues now:

JavaScript:
//***************************************************************************
//*
//*  Global Variables
//*
//***************************************************************************

globals
    // User-defined
    integer                 udg_gold                   = 0
    integer                 udg_lumber                 = 0
    integer                 udg_gold_blue              = 0
    integer                 udg_gold_teal              = 0
    integer                 udg_gold_purple            = 0
    integer                 udg_Config_CH_Unit         = 0
    integer                 udg_CH_Dex                 = 0
    unit array              udg_CH_Caster
    location                udg_CH_p                   = null
    integer                 udg_ShadDragonType         = 0
    unit                    udg_ShadDragonUnit         = null
    integer                 udg_DP_Glow                = 0

    // Generated
    trigger                 gg_trg_Melee_Initialization = null
    trigger                 gg_trg_hero_limit          = null
    trigger                 gg_trg_hero_type_limit     = null
    trigger                 gg_trg_extra_hero_type_limit = null
    trigger                 gg_trg_Dissipate           = null
    trigger                 gg_trg_Dissipate_100       = null
    trigger                 gg_trg_ability_player_red  = null
    trigger                 gg_trg_disable_player_red  = null
    trigger                 gg_trg_enable_player_red   = null
    trigger                 gg_trg_ability_player_blue = null
    trigger                 gg_trg_disable_player_blue = null
    trigger                 gg_trg_enable_player_blue  = null
    trigger                 gg_trg_undead_unit_limit   = null
    trigger                 gg_trg_IceElemBirth        = null
    trigger                 gg_trg_dpbook              = null
    trigger                 gg_trg_teamColor           = null
    trigger                 gg_trg_VampireTTeamColor   = null
    trigger                 gg_trg_Hash2               = null
    trigger                 gg_trg_FrostWyrm           = null
    trigger                 gg_trg_FrostWyrm2          = null
    trigger                 gg_trg_ShadowDragonInvisible = null
endglobals

function InitGlobals takes nothing returns nothing
    local integer i = 0
    set udg_gold = 0
    set udg_lumber = 0
    set udg_gold_blue = 0
    set udg_gold_teal = 0
    set udg_gold_purple = 0
    set udg_CH_Dex = 0
endfunction

// 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 = 'B005'
        // 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

To me, it just won't load (save and/or enable trigger) neither this library nor any other. Not even a template.
Again, I'm a noob when it comes with this JASS and vJASS thing, and I simply don't understand what's going on.
 
Last edited:
WEX is SharpCraft. If you update your WE install to 1.30 or later vJASS is supported natively in the editor now so you don’t even need a 3rd party editor.

It’s possible you already have the InitTrig_Dissipation function defined so you can put “private” in front of “function InitTrig...” near the bottom of the library.
 
Status
Not open for further replies.
Back
Top