| 06-17-2009, 04:11 PM | #1 |
Okay i need spell to take all the units from the region and port em exactly in the same position with the same angle. Pitty the script by friend gave me doesn't work an we both don't know what is wrong please if you can help. JASS:library NatureArena initializer Storage globals private constant rect NatureArena = gg_rct_NatureArena private integer index = 1 private integer array StoredUnit [1] private real array Distance [1] private real array Angle [1] private real array WidgetFace [1] endglobals private function Storage takes nothing returns nothing local group g = CreateGroup() local unit u local real cX = GetRectCenterX(NatureArena) local real cY = GetRectCenterY(NatureArena) local real tX local real tY call GroupEnumUnitsInRect(g,NatureArena,null) call DisplayTextToForce( GetPlayersAll(), "It Works" ) loop set u = FirstOfGroup(g) exitwhen u == null set StoredUnit[index] = GetUnitTypeId(u) set tX = GetUnitX(u) set tY = GetUnitY(u) set Distance[index] = SquareRoot((tX-cX)*(tX-cX) + (tY-cY)*(tY-cY)) set Angle[index] = bj_RADTODEG*Atan2(tY-cY, tX-cX) set WidgetFace[index] = GetUnitFacing(u) set index = index+1 call GroupRemoveUnit(g,u) endloop call DestroyGroup(g) set g = null endfunction function RecreateNature takes rect r returns nothing local real x = GetRectCenterX(r) local real y = GetRectCenterY(r) local integer i = 1 local real nX local real nY local real nF loop exitwhen i > index set nX = x + Distance[i] * Cos(Angle[i] * bj_DEGTORAD) set nY = x + Distance[i] * Sin(Angle[i] * bj_DEGTORAD) call CreateUnit(Player(13),StoredUnit[i],nX,nY,WidgetFace[i]) set i = i+1 endloop endfunction endlibrary The we tried to use scopes and it gave us error when calling the function "RecreateNature" Please help us. |
| 06-17-2009, 04:13 PM | #2 |
The gg_*** vars are initialized AFTER the global declarations are assigned... |
| 06-17-2009, 04:20 PM | #3 |
yes i know this, how can i fix the trigger to run correctly? |
| 06-17-2009, 04:31 PM | #4 |
If you know it then the fix is ready... Just do the assignment in the initializer. JASS:private function Storage takes nothing returns nothing local group g = CreateGroup() local unit u local real cX local real cY local real tX local real tY set NatureArena = gg_rct_whatever set cX = GetRectCenterX(NatureArena) set cY = GetRectCenterY(NatureArena) call GroupEnumUnitsInRect(g,NatureArena,null) call DisplayTextToForce( GetPlayersAll(), "It Works" ) loop set u = FirstOfGroup(g) exitwhen u == null set StoredUnit[index] = GetUnitTypeId(u) set tX = GetUnitX(u) set tY = GetUnitY(u) set Distance[index] = SquareRoot((tX-cX)*(tX-cX) + (tY-cY)*(tY-cY)) set Angle[index] = bj_RADTODEG*Atan2(tY-cY, tX-cX) set WidgetFace[index] = GetUnitFacing(u) set index = index+1 call GroupRemoveUnit(g,u) endloop call DestroyGroup(g) //DONT set g = null endfunction |
| 06-17-2009, 04:45 PM | #5 |
Thanks, i'll just test it and see if it works |
