define PHYS1 9695

gamevar phys_var 0 1
gamevar phys_spawn 0 1
gamevar phys_z 0 2
gamevar ex_damage 0 2
gamevar paang 0 1
gamevar ex_ang 0 2
gamevar ex_picnum 0 2
gamevar ex_killit 0 2
gamevar ex_phys 0 2
gamevar phys_owner 0 2
gamevar phys_zvel_var 0 2
gamevar phys_plnum 0 2

actor PHYS1
sizeat 32 32 cstat 0

 getactorvar[THISACTOR].ex_damage htextra 
 getactorvar[THISACTOR].ex_ang htang

	ifstrength 0
	{
		setvarvar in1 htang 
		setvarvar in2 htextra 
		mulvar in2 4
		getactorvar[THISACTOR].phys_zvel_var phys_zvel_var
		mulvar phys_zvel_var 2

		setvarvar in3 phys_zvel_var // -6144 max
		
		state physics_start
		state phys_reset_vel
		state phys_add_vel_ang
		state physics_end		
		
		setactorvar[THISACTOR].phys_air_damping_x 1050
		setactorvar[THISACTOR].phys_air_damping_y 1050
		setactorvar[THISACTOR].phys_air_damping_z 1050		
		
		setactorvar[THISACTOR].phys_gravity_x 0 
		setactorvar[THISACTOR].phys_gravity_y 0
		randvar tmp 200
		addvar tmp 400
		setactorvar[THISACTOR].phys_gravity_z tmp
		
		strength 1
	}
	
	state physics_start
	state physics_interact_air

	
	getactorvar[THISACTOR].phys_plnum phys_plnum
    getinput[phys_plnum].extbits tmp
	ifvarg tmp 0
	{
		getplayer[THISACTOR].ang pang
		ifvare tmp 2 { mulvar pang -1 } else
		ifvare tmp 4 { addvar pang -512 } else
		ifvare tmp 5 { addvar pang -256 } else
		ifvare tmp 6 { addvar pang -768 } else
		ifvare tmp 8 { addvar pang 512 } else
		ifvare tmp 9 { addvar pang 256 } else
		ifvare tmp 10 { addvar pang 768 }
		cos x pang
		sin y pang
		ifvare tmp 2 { mulvar x -1 }
		divvar x 50
		divvar y 50
		setvarvar phys_x_internal x
		setvarvar phys_y_internal y
	}
	
	
	state physics_move
	state physics_end
	
	setvar tmp2 0
	whilevarn tmp2 2048
	{
		getactor[THISACTOR].x x
		getactor[THISACTOR].y y
		setvarvar x2 x
		addvarvar x2 200
		rotatepoint x y x2 y tmp2 x3 y3
		updatesector x3 y3 RETURN
		ifvare RETURN -1 { setvarvar in2 0 }
		addvar tmp2 1
	}
	
	addvar COUNTER 24
	subvarvar in2 COUNTER
	ifvarl in2 0 { setactorvar[THISACTOR].ex_phys 0 killit } else setactorvar[THISACTOR].ex_phys 1
enda