Here's a very simple camera code that may help.
function camera_code() // call this from within that while loop in your player function
{
temp[0] = c_trace(my.x,camera.x,IGNORE_ME+IGNORE_PASSABLE);
if(temp[0] != 0) { cam_dist[0] = maxv(-125,-1*temp[0]); } else { cam_dist[0] = -125; }
cam_dist[1] = 0;
cam_dist[2] = 0;
vec_set(camera.x, my.x);
vec_rotate(cam_dist, my.pan);
vec_add(camera.x, cam_dist);
}
It's Lite-C technically but it should work in C-Script, if it doesn't let me know and I'll take a look.
Just replace your camera code with that.
cam_dist[0...3] should be set to how far back you want the camera behind the player.
E.g.
cam_dist[0] = -125; // -125 units behind the player if it can
cam_dist[1] = 0; // to the side, I suppose
cam_dist[2] = 15; // 15 above default level