Hey everyone, I am getting a random crash in my game. It seems to happen sporadically, and very rarely. Sometimes I can get through the whole game with no problem. But occasionally it just shuts down. It gives me this Sys_marker in the error message (CH3) so I know it is happening somewhere in this script. This is in my character's main loop, so it is called in every frame.

Does anything stand out here as a possible cause?
Code
		sys_marker("CH3");
		
		
		//TEST JUMPING
		if(var_level_number == 0)
		{
			jump_test = c_trace(my.x,vector(my.x,my.y,my.z-2048),IGNORE_ME|IGNORE_PASSABLE|USE_POLYGON|IGNORE_FLAG2|USE_BOX);
		}
		else
		{
			jump_test = c_trace(my.x,vector(my.x,my.y,my.z-2048),IGNORE_ME|IGNORE_PASSABLE|USE_POLYGON|IGNORE_FLAG2);
		}
		
		if(jump_test > 0)//stores last reliable surface position
		{
			
			surface_z = hit.z;
		}
		
		if(var_jump == 1 && ((jump_test <= my_height) || (hit.entity.skill1 == 62 && on_ground = 1)))
		{
			
			if(jump_wait <= 0 && on_ground != 1)
			{
				if(!snd_playing(land_handle))
				{
					land_handle = snd_play(snd_land,100 * (main_volume/100),0);
				}
			}
			
			on_ground = 0;
			jumping = var_jump_amount;//5.0
		}
		else if(jump_test > my_height)
		{
			if(hit.entity.skill1 == 62 && jumping == 0 && jump_test < 32)
			{
				on_ground = 1;
				my.z = surface_z + my_height;
			}
			else
			{
				on_ground = 0;
				jumping -= 1.2 * time_step;
			}
		}
		else
		{
			if(on_ground == 0 && jumping < -4)
			{
				if(!snd_playing(land_handle))
				{
					land_handle = snd_play(snd_land,100 * (main_volume/100),0);
				}
			}
			
			on_ground = 1;
			my.z = surface_z + my_height;
			jumping = 0;
		}
		
		
		sys_marker("CH4");
		

Last edited by Dooley; 10/11/19 18:52. Reason: Changed Quote to Code as advised