Need help ( newbie )

tuantai120

Cool Member
Reaction score
1
i want to make a dummy move around caster but it not work , i use CS data
here is the code :
JASS:
scope Shield initializer Init
globals
    private constant integer Spell_ID = 'A000'
    private constant integer Dummy_ID = 'h000'
    private constant real Interval = 0.04
    private constant real Damage_Max = 300
    private constant real Speed = 500
    private constant real Dis = 300
endglobals

private constant function Shield1 takes integer lvl  returns real
    return 100. * lvl
endfunction

private constant function Shield2 takes integer lvl  returns real
    return Damage_Max * lvl
endfunction

private constant function condition takes nothing returns boolean
   return GetSpellAbilityId () == Spell_ID
endfunction

private struct knockbackdata
    unit whichUnit
    real angle
    integer tick
    real distance
    string sfx
    integer lvl = 1
endstruct

function KnockBackE takes nothing returns nothing
    local timer ti = GetExpiredTimer()
    local knockbackdata data = GetCSData( ti )
    
    local location loc = GetUnitLoc( data.whichUnit )
    local location loc2 = PolarProjectionBJ( loc, data.distance, data.angle )

    call AddSpecialEffectLocBJ( loc2, data.sfx )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )

    call SetUnitPositionLoc( data.whichUnit, loc2 )

    call RemoveLocation( loc )
    call RemoveLocation( loc2 )
    set loc = null
    set loc2 = null    

    set data.tick = data.tick - 1

    if data.tick <= 0 then
        call data.destroy()
        call ReleaseTimer( ti )
    endif
    set ti = null
endfunction

function KnockBack takes unit whichUnit, real distance, real angle, real duration, string sfx returns nothing
    local knockbackdata data = knockbackdata.create()
    local timer ti = NewTimer()

    set data.whichUnit = whichUnit
    set data.angle = angle
    set data.tick = R2I( duration / 0.04 )
    set data.distance = distance / data.tick
    set data.sfx = sfx

    call SetCSData( ti , data )
    call TimerStart( ti, 0.04, true, function KnockBackE )
     
    set ti = null
endfunction

function action takes nothing returns nothing
    local unit caster
    local unit dummy
    local location point1 = GetUnitLoc(caster)
    local location point2 = PolarProjectionBJ(point1,200,0.)
    local real angle = GetUnitFacing(caster)
    set dummy = CreateUnitAtLoc(GetOwningPlayer(caster),Dummy_ID,point2,angle)
    call KnockBack (dummy,Speed,angle+5,Interval,"Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl") 
    call UnitApplyTimedLife(dummy,'BLTF',10.)
    call RemoveLocation (point1)
    set point1 = null
    call RemoveLocation(point2)
    set point2 = null
    set caster = null
    set dummy = null
endfunction
   
   
   

//===========================================================================
function Init takes nothing returns nothing
    local trigger shield
    set shield = CreateTrigger(  )
    call TriggerAddAction( shield, function action )
    call TriggerAddCondition( shield , Condition( function  condition ) )
endfunction

endscope
 

Viikuna

No Marlo no game.
Reaction score
265
You need to learn how to Debug your code.

Add soem BJDebugMsg calls there and see which ones of them get displayed, and which ones dont. this way you find where your code fails and its easier to find the cause too.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top