| 09-27-2007, 02:30 PM | #1 |
I've been working on this spell called Elemental Fury, that basically shoots 4 breath of fires every 90 degrees from the caster point and 4 breath of frosts in between the fire. It then alternates 4 times every second for 4 seconds, frost where fire was, and vice versa. It works as intended, except right before the first wave there is a slight second of lag. The lag usually does not persist, it stops after the first time it's cast, sometimes it lags everytime. I thought it might be because I've read using gamecache is slow but I don't think this is the case. I think it might be the if/elseif/then in the very first part that's run checking the ability. Perhaps maybe using a timer array and setting em? JASS:function ElementalFuryCond takes nothing returns boolean local integer i = GetSpellAbilityId() return (i == 'A04I') or (i == 'A04U') or (i == 'A04V') or (i == 'A04T') or (i == 'A04W') endfunction function ElementalWave takes nothing returns nothing local timer t = GetExpiredTimer() local unit u = GetHandleUnit(t, "caster") local integer spell1 = GetHandleInt(t, "spell1") local integer spell2 = GetHandleInt(t, "spell2") local string order1 = GetHandleString(t, "order1") local string order2 = GetHandleString(t, "order2") local player p = GetOwningPlayer(u) local integer i = 1 local real x1 = GetUnitX(u) local real y1 = GetUnitY(u) local real x2 local real y2 local unit v = CreateUnit(p, 'h062', x1, y1, 270) loop exitwhen i > 8 set x2 = x1 + 300 * Cos(45* I2R(i) * bj_DEGTORAD) set y2 = y1 + 300 * Sin(45* I2R(i) * bj_DEGTORAD) if (i==2) or (i==4) or (i==6)or (i==8) then call UnitAddAbility(v, spell1) call IssuePointOrder(v, order1, x2, y2) else call UnitAddAbility(v, spell2) call IssuePointOrder(v, order2, x2, y2) endif call UnitRemoveAbility(v, spell1) call UnitRemoveAbility(v, spell2) set i = i + 1 endloop call RemoveUnit(v) call FlushHandleLocals(t) call PauseTimer(t) call DestroyTimer(t) set t = null set u = null set p = null set v = null endfunction function ElementalFury takes nothing returns nothing local unit u = GetSpellAbilityUnit() local integer id = GetSpellAbilityId() local integer spell1 local integer spell2 local integer i = 1 local real x1 = GetUnitX(u) local real y1 = GetUnitY(u) local real x2 local real y2 local timer array t set t[1] = CreateTimer() set t[2] = CreateTimer() set t[3] = CreateTimer() set t[4] = CreateTimer() if (id == 'A04I') then set spell1 = 'A04J' set spell2 = 'A04K' elseif (id == 'A04U') then set spell1 = 'A04N' set spell2 = 'A04P' elseif (id == 'A04V') then set spell1 = 'A04M' set spell2 = 'A04Q' elseif (id == 'A04T') then set spell1 = 'A04O' set spell2 = 'A04R' elseif (id == 'A04W') then set spell1 = 'A04L' set spell2 = 'A04S' endif loop exitwhen i > 4 call SetHandleHandle(t[i], "caster", u) if (i == 1) or (i ==3) then call SetHandleInt(t[i], "spell1", spell1) call SetHandleInt(t[i], "spell2", spell2) call SetHandleString(t[i], "order1", "breathoffire") call SetHandleString(t[i], "order2", "breathoffrost") else call SetHandleInt(t[i], "spell1", spell2) call SetHandleInt(t[i], "spell2", spell1) call SetHandleString(t[i], "order1", "breathoffrost") call SetHandleString(t[i], "order2", "breathoffire") endif call TimerStart(t[i], i * 1, false, function ElementalWave) set t[i] = null set i = i + 1 endloop set u = null endfunction function InitTrig_ElementalFuryCast takes nothing returns nothing local integer i = 0 local player p set gg_trg_ElementalFuryCast = CreateTrigger() loop exitwhen i > 11 set p = Player(i) call TriggerRegisterPlayerUnitEvent(gg_trg_ElementalFuryCast, p, EVENT_PLAYER_UNIT_SPELL_EFFECT, null) set i = i + 1 endloop call TriggerAddCondition(gg_trg_ElementalFuryCast, Condition(function ElementalFuryCond)) call TriggerAddAction(gg_trg_ElementalFuryCast, function ElementalFury) set p = null endfunction |
| 09-27-2007, 03:10 PM | #2 |
Just a wild guess but maybe the dummy unit caster isn't turning fast enough. Or the dummy unit caster has a long animation cast point. I'm also not familiar with how a loop of orders works, I don't believe it chains them. So your ElementalWave loop which does 8 UnitPointOrder's may only actually be doing one of them (or none). It actually may be undefined. Try creating one dummy unit per order, and instead of removing it right away give it a timed life of 0.5 or 1.0. See if this fixes the problem then you know where to aim your efforts. |
| 09-27-2007, 03:52 PM | #3 |
I made the changes and no dice so far :(. Dummy unit turn rate is max and animation cast point is 0, but I changed it anyway to create seperate unit for each cast just to see. It lags just long enough after it starts to cast, you just see the first wave shoot out real fast, then it works normally. I even changed the created units facing to where it will cast. JASS:
loop
exitwhen i > 8
set x2 = x1 + 300 * Cos(45* I2R(i) * bj_DEGTORAD)
set y2 = y1 + 300 * Sin(45* I2R(i) * bj_DEGTORAD)
set v = CreateUnit(p, 'h062', x1, y1, 45*i)
call UnitApplyTimedLife(v, 'BTLF', 1.5)
if (i==2) or (i==4) or (i==6)or (i==8) then
call UnitAddAbility(v, spell1)
call IssuePointOrder(v, order1, x2, y2)
else
call UnitAddAbility(v, spell2)
call IssuePointOrder(v, order2, x2, y2)
endif
call UnitRemoveAbility(v, spell1)
call UnitRemoveAbility(v, spell2)
set i = i + 1
endloop
|
| 09-28-2007, 12:37 AM | #4 |
I also had the same problem with one of my spells. Try preloading the fire and ice spells. I know there not effects but i may help. |
| 09-28-2007, 01:53 AM | #5 |
Yeah, the problem is that the graphics are not yet loaded. To fix this, have a dummy unit cast each of your dummy spells on a random point at map init. Or you could try preloading the effects listed in the Object Editor field for Breath of Fire/Frost. |
| 09-28-2007, 03:07 AM | #6 |
Hey that worked great, thanks guys. I didn't know effects had to be loaded first . Creating a dummy to cast em both on map init did the trick, now it runs smooth. |
