Hello.
For an RTS I'm making I wrote some code that will rotate the selected units box to face a certain direction. This way you can make a unit "wall" to face wherever you want. it works fine. Now I'm working on code to make it so the user can choose how many units are in a line, and if there are more than the set number it will start a new line behind the old
However whenever I try to add code to start a new line behind the current. It can't seem to do it. no matter were I put it in the sine code.
I'm sure it must be a simple fix, But I can't seem to find it. maybe it's to close to me.
reference
ai(num,4) = selected or not, 1 for selected
numselected = ai's spot in line placement.
totalselected = total number of units selected.
currentline = current line to work on. right now it's merely how far to offset the current row from the found sine value.
linemax=max amount of units in each line
ai(0,0) number of ai
playerdata#(0) = placment object, I,E mouse pointer
for a = 1 to ai(0,0)
numselected=0
totalselected=0 <--- this finds out how many ai are selected
for a =1 to ai(0,0)
if ai(a,4)=1 then inc totalselected,1
NEXT a
linemax = 5
currentline = 0
if mouseclick()=2 and ai(a,4)=1 <---- code to see if a unit needs to be positioned
`do math
if numselected > linemax then numselected = 0 : inc currentline,60
x1#=cos(wrapvalue(ax)) * (500 + object position x(playerdata#(0)))
y1#=sin(wrapvalue(ax)) * (500 + object position z(playerdata#(0)))
x2#=cos(wrapvalue(ax + 180 )) * (500 + object position x(playerdata#(0)))
y2#=sin(wrapvalue(ax + 180 )) * ( 500 + object position z(playerdata#(0)))
dx# = (x2# - x1#) / totalselected
dy# = (y2# - y1#) / totalselected
AI Set Entity position ai(a,3), object position x(playerdata#(0)) + (dx# * numselected) ,object position z(playerdata#(0)) + (dy# * numselected)
`print " (dx# * numselected) ", (dx# * numselected)
ENDIF `mouseclick()=2 and ai(a,4)=1
if ai(a,4)=1 then inc numselected,1
next a
Thanks