Brewball review

Odd error in terms of interaction between firetraps and .isPathClear

I was using SafeMove(potion.targetPos) and am running straight into the firetraps. Can anyone identify why .isPathClear is not identifying the fact there are firetraps on the route?

def SafePath(tarA):
    vecA = Vector.subtract(tarA, self.pos)
    # This creates a 90° rotated, 1 m long vector realtive to vec.
    normV = Vector.multiply(Vector.normalize(Vector.rotate(vecA, 1.5708)), 0.5)
    targetL = [tarA,   Vector.add(tarA, normV),   Vector.subtract(tarA, normV)]
    startL  = [self.pos, Vector.add(self.pos, normV), Vector.subtract(self.pos, normV)]
    isFree = True
    for s in startL:
        for t in targetL:
            if s and t:
                isFree = isFree and self.isPathClear(s, t) 
            else:
                isFree = False
    return isFree

def SafeMove(tarA):
    tarLoc = tarA
    cAngle = 0
    adjAngle = 0.25
    while (not(SafePath(tarLoc)) and (cAngle < 2*Math.PI)):
        vecA = Vector.normalize(Vector.subtract(tarLoc, self.pos))
        adjAngle2 = adjAngle 
        vecB = Vector.multiply(Vector.rotate(vecA, adjAngle2),5)
        tarLoc = Vector.add(self.pos, vecB)
        cAngle = cAngle + adjAngle2 
    self.move(tarLoc)
1 Like