Parts 2-5 are distinct problems that can be generalised fairly easily.
I'll look at part 3/4 first since I've already convincingly solved part 2 several times over..
The third part of the problem is to calculate the point where a line drawn from the camera intersects with the line 1 from part 2, and where it intersects with line 2 from part 2.
The fourth part of the problem is to determine which intersection point we found in part 3 is further from the camera; the line that is furthest from the camera will have the pseudovertex added (potentially).
camX = GetCameraX()
camY = GetCameraY()
camZ = CameraZ -- this is a custom function of mine..
i3dX = intersectX -- the 2D intersection coordinate from step 2
i3dY = intersectY
i3dZ = 0 -- 2D leveldraw coordinates can expressed in 3D simply by adding Z = 0, the flat plane that is the game screen.
-- So where does the line defined by (camX, camY, camZ) (i3dX, i3dY, i3dZ) intersect with (x1, y1, z1) (x2, y2, z2) ?
-- First calculate camdx, camdy, camdz
camdx = camX - i3dX
camdy = camY - i3dY
camdz = camZ - i3dZ
-- Then calculate dx, dy, dz
dx = x2 - x1
dy = y2 - y1
dz = z2 - z1
-- Define line 1 to contain point (camX,camY,camZ) with vector (camdx,camdy,camdz).
-- Define line 2 to contain point (x1,y1,z1) with vector (dx, dy, dz).
(Need help with this!)