| 06-05-2006, 08:39 PM | #1 |
Hi, any JASSers here, I am in need =(. I made the following trigger, so i can make missile effects: JASS:function Missile takes nothing returns nothing //===================IMPORTED VARS=========================== local timer t = GetExpiredTimer() local integer ExploType = GetHandleInt(t,"ExploID") local unit u = GetHandleUnit(t,"u") local unit cast = GetHandleUnit(t,"cast") local unit targ = null local real dmg = GetHandleReal(t,"dmg") local real radius = GetHandleReal(t,"rad") local real sense = GetHandleReal(t,"sns") local boolean homing = GetHandleBoolean(t,"Hom") local boolean FF = GetHandleBoolean(t,"FF") local location target = GetHandleLocation(t,"targloc") local real speed = GetHandleReal(t,"Speed") local real maxdist = GetHandleReal(t,"MxDist") local real dist = GetHandleReal(t,"Dist") local sound explode = GetHandleSound (t,"Sonido") //===================NOT IMPORTED VARS=========================== local boolean ReachesRegion=false local boolean NOW=false local boolean multit = true local boolean hit = true local unit U local group g local real x = GetUnitX( u ) + (speed) * Cos( GetUnitFacing( u )*bj_DEGTORAD ) local real y = GetUnitY( u ) + (speed) * Sin( GetUnitFacing( u )*bj_DEGTORAD) local location locazo if (homing) then set targ = GetHandleUnit(t,"target") set target = GetUnitLoc(targ) set locazo = GetUnitLoc(u) call SetUnitFacingTimed(u,AngleBetweenPoints(locazo,target),0.04) set x = GetUnitX( u ) + (speed) * Cos( GetUnitFacing(u)*bj_DEGTORAD ) set y = GetUnitY( u ) + (speed) * Sin( GetUnitFacing( u )*bj_DEGTORAD ) endif if(maxdist==0)then set ReachesRegion=true endif if(radius==0)then set multit=false endif //================= moves the projectile ================= if x < GetRectMaxX( bj_mapInitialPlayableArea ) and x > GetRectMinX( bj_mapInitialPlayableArea ) and y < GetRectMaxY( bj_mapInitialPlayableArea ) and y > GetRectMinY( bj_mapInitialPlayableArea ) then call SetUnitX( u, x ) call SetUnitY( u, y ) endif set dist=dist+speed call SetHandleReal(t,"Dist",dist) //================== should it explode?=================== set locazo = GetUnitLoc(u) set g = GetUnitsInRangeOfLocAll(sense,locazo) set U = FirstOfGroup(g) if(homing)then loop set U = FirstOfGroup(g) exitwhen (U==null)or(NOW) if(U==targ)then set NOW=true endif call GroupRemoveUnit( g, U) set U=null endloop else if(FF)then loop set U = FirstOfGroup(g) exitwhen(U==null)or(NOW) if(U!=cast)and(U!=u)and(GetUnitStateSwap(UNIT_STATE_LIFE,U)>0)then set NOW = true set targ=U endif call GroupRemoveUnit( g, U) set U=null endloop else loop set U = FirstOfGroup(g) exitwhen(U==null)or(NOW) if(GetUnitStateSwap(UNIT_STATE_LIFE,U)>0)and(IsUnitEnemy(U,GetOwningPlayer(cast)))then set NOW = true set targ=U endif call GroupRemoveUnit( g, U) set U=null endloop endif endif if(ReachesRegion)then if(DistanceBetweenPoints(locazo,target)<=30)then set NOW = true endif elseif(dist>=maxdist)then set NOW = true set hit = false endif //=============== did it explode? ======================== if(NOW)then if(explode!=null)then call PlaySoundAtPointBJ(gg_snd_FBTarg,100,locazo,0.00) endif if(ExploType!=0)then set U= CreateUnit( GetOwningPlayer(u), ExploType, GetUnitX(u),GetUnitY(u), 0 ) call KillUnit( U ) endif call KillUnit( u ) if(hit)then if(multit)then set g = GetUnitsInRangeOfLocAll(radius,locazo) if(FF)then call UnitDamagePoint( cast, 0, radius, x,y, dmg,true,false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL ,WEAPON_TYPE_WHOKNOWS ) else loop set U = FirstOfGroup(g) exitwhen(U==null) if(IsUnitEnemy(U,GetOwningPlayer(cast)))then call UnitDamageTarget(cast, targ, dmg, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) endif call GroupRemoveUnit(g,U) set U=null endloop endif else call UnitDamageTarget(cast, targ, dmg, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) endif endif call RemoveLocation (target) call PauseTimer( t ) call FlushHandleLocals( t ) call DestroyTimer( t ) endif call RemoveLocation (locazo) set target = null set u = null call DestroyGroup( g ) set g = null set locazo = null endfunction I went through it thousand of times and it still leaks somewhere... If anybody can find these leaks, i'd be really thankful! It works great for one single missile. Even for ten missiles at the same time. But when I go over 30 missiles it starts generating a terrible lag. Even if it is run every 0.04 secs instead of every 0.01 |
| 06-05-2006, 08:44 PM | #2 |
Not nullified: - cast - targ - t - explode |
| 06-05-2006, 08:53 PM | #3 |
I think the lag you're experiencing is more general lag from having so many timer events firing at the same time, getting all the attached data, and moving so many units. Of course, I think there are still leaks and you can fix what CaptainGriffen pointed out as well, but like I said, I think the lag is caused by other issues. |
