HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Scattershot

05-02-2006, 03:29 AM#1
Kam
I have been using Scattershot for several months and it seems to be causing crashes. I'm not sure why, but I think they code may be leaking or some such.

Here is the code for those to lazy to download that:
Collapse JASS:
function Trig_Scatter_Shot_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A017'
endfunction 

function Trig_Scatter_Shot_Actions takes nothing returns nothing
    local location Target = GetSpellTargetLoc()
    local unit Caster = GetTriggerUnit()    
    local player CasterOwner = GetOwningPlayer(Caster)
    local integer i = 1
    local location Random
    local unit Dummy
    local integer ScatterAmount = 4 + ( 4 * GetUnitAbilityLevelSwapped('A017', Caster) ) 
    call TriggerSleepAction( 0.25 )
    loop        
        exitwhen i > ScatterAmount
        set Dummy = CreateUnit (CasterOwner,'e005',GetUnitX(Caster),GetUnitY(Caster),bj_UNIT_FACING)
        set Random = PolarProjectionBJ(Target,GetRandomDirectionDeg(),GetRandomDirectionDeg())
        call IssuePointOrder(Dummy, "attackground", GetLocationX(Random),GetLocationY(Random) )
        call RemoveLocation ( Random )
        call UnitApplyTimedLife( Dummy, 'BTLF', 0.50 ) 
        set i = i + 1       
    endloop
    call RemoveLocation( Target )
    set Target = null            
    set Random = null    
    set Caster = null    
    set Dummy = null
    set CasterOwner = null
endfunction

//===========================================================================
function InitTrig_Scatter_Shot takes nothing returns nothing
    set gg_trg_Scatter_Shot = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Scatter_Shot, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Scatter_Shot, Condition( function Trig_Scatter_Shot_Conditions ) )
    call TriggerAddAction( gg_trg_Scatter_Shot, function Trig_Scatter_Shot_Actions )
endfunction

Edited by Blade.dk. Reason: Use the correct tags, thanks!.
05-02-2006, 03:34 AM#2
paidan_fain
For a start, why not try intializing ALL variables before using them. Its just good practice and keeps you from getting lazy.

Also, try this: Comment out all code within the loop except the augmentor. Then displayTexttoPlayer there instead. If the text never appears, that means your loop is infinite.
05-02-2006, 03:39 AM#3
emjlr3
the code is fine, i made it, a while back, but its still good and wont cause anything bad
05-02-2006, 05:20 AM#4
Kam
So it is ok for multi instance use, as in up to 5 at once?
05-02-2006, 05:28 AM#5
emjlr3
up to xxxx at once