Okay this is really weird.
I added some debugging bits to try and find out why my code won't work.
So I have a small loop that resets my Path array to zero like so:
Quote: "//reset old AI Path & fill H values
for tempx=2 to areamaxx
for tempy=2 to areamaxy
AIPath[PlayerID,tempx,tempy].Closed = 0
AIPath[PlayerID,tempx,tempy].Fval = 0
AIPath[PlayerID,tempx,tempy].Gval = 0
AIPath[PlayerID,tempx,tempy].Hval = 10 * trunc(abs(tempx-targetx)+abs(tempy-targety))
AIPath[PlayerID,tempx,tempy].Open = 0
AIPath[PlayerID,tempx,tempy].ParentX = 0
AIPath[PlayerID,tempx,tempy].ParentY = 0
repeat
print("Next Target X:"+str(tempx)+", Y:"+str(tempy)+", Open:"+str(AIPath[PlayerID,tempx,tempy].Open)+", Lowest F:"+str(AIPath[PlayerID,tempx,tempy].FVal))
sync()
until getrawkeyreleased(13)=1
next tempy
next tempx
//reset complete"
You can see I added in a break so that I could check that te .Open part of the array was set to zero.
Then I change ONE value in the array
Quote: "//add starting position to open list
AIPath[PlayerID,startx,starty].Open = 1
repeat
print("Next Target X:"+str(startx)+", Y:"+str(starty)+", Open:"+str(AIPath[PlayerID,startx,starty].Open)+", Lowest F:"+str(AIPath[PlayerID,startx,starty].FVal))
sync()
until getrawkeyreleased(13)=1"
As you can see I added another break to confirm the element had changed to .Open=1
I then checked to see which element in the array had actually changed:
Quote: "for tempx=2 to areamaxx
for tempy=2 to areamaxy
if AIPath[PlayerID,tempx,tempy].Open>0
repeat
print("ERROR X:"+str(tempx)+", Y:"+str(tempy)+", Open:"+str(AIPath[PlayerID,tempx,tempy].Open))
sync()
until getrawkeyreleased(13)=1
endif
next tempy
next tempx"
To my suprise every .Open element in the array had changed to .Open=1 !!!!!
Is this a known bug in 109? Why would setting element make them all change?
I don't have problems with my other UDTs in the game, only this one.
Here's the full sequence:
//reset old AI Path & fill H values
for tempx=2 to areamaxx
for tempy=2 to areamaxy
AIPath[PlayerID,tempx,tempy].Closed = 0
AIPath[PlayerID,tempx,tempy].Fval = 0
AIPath[PlayerID,tempx,tempy].Gval = 0
AIPath[PlayerID,tempx,tempy].Hval = 10 * trunc(abs(tempx-targetx)+abs(tempy-targety))
AIPath[PlayerID,tempx,tempy].Open = 0
AIPath[PlayerID,tempx,tempy].ParentX = 0
AIPath[PlayerID,tempx,tempy].ParentY = 0
//repeat
//print("Next Target X:"+str(tempx)+", Y:"+str(tempy)+", Open:"+str(AIPath[PlayerID,tempx,tempy].Open)+", Lowest F:"+str(AIPath[PlayerID,tempx,tempy].FVal))
//sync()
//until getrawkeyreleased(13)=1
next tempy
next tempx
//reset complete
//add starting position to open list
AIPath[PlayerID,startx,starty].Open = 1
repeat
print("Next Target X:"+str(startx)+", Y:"+str(starty)+", Open:"+str(AIPath[PlayerID,startx,starty].Open)+", Lowest F:"+str(AIPath[PlayerID,startx,starty].FVal))
sync()
until getrawkeyreleased(13)=1
for tempx=2 to areamaxx
for tempy=2 to areamaxy
if AIPath[PlayerID,tempx,tempy].Open>0
repeat
print("ERROR X:"+str(tempx)+", Y:"+str(tempy)+", Open:"+str(AIPath[PlayerID,tempx,tempy].Open))
sync()
until getrawkeyreleased(13)=1
endif
next tempy
next tempx