HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spell: Scattershot - Trouble

01-22-2007, 10:10 PM#1
Fulla
Scatter Shot:
Fires a ball full of shrapnel into the air. which promptly explodes, showering the target area in explosive pellets, each doing 10-35 physical damage in a 200 area of effect.


I had to make my own version of scattershot, as the generic damage system being used does not allow 'attackground' (it crashed).

So when the dummy unit is created, I must remove orb ability then proceed.

Collapse JASS:
    //####################################################################################\\
    //                            Spell Name: Scatter Shot                                \\
    //                            Spell Auth: Fulla                                       \\
    //####################################################################################\\


            //################################################################\\
            //                                                                \\
            //                     Configuration Section                      \\
            //                                                                \\
            //################################################################\\


// Scatter Shot Hero Ability
constant function Scatter_Shot_AbilId takes nothing returns integer
    return 'A05Y'
endfunction

// Scatter Shot Dummy Unit
constant function Scatter_Shot_DummyId takes nothing returns integer
    return 'e001'
endfunction

// Generic Damage System orb Ability (needs to be removed from dummy unit)
constant function Scatter_Shot_OrbId takes nothing returns integer
    return 'A08J'
endfunction

// Number of pellets
constant function Scatter_Shot_Pellets takes integer lvl returns integer
    if (lvl !=5) then
        return (lvl * 4) + 4
    endif
    return 28
endfunction


            //################################################################\\
            //                                                                \\
            //                        Spell Section                           \\
            //                                                                \\
            //################################################################\\


function Trig_Scatter_Shot_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Scatter_Shot_AbilId()
endfunction

function Scatter takes nothing returns nothing
    local timer t = GetExpiredTimer()    
    local string s = GetAttachmentTable(t)
    
    local unit caster = GetTableUnit(s,"Caster")
    local real x = GetTableReal(s,"X") 
    local real y = GetTableReal(s,"Y")
    local player owner = GetOwningPlayer(caster)
    local unit dummy
    local location random  
    
    set dummy = CreateUnit(owner, Scatter_Shot_DummyId(), GetUnitX(caster), GetUnitY(caster), bj_UNIT_FACING)
    set random = PolarProjectionBJ(Location(x, y), GetRandomDirectionDeg(), GetRandomDirectionDeg())
    call TriggerSleepAction(0.1)
    call UnitRemoveAbility(dummy, Scatter_Shot_OrbId())
    call IssuePointOrder(dummy, "attackground", GetLocationX(random),GetLocationY(random))
    call UnitApplyTimedLife(dummy, 'BTLF', 2)
    
    call RemoveLocation (random)
    set random = null
    set caster = null
    set owner = null
endfunction

function Trig_Scatter_Shot_Actions takes nothing returns nothing
    local timer t = CreateTimer()    
    local string s = GetAttachmentTable(t)
    
    local unit caster = GetTriggerUnit()
    local integer lvl = GetUnitAbilityLevel(caster, Scatter_Shot_AbilId())    
    local location target = GetSpellTargetLoc()
    local real x = GetLocationX(target)
    local real y = GetLocationY(target)
    local integer i = 0
    local integer amount = Scatter_Shot_Pellets(lvl)
    
    loop
        set i = i + 1
        exitwhen i > amount
        call SetTableObject(s,"Caster",caster)
        call SetTableReal(s,"X",x)
        call SetTableReal(s,"Y",y)
        call TimerStart(t, 0.1, false, function Scatter)
        set amount = amount + 1        
    endloop
    
    call RemoveLocation(target)
    set target = null            
    set caster = 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

It worked fine without the timers and a simple 'wait' in a loop, but then the scattered shots did not fire simultaneously, which I need.

Can I not run timers like this, i.e. 8 at once using same values?

Currently: The unit are created. but nothing happens o.0
01-22-2007, 10:14 PM#2
Mezzer
Why are you attackgrounding anyway? There are a lot of easier ways to make that spell
01-22-2007, 10:18 PM#3
Fulla
Oho? Please enlighten me.
01-22-2007, 10:28 PM#4
Mezzer
Well, the original spell uses the rockets off of the ogre alchemist (whatever) hero. And that's it really.
01-22-2007, 10:43 PM#5
Fulla
hmm, just looked in the Dota map, he does same way as me.
01-22-2007, 10:50 PM#6
Mezzer
Seriously? Why? Just do it off of the missle spell, it takes minimal customizing. Unless you need some extra options or something.
01-22-2007, 11:07 PM#7
Fulla
Ok, which spell thou?

Cluster Rockets - MUST target a unit
Acid Bomb - MUST target a unit
Healing Spray - works, but projectiles dont all come out instantly and not at correct angle.
01-22-2007, 11:08 PM#8
Joker
This should not be a constant
Collapse JASS:
constant function Scatter_Shot_Pellets takes integer lvl returns integer
    if (lvl !=5) then
        return (lvl * 4) + 4
    endif
    return 28
endfunction
2nd time i seen you do this...
01-22-2007, 11:15 PM#9
Mezzer
Cluster rockets, and it target's an area.
01-22-2007, 11:17 PM#10
Ryude
Cluster Rockets can be customized to fire all at once.
01-22-2007, 11:35 PM#11
Fulla
Zoom (requires log in)

Scattershot just doesnt look right
Attached Images
File type: jpgScattershot.JPG (112.6 KB)
01-22-2007, 11:38 PM#12
Mezzer
Use a higher arc for the missles, that'll make it look more natural. Edit it to fire the missles in 0.01 intervals, set the stun to 0.01, and the rest is up to your needs.
01-22-2007, 11:42 PM#13
Chuckle_Brother
@Joker - You're wrong, go away.

Anyways, create the units, store them, then do a short timer of 0.001 seconds and do the rest of your actions. A wait will just goof up.