HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spell doesnt activate at all...

01-31-2008, 01:44 AM#1
shadowange1
This spell is meant to create explosions on the unit 4 times or and damage any units including it and the surrounding unit.

The spell doesnt work at all t never even gets activated and i dont know why.
I added some diplay text to see where it gets to if anywhere and not one even pops up.
Anyone know what i did wrong in the code below?
Collapse JASS:
function Trig_Pulse_Explosion_Conditions takes nothing returns boolean
    if (GetSpellAbilityId() == 'A03O') then
        return true
    endif
    return false
endfunction

function Trig_Pulse_Explosion_Actions takes nothing returns nothing
    local unit cas = GetSpellAbilityUnit()
    local unit tar = GetSpellTargetUnit()
    local unit f
    local group g1
    local group g2
    local effect e1
    local real x
    local real y
    local real d = I2R(GetHeroStatBJ(bj_HEROSTAT_INT, cas, true))
    set x=GetUnitX(tar)
    set y=GetUnitY(tar)
    call GroupEnumUnitsInRange(g1, x, y, 150, null)
    set g2=g1
    call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "abc" )
    loop
        set f = FirstOfGroup(g2)
        exitwhen f==null
        if ( (IsUnitType(f, UNIT_TYPE_STRUCTURE)==true) or (IsUnitDeadBJ(f)==true) or (IsUnitType(f, UNIT_TYPE_MAGIC_IMMUNE)==true) or (IsUnitAlly(f, GetOwningPlayer(cas))==true)) then
            call GroupRemoveUnit( g1, f )
        endif
        call GroupRemoveUnit(g2,f)
    endloop
    if (GetUnitState(tar, UNIT_STATE_LIFE) > 0.405) then
        set e1 = AddSpecialEffect( "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl", x, y )
        call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "effect" )
    endif
    call TriggerSleepAction( .5 )
    loop
        set f = FirstOfGroup(g1)
        exitwhen f==null
        if ((GetUnitState(f, UNIT_STATE_LIFE) > 0.405) and (GetUnitState(tar, UNIT_STATE_LIFE) > 0.405)) then
            call UnitDamageTargetBJ( cas, f, d, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC )
            call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "damage" )
        endif
        call GroupRemoveUnit(g1,f)
    endloop
    call DestroyGroup (g1)
    call DestroyGroup (g2)
    call DestroyEffectBJ( e1 )
    set f=null
    call TriggerSleepAction( .5 )
//2
    set x=GetUnitX(tar)
    set y=GetUnitY(tar)
    call GroupEnumUnitsInRange(g1, x, y, 150, null)
    set g2=g1
    loop
        set f = FirstOfGroup(g2)
        exitwhen f==null
        if ( (IsUnitType(f, UNIT_TYPE_STRUCTURE)==true) or (IsUnitDeadBJ(f)==true) or (IsUnitType(f, UNIT_TYPE_MAGIC_IMMUNE)==true) or (IsUnitAlly(f, GetOwningPlayer(cas))==true)) then
            call GroupRemoveUnit( g1, f )
        endif
        call GroupRemoveUnit(g2,f)
    endloop
    if (GetUnitState(tar, UNIT_STATE_LIFE) > 0.405) then
        set e1 = AddSpecialEffect( "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl", x, y )
    endif
    call TriggerSleepAction( .5 )
    loop
        set f = FirstOfGroup(g1)
        exitwhen f==null
        if ((GetUnitState(f, UNIT_STATE_LIFE) > 0.405) and (GetUnitState(tar, UNIT_STATE_LIFE) > 0.405)) then
            call UnitDamageTargetBJ( cas, f, d, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC )
        endif
        call GroupRemoveUnit(g1,f)
    endloop
    call DestroyGroup (g1)
    call DestroyGroup (g2)
    call DestroyEffectBJ( e1 )
    set f=null
    call TriggerSleepAction( .5 )
//3
    set x=GetUnitX(tar)
    set y=GetUnitY(tar)
    call GroupEnumUnitsInRange(g1, x, y, 150, null)
    set g2=g1
    loop
        set f = FirstOfGroup(g2)
        exitwhen f==null
        if ( (IsUnitType(f, UNIT_TYPE_STRUCTURE)==true) or (IsUnitDeadBJ(f)==true) or (IsUnitType(f, UNIT_TYPE_MAGIC_IMMUNE)==true) or (IsUnitAlly(f, GetOwningPlayer(cas))==true)) then
            call GroupRemoveUnit( g1, f )
        endif
        call GroupRemoveUnit(g2,f)
    endloop
    if (GetUnitState(tar, UNIT_STATE_LIFE) > 0.405) then
        set e1 = AddSpecialEffect( "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl", x, y )
    endif
    call TriggerSleepAction( .5 )
    loop
        set f = FirstOfGroup(g1)
        exitwhen f==null
        if ((GetUnitState(f, UNIT_STATE_LIFE) > 0.405) and (GetUnitState(tar, UNIT_STATE_LIFE) > 0.405)) then
            call UnitDamageTargetBJ( cas, f, d, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC )
        endif
        call GroupRemoveUnit(g1,f)
    endloop
    call DestroyGroup (g1)
    call DestroyGroup (g2)
    call DestroyEffectBJ( e1 )
    set f=null
    call TriggerSleepAction( .5 )
//4
    set x=GetUnitX(tar)
    set y=GetUnitY(tar)
    call GroupEnumUnitsInRange(g1, x, y, 150, null)
    set g2=g1
    loop
        set f = FirstOfGroup(g2)
        exitwhen f==null
        if ( (IsUnitType(f, UNIT_TYPE_STRUCTURE)==true) or (IsUnitDeadBJ(f)==true) or (IsUnitType(f, UNIT_TYPE_MAGIC_IMMUNE)==true) or (IsUnitAlly(f, GetOwningPlayer(cas))==true)) then
            call GroupRemoveUnit( g1, f )
        endif
        call GroupRemoveUnit(g2,f)
    endloop
    if (GetUnitState(tar, UNIT_STATE_LIFE) > 0.405) then
        set e1 = AddSpecialEffect( "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl", x, y )
    endif

    call TriggerSleepAction( .5 )
    loop
        set f = FirstOfGroup(g1)
        exitwhen f==null
        if ((GetUnitState(f, UNIT_STATE_LIFE) > 0.405) and (GetUnitState(tar, UNIT_STATE_LIFE) > 0.405)) then
            call UnitDamageTargetBJ( cas, f, d, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC )
        endif
        call GroupRemoveUnit(g1,f)
    endloop
    call DestroyGroup (g1)
    call DestroyGroup (g2)
    call DestroyEffectBJ( e1 )
    set f=null
    set cas = null
    set tar = null
endfunction

//===========================================================================
function InitTrig_Pulse_Explosion takes nothing returns nothing
    set gg_trg_Pulse_Explosion = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Pulse_Explosion, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Pulse_Explosion, Condition( function Trig_Pulse_Explosion_Conditions ) )
    call TriggerAddAction( gg_trg_Pulse_Explosion, function Trig_Pulse_Explosion_Actions )
endfunction

01-31-2008, 01:50 AM#2
Blue_Jeans
I think your event is wrong. I think it should be EVENT_PLAYER_UNIT_SPELL_EFFECT, but I may not be correct. This would make your trigger not work at all, if it is the case.

Also, you need to do some code clean-up. For example, this:
Collapse JASS:
function Trig_Pulse_Explosion_Conditions takes nothing returns boolean
    if (GetSpellAbilityId() == 'A03O') then
        return true
    endif
    return false
endfunction
should be this:
Collapse JASS:
function Trig_Pulse_Explosion_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A03O'
endfunction
Edit: I have time to play around with this. I'll see what I can do.
01-31-2008, 02:12 AM#3
shadowange1
Thanks Blue_Jeans i will try that right now and as for code clean up i convert some parts of the trigger from custom text to help me out since i'm still in the starting stages of learning jass, but ty a bunch for that correction.

Okay i tried that and it didint work, but ty for trying to help
01-31-2008, 02:12 AM#4
moyack
Collapse JASS:
local group g1 = CreateGroup()
You have to create the group.

set g2=g1 if this line is for copy the group, then you're failing horribly, because it won't copy it, just giving a reference to g2 to the same handle. Copying should be made in this way:

Collapse Copy group:
function CopyGroup takes group g returns group
    set bj_groupAddGroupDest = CreateGroup()
    call ForGroup(g, function GroupAddGroupEnum)
    return bj_groupAddGroupDest
endfunction

Think seriously is avoid the triggersleepactions, it will limit you a lot in obtain good quality spells.

My best advice: cehck this tutorial, it will help you a lot to get tricks: http://www.wc3campaigns.net/showthread.php?t=83337
01-31-2008, 02:33 AM#5
shadowange1
Moyack i will try that right now,but the sleep actions are to damage every second and to make the damage happen as the effect lands(since it comes from the air). Thanks for the quick reply
Is there anyway of doing this better?

and at the set g2=g1 ive programed in c++ b4 and that was how i copied stuff so i was assuming i could do that here. So does that mean ther equal thing wont work for anthing else or is this just something i cant do for groups?

EDIT:
Okay Moyack ty a bunch it worked =) now i just have to fix the damage that only happens once but that should be easy.
01-31-2008, 05:32 AM#6
Blue_Jeans
Here, I made this spell. I am not saying this is the best way to do it, I simply used similar tactics to the one you were using. This isn't how I would do it, but it does work and you should be able to modify it to your needs.

Collapse JASS:
constant function Pulse_Explosion_RC takes nothing returns integer
    return 'A002'
endfunction
function Pulse_Explosion_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Pulse_Explosion_RC()
endfunction
function Pulse_CopyGroup takes group g returns group
    set bj_groupAddGroupDest = CreateGroup()
    call ForGroup(g, function GroupAddGroupEnum)
    return bj_groupAddGroupDest
endfunction
function Pulse_Explosion_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit f
    local group g
    local group copy
    local real x
    local real y
    local integer level = GetUnitAbilityLevel(caster,Pulse_Explosion_RC())
    local integer i=4
    loop
        exitwhen i==0
        set x=GetUnitX(caster)
        set y=GetUnitY(caster)
        set g=CreateGroup()
        call GroupEnumUnitsInRange(g, x, y, 300, null)
        set copy=Pulse_CopyGroup(g)
        loop
            set f = FirstOfGroup(copy)
            exitwhen f==null
            if ( (IsUnitType(f, UNIT_TYPE_STRUCTURE)==true) or (IsUnitDeadBJ(f)==true) or (IsUnitType(f, UNIT_TYPE_MAGIC_IMMUNE)==true) or (IsUnitAlly(f, GetOwningPlayer(caster))==true)) then
                call GroupRemoveUnit(g,f)
            endif
            call GroupRemoveUnit(copy,f)
        endloop
        call DestroyGroup(copy)
        set copy=null
        loop
            set f = FirstOfGroup(g)
            exitwhen f==null
            if (GetUnitState(f, UNIT_STATE_LIFE) > 0.405) then
                call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaostarget.mdl", f,"chest"))
            endif
            call UnitDamageTarget(caster, f, 60*level, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
            call GroupRemoveUnit(g,f)
        endloop
        call DestroyGroup(g)
        set g=null
        set i=i-1
        call TriggerSleepAction(1)
    endloop
    set caster = null
endfunction

//===========================================================================
function InitTrig_Pulse_Explosion takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( trig, Condition( function Pulse_Explosion_Conditions ) )
    call TriggerAddAction( trig, function Pulse_Explosion_Actions )
endfunction 

Rep me if you feel like it.