• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Chaos Bomb - Spell

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2008
Messages
253
I'm making a spell called Chaos Bomb, it creates a small ball that keeps growing and eventually will explode and deal 6xint in damage to all units in 400 range. I have the growing part but the damage part doesnt work for me :sad:

This is what i have:

JASS:
function Trig_Chaos_Bomb_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A010' ) ) then
        return false
    endif
    return true
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
    call CreateNUnitsAtLoc( 1, 'h00B', GetOwningPlayer(caster), GetSpellTargetLoc(), bj_UNIT_FACING )
    set bomb = GetLastCreatedUnit()
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 50
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set size = ( size + 10 )
        call SetUnitScalePercent( bomb, size, size, size )
        call TriggerSleepAction( 0.01 )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call RemoveUnit(bomb)
    call CreateNUnitsAtLoc( 1, 'h00C', GetOwningPlayer(caster), GetUnitLoc(bomb), bj_UNIT_FACING)
    set explosion = GetLastCreatedUnit()
    call TriggerSleepAction( 1.00 )
    set g = CreateGroup()
    call GetUnitsInRangeOfLocAll (400, GetUnitLoc (bomb) )
    loop
        exitwhen u == null
        set u = FirstOfGroup ( g )
        if IsUnitEnemy(u, GetOwningPlayer(caster)) then
            call UnitDamageTargetBJ(caster, u, ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, caster, true)) * 6.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )  
        endif 
        call GroupRemoveUnit (g , u )
        call RemoveUnit(explosion)
    set bomb = null
    set caster = null
    endloop
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

Can anyone help me fix it?

Thanks in advance,
Quetzalcotl
 
Level 21
Joined
Aug 9, 2006
Messages
2,384
You are such a genius... you picked the units wrong...



call GetUnitsInRangeOfLocAll (400, GetUnitLoc (bomb) )

should be:

set g = GetUnitsInRangeOfLocAll (400, GetUnitLoc (bomb) )

And fix the GetUnitLoc, it leaks. Set it before to a local var and remove it afterwards.


Together with the other change it should work now.
 
Level 7
Joined
Jul 9, 2008
Messages
253
I tried to do that (i'm new to JASS so that's why im not good) but it still doesnt work

This is what i have now :

JASS:
function Trig_Chaos_Bomb_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A010' ) ) then
        return false
    endif
    return true
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 location bombloc = GetUnitLoc(bomb)
    call CreateNUnitsAtLoc( 1, 'h00B', GetOwningPlayer(caster), GetSpellTargetLoc(), bj_UNIT_FACING )
    set bomb = GetLastCreatedUnit()
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 50
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set size = ( size + 10 )
        call SetUnitScalePercent( bomb, size, size, size )
        call TriggerSleepAction( 0.01 )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call RemoveUnit(bomb)
    call CreateNUnitsAtLoc( 1, 'h00C', GetOwningPlayer(caster), bombloc, bj_UNIT_FACING)
    set explosion = GetLastCreatedUnit()
    call TriggerSleepAction( 1.00 )
    set g = GetUnitsInRangeOfLocAll (400, bombloc )
    loop
        exitwhen u == null
        set u = FirstOfGroup ( g )
        if IsUnitEnemy(u, GetOwningPlayer(caster)) then
            call UnitDamageTargetBJ(caster, u, ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, caster, true)) * 6.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )  
        endif 
        call GroupRemoveUnit (g , u )
        call RemoveUnit(explosion)
    set bomb = null
    set caster = null
    call RemoveLocation( bombloc )
    endloop
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
 
Level 14
Joined
Jan 15, 2007
Messages
349
Hmm you had two leaks, also you should learn to use natives and no BJ's. Well but I fixed the main stuff. There you got:

JASS:
function Trig_Chaos_Bomb_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A010'
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 )
    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 havent tested it yet because Im at work but it should work.
 
Last edited:
Level 7
Joined
Jul 9, 2008
Messages
253
What doesnt work?... maybe closer information...? This is like a riddle... and I hate riddles...

Well the growing thing works fine but when it explode and should do damage, it doesnt.

EDIT: So i tried something else

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 ExecuteFunc (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 now when i press enable trigger, editor shuts off >.>
 
Last edited:
Status
Not open for further replies.
Top