///Change Terrain
VECTOR pos1,pos2;
vec_set( pos1 , vector(mouse_pos.x,mouse_pos.y,0) );
vec_for_screen (pos1, camera);
vec_set(pos2 , vector(mouse_pos.x,mouse_pos.y,10000));
vec_for_screen (pos2, camera);
c_trace (pos1.x, pos2.x, IGNORE_ME | IGNORE_CONTENT | IGNORE_SPRITES | IGNORE_MAPS | IGNORE_PASSABLE | IGNORE_MODELS | IGNORE_FLAG2 | SCAN_TEXTURE);
if (HIT_TARGET && you && ent_type(you) == 4) // click onto terrain
{
var vertex_num1 = ent_nextvertex(you,hit.x);
CONTACT* c1 = ent_getvertex(you,NULL,vertex_num1);
var vertex_num2 = ent_getvertex(you,NULL,vertex_num1 + 1);
var vertex_num3 = ent_getvertex(you,NULL,vertex_num1 + 66);
var vertex_num4 = ent_getvertex(you,NULL,vertex_num2 + 66);
draw_point3d(hit.x,COLOR_RED,100,5);
if(mouse_left){
c1.z = my.z + my.min_z; // increase the vertex height
c1.v = NULL; // c.x,y,z was changed, instead of c.v
ent_setvertex(you,c1,vertex_num1); // update the mesh
my.z = c1.z - my.min_z - 1;
wait(-1); // reload
}
}