HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Jass Help

06-17-2009, 04:11 PM#1
CeDiL
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.
Collapse 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
we tried to use this as a library and it gave me this error.
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
Vexorian
The gg_*** vars are initialized AFTER the global declarations are assigned...
06-17-2009, 04:20 PM#3
CeDiL
yes i know this, how can i fix the trigger to run correctly?
06-17-2009, 04:31 PM#4
Vexorian
If you know it then the fix is ready... Just do the assignment in the initializer.

Collapse 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
CeDiL
Thanks, i'll just test it and see if it works