@Jip said in Scouting overlay mod.:
@techmind_ the textures currently don't have a resolution to the power of 2 - I'd recommend doing that. E.g., make them 256x256 instead of 200x200. If I have a texture that is 4097 the load time is increased by 10 seconds, but if it is 4096 (a power of 2) then it costs almost no time .
I don't think these small sizes will affect it, but it can't hurt either.
Edit:
predictTimes = math.floor(ScanTimes - 1) destination = currentCommand.position xDiff = destination[1] - ux zDiff = destination[3] - uz xDiff2 = xDiff * xDiff zDiff2 = zDiff * zDiff squareDiff = xDiff * xDiff + zDiff * zDiff xSpeed = math.sqrt(uBp.Physics.MaxSpeed * uBp.Physics.MaxSpeed / squareDiff * xDiff2) zSpeed = math.sqrt(uBp.Physics.MaxSpeed * uBp.Physics.MaxSpeed / squareDiff * zDiff2)
Removing all the prints / logs will make it significantly faster too.I understand you are trying to predict where the scouts are going but square roots are expensive and should be prevented if possible. You can compute the vector towards the target point - normalize it (that is 1 square root) and then multiply that with the time you expect it to move in that direction. That would be your predictedX/Y and reduce the number of square roots / unit by 1. Personally I'd even go for a version without a square root, but that is for another conversation 🙂 .
I'm not entirely sure but it appears you keep creating / removing labels. Did you test to see whether it is faster to keep them around and hide them / move them out of vision? Allocation is generally expensive and I think you're doing it a lot by creating / removing them.
if (r.path) then -- CREATING? -- if (not r.label) then -- last parameter in monitor pixels, need to change with zoom somehow =( r.label = reclaim.CreateScoutLabel(view.ReclaimGroup, r.path, squareSize) r.position = position r.labelIndex = labelIndex LabelPool[labelIndex] = r.label labelIndex = labelIndex + 1 end r.onScreen = reclaim.OnScreen(view, position) if r.onScreen then onScreenSquared[onScreenSquareIndex] = r onScreenSquareIndex = onScreenSquareIndex + 1 --tprint(r.position) else r.label:Hide() end labelsData[sX][sZ] = r else -- REMOVING? -- if (LabelPool[r.labelIndex]) then LabelPool[r.labelIndex]:Destroy() LabelPool[r.labelIndex] = nil end labelsData[sX][sZ].label = nil end
It only removes label if square was scouted, otherwise they stay created (well that was intention, but there might be some bugs). Remove shoudl trigger then where is no 'path' variable (meaning empty texture - so it forces label deletion)..