Help convert to vJass

spectre37

New Member
Reaction score
1
JASS:
function Buster_Dive_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A01E' 
endfunction

function GB_Destroy_Trees takes nothing returns nothing
    call KillDestructable(GetEnumDestructable())
endfunction

function Buster_Knockback takes nothing returns nothing
    local timer t2 = GetExpiredTimer()
    local unit v = GetHandleUnit(t2, "targ")
    local location l = GetHandleLocation(t2,"l") 
    local real dist = GetHandleReal(t2,"dist")    
    local real angle = GetHandleReal(t2,"angle")
    local location m = Location(GetUnitX(v)+dist*CosBJ(angle),GetUnitY(v)+dist*SinBJ(angle))        
   
    if DistanceBetweenPoints(m,l) < 400 and dist > 0.5 then
        call SetUnitPositionLoc( v, m )
        call SetHandleReal(t2,"dist", dist*.98)   
        call DestroyEffect(AddSpellEffectByIdLoc('A01E', EFFECT_TYPE_SPECIAL, m))        
        call EnumDestructablesInCircleBJ(150.,m,function GB_Destroy_Trees)
    else
        call FlushHandleLocals(t2)
        call PauseTimer(t2)
        call DestroyTimer(t2)   
    endif
    
    set t2 = null
    call RemoveLocation(m)
    set m = null
endfunction

function Buster_Move takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local timer t2 = CreateTimer()
    local unit c = GetHandleUnit(t,"c")
    local unit u = GetHandleUnit(t,"u")
    local unit v = GetHandleUnit(t,"v")        
    local location l = GetHandleLocation(t,"l")   
    local real r = GetHandleReal(t,"r")
    local real s = AngleBetweenPoints(GetUnitLoc(c) ,l)
    local location n = PolarProjectionBJ(GetUnitLoc(c) ,r/40,s)
   
    if DistanceBetweenPoints(n,l) > 100 then
        call SetUnitPositionLoc(c,n)
        call EnumDestructablesInCircleBJ(150. ,n , function GB_Destroy_Trees)
    else
        call SetUnitPositionLoc(u, GetUnitLoc(c))
        call KillUnit(c)            
        
        call SetHandleHandle(t2, "targ", v)
        call SetHandleHandle(t2,"l", GetUnitLoc(u))
        call SetHandleReal(t2,"dist", 8)    
        call SetHandleReal(t2,"angle",s)
        call TimerStart(t2, .01, true, function Buster_Knockback)        
        
        call ShowUnitShow(u)   
        call UnitDamageTargetBJ( u, v, (GetUnitAbilityLevel(u, 'A01E')+ 1)* 100, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
        call IssueImmediateOrder(v, "stop")
        call ClearSelectionForPlayer(GetOwningPlayer(u))
        call SelectUnitAddForPlayer(u, GetOwningPlayer(u)) 
        
        call PauseTimer(t)        
        call TriggerSleepAction(.01)        
        call DestroyTimer(t)        
    endif
       
    call RemoveLocation(n)
    set n = null
    set c = null
    set t = null
endfunction

function Buster_Dive_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit() 
    local unit v = GetSpellTargetUnit()
    local location l = GetUnitLoc(v)       
    local real r = DistanceBetweenPoints(l, GetUnitLoc(u))
    local real cost = (GetUnitAbilityLevel(u, 'A01E')+ 1)*50
    local timer t = CreateTimer()
    local unit n
        
    if r > 250 then
        set n = CreateUnit( GetOwningPlayer(u), 'u006', GetLocationX(GetUnitLoc(u)), GetLocationY(GetUnitLoc(u)), AngleBetweenPoints(GetUnitLoc(u),l) )
        call ShowUnitHide(u)
    
        call SetHandleHandle(t,"c",n)
        call SetHandleHandle(t,"u",u)
        call SetHandleHandle(t,"v",v)
        call SetHandleHandle(t,"l",l)
        call SetHandleReal(t,"r",r)    
        call TimerStart(t, .005, true, function Buster_Move)    
        call TriggerSleepAction(2)
    else
        call IssueImmediateOrder(u, "stop")
        call QuestMessageBJ( GetForceOfPlayer(GetOwningPlayer(u)), bj_QUESTMESSAGE_ALWAYSHINT, "TRIGSTR_355" )
        call TriggerSleepAction(.1)
        call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA) + cost)
    endif    
    
    call RemoveLocation(l)
    set l = null
    set u = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Buster_Dive takes nothing returns nothing
    set gg_trg_Buster_Dive = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Buster_Dive, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Buster_Dive, Condition( function Buster_Dive_Conditions ) )
    call TriggerAddAction( gg_trg_Buster_Dive, function Buster_Dive_Actions )
endfunction


Can someone help me convert my spell to vJass?

JASS:
function Firebolts_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A005'        
endfunction

function Firebolts_Actions takes nothing returns nothing
    local unit c = GetSpellAbilityUnit()
    local unit t = GetSpellTargetUnit()
    local unit n
    local integer i = 1
    local player p = GetOwningPlayer(c)        
    local location l = GetUnitLoc(c)
    
    call SetUnitAnimationWithRarity( c, "attack", RARITY_RARE )
    loop
        exitwhen i > 4
            set n = CreateUnit( p, 'n000', GetLocationX(l), GetLocationY(l), bj_UNIT_FACING )
            call UnitAddAbility( n, 'A006' )
            call SetUnitAbilityLevelSwapped( 'A006', n, GetUnitAbilityLevelSwapped('A005', c) )
            call IssueTargetOrder( n, "thunderbolt", t )
            call UnitApplyTimedLife( n, 'BTLF', 1.00 )
            set i = i + 1
            call TriggerSleepAction( 0.25 )
    endloop
    call ResetUnitAnimation(c)
    call RemoveLocation(l)
    
    set l = null
    set p = null
    set n = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Firebolts takes nothing returns nothing
    set gg_trg_Firebolts = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Firebolts, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Firebolts, Condition( function Firebolts_Conditions ) )
    call TriggerAddAction( gg_trg_Firebolts, function Firebolts_Actions )
endfunction


And this too, i try to use timer but dunno why it leaks =.=
 

Carnerox

The one and only.
Reaction score
84
Fixed up your Fire bolt code even tho you wanted Vjass(I don't see why you want it when your code was fine.)

JASS:
function Firebolts_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A005'        
endfunction

function Firebolts_Actions takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local unit n
    local player p = GetOwningPlayer(c) 
    local integer i = 1
    local real x = GetUnitX(c)
    local real y = GetUnitY(c)
    
    call SetUnitAnimationWithRarity (c, "attack", RARITY_RARE)
    loop
        exitwhen i > 4
            set n = CreateUnit (p, 'n000', x, y, 1.)
            call UnitAddAbility (n, 'A006')
            call SetUnitAbilityLevel (n, 'A006', GetUnitAbilityLevel (c, 'A005'))
            call IssueTargetOrder (n, "thunderbolt", t)
            call UnitApplyTimedLife (n, 'BTLF', 1.00)
            set i = i + 1
            call TriggerSleepAction (0.25)
    endloop
    call ResetUnitAnimation(c)
    
    set p = null
    set n = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Firebolts takes nothing returns nothing
    local trigger T = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ (T, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition (T, Condition( function Firebolts_Conditions))
    call TriggerAddAction (T, function Firebolts_Actions)
    set T = null
endfunction
 

tooltiperror

Super Moderator
Reaction score
231
1) Use [ljass]call SetUnitAnimation(c, "stand")[/ljass]. That's just a stupid function call.

2) Libraries are so fancy, I would use them anyway, just in case of random conflicts.
 

Carnerox

The one and only.
Reaction score
84
I've never used library, scopes, etc.. First try so.


JASS:
library Firebolts initializer Init

private function Cast takes nothing returns boolean
    return GetSpellAbilityId() == 'A005'        
endfunction

private function Actions takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local unit n
    local player p = GetOwningPlayer(c) 
    local integer i = 1
    local real x = GetUnitX(c)
    local real y = GetUnitY(c)
    
    call SetUnitAnimation (c, "attack")
    loop
        exitwhen i > 4
            set n = CreateUnit (p, 'n000', x, y, 1.)
            call UnitAddAbility (n, 'A006')
            call SetUnitAbilityLevel (n, 'A006', GetUnitAbilityLevel (c, 'A005'))
            call IssueTargetOrder (n, "thunderbolt", t)
            call UnitApplyTimedLife (n, 'BTLF', 1.00)
            set i = i + 1
            call TriggerSleepAction (0.25)
    endloop
    call SetUnitAnimation (c, "stand")
    
    set p = null
    set n = null
    set t = null
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger T = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ (T, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition (T, Condition( function Cast))
    call TriggerAddAction (T, function Actions)
    set T = null
endfunction
endlibrary
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top