Couple of ideas, for when you get back to it.

1> You werent checking for a valid hit...
Code:
function get_ambient()
{
	var fmt, pxl;  COLOR tmpC;
	c_trace(my.x,vector(my.x,my.y,(my.z - 500)),IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES|SCAN_TEXTURE);
	if(trace_hit)
	{
		my.ambient = -55;
		fmt = bmap_lock(hit.skin2,0);
		pxl = pixel_for_bmap(hit.skin2,hit.u1,hit.v1);
		bmap_unlock(hit.skin2);
		pixel_to_vec(tmpC, NULL, fmt, pxl);
		my.ambient = my.ambient + ((tmpC.red + tmpC.green + tmpC.blue) / 3);
	}
}
//


2> Does a second skin even exists if it is a WED block? This could generate the error.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial