| 09-19-2007, 03:25 AM | #1 |
JASS:struct TArrows unit triggerunit integer level integer time2 real x real y endstruct struct TArrows2 unit arrow real angle real speed integer level unit triggerunit real x real y static unit u endstruct function TArrows_Filter takes nothing returns boolean return GetWidgetLife(GetFilterUnit()) > 0 and IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(TArrows2.u)) and not IsUnitType(GetFilterUnit(),UNIT_TYPE_FLYING) endfunction function TArrows_Final2 takes nothing returns nothing local timer t = GetExpiredTimer() local TArrows2 ta2 = TArrows2(GetAttachedInt(t,"ta2")) local group g = CreateGroup() local unit u call KillUnit(ta2.arrow) call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Feedback\\SpellBreakerAttack.mdl",GetUnitX(ta2.arrow),GetUnitY(ta2.arrow))) set TArrows2.u = ta2.triggerunit call GroupEnumUnitsInRange(g,GetUnitX(ta2.arrow),GetUnitY(ta2.arrow),50,Filter(function TArrows_Filter)) loop set u = FirstOfGroup(g) exitwhen u == null call GroupRemoveUnit(g,u) call UnitDamageTarget(ta2.triggerunit,u,50.0,true,true,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS) endloop call CleanAttachedVars(t) call DestroyTimer(t) call TArrows2.destroy(ta2) set t = null call DestroyGroup(g) set g = null set u = null endfunction function TArrows_Final takes nothing returns nothing local timer t = GetExpiredTimer() local TArrows2 ta2 = TArrows2(GetAttachedInt(t,"ta2")) local real x = ta2.x + GetRandomReal(0,300) * Cos(GetRandomReal(0,360) * bj_DEGTORAD) local real y = ta2.y + GetRandomReal(0,300) * Sin(GetRandomReal(0,360) * bj_DEGTORAD) set ta2.arrow = CreateUnit(GetOwningPlayer(ta2.triggerunit),'h000',x,y,GetRandomReal(0,360)) call AddSpecialEffectTarget("Abilities\\Weapons\\MoonPriestessMissile\\MoonPriestessMissile.mdl",ta2.arrow,"origin") call SetUnitAnimationByIndex(ta2.arrow,0) call SetUnitFlyHeight(ta2.arrow,2050,0) call SetUnitFlyHeight(ta2.arrow,17,2000) call PauseTimer(t) call AttachInt(t,"ta2",ta2) call TimerStart(t,1.05,false,function TArrows_Final2) set t = null endfunction function TArrows_Move takes nothing returns nothing local timer t = GetExpiredTimer() local TArrows2 ta2 = TArrows2(GetAttachedInt(t,"ta2")) local real x = GetUnitX(ta2.arrow) + ta2.speed * Cos(ta2.angle * bj_DEGTORAD) local real y = GetUnitY(ta2.arrow) + ta2.speed * Sin(ta2.angle * bj_DEGTORAD) call SetUnitX(ta2.arrow,x) call SetUnitY(ta2.arrow,y) if GetWidgetLife(ta2.arrow) == 0 then call PauseTimer(t) set ta2.arrow = null call AttachInt(t,"ta2",ta2) call TimerStart(t,6.0,false,function TArrows_Final) endif set t = null endfunction function TArrows_Timer1 takes nothing returns nothing local timer t = GetExpiredTimer() local timer t2 = CreateTimer() local timer t3 local TArrows ta = TArrows(GetAttachedInt(t,"ta")) local TArrows2 ta2 = TArrows.create() set ta2.arrow = CreateUnit(GetOwningPlayer(ta.triggerunit),'h000',GetUnitX(ta.triggerunit),GetUnitY(ta.triggerunit),GetRandomReal(0,360)) call AddSpecialEffectTarget("Abilities\\Weapons\\MoonPriestessMissile\\MoonPriestessMissile.mdl",ta2.arrow,"origin") call SetUnitAnimationByIndex(ta2.arrow,180) call SetUnitFlyHeight(ta2.arrow,90.0,0) call SetUnitFlyHeight(ta2.arrow,2090.0,1000.0) call UnitApplyTimedLife(ta2.arrow,'BTLF',2.0) set ta2.angle = GetRandomReal(0,360) set ta2.speed = (GetRandomReal(0,75) * 0.04) set ta2.level = ta.level set ta2.x = ta.x set ta2.y = ta.y set ta2.triggerunit = ta.triggerunit call AttachInt(t2,"ta2",ta2) call TimerStart(t2,0.04,true,function TArrows_Move) if GetUnitCurrentOrder(ta.triggerunit) != 852238 then call PauseTimer(t) set ta.triggerunit = null call CleanAttachedVars(t) call DestroyTimer(t) call TArrows.destroy(ta) endif set t = null set t2 = null set t3 = null endfunction function TArrows_Actions takes nothing returns nothing local timer t = CreateTimer() local TArrows ta = TArrows.create() local location l = GetSpellTargetLoc() set ta.triggerunit = GetTriggerUnit() set ta.level = GetUnitAbilityLevel(ta.triggerunit,'A003') set ta.x = GetLocationX(l) set ta.y = GetLocationY(l) call RemoveLocation(l) set l = null call AttachInt(t,"ta",ta) call TimerStart(t,(3.0/200.0),true,function TArrows_Timer1) set t = null endfunction function TArrows_Conds takes nothing returns boolean return GetSpellAbilityId() == 'A003' endfunction function InitTrig_TArrows takes nothing returns nothing set gg_trg_TArrows = CreateTrigger( ) call TriggerAddAction( gg_trg_TArrows, function TArrows_Actions ) call TriggerAddCondition(gg_trg_TArrows,Condition(function TArrows_Conds)) call TriggerRegisterAnyUnitEventBJ(gg_trg_TArrows,EVENT_PLAYER_UNIT_SPELL_EFFECT) endfunction |
| 09-19-2007, 03:31 AM | #2 |
why do you attach ta2 again to TArrows_Move ? The only time in which you assign triggerunit to ta2 seems to be in a place in which you assign null to it in function TArrows_Timer1 ... |
| 09-19-2007, 03:39 AM | #3 |
Thanks. That was the problem.. im stupid. |
| 09-19-2007, 10:47 PM | #4 |
*bump* New question. The spell now works fine, with absolutely no lag (i drop 1 fps when casting). The problem is using it causes MASSIVE movelag. When I say massive I mean our characters weren't responding at all. Could anyone think of any reasons why this would cause such lag? Almost every jass spell seems to have some problem move lag... |
| 09-20-2007, 06:03 PM | #5 |
You do have a memory leak, regarding move lag, if I understand correctly you should take a look to any pause, issue order and set unit position action in your whole map, does this spell alone cause the issue? |
| 09-20-2007, 10:29 PM | #6 |
This is the only spell in the map, and right when you cast it the movelag happens. Could you list every reason why there WOULD be massive movelag but no FPS decrease? Oh, and it only makes movelag in multiplayer games, singleplayer is fine. |
| 09-20-2007, 10:33 PM | #7 |
well... memory leaks :/ um as for anything else the only reason that multiplayer would lag when single player doesnt that I can think of would be that if you do something for every player like an loop from 1-# of players... |
| 09-20-2007, 10:38 PM | #8 |
I believe it has something to do with too much network traffic... but im not sure. I don't think memory leaks can cause move lag, though. |
| 09-20-2007, 11:21 PM | #9 |
Humm... leaks can cause lag but ne ways... the only thing that would cause more network traffic of changes from the last state like move orders fly heights ect |
