I would probably try:
1) set laser to max range
2) check for overlaps
3) loop over each of the overlapped targets
4) loop over the lines of the collision polygon of those targets; determine the intersection of the two line segments; if the intersections distance from the shooting point is smaller than localvar_distance (which is initially set at maxrange + 1), save the intersection point to local variables as well as the UID of the hit unit.
-> after all lines are checked, you will have determined the first collision with your ray, have the x and y of the collision point and UID of the hit unit, in case you wanna know which unit is hit.
Currently you are doing 50000 collision checks and 7000 poly checks per second for one laser, which is very hefty. With the solution above you would probably do 2 checks (1 for sight, 1 for determining the hit) * amounts of enemy units * 60 fps = 720 checks (current example scene) and then some math calculations, limited to only the objects that could potentially be hit. I think it will be faster.
One problem is that you can't access the collision polygon coordinates. so you'll have to place image points at the collision polygon points (in an orderly fashion). If you need image points for something else, you will also need a way to determine which image points belong to the collision polygon and which are there for another purpose.
One way for determining intersections (I haven't tested it myself) can be found here: https://lassieadventurestudio.wordpress ... -hit-test/