| 06-14-2006, 11:08 PM | #1 |
any ideas why these dont work in the same manor, what have I optimized wrong? JASS:function JXJX takes nothing returns nothing local string fTT=H2S(GetExpiredTimer()) local group Jyy=GetStoredDTAXGroup(fTT,"pbgroup") local group g=CreateGroup() local location JYY=GetStoredDTAXLocation(fTT,"castloc") local real Jzz=GetStoredDTAXReal(fTT,"castangle") local unit JZZ local location J00 local real J11 local location J22 local effect e call GroupAddGroup(Jyy,g) set JZZ=FirstOfGroup(g) loop exitwhen JZZ==null set J00=GetUnitLoc(JZZ) set J11=AngleBetweenPoints(JYY,J00) if(SinBJ(J11-Jzz)<0)then set J22=PolarProjectionBJ(J00,20,Jzz-90) call SetUnitPositionLoc(JZZ,J22) call SetUnitFacingTimed(JZZ,Jzz+90,.3) else set J22=PolarProjectionBJ(J00,20,Jzz+90) call SetUnitPositionLoc(JZZ,J22) call SetUnitFacingTimed(JZZ,Jzz-90,.3) endif set e=AddSpecialEffectTarget("Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl",JZZ,"origin") call DestroyEffect(e) call RemoveLocation(J00) call RemoveLocation(J22) call GroupRemoveUnit(g,JZZ) set JZZ=FirstOfGroup(g) endloop call DestroyGroup(g) endfunction JASS:function PR_Effects takes nothing returns nothing local timer t = GetExpiredTimer() local group groupy = GetHandleGroup(t,"group") local group g = CreateGroup() local real xcast = GetHandleReal(t,"xcast") local real ycast = GetHandleReal(t,"ycast") local real ang = GetHandleReal(t,"ang") local unit u local real x local real y local real angle call GroupAddGroup(groupy,g) set u = FirstOfGroup(g) loop exitwhen u==null set x = GetUnitX(u) set y = GetUnitY(u) set angle = bj_RADTODEG * Atan2(ycast - y, xcast - x) if(SinBJ(angle-ang)<0)then set x = x + 20 * Cos(ang-90 * bj_DEGTORAD) set y = y + 20 * Sin(ang-90 * bj_DEGTORAD) call SetUnitPosition(u,x,y) call SetUnitFacingTimed(u,ang+90,.3) else set x = x + 20 * Cos(ang+90 * bj_DEGTORAD) set y = y + 20 * Sin(ang+90 * bj_DEGTORAD) call SetUnitPosition(u,x,y) call SetUnitFacingTimed(u,ang-90,.3) endif call DestroyEffect(AddSpecialEffectTarget("Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl",u,"origin")) call GroupRemoveUnit(g,u) set u=FirstOfGroup(g) endloop call DestroyGroup(g) set g = null endfunction where the stored locals castloc=xcast/ycast ang = castangle pbgroup = group |
| 06-14-2006, 11:24 PM | #2 |
*eyes burning* use vex optimizer for renaming! maybe other stuff, but a little order of operations problem. Add a few sets of parenthesis: JASS:set angle = bj_RADTODEG * Atan2(ycast - y, xcast - x) if(SinBJ(angle-ang)<0)then set x = x + 20 * Cos((ang-90) * bj_DEGTORAD) //here set y = y + 20 * Sin((ang-90) * bj_DEGTORAD) //here call SetUnitPosition(u,x,y) call SetUnitFacingTimed(u,ang+90,.3) else set x = x + 20 * Cos((ang+90) * bj_DEGTORAD) //here set y = y + 20 * Sin((ang+90) * bj_DEGTORAD) //here call SetUnitPosition(u,x,y) call SetUnitFacingTimed(u,ang-90,.3) endif you could also move firstofgroup inside and up top in the loop and then need only one line of it in the function |
| 06-15-2006, 12:21 AM | #3 |
ty ill give it a whirl |
| 06-15-2006, 01:31 PM | #4 |
JASS:local string fTT=H2S(GetExpiredTimer()) What does this H2S function do exactly? Does it try to return bug a handle straight to a string, or does it return I2S(H2I(handle)). JASS:set e=AddSpecialEffectTarget("Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl",JZZ,"origin") call DestroyEffect(e) JASS:call DestroyEffect(AddSpecialEffectTarget("Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl",JZZ,"origin")) Which one of the two is the 'optemised' one anyway? That's not very clear (if it's the first, why do you use locations? if it's the second, why do you use handle variables instead of direct GC useage where possible and the timer string value?) |
| 06-15-2006, 03:45 PM | #5 |
second, obviosuly, i use handle vars cuz well thats what I use, and i see no need to deviate from that, its not a big deal to me, and the person I am maknig it for uses them the first code is the shitty code that dota uses in their map |
| 06-15-2006, 04:58 PM | #6 |
So what you are doing is modifying DotA's code to use it yourself? Using Gamecache and return bug directly instead of handle variables, will most likely optimize your script a lot more than the rest you have done does. |
| 06-15-2006, 05:15 PM | #7 | |
Quote:
Not so obvious, considering that repeated use of handle vars is, as Blade said, much less efficient than storing the string and using it directly. And I concur on the 'why the hell are you taking code from dota', almost certainly without permission. Even if it's for someone else, you're basically endorsing it by doing it yourself. On the note of actual function improvement, you should store the sin/cos values of angle +/- 90 degrees instead of calculating them each time in the timer callback this is no doubt in. |
| 06-15-2006, 05:52 PM | #8 |
like I said, this is what the guy uses, so this is what I must make for him...since its not for me its for someone else and this code isnt from dota, its what ice frog used from a user submitted map in dota, if others want to give credit thats not up to them, I just recoded it |
| 06-15-2006, 05:56 PM | #9 |
You should ask permission before taking someone else's work, unless explicit general permission is given (like in that case of resources posted here), credit or none. |
