HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why isn't the loop working?

07-11-2006, 01:56 PM#1
JeffreyQ
Trigger:
Holy Blast
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to Holy Blast (Angel)
Collapse Actions
Set HolyBlast_Caster = (Casting unit)
Set HolyBlast_Dmg = ((Intelligence of HolyBlast_Caster (Include bonuses)) x 10
Unit - Create 1 Holy Blast Dummy for (Owner of HolyBlast_Caster) at (Position of HolyBlast_Caster) facing (Target point of ability being cast)
Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
Collapse For each (Integer B) from 1 to 9, do (Actions)
Collapse Loop - Actions
Set HolyBlast_OffsetAdd = (HolyBlast_OffsetAdd + 125)
Unit - Cause HolyBlast_Caster to damage circular area after 0.00 seconds of radius 180.00 at ((Position of HolyBlast_Caster) offset by (Real(HolyBlast_OffsetAdd)) towards (Facing of HolyBlast_Caster) degrees), dealing (Real(HolyBlast_Dmg)) damage of attack type Hero and damage type Normal
Floating Text - Create floating text that reads ((String(HolyBlast_Dmg)) + !) at ((Position of HolyBlast_Caster) offset by (Real(HolyBlast_OffsetAdd)) towards (Facing of HolyBlast_Caster) degrees) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 0.00%), and 0.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds

Collapse JASS:
function Trig_Holy_Blast_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A04M' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Holy_Blast_Actions takes nothing returns nothing
    set udg_HolyBlast_Caster = GetSpellAbilityUnit()
    set udg_HolyBlast_Dmg = ( GetHeroStatBJ(bj_HEROSTAT_INT, udg_HolyBlast_Caster, true) * 10 )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'e011', GetOwningPlayer(udg_HolyBlast_Caster), GetUnitLoc(udg_HolyBlast_Caster), GetSpellTargetLoc() )
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', GetLastCreatedUnit() )
    set bj_forLoopBIndex = 1
    set bj_forLoopBIndexEnd = 9
    loop
        exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
        set udg_HolyBlast_OffsetAdd = ( udg_HolyBlast_OffsetAdd + 125 )
        call UnitDamagePointLoc( udg_HolyBlast_Caster, 0.00, 180.00, PolarProjectionBJ(GetUnitLoc(udg_HolyBlast_Caster), I2R(udg_HolyBlast_OffsetAdd), GetUnitFacing(udg_HolyBlast_Caster)), I2R(udg_HolyBlast_Dmg), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
        call CreateTextTagLocBJ( ( I2S(udg_HolyBlast_Dmg) + "!" ), PolarProjectionBJ(GetUnitLoc(udg_HolyBlast_Caster), I2R(udg_HolyBlast_OffsetAdd), GetUnitFacing(udg_HolyBlast_Caster)), 0, 10, 100.00, 100.00, 0.00, 0 )
        call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
        call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 64, 90 )
        call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 1.50 )
        call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 1.00 )
        set bj_forLoopBIndex = bj_forLoopBIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Holy_Blast takes nothing returns nothing
    set gg_trg_Holy_Blast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Holy_Blast, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Holy_Blast, Condition( function Trig_Holy_Blast_Conditions ) )
    call TriggerAddAction( gg_trg_Holy_Blast, function Trig_Holy_Blast_Actions )
endfunction

I notice the loop actions only work for the 1st time when the ability is 1st casted. But it won't work for the 2nd time. Why?
07-11-2006, 02:37 PM#2
Whitehorn
It does it 9 times in 0 seconds.. ?
07-11-2006, 02:39 PM#3
JeffreyQ
yes, for the first time. The floating text is for checking. But it only works for the 1st time.
07-11-2006, 02:51 PM#4
Whitehorn
My point is you have a loop that does 9 things in 0 seconds, so you probably only see the last 'time'...
07-11-2006, 03:06 PM#5
The)TideHunter(
Whitehorn's right, the text's probally all overlap each other.
A way to test this would be to check if the units you are hurting take 1 set of damage or 9 instantly.
07-11-2006, 03:12 PM#6
JeffreyQ
the above spell should damage and display text in a straight line.
it display the damage of the spell correctly as what i wanted it to do, and it does the correct amount of damage in a line. But the 2nd time, it doesn't do any damage to units or show any text. I tested this a few times with my friends.

i cant figure out why cant the loop work when i use the spell for the 2nd and above time.
07-12-2006, 11:42 AM#7
Zypherion
Make sure you set udg_HolyBlast_OffsetAdd to 0 when the spell is done... that's the only thing i can see which could cause it...
07-12-2006, 12:36 PM#8
JeffreyQ
yea, thx Zypherion. Didnt notice that. I was wrong to blame the loop.