HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Chaos Bomb

09-28-2008, 03:14 PM#1
Quetzalcotl
I'm busy with a rpg and I'm making some spells in JASS (first it was in GUI but i just transfered to JASS)

The spell summons a small ball that grows bigger and it will eventually explode, dealing 6xInt in damage to all nearby enemy units

This is what i have:

Collapse JASS:
function Trig_Chaos_Bomb_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A010'
endfunction

function Chaos_Bomb_Damage takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit u
    local player p = GetOwningPlayer(caster)
    local group g
    local location bombloc = GetSpellTargetLoc()
    set g = GetUnitsInRangeOfLocAll (400, bombloc )
        loop
        set u = FirstOfGroup ( g )
        exitwhen u == null
        call GroupRemoveUnit (g , u )
        if IsUnitEnemy(u, p) then
            call UnitDamageTargetBJ(caster, u, ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, caster, true)) * 6.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
        endif
    endloop
endfunction    

function Trig_Chaos_Bomb_Actions takes nothing returns nothing
    local real size = 100.00
    local unit caster = GetTriggerUnit()
    local unit bomb
    local unit explosion
    local unit u
    local group g
    local player p = GetOwningPlayer(caster)
    local location bombloc = GetSpellTargetLoc()
    set bomb = CreateUnitAtLoc(p,'h00B',bombloc,bj_UNIT_FACING)
    set bj_forLoopAIndex = 1
    loop
    exitwhen bj_forLoopAIndex > 50
        set size = ( size + 10 )
        call SetUnitScalePercent( bomb, size, size, size )
        call TriggerSleepAction( 0.01 )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call RemoveUnit(bomb)
    set explosion = CreateUnitAtLoc(p,'h00C',bombloc,bj_UNIT_FACING)
    call TriggerSleepAction( 1.00 )
    call function (Chaos_Bomb_Damage())
    call DestroyGroup(g)
    call RemoveLocation( bombloc )
    call RemoveUnit(explosion)
    set bomb = null
    set caster = null
    set bombloc=null
    set explosion=null
    set g=null
    set p=null
endfunction

//===========================================================================
function InitTrig_Chaos_Bomb takes nothing returns nothing
    set gg_trg_Chaos_Bomb = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Chaos_Bomb, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Chaos_Bomb, Condition( function Trig_Chaos_Bomb_Conditions ) )
    call TriggerAddAction( gg_trg_Chaos_Bomb, function Trig_Chaos_Bomb_Actions )
endfunction

But when i test it i get a fatal error...
Can anyone help me fix this?
09-28-2008, 03:31 PM#2
Zerzax
Collapse JASS:
 call Chaos_Bomb_Damage()
instead of
Collapse JASS:
call function (Chaos_Bomb_Damage())

Your main problem is most likely that you are using event natives inside your damage function. You can only use natives such as GetTriggerUnit() inside your action function. Use all of the data you have in your action function to deal the damage. Also, you don't need to declare a local player for GetOwningPlayer(caster), it's unnecessary.
09-28-2008, 03:41 PM#3
Quetzalcotl
Ok first: I have good news and bad news, the good news is that it doesnt crash but the bad news is that it doesnt do damage either...

And about the other part, how am I supposed to use them in the other function then?
09-28-2008, 04:02 PM#4
Zerzax
Collapse JASS:
function Trig_Chaos_Bomb_Actions takes nothing returns nothing
    local real size = 100.00
    local unit caster = GetTriggerUnit()
    local unit bomb
    local unit explosion
    local unit u
    local group g
    local player p = GetOwningPlayer(caster)
    local location bombloc = GetSpellTargetLoc()
    set bomb = CreateUnitAtLoc(p,'h00B',bombloc,bj_UNIT_FACING)
    set bj_forLoopAIndex = 1
    loop
    exitwhen bj_forLoopAIndex > 50
        set size = ( size + 10 )
        call SetUnitScalePercent( bomb, size, size, size )
        call TriggerSleepAction( 0.01 )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call RemoveUnit(bomb)
    set explosion = CreateUnitAtLoc(p,'h00C',bombloc,bj_UNIT_FACING)
    call TriggerSleepAction( 1.00 )


    set g = GetUnitsInRangeOfLocAll (400, bombloc )
        loop
        set u = FirstOfGroup ( g )
        exitwhen u == null
        call GroupRemoveUnit (g , u )
        if IsUnitEnemy(u, p) then
            call UnitDamageTargetBJ(caster, u, ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, caster, true)) * 6.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
        endif
    endloop


    call DestroyGroup(g)
    call RemoveLocation( bombloc )
    call RemoveUnit(explosion)
    set bomb = null
    set caster = null
    set bombloc=null
    set explosion=null
    set g=null
    set p=null
endfunction


I basically pasted your damage in, but you get the point right? You can do all you want to without calling that function: you know the location, the caster, you have a group ready, and you can deal the damage inside the action function.
09-28-2008, 04:31 PM#5
Quetzalcotl
Dude... U'r a genious! Thank you so much! :D
09-28-2008, 04:46 PM#6
Zerzax
Glad to help.