#!/usr/bin/perl
#	 License: GPLv2
#	--MikeeUSA--
$reverse_fan_roll_speed_asthetics_obj_from_mc = 1; #Reverse roll speed for fans as exported models are inverse 
$CONVERT_SOME_NOISES_TO_SIMPLER_STRING = 1;
#
$mode = 0; #1= lights
$DEBUGPRINTS = 0;
$TESTLIGHTPRINTS = 0;
$TESTUNKNOWNPRINTS = 1;
$IGNOREPATHNODES = 1;
$IGNORELEVELINFO = 1;
$IGNOREZONEINFO = 1;
$PRINTORIGINALSOUNDINFOASCOMMENTIFCONVERTED = 1;
$PRINTORIGINALROTATIONINFOASCOMMENTIFCONVERTED = 1;
$PRINTMINSMAXSASCOMMENTIFFOUND_FORMOVER = 1;
$PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER = 1;
$COMMENTOUTUNKNOWNSIFTESTUNKNOWNPRINTS = 1;
$NEWLINEBETWEENSECTIONS = 2;
$comment_oldclassname_for_all = 1;
$ENABLE_ADD_Z_TOPLAYERSTART = 1;
#
#Some ammos
$PAMMOUSESREGULAR = 0; #1 means use cells instead of custom
$SHOCKCOREUSESREGULAR = 0; #1 means use cells instead of custom
$PICKUP_UT_SniperRifle_OPTIONS = 1; #0 use lrr, 1 use t17mm
#
$add_z_toplayerstart = 64; #helps keep out of solid
$PRINTINFOREGARDINGADDINGZTOPLAYERSTART = 1; #print the info regarding adding Z to player start, ie print the original as a comment
$PRINTORIGINALHUESATURATIONBRIGHTNESSINFOASCOMMENTIFCONVERTED = 1;
$rtlight_radius_scale = 10; #for some 10 seems good, for other maps 5...
$SET_UNSET_LIGHT_COLOR = 1;
$SET_UNSET_LIGHT_RADIUS = 1;
$comment_mover_information = 1;
$ALLOW_DESTRUCTABLES_MOVERS = 0; #evaluate destructable like glass, difficult as they are just movers that move in 0 seconds and point to a trigger event
$OMIT_NEWER_MOVERS = 0; #omit the newer movers after the destructables?
$OMIT_NEWER_MOVERS2 = 0; #omit the even newer movers after ElevatorE?
$OMITNAMELINECONTAININGACTIVELINE_FIX = 1; #ignore lines like '     Name="AmbientSound2"'
#
#
$Set_Default_HSV_and_Radius_At_Begining_Instead = 1;
#
#
$ignore_unset_lights = 0;
#
#
$use_curve = 1;
#
$PRINTCOMMANDARGUMENTSFORRTLIGHTS = 1; #end of file
$PRINTDEBUGINFOASCOMMENTFORRTLIGHTS = 0; #for each one
#$originalerrorsethuetosaturation = 0; #original error was to set hue to saturation and was used for tundra rtlight originall
#
$ORIGINFORUNKNOWNSIFTESTUNKNOWNPRINTS = 1; #can be 1 or 2
#
$STRICTFILECONTROL = 1;

sub newlinebetweensections {
		if ($comment_oldclassname_for_all) {
			if ($originalclassname) {
				print('//'); print('#'); print("$originalclassname"); print("\n");
			}
		}
		if ($NEWLINEBETWEENSECTIONS) {
			if ($NEWLINEBETWEENSECTIONS > 10) {
				print("\n");
			} else {
				print("\n" x $NEWLINEBETWEENSECTIONS);
			}
		}
}
#It happens that when one exports an obj file as a static mesh
#and decides to use it as an obj_from_mc with basescale1 (ie no scaling)
#this all works out if you have made sure you centred your brush on 0,0,0
#wouldn't think it would because in darkplaces quake1 engine the obj seems to be flipped left to right or something
#but I guess this just worked out it seemed
#it did when I did it by hand
#
#so when you want to export a map to obj in unreal editor 2.1 for old unreal
#what you do is you make a box brush, then center it on 0,0,0 as it's location
#then make it bigger than your level
#then press the intersect button
#it's a box from the bottom going into another box, cyan on top but in bottom corner atop a dark blue one
#    ////////////
#    ..        //
#/////////// B //
#//       // L //
#//       // U //
#// cyan  // E //
#//       //...//
#//       //
#///////////
#then you will have a red outline of the whole map
#save your .unr map to intersectedbrushmap.unr or so
#then open it up again
#now "wrong click" (right click) on the red brush, like a line of it
#then in unreal ed 2.1 you will have a menu pop up
#it will have an option to convert the brush to static mesh
#somewhere in there
#do that, then export it to obj
#then rename the obj somemap.basescale1.obj_from_mc
#now, go back to your original .unr map
#export that as a t3d from the file menu
#that's what this reads
# later alongside the somemap.basescale1.obj_from_mc
# you can have a      somemap.basescale1.ent
# the engine will load that
#
$dostuff = 0;
$endnow = 0;
$classname = "";
$islocationline = 0;
$isrotationline = 0;
$isrotationrateline = 0;
$isambientsoundline = 0;
$islight_hueline = 0;
$islight_saturationline = 0;
$islight_brightnessline = 0;
$islightradiusline = 0;
$isbaseposline_formover = 0; #Seems to be same as location
$iskeyrotline_formover = 0;  #where to rotate
$iskeyposline_formover = 0; 
$iskeypos2line_formover = 0; 
$issavedposline_formover = 0; #is by default: (X=-12345.000000,Y=-12345.000000,Z=-12345.000000)
$issavedrotline_formover = 0;  #is by default: (Pitch=123,Yaw=456,Roll=789)
$isencroachdamageline_formover = 0; 
$isdrawscaleline = 0;
$isencroachtypeline_formover = 0; 
$istagline_formover = 0; 
$isbumpeventline_formover = 0;
$isopeningsoundline_formover = 0;
$isclosingsoundline_formover = 0;
$isclosingingsoundline_formover = 0;
$ismoveambientsoundline_formover = 0;
$isbumptypeline_formover = 0; 
$ismovetimeline_formover = 0; 
$isvertexline_a_formover = 0; #one of many
$isinitialstateline_formover = 0; 
$ismoverglidetypeline_formover = 0; 
$iseventline_formover = 0;  
$isbdamagetriggeredline_formover = 0; 
$isdamagethresholdline_formover = 0;
$isstayopentimeline_formover = 0; 
#
$moverkey_rotation_pitch = 0;
$moverkey_rotation_yaw = 0;
$moverkey_rotation_roll = 0; #set on door trap rotating down (Roll=16384)
$moverkey_pos_origin_x = 0; #dejavu (key_pos)
$moverkey_pos_origin_y = 0; 
$moverkey_pos_origin_z = 0; 
$moverkey_pos2_origin_x = 0;
$moverkey_pos2_origin_y = 0; 
$moverkey_pos2_origin_z = 0; 
$mover_basepos_origin_x = 0; #Seems to be same as location
$mover_basepos_origin_y = 0;
$mover_basepos_origin_z = 0;
$saved_moverkey_rotation_pitch = 0;   #is by default: (Pitch=123,Yaw=456,Roll=789)
$saved_moverkey_rotation_yaw = 0; 
$saved_moverkey_rotation_roll = 0; 
$saved_mover_basepos_origin_x = 0; #is by default: (X=-12345.000000,Y=-12345.000000,Z=-12345.000000)
$saved_mover_basepos_origin_y = 0;
$saved_mover_basepos_origin_z = 0;
$mover_encroachdamage = 0;
$drawscale = 0;
$mover_encroachtype = 0; #1 crush
$mover_tag = '';
$mover_bumpevent = '';
$mover_event = '';
$force_angles_rather_than_angle = 0; #for mover
$no_angle_conversion_allready_done = 0; #for mover
$targetname = '';
$target = '';
$mover_bumptype = 0; #1 = Any
$mover_movetime = 0;
$mover_movetimewasset = 0; #used to denote the line was set to something in the file, even if 0
$mover_moverglidetype = 0;
$mover_bdamagetriggered = 0;
$mover_damagethreshold = 0;
$mover_stayopentime = 0;
$mover_stayopentimewasset = 0; #used to denote the line was set to something in the file, even if 0 #added because pattern
$speed = 0;
$formover_maximum_seen_vertex_x = 0;
$formover_maximum_seen_vertex_y = 0;
$formover_maximum_seen_vertex_z = 0;
$formover_littlest_seen_vertex_x = 0;
$formover_littlest_seen_vertex_y = 0;
$formover_littlest_seen_vertex_z = 0;
#
$origin_x = 0;
$origin_y = 0;
$origin_z = 0;
$rotation_pitch = 0; #X looking up down (.angles_x)  (up-down)
$rotation_yaw = 0;  #Y yaw, what way looking side to side (.angles_y), also alone can be .angle (side-side, regular rotation, like a pole rotating)
$rotation_roll = 0; #Z roll, like a barrel (.angles_z)  (like a plane spinning while going forward via changing the flaps on it's wings)
$rotationrate_pitch = 0;
$rotationrate_yaw = 0;
$rotationrate_roll = 0;
$noise = '';
$originalnoisecomment = '';
$model = '';
$count = '';
$originalclassname = '';
$ignoreingalllinesinbrush = 0;
$hue = 0;
$saturation = 0;
$brightness = 0;
$light_radius = 0;
$color_r = 0;
$color_g = 0;
$color_b = 0;
$spawnflags = 0;
$cubemap = '';
$corona = 0;
$coronasize = 0; # 0.25; #default 0.25 but corona is off by default
$ambient = 0;
$diffuse = 1; #default 1
$specular= 1; #default 1
$specialextrastuffname = '';
$specialextrastuffamnt = '';
$specialextrastuffname0 = '';
$specialextrastuffamnt0 = '';
$specialextrastuffname1 = '';
$specialextrastuffamnt1 = '';
$specialextrastuffname2 = '';
$specialextrastuffamnt2 = '';
$specialextrastuffname3 = '';
$specialextrastuffamnt3 = '';
$specialextrastuffname4 = '';
$specialextrastuffamnt4 = '';
$specialextrastuffname5 = '';
$specialextrastuffamnt5 = '';
$no_color_set_by_map = 1; #for SET_UNSET_LIGHT_COLOR = 1; and ignore
$no_radius_set_by_map = 1; #for SET_UNSET_LIGHT_RADIUS = 1;; and ignore
$is_light_entity = 0; #so we may ignore if need be
$is_mover = 0; #so we may ignore if need be
$is_fan = 0; #so we may ignore if need be
$moveambientnoise_formover = '';
$openingnoise_formover = '';
$closingnoise_formover = '';
$closingingnoise_formover = '';
$originalnoisecomment_m = '';
$originalnoisecomment_o = '';
$originalnoisecomment_c = '';
$originalnoisecomment_cc = '';
$infooriginal_mover_rotation_pitch = 0; #Just for info
$infooriginal_mover_rotation_yaw = 0; #Just for info
$infooriginal_mover_rotation_roll = 0; #Just for info
$name = '';
$did_mover_name_allready = 0;
$mover_initialstate = 0;
$omitangles_allready_set_angle = 0; #for movers

$default_mover_speed = 300;

$fallbackdatafile = "data2.t3d";
$datafile = '';
$rtlights_add_an_exclaimation_point = 0;
$hsvalgo = 0;
$hsvalgousedstring = '';
$printmode_testhsv_sa_br_hue = 0;

#Accept as input a value for what file to parse
	if (@ARGV[0]) {
		$datafile = @ARGV[0]; #normal
		
		if (@ARGV[0]  eq '--testhsv' || @ARGV[0]  eq '--test_hsv_to_rgb' || @ARGV[0]  eq '--sa_br_hue' ) {
			if (@ARGV[1] eq '--algo' && @ARGV[2]) {
				$hsvalgo = @ARGV[2];
			} elsif (@ARGV[0] eq '--sa_br_hue'  && @ARGV[3]) {
				$saturation	= @ARGV[1];;
				$brightness	= @ARGV[2];
				$hue 		= @ARGV[3];
				$printmode_testhsv_sa_br_hue = 1;
			}
			test_hsv_to_rgb();
			exit; # allready has an exit
		} elsif (@ARGV[0]  eq '-l') {
			$mode = 1; #lights
			if (@ARGV[1]) {
				$datafile = @ARGV[1];
			} else {
				$datafile = $fallbackdatafile;
			}
		} elsif ((@ARGV[0]  eq '-rt')
			|| (@ARGV[0]  eq '-rt1') 
			|| (@ARGV[0]  eq '-rt2')
			|| (@ARGV[0]  eq '-rt3')
			|| (@ARGV[0]  eq '-rt4')
			|| (@ARGV[0]  eq '-rt5')
			|| (@ARGV[0]  eq '-rt7')
			|| (@ARGV[0]  eq '-rt8')
			|| (@ARGV[0]  eq '-rt9')
			|| (@ARGV[0]  eq '-rt10')
			|| (@ARGV[0]  eq '-rt15')
			|| (@ARGV[0]  eq '-rt20')
			|| (@ARGV[0]  eq '-rt25')
			|| (@ARGV[0]  eq '-rt30')
			|| (@ARGV[0]  eq '-rt35')
			|| (@ARGV[0]  eq '-rt40')
			|| (@ARGV[0]  eq '-rt45')
			|| (@ARGV[0]  eq '-rt50')
			|| (@ARGV[0]  eq '-rt55')
			|| (@ARGV[0]  eq '-rt60')
			|| (@ARGV[0]  eq '-rt65')
			|| (@ARGV[0]  eq '-rt70')
			|| (@ARGV[0]  eq '-rt75')
			|| (@ARGV[0]  eq '-rt80')
			|| (@ARGV[0]  eq '-rt85')
			|| (@ARGV[0]  eq '-rt90')
			|| (@ARGV[0]  eq '-rt95')
			|| (@ARGV[0]  eq '-rt100')
			|| (@ARGV[0]  eq '-rt200')
			|| (@ARGV[0]  eq '-rt300'))
		{
			#Yes this could be done a cleverer way, 10 is good for most maps, 
			#but some maps are too much for using realtime light
			#When using curves (default now) 30 is better
			
			$mode = 2; #rtlights
			if (@ARGV[0]  eq '-rt') {
				#default scale is 10
			} elsif (@ARGV[0]  eq '-rt9') {
				$rtlight_radius_scale = 9;
			} elsif (@ARGV[0]  eq '-rt8') {
				$rtlight_radius_scale = 8;
			} elsif (@ARGV[0]  eq '-rt7') {
				$rtlight_radius_scale = 7;
			} elsif (@ARGV[0]  eq '-rt5') {
				$rtlight_radius_scale = 5;
			} elsif (@ARGV[0]  eq '-rt4') {
				$rtlight_radius_scale = 4;
			} elsif (@ARGV[0]  eq '-rt3') {
				$rtlight_radius_scale = 3;
			} elsif (@ARGV[0]  eq '-rt2') {
				$rtlight_radius_scale = 2;
			} elsif (@ARGV[0]  eq '-rt1') {
				$rtlight_radius_scale = 1;
			} elsif (@ARGV[0]  eq '-rt10') {
				$rtlight_radius_scale = 10;
			} elsif (@ARGV[0]  eq '-rt15') {
				$rtlight_radius_scale = 15;
			} elsif (@ARGV[0]  eq '-rt20') {
				$rtlight_radius_scale = 20;
			} elsif (@ARGV[0]  eq '-rt25') {
				$rtlight_radius_scale = 25;
			} elsif (@ARGV[0]  eq '-rt30') {
				$rtlight_radius_scale = 30;
			} elsif (@ARGV[0]  eq '-rt35') {
				$rtlight_radius_scale = 35;
			} elsif (@ARGV[0]  eq '-rt40') {
				$rtlight_radius_scale = 40;
			} elsif (@ARGV[0]  eq '-rt45') {
				$rtlight_radius_scale = 45;
			} elsif (@ARGV[0]  eq '-rt50') {
				$rtlight_radius_scale = 50;
			} elsif (@ARGV[0]  eq '-rt55') {
				$rtlight_radius_scale = 55;
			} elsif (@ARGV[0]  eq '-rt60') {
				$rtlight_radius_scale = 60;
			} elsif (@ARGV[0]  eq '-rt65') {
				$rtlight_radius_scale = 65;
			} elsif (@ARGV[0]  eq '-rt70') {
				$rtlight_radius_scale = 70;
			} elsif (@ARGV[0]  eq '-rt75') {
				$rtlight_radius_scale = 75;
			} elsif (@ARGV[0]  eq '-rt80') {
				$rtlight_radius_scale = 80;
			} elsif (@ARGV[0]  eq '-rt85') {
				$rtlight_radius_scale = 85;
			} elsif (@ARGV[0]  eq '-rt90') {
				$rtlight_radius_scale = 90;
			} elsif (@ARGV[0]  eq '-rt95') {
				$rtlight_radius_scale = 95;
			} elsif (@ARGV[0]  eq '-rt100') {
				$rtlight_radius_scale = 100;
			} elsif (@ARGV[0]  eq '-rt200') {
				$rtlight_radius_scale = 200;
			} elsif (@ARGV[0]  eq '-rt300') {
				$rtlight_radius_scale = 300;
			}
			
			
			if (@ARGV[1]) {
				$datafile = @ARGV[1];
			} else {
				$datafile = $fallbackdatafile;
			}
			
			if (@ARGV[2] || @ARGV[3] || @ARGV[4]) {
				if (@ARGV[2]  eq '--nc' || @ARGV[3]  eq '--nc' || @ARGV[4]  eq '--nc') {
					$use_curve = 0; #no curve
				}
				if (@ARGV[2]  eq '--ex' || @ARGV[3]  eq '--ex' || @ARGV[4]  eq '--ex') {
					$rtlights_add_an_exclaimation_point = 1;
				}
				if (@ARGV[2]  eq '--ig' || @ARGV[3]  eq '--ig' || @ARGV[4]  eq '--ig') {
					#ignore unset
					#can strip out lazy mapping lights and give darker better atmosphere to some maps
					$SET_UNSET_LIGHT_COLOR = 0;
					$SET_UNSET_LIGHT_RADIUS = 0;
					$Set_Default_HSV_and_Radius_At_Begining_Instead = 1; #new default added
					$ignore_unset_lights = 1; #added
				 
				  } elsif (@ARGV[2]  eq '--dontsetunset' || @ARGV[3]  eq '--dontsetunset' || @ARGV[4]  eq '--dontsetunset') {
						#PREVIOUS, ONLY SET THE CAPITALS
					#Setting
					#ignore unset
					#can strip out lazy mapping lights and give darker better atmosphere to some maps
					$SET_UNSET_LIGHT_COLOR = 0;
					$SET_UNSET_LIGHT_RADIUS = 0;
					$ignore_unset_lights = 0; #added as that more strictcode wasn't in
					$Set_Default_HSV_and_Radius_At_Begining_Instead = 0; #this didn't used to exist
					#!!!!this used to be the ig setting before set default hsv 
					
				#Alternative to above
				} elsif (@ARGV[2]  eq '--setunset' || @ARGV[3]  eq '--setunset' || @ARGV[4]  eq '--setunset') {
					#mutually exclusive to above
					#this is the default, but if you change it above, you can reset it
					#Doesn't set defaults so has an effect
					$SET_UNSET_LIGHT_COLOR = 1;
					$SET_UNSET_LIGHT_RADIUS = 1;
					$ignore_unset_lights = 0; 
					$Set_Default_HSV_and_Radius_At_Begining_Instead = 0;
				
				  #Other versions of above
				  } elsif (@ARGV[2]  eq '--setunsetdefault' || @ARGV[3]  eq '--setunsetdefault' || @ARGV[4]  eq '--setunsetdefault') {
					#mutually exclusive to above
					#this is the default, but if you change it above, you can reset it
					$SET_UNSET_LIGHT_COLOR = 1;
					$SET_UNSET_LIGHT_RADIUS = 1;
					#!!!!this used to be the setunset setting
					$ignore_unset_lights = 0; 
					$Set_Default_HSV_and_Radius_At_Begining_Instead = 1;
					
				  } elsif (@ARGV[2]  eq '--setunsetonly' || @ARGV[3]  eq '--setunsetonly' || @ARGV[4]  eq '--setunsetonly') {
					#mutually exclusive to above
					#this is the default, but if you change it above, you can reset it
					$SET_UNSET_LIGHT_COLOR = 1;
					$SET_UNSET_LIGHT_RADIUS = 1;
					#!!!!this used to be the setunset setting
				}
			}
		} elsif (@ARGV[0]  eq '-m') {
			$mode = 4; #mover
			if (@ARGV[1]) {
				$datafile = @ARGV[1];
				
				if (@ARGV[2]  eq '--du' || @ARGV[3]  eq '--du') {
					$ALLOW_DESTRUCTABLES_MOVERS = 1;
				} elsif (@ARGV[2]  eq '--ndu' || @ARGV[3]  eq '--ndu') {
					$ALLOW_DESTRUCTABLES_MOVERS = 0;
				}
				
				if (@ARGV[2]  eq '--omn' || @ARGV[3]  eq '--omn') {
					$OMIT_NEWER_MOVERS = 1;
					$OMIT_NEWER_MOVERS2 = 1;
				} elsif (@ARGV[2]  eq '--nomn' || @ARGV[3]  eq '--nomn') {
					$OMIT_NEWER_MOVERS = 0;
					$OMIT_NEWER_MOVERS2 = 0;
					
				} elsif (@ARGV[2]  eq '--omn1' || @ARGV[3]  eq '--omn1') {
					$OMIT_NEWER_MOVERS = 1;
				} elsif (@ARGV[2]  eq '--nomn1' || @ARGV[3]  eq '--nomn1') {
					$OMIT_NEWER_MOVERS = 0;
					
				} elsif (@ARGV[2]  eq '--omn2' || @ARGV[3]  eq '--omn2') {
					$OMIT_NEWER_MOVERS2 = 1;
				} elsif (@ARGV[2]  eq '--nomn2' || @ARGV[3]  eq '--nomn2') {
					$OMIT_NEWER_MOVERS2 = 0;
				} 
			} else {
				$datafile = $fallbackdatafile;
			}
		}
		
		#normal
		if ($STRICTFILECONTROL) {
			if (index(lc($datafile), lc('.t3d')) != -1) {
				##Happy
			} else {
				die "not .t3d file and strict file control is on";
			}
		}
	} else {
		$datafile = $fallbackdatafile;
	}










#sub rotation_for_obj_from_mc ($x)
#{
#	return (((65536 - $x) / 65536) * 360);
#}

sub unr_rotation_to_deg #($x)
{	my $x = $_[0]; #had to add
	return (($x) * (360 / 65535));
}

sub rotation_convert #($unrnum) 
{	my $unrnum = $_[0]; #had to add
	my $v;
	$v = &unr_rotation_to_deg ($unrnum);
	if ($v > 180) { $v -= 360; }
	if ($v < -180) { $v += 360; }
	return $v;
}


#test_hsv_to_rgb();
sub test_hsv_to_rgb {
	#$hue 		= 28;
	#$saturation	= 32;
	#$brightness	= 96;
	if (!$hue ) { $hue 		= 28;
		$saturation	= 255;
		$brightness	= 128;
	}
	print("H $hue  S $saturation  B $brightness\n");
	print("Algo: $hsvalgo ");
		setstringhsvinfo();
		print("$hsvalgousedstring\n");
	hsv_to_rgb();
	print("$color_r $color_g $color_b\n");
	print($color_r*255,' ', $color_g*255,' ',  $color_b*255,' ',  "\n");
	if ($printmode_testhsv_sa_br_hue) {
		print("\t",'"','color','"',' '); print('"',"$color_r $color_g $color_b",'"'); print("\n");
		print("\t",'"','b_Rgb','"',' '); print('"',"$b_Red $b_Green $b_Blue",'"'); print("\n");
	}
	print("saturation(0..255) brightness(0..255) hue(0..255)\n");
	print("$saturation $brightness $hue\n");
	exit;
}

sub hsv_to_rgb
{
	if ($hsvalgo == 1 || !$hsvalgo) {
		myhsv_to_rgb();
	} elsif ($hsvalgo == 2) {
		hsv_to_rgb___std_win(); #240 version
	} elsif ($hsvalgo == 3) {
		hsv_to_rgbprev();	#Used this for a time
	} elsif ($hsvalgo == 4) {
		hsv_to_rgbanothertry();	#Algo that combines 
	} elsif ($hsvalgo == 5) {
		althsv_to_rgb();
	} 
}
#information to print regarding which algo was used
#done here so as not to waste time
sub setstringhsvinfo
{
	if ($hsvalgo == 1 || !$hsvalgo) {
		$hsvalgousedstring = 'myhsv_to_rgb';
	} elsif ($hsvalgo == 2) {
		$hsvalgousedstring = 'hsv_to_rgb___std_win';
	} elsif ($hsvalgo == 3) {
		$hsvalgousedstring = 'hsv_to_rgbprev';
	} elsif ($hsvalgo == 4) {
		$hsvalgousedstring = 'hsv_to_rgbanothertry';
	} elsif ($hsvalgo == 5) {
		$hsvalgousedstring = 'althsv_to_rgb';
	} 
}

##########################################################################################
##########################################################################################
sub myhsv_to_rgb
{
	hueapply();
	betweenhues(); #deals with hues not in the 16 table
	saturationapply();
	brightnessapply();
}

#These are the subroutines that do the work
#apply them in succession to get the rgb 0..1 color:
#set: $hue $saturation $brightness
#	hueapply();
#	saturationapply();
#	brightnessapply();
#get: $color_r $color_b $color_g
sub formatforrgb
{
	$red = $b_Red/255;
	$green = $b_Green/255;
	$blue = $b_Blue/255;
}
sub betweenhues
{
	$oldhue = $hue; #save
	betweenhues_interior();
	formatforrgb();
	$hue = $oldhue; #restore
}
sub setbColor0
{
	$b_Red0 = $b_Red;
	$b_Green0 = $b_Green;
	$b_Blue0 = $b_Blue;
}
sub setbColor1
{
	$b_Red1 = $b_Red;
	$b_Green1 = $b_Green;
	$b_Blue1 = $b_Blue;
}
#sub betweenhues_interior
#{
#	if ($oldhue > 240 && $oldhue < 255) {
#		print("hello!\n");
#		$hue = 240; hueapply(); setbColor0();
#		$hue = 255; hueapply(); setbColor1();
#		$myrange = 255 - 240; #15
#		$myfrombottom = $oldhue - 240; #ex: 241 - 240 = 1
#		$myfromtop   =  255 - $oldhue; #ex: 255 - 241 = 14
#		
#		$bottomweight = $myfromtop/$myrange;
#		$topweight = $myfrombottom/$myrange;
#		
#		$b_Red = ($b_Red0 * $bottomweight) + ($b_Red1 * $topweight);
#		$b_Green = ($b_Green0 * $bottomweight) + ($b_Green1 * $topweight);
#		$b_Blue = ($b_Blue0 * $bottomweight) + ($b_Blue1 * $topweight);
#	}
#}
sub betweenhues_interior
{
	$lownum = 0;
	$highnum = 0;
	#(0,  16,  32,  48,  64,  80,  96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 255);
	     if ($oldhue > 240 && $oldhue < 255) {
		$lownum = 240;
		$highnum = 255;
		
	} elsif ($oldhue > 224 && $oldhue < 240) {
		$lownum = 224;
		$highnum = 240;
		
	} elsif ($oldhue > 208 && $oldhue < 224) {
		$lownum = 208;
		$highnum = 224;
			
	} elsif ($oldhue > 192 && $oldhue < 208) {
		$lownum = 192;
		$highnum = 208;
			
	} elsif ($oldhue > 176 && $oldhue < 192) {
		$lownum = 176;
		$highnum = 192;
			
	} elsif ($oldhue > 144 && $oldhue < 176) {
		$lownum = 144;
		$highnum = 176;
			
	} elsif ($oldhue > 128 && $oldhue < 144) {
		$lownum = 128;
		$highnum = 144;
			
	} elsif ($oldhue > 112 && $oldhue < 128) {
		$lownum = 112;
		$highnum = 128;
			
	} elsif ($oldhue > 96 && $oldhue < 112) {
		$lownum = 96;
		$highnum = 112;
			
	} elsif ($oldhue > 80 && $oldhue < 96) {
		$lownum = 80;
		$highnum = 96;
			
	} elsif ($oldhue > 64 && $oldhue < 80) {
		$lownum = 64;
		$highnum = 80;
			
	} elsif ($oldhue > 48 && $oldhue < 64) {
		$lownum = 48;
		$highnum = 64;
			
	} elsif ($oldhue > 32 && $oldhue < 48) {
		$lownum = 32;
		$highnum = 48;
			
	} elsif ($oldhue > 16 && $oldhue < 32) {
		$lownum = 16;
		$highnum = 32;
			
	} elsif ($oldhue > 0 && $oldhue < 16) {
		$lownum = 0;
		$highnum = 16;
			
	}
	
	
	if ($lownum || $highnum) {
		betweenhues_interior_interior();
	} else {
		#Do nothing as we are spot on one of the table values
	}
	
}
sub betweenhues_interior_interior
{
	if ($oldhue > $lownum && $oldhue < $highnum) {
		#print("hello!\n");
		$hue = $lownum; hueapply(); setbColor0();
		$hue = $highnum; hueapply(); setbColor1();
		$myrange = $highnum - $lownum; #15
		$myfrombottom = $oldhue - $lownum; #ex: 241 - $lownum = 1
		$myfromtop   =  $highnum - $oldhue; #ex: $highnum - 241 = 14
		
		$bottomweight = $myfromtop/$myrange;
		$topweight = $myfrombottom/$myrange;
		
		$b_Red = ($b_Red0 * $bottomweight) + ($b_Red1 * $topweight);
		$b_Green = ($b_Green0 * $bottomweight) + ($b_Green1 * $topweight);
		$b_Blue = ($b_Blue0 * $bottomweight) + ($b_Blue1 * $topweight);
		
		#format removing decimals
		$b_Red = int($b_Red);
		$b_Green = int($b_Green);
		$b_Blue = int($b_Blue);
	}
}

##test
#$hue = 241; $hue=$originalhuefromcommandline; hueapply();
#betweenhues();
#print("\t",'"','b_Rgb','"',' '); print('"',"$b_Red $b_Green $b_Blue",'"'); print("\n");


sub hueapply
{
	$b_Red		= 0;
	$b_Green	= 0;
	$b_Blue		= 0;
	
	if ($hue >= 255) { #FF0000 Below
		$b_Red		= 255;
		$b_Green	= 0;
		$b_Blue		= 0;
	}  elsif ($hue >= 240) {#E50030 Below
		$b_Red		= 229;
		$b_Green	= 0;
		$b_Blue		= 48;
	}  elsif ($hue >= 224) {#B20061 Below
		$b_Red		= 178;
		$b_Green	= 0;
		$b_Blue		= 97;
	}  elsif ($hue >= 208) {#8300A3 Below
		$b_Red		= 131;
		$b_Green	= 0;
		$b_Blue		= 163;
	}  elsif ($hue >= 192) {#4200D5 Below
		$b_Red		= 66;
		$b_Green	= 0;
		$b_Blue		= 213;
	}  elsif ($hue >= 176) {#1000FE Below
		$b_Red		= 16;
		$b_Green	= 0;
		$b_Blue		= 254;
	}  elsif ($hue >= 160) {#001EEA Below
		$b_Red		= 0;
		$b_Green	= 30;
		$b_Blue		= 234;
	} elsif ($hue >= 144) {#0052BA Below
		$b_Red		= 0;
		$b_Green	= 82;
		$b_Blue		= 186;
	} elsif ($hue >= 128) {#008388  Below
		$b_Red		= 0;
		$b_Green	= 131;
		$b_Blue		= 136;
	} elsif ($hue >= 112) { #00B255  Below
		$b_Red		= 0;
		$b_Green	= 178;
		$b_Blue		= 85;
	} elsif ($hue >= 96) { #00E820  Below
		$b_Red		= 0;
		$b_Green	= 232;
		$b_Blue		= 32;
	} elsif ($hue >= 80) { #10F600  Below
		$b_Red		= 16;
		$b_Green	= 246;
		$b_Blue		= 0;
	} elsif ($hue >= 64) { #42CA00  Below
		$b_Red		= 66;
		$b_Green	= 202;
		$b_Blue		= 0;
	} elsif ($hue >= 48) { #84A500  Below
		$b_Red		= 132;
		$b_Green	= 165;
		$b_Blue		= 0;
	} elsif ($hue >= 32) { #B16700  Below
		$b_Red		= 177;
		$b_Green	= 103;
		$b_Blue		= 0;
	} elsif ($hue >= 16) {#CF2E00  Below
		$b_Red		= 207;
		$b_Green	= 46;
		$b_Blue		= 0;
	} elsif ($hue >= 0) { #FF0000  Below
		$b_Red		= 255;
		$b_Green	= 0;
		$b_Blue		= 0;
	}
	
	$red = $b_Red/255;
	$green = $b_Green/255;
	$blue = $b_Blue/255;
}


sub saturationapply
{
	$whiteamnt = $saturation/255;
	$coloramnt = 1 - $whiteamnt;
		$pre_color_r = $red * $coloramnt;
		$pre_color_g = $green * $coloramnt;
		$pre_color_b = $blue * $coloramnt;
		
	$color_r = $pre_color_r + $whiteamnt;
	$color_g = $pre_color_g + $whiteamnt;
	$color_b = $pre_color_b + $whiteamnt;
}

sub brightnessapply
{
	$color_r = $color_r * ($brightness/255);
	$color_g = $color_g * ($brightness/255);
	$color_b = $color_b * ($brightness/255);
}

#above are needed
############################################################





##########################################################################################
##########################################################################################
# Various other hsv algos
#sub max ($$) { $_[$_[0] < $_[1]] }
sub min ($$) { $_[$_[0] > $_[1]] }

sub hsv_to_rgb___std_win #trying with 240 value #this was the standard for awhile
{	my $offset_saturation = 0;
	$color_r = 0; $color_g = 0; $color_b = 0;
	#$hue 		#H
	#$saturation	#S
	#$brightness	#L
	
	#added
	if ($hue < 0) { $hue = (240 - $hue) % 240; }
	else { $hue = $hue % 240; }
	#added

	#Different way
	if ($hue < 80) {
		$color_r = min(255, 255 * (80 - $hue) / 40);
	} elsif ($hue > 160) {
		$color_r = min(255, 255 * ($hue - 160) / 40);
	}
	
	if ($hue < 160) {
		$color_g = min(255, 255 * (80 - abs($hue - 80)) / 40);
	}
	
	if ($hue > 80) {
		$color_b = min(255, 255 * (80 - abs($hue - 160)) / 40);
	}
	#Different way
			
	if ($saturation < 240) {
		$color_r = $color_r * ($saturation / 240);
		$color_g = $color_g * ($saturation / 240);
		$color_b = $color_b * ($saturation / 240);
		$offset_saturation = 128 * (240 - $saturation) / 240;
		$color_r += $offset_saturation;
		$color_g += $offset_saturation;
		$color_b += $offset_saturation;
	}
	
	#Different way
	$brightness = min(255, $brightness);
	$color_r = $color_r * ((120 - abs($brightness - 120)) / 120);
	$color_g = $color_g * ((120 - abs($brightness - 120)) / 120);
	$color_b = $color_b * ((120 - abs($brightness - 120)) / 120);
	

	if ($brightness > 120) {
		$offset_brightness = 256 * ($brightness - 120) / 120;
		$color_r += $offset_brightness;
		$color_g += $offset_brightness;
		$color_b += $offset_brightness;
	}
	#Different way
	
	$color_r = $color_r / 256;
	$color_g = $color_g / 256;
	$color_b = $color_b / 256;
	
	#format
	$color_r = eval sprintf('%.6f', $color_r);
	$color_g = eval sprintf('%.6f', $color_g);
	$color_b = eval sprintf('%.6f', $color_b);	
}


sub hsv_to_rgbanothertry #too green
{	my $offset_saturation = 0;
	$color_r = 0; $color_g = 0; $color_b = 0;
	#$hue 		#H
	#$saturation	#S
	#$brightness	#L
	
	#Different way
	if ($hue < 85) {
		$color_r = min(255, 255 * (85 - $hue) / 42.5);
	} elsif ($hue > 170) {
		$color_r = min(255, 255 * ($hue - 170) / 42.5);
	}
	
	if ($hue < 170) {
		$color_g = min(255, 255 * (85 - abs($hue - 85)) / 42.5);
	}
	
	if ($hue > 85) {
		$color_b = min(255, 255 * (85 - abs($hue - 170)) / 42.5);
	}
	#Different way
			
	if ($saturation < 255) {
		$color_r = $color_r * ($saturation / 255);
		$color_g = $color_g * ($saturation / 255);
		$color_b = $color_b * ($saturation / 255);
		$offset_saturation = 128 * (255 - $saturation) / 255;
		$color_r += $offset_saturation;
		$color_g += $offset_saturation;
		$color_b += $offset_saturation;
	}
	
	#Different way
	$brightness = min(255, $brightness);
	$color_r = $color_r * ((120 - abs($brightness - 120)) / 120);
	$color_g = $color_g * ((120 - abs($brightness - 120)) / 120);
	$color_b = $color_b * ((120 - abs($brightness - 120)) / 120);
	

	if ($brightness > 120) {
		$offset_brightness = 256 * ($brightness - 120) / 120;
		$color_r += $offset_brightness;
		$color_g += $offset_brightness;
		$color_b += $offset_brightness;
	}
	#Different way
	
	$color_r = $color_r / 256;
	$color_g = $color_g / 256;
	$color_b = $color_b / 256;
	
	#format
	$color_r = eval sprintf('%.6f', $color_r);
	$color_g = eval sprintf('%.6f', $color_g);
	$color_b = eval sprintf('%.6f', $color_b);	
}
sub hsv_to_rgbprev #ok, not as blue as supposed to
{	my $offset_saturation = 0;
	$color_r = 0; $color_g = 0; $color_b = 0;
	#$hue 		#H
	#$saturation	#S
	#$brightness	#L
	
	#Different way
	if ($hue < 80) {
		$color_r = min(255, 255 * (80 - $hue) / 40);
	} elsif ($hue > 160) {
		$color_r = min(255, 255 * ($hue - 160) / 40);
	}
	
	if ($hue < 160) {
		$color_g = min(255, 255 * (80 - abs($hue - 80)) / 40);
	}
	
	if ($hue > 80) {
		$color_b = min(255, 255 * (80 - abs($hue - 160)) / 40);
	}
	#Different way
			
	if ($saturation < 255) {
		$color_r = $color_r * ($saturation / 255);
		$color_g = $color_g * ($saturation / 255);
		$color_b = $color_b * ($saturation / 255);
		$offset_saturation = 128 * (255 - $saturation) / 255;
		$color_r += $offset_saturation;
		$color_g += $offset_saturation;
		$color_b += $offset_saturation;
	}
	
	#Different way
	$brightness = min(255, $brightness);
	$color_r = $color_r * ((120 - abs($brightness - 120)) / 120);
	$color_g = $color_g * ((120 - abs($brightness - 120)) / 120);
	$color_b = $color_b * ((120 - abs($brightness - 120)) / 120);
	

	if ($brightness > 120) {
		$offset_brightness = 256 * ($brightness - 120) / 120;
		$color_r += $offset_brightness;
		$color_g += $offset_brightness;
		$color_b += $offset_brightness;
	}
	#Different way
	
	$color_r = $color_r / 256;
	$color_g = $color_g / 256;
	$color_b = $color_b / 256;
	
	#format
	$color_r = eval sprintf('%.6f', $color_r);
	$color_g = eval sprintf('%.6f', $color_g);
	$color_b = eval sprintf('%.6f', $color_b);	
}


sub althsv_to_rgb
{	my $offset_saturation = 0;
	$color_r = 0; $color_g = 0; $color_b = 0;
	#$hue 		#H
	#$saturation	#S
	#$brightness	#L
	$saturation = 255 - $saturation; #Tried
	
	if ($hue < 85) {
		$color_r = min(1, (85 - $hue) / 42.5);
	} elsif ($hue > 170) {
		$color_r = min(1, ($hue - 170) / 42.5);
	}
				
	if ($hue < 170) {
		$color_g = min(1, (85 - abs($hue - 85)) / 42.5);
	}
					
	if ($hue > 85) {
		$color_b = min(1, (85 - abs($hue - 170)) / 42.5);
	}

	
	if ($saturation < 255) {
		$color_r = $color_r * ($saturation / 255);
		$color_g = $color_g * ($saturation / 255);
		$color_b = $color_b * ($saturation / 255);
		$offset_saturation = 128 * (255 - $saturation) / 255;
		$color_r += $offset_saturation;
		$color_g += $offset_saturation;
		$color_b += $offset_saturation;
	}
	
	#Tried
	$color_r = ((255 - abs($brightness - 255)) / 255);
	$color_g = ((255 - abs($brightness - 255)) / 255);
	$color_b = ((255 - abs($brightness - 255)) / 255);
	
	#format
	$color_r = eval sprintf('%.6f', $color_r);
	$color_g = eval sprintf('%.6f', $color_g);
	$color_b = eval sprintf('%.6f', $color_b);	
}










setdefault_light_and_radius_maybe();
sub prc #printcommentifunknownmover
{
	if ($dostuff == 2001 && $is_mover) {
			print('//'); 
			print('#');
	}
}
sub soundguessfornoiseofsecretdoormovers
{
		if ($openingnoise_formover) { 
			$specialextrastuffname = 'noise3';
			$specialextrastuffamnt = "$openingnoise_formover".'.wav';
			#note can also do it: #$specialextrastuffamnt = $openingnoise_formover;
			#                     #$specialextrastuffamnt .= '.wav';
		}
		
		if ($moveambientnoise_formover) { 
			$specialextrastuffname0 = 'noise2';
			$specialextrastuffamnt0 = "$moveambientnoise_formover".'.wav';
		}
		
		if ($closingingnoise_formover) { 
			$specialextrastuffname1 = 'noise1';
			$specialextrastuffamnt1 = "$closingingnoise_formover".'.wav';
		}
}
sub soundguessfornoiseofliftmovers
{
		if ($openingnoise_formover) { 
			$specialextrastuffname = 'noise1';
			$specialextrastuffamnt = "$openingnoise_formover".'.wav';
			#note can also do it: #$specialextrastuffamnt = $openingnoise_formover;
			#                     #$specialextrastuffamnt .= '.wav';
		}
		
		if ($moveambientnoise_formover) { 
			$specialextrastuffname0 = 'noise2';
			$specialextrastuffamnt0 = "$moveambientnoise_formover".'.wav';
		}
}
sub soundguessfornoiseofrotatingdoortrapmovers
{
		if ($openingnoise_formover) { 
			$specialextrastuffname = 'noise1';
			$specialextrastuffamnt = "$openingnoise_formover".'.wav';
		}
		
		if ($closingnoise_formover) { 
			$specialextrastuffname0 = 'noise2';
			$specialextrastuffamnt0 = "$closingnoise_formover".'.wav';
		}
}
sub othergeneralstuffformovers
{
		if ($mover_encroachtype = 1) { #crush
			if ($mover_encroachdamage) {
				$specialextrastuffname1 = 'dmg';
				$specialextrastuffamnt1 = $mover_encroachdamage;
			}
		}
}
sub setmovetimeifnotset
{
	if ($mover_movetime) {
		#do nothing
	} else {
		$mover_movetime = 1; #one second
	}
}
sub speedguessformovers
{
		if ($mover_movetime) {
			if ($mover_movetime != 0) { #had to add extra check for things like "00.000000"
			$speed = $default_mover_speed / $mover_movetime;
			}
		}
}

open (FILE, "$datafile") || die "can't open file because $!";
while (my $line = <FILE>)
{
	if ($DEBUGPRINTS > 1) {print ("!!!!! $line");}
$thing = $line;
# #The point of this is to iterate through a t3d file and look for things to print in the entity format
# open (FILE, 'data.t3d'); #for data mode
# #while (<FILE>) {         #for data mode
# while (<>) {  #attempt for data mode
# #while (1) {             #for pasting mode

$beforeequals = "";
$afterequals = "";
$islocationline = 0;
$isrotationline = 0;
$isrotationrateline = 0;
$islight_hueline = 0;
$islight_saturationline = 0;
$islight_brightnessline = 0;
$islightradiusline = 0;
$isambientsoundline = 0;
#
$isbaseposline_formover = 0; #Seems to be same as location
$iskeyrotline_formover = 0;  #where to rotate
$iskeyposline_formover = 0; 
$iskeypos2line_formover = 0; 
$issavedposline_formover = 0; #is by default: (X=-12345.000000,Y=-12345.000000,Z=-12345.000000)
$issavedrotline_formover = 0;  #is by default: (Pitch=123,Yaw=456,Roll=789)
$isencroachdamageline_formover = 0; 
$isdrawscaleline = 0; 
$isencroachtypeline_formover = 0; 
$istagline_formover = 0;  
$isbumpeventline_formover = 0; 
$isopeningsoundline_formover = 0;
$isclosingsoundline_formover = 0;
$isclosingingsoundline_formover = 0;
$ismoveambientsoundline_formover = 0;
$isbumptypeline_formover = 0; 
$ismovetimeline_formover = 0;
$isvertexline_a_formover = 0; #one of many 
$isinitialstateline_formover = 0;
$ismoverglidetypeline_formover = 0;
$iseventline_formover = 0;  
$isbdamagetriggeredline_formover = 0; 
$isdamagethresholdline_formover = 0;
$isstayopentimeline_formover = 0;

# ##$thing = <STDIN>; #for pasting mode
# ##chomp($thing); #for pasting mode
# #$thing = chomp($_); #for data mode
# $thing = <FILE>; #attempt for data mode
# chomp($thing); #attempt for data mode
# #$thing = chomp; #attempt for data mode2
chomp($thing);

	if ($thing eq 'End Actor') {
				if ($DEBUGPRINTS) { print("    **** Says End Actor\n"); }
		$endnow = 1;
		$ignoreingalllinesinbrush = 0;
	} elsif (index(lc($thing), lc('End Actor')) != -1) {
			if ($DEBUGPRINTS) {  print "contains end actor\n"; }
		$endnow = 1;
		$ignoreingalllinesinbrush = 0;
	} elsif ($ignoreingalllinesinbrush == 1) {
			if ($DEBUGPRINTS) {  print("    _____I\n"); }
	} elsif (index(lc($thing), lc('Begin Actor Class=Brush')) != -1) {
			if ($DEBUGPRINTS) {  print "actor class brush wait till past maybe\n"; }
		$ignoreingalllinesinbrush = 1;
	} elsif (index(lc($thing), lc('Begin Actor')) != -1) {
			if ($DEBUGPRINTS) {  print "ignoring begin actor line so does not conflict with ambient sound\n"; }
	} elsif ((index(lc($thing), lc('     Name="')) != -1) && ($OMITNAMELINECONTAININGACTIVELINE_FIX)) {
		#//Ignore this line, has a name of something that breaks our script
		#//Saw in a map so adding this fix,
		#//We don't use the name line for anything right now
		#//Included the "tab" (really blank spaces) as that's how the files put this out and want to avoid others
		#//Added for (talltowa)
		#//That is: the name line, which is not yet used, has one of the following in it for some reason"
	} elsif (index(lc($thing), lc('Location')) != -1) {
   				if ($DEBUGPRINTS) {  print "$thing contains Location\n"; }
		$islocationline = 1;
	} elsif (index(lc($thing), lc('RotationRate')) != -1) {
   				if ($DEBUGPRINTS) {  print "$thing contains Rotation\n"; }
		$isrotationrateline = 1; #had to do before rotation so wont conflict
	} elsif (index(lc($thing), lc('Rotation')) != -1) {
   				if ($DEBUGPRINTS) {  print "$thing contains Rotation\n"; }
		$isrotationline = 1;
	} elsif (index(lc($thing), lc('LightHue')) != -1) {
		$islight_hueline = 1;
	} elsif (index(lc($thing), lc('LightSaturation')) != -1) {
		$islight_saturationline = 1;
	} elsif (index(lc($thing), lc('LightBrightness')) != -1) {
		$islight_brightnessline = 1;
	} elsif (index(lc($thing), lc('LightRadius')) != -1) {
		$islightradiusline = 1;
	} elsif (index(lc($thing), lc('MoveAmbientSound')) != -1) {
		$ismoveambientsoundline_formover = 1;
	} elsif (index(lc($thing), lc('OpenedSound')) != -1) {
		$isopeningsoundline_formover = 1;
	} elsif (index(lc($thing), lc('ClosedSound')) != -1) {
		$isclosingsoundline_formover = 1;
	} elsif (index(lc($thing), lc('ClosingSound')) != -1) {
		$isclosingingsoundline_formover = 1;
	} elsif (index(lc($thing), lc('AmbientSound')) != -1) {
   				if ($DEBUGPRINTS) {  print "$thing contains AmbientSound\n"; }
		$isambientsoundline = 1;
	#Mover stuff, omitted if not mover
	} elsif ( (index(lc($thing), lc('BasePos')) != -1) && ($is_mover) ) {
		$isbaseposline_formover = 1;
		#seems to be same as origin for the movers we're interested in so far
	} elsif ( (index(lc($thing), lc('KeyRot')) != -1) && ($is_mover) ) { #really KeyRot(1)
		$iskeyrotline_formover = 1;
		#when only the Y is set it is a rotating down floor trap
	} elsif ( (index(lc($thing), lc('SavedPos')) != -1) && ($is_mover) ) {
		$issavedposline_formover = 1;
		#set to (X=-12345.000000,Y=-12345.000000,Z=-12345.000000)
		#for the movers we are interested so far
	} elsif ( (index(lc($thing), lc('SavedRot')) != -1) && ($is_mover) ) {
		$issavedrotline_formover = 1;
		#Set to (Pitch=123,Yaw=456,Roll=789) for the movers we are interested in so far
	} elsif ( (index(lc($thing), lc('EncroachDamage')) != -1) && ($is_mover) ) {
		$isencroachdamageline_formover = 1;
		#Examples we've seen so far are EncroachDamage=1000000 for crusher and trap floors
	} elsif ( (index(lc($thing), lc('MoverEncroachType')) != -1) && ($is_mover) ) {
		$isencroachtypeline_formover = 1;
		#MoverEncroachType=ME_CrushWhenEncroach is what we've seen so far
	} elsif ( (index(lc($thing), lc('Tag')) != -1) && ($is_mover) ) {
		$istagline_formover = 1; 
		#MoverEncroachType=ME_CrushWhenEncroach is what we've seen so far
	} elsif ( (index(lc($thing), lc('BumpEvent')) != -1) && ($is_mover) ) {
		$isbumpeventline_formover = 1; 
		#MoverEncroachType=ME_CrushWhenEncroach is what we've seen so far
	} elsif ( (index(lc($thing), lc('BumpType')) != -1) && ($is_mover) ) {
		$isbumptypeline_formover = 1; 
		#MoverEncroachType=ME_CrushWhenEncroach is what we've seen so far
	} elsif ( (index(lc($thing), lc('MoverGlideType')) != -1) && ($is_mover) ) {
		$ismoverglidetypeline_formover = 1; 
		#MoverEncroachType=ME_CrushWhenEncroach is what we've seen so far
	} elsif ( (index(lc($thing), lc('MoveTime')) != -1) && ($is_mover) ) {
		$ismovetimeline_formover = 1; 
		#MoverEncroachType=ME_CrushWhenEncroach is what we've seen so far
	} elsif ( (index(lc($thing), lc('KeyPos(2)')) != -1) && ($is_mover) ) { #really KeyPos(2)
		$iskeypos2line_formover = 1; #was an error had as 0
	} elsif ( (index(lc($thing), lc('KeyPos')) != -1) && ($is_mover) ) { #really KeyPos(1)
		$iskeyposline_formover = 1; #was an error had as 0
	} elsif ( (index(lc($thing), lc('Vertex')) != -1) && ($is_mover) ) { #Vertex   -00008.000000,+00016.000000,-00016.000000
		$isvertexline_a_formover = 1; #one of many
	} elsif ( (index(lc($thing), lc('Drawscale')) != -1)) {
		$isdrawscaleline = 1;
		#Examples we've seen so far are DrawScale=6.250000 for fan
	} elsif ( (index(lc($thing), lc('InitialState')) != -1) && ($is_mover) ) {
		$isinitialstateline_formover = 1; 
	} elsif ( (index(lc($thing), lc('Event')) != -1) && ($is_mover) ) {
		$iseventline_formover = 1;  
	} elsif ( (index(lc($thing), lc('bDamageTriggered')) != -1) && ($is_mover) ) {
		$isbdamagetriggeredline_formover = 1;   
	} elsif ( (index(lc($thing), lc('DamageThreshold')) != -1) && ($is_mover) ) {
		$isdamagethresholdline_formover = 1;    
	} elsif ( (index(lc($thing), lc('StayOpenTime')) != -1) && ($is_mover) ) {
		$isstayopentimeline_formover = 1; 
	} else {
				if ($DEBUGPRINTS) {  print("    _____Nothing\n"); }
		#$dostuff = 0;
	}

	if ($ignoreingalllinesinbrush == 1) {
		if ($DEBUGPRINTS) {  print("    _____IgnoringBrush\n"); }
	###############
	#Actual origin
	} elsif ($islocationline) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS) {  print("AFTEREQUALSLOCATIONLINE   ***$afterequals\n"); }
		$afterequals =~ s/\(//;
		$afterequals =~ s/\)//;
				if ($DEBUGPRINTS) {  print("                      2   ***$afterequals\n\n\n"); }
			
		
		$origin_x = 0;
		$origin_y = 0;
		$origin_z = 0;
		
		@tokens = split(/,/, $afterequals);
		foreach my $token (@tokens) {
		    		if ($DEBUGPRINTS) {  print("$token\n"); }
		    ($beforeequals, $afterequals) = split("=",$token,2);
		   		if ($DEBUGPRINTS) {   print("	$beforeequals\n"); }
		   		if ($DEBUGPRINTS) {   print("	$afterequals\n"); }
				
				#Getrid of whitespaces etc to get rid of carraigertrn ##
				$afterequals =~ s/\A\s+//s;                           ##
    				$afterequals =~ s/\s+\Z//s;                           ##
				#Getrid of whitespaces etc to get rid of carraigertrn ##
			
		    if ($beforeequals eq 'X') {
		    	$origin_x = $afterequals;
		    } elsif ($beforeequals eq 'Y') {
		    	$origin_y = $afterequals;
		    } elsif ($beforeequals eq 'Z') {
		    	$origin_z = $afterequals;
		    }
		}
	#BELOW: FOR MOVER, but seems to be same as location
	} elsif ($isbaseposline_formover) { #origin type
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS) {  print("AFTEREQUALSBASEPOSLINE   ***$afterequals\n"); }
		$afterequals =~ s/\(//;
		$afterequals =~ s/\)//;
				if ($DEBUGPRINTS) {  print("                      2   ***$afterequals\n\n\n"); }
			
		
		$mover_basepos_origin_x = 0;
		$mover_basepos_origin_y = 0;
		$mover_basepos_origin_z = 0;
		
		@tokens = split(/,/, $afterequals);
		foreach my $token (@tokens) {
		    		if ($DEBUGPRINTS) {  print("$token\n"); }
		    ($beforeequals, $afterequals) = split("=",$token,2);
		   		if ($DEBUGPRINTS) {   print("	$beforeequals\n"); }
		   		if ($DEBUGPRINTS) {   print("	$afterequals\n"); }
				
				#Getrid of whitespaces etc to get rid of carraigertrn ##
				$afterequals =~ s/\A\s+//s;                           ##
    				$afterequals =~ s/\s+\Z//s;                           ##
				#Getrid of whitespaces etc to get rid of carraigertrn ##
			
		    if ($beforeequals eq 'X') {
		    	$mover_basepos_origin_x = $afterequals;
		    } elsif ($beforeequals eq 'Y') {
		    	$mover_basepos_origin_y = $afterequals;
		    } elsif ($beforeequals eq 'Z') {
		    	$mover_basepos_origin_z = $afterequals;
		    }
		}
	#BELOW: FOR MOVER
	} elsif ($issavedposline_formover) { #origin type
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS) {  print("AFTEREQUALSBASEPOSLINE   ***$afterequals\n"); }
		$afterequals =~ s/\(//;
		$afterequals =~ s/\)//;
				if ($DEBUGPRINTS) {  print("                      2   ***$afterequals\n\n\n"); }
			
		
		$saved_mover_basepos_origin_x = 0;
		$saved_mover_basepos_origin_y = 0;
		$saved_mover_basepos_origin_z = 0;
		
		@tokens = split(/,/, $afterequals);
		foreach my $token (@tokens) {
		    		if ($DEBUGPRINTS) {  print("$token\n"); }
		    ($beforeequals, $afterequals) = split("=",$token,2);
		   		if ($DEBUGPRINTS) {   print("	$beforeequals\n"); }
		   		if ($DEBUGPRINTS) {   print("	$afterequals\n"); }
				
				#Getrid of whitespaces etc to get rid of carraigertrn ##
				$afterequals =~ s/\A\s+//s;                           ##
    				$afterequals =~ s/\s+\Z//s;                           ##
				#Getrid of whitespaces etc to get rid of carraigertrn ##
			
		    if ($beforeequals eq 'X') {
		    	$saved_mover_basepos_origin_x = $afterequals;
		    } elsif ($beforeequals eq 'Y') {
		    	$saved_mover_basepos_origin_y = $afterequals;
		    } elsif ($beforeequals eq 'Z') {
		    	$saved_mover_basepos_origin_z = $afterequals;
		    }
		}
	} elsif ($iskeyposline_formover) { #origin type
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS) {  print("AFTEREQUALSBASEPOSLINE   ***$afterequals\n"); }
		$afterequals =~ s/\(//;
		$afterequals =~ s/\)//;
				if ($DEBUGPRINTS) {  print("                      2   ***$afterequals\n\n\n"); }
			
		
		$moverkey_pos_origin_x = 0;
		$moverkey_pos_origin_y = 0;
		$moverkey_pos_origin_z = 0;
		
		@tokens = split(/,/, $afterequals);
		foreach my $token (@tokens) {
		    		if ($DEBUGPRINTS) {  print("$token\n"); }
		    ($beforeequals, $afterequals) = split("=",$token,2);
		   		if ($DEBUGPRINTS) {   print("	$beforeequals\n"); }
		   		if ($DEBUGPRINTS) {   print("	$afterequals\n"); }
				
				#Getrid of whitespaces etc to get rid of carraigertrn ##
				$afterequals =~ s/\A\s+//s;                           ##
    				$afterequals =~ s/\s+\Z//s;                           ##
				#Getrid of whitespaces etc to get rid of carraigertrn ##
			
		    if ($beforeequals eq 'X') {
		    	$moverkey_pos_origin_x = $afterequals;
		    } elsif ($beforeequals eq 'Y') {
		    	$moverkey_pos_origin_y = $afterequals;
		    } elsif ($beforeequals eq 'Z') {
		    	$moverkey_pos_origin_z = $afterequals;
		    }
		}
	} elsif ($iskeypos2line_formover) { #origin type
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS) {  print("AFTEREQUALSBASEPOSLINE   ***$afterequals\n"); }
		$afterequals =~ s/\(//;
		$afterequals =~ s/\)//;
				if ($DEBUGPRINTS) {  print("                      2   ***$afterequals\n\n\n"); }
			
		
		$moverkey_pos2_origin_x = 0;
		$moverkey_pos2_origin_y = 0;
		$moverkey_pos2_origin_z = 0;
		
		@tokens = split(/,/, $afterequals);
		foreach my $token (@tokens) {
		    		if ($DEBUGPRINTS) {  print("$token\n"); }
		    ($beforeequals, $afterequals) = split("=",$token,2);
		   		if ($DEBUGPRINTS) {   print("	$beforeequals\n"); }
		   		if ($DEBUGPRINTS) {   print("	$afterequals\n"); }
				
				#Getrid of whitespaces etc to get rid of carraigertrn ##
				$afterequals =~ s/\A\s+//s;                           ##
    				$afterequals =~ s/\s+\Z//s;                           ##
				#Getrid of whitespaces etc to get rid of carraigertrn ##
			
		    if ($beforeequals eq 'X') {
		    	$moverkey_pos2_origin_x = $afterequals;
		    } elsif ($beforeequals eq 'Y') {
		    	$moverkey_pos2_origin_y = $afterequals;
		    } elsif ($beforeequals eq 'Z') {
		    	$moverkey_pos2_origin_z = $afterequals;
		    }
		}
	} elsif ($isvertexline_a_formover) { #origin type
		my $temp_vertex_x;
		my $temp_vertex_y;
		my $temp_vertex_z;
		my $temp_num;
		#print("try1111\n");
		($beforeequals, $afterequals) = split("Vertex",$thing,2);
		#		if (1 || $DEBUGPRINTS) {  print("AFTEREQUALSVERTEXLINE   ***$afterequals\n"); }
		#$afterequals =~ s/\(//;
		#$afterequals =~ s/\)//;
		#		if (1 || $DEBUGPRINTS) {  print("                      2   ***$afterequals\n\n\n"); }
			
		
		$temp_vertex_x = 0;
		$temp_vertex_y = 0;
		$temp_vertex_z = 0;
		
		$temp_num = 0;
		
		@tokens = split(/,/, $afterequals);
		foreach my $token (@tokens) {
			$temp_num++; #Increase it first
			#	if (1 || $DEBUGPRINTS) {  print("$token\n"); }	
			#	#Getrid of whitespaces etc to get rid of carraigertrn ##
				$token =~ s/\A\s+//s;                           ##
    				$token =~ s/\s+\Z//s;                           ##
			#	#Getrid of whitespaces etc to get rid of carraigertrn ##
		
		    if ($temp_num == 1) {
		    	$temp_vertex_x = 0 + $token; #Adding the 0 gets it into number format
		    } elsif ($temp_num == 2) {
		    	$temp_vertex_y = 0 + $token; 
		    } elsif ($temp_num == 3) {
		    	$temp_vertex_z = 0 + $token; 
		    }
		}
		
		#if (1 || $DEBUGPRINTS) {  print("$temp_vertex_x $temp_vertex_y $temp_vertex_z\n\n"); }
		
		if ($temp_vertex_z > $formover_maximum_seen_vertex_z) {
			$formover_maximum_seen_vertex_z = $temp_vertex_z;
		}
		if ($temp_vertex_x > $formover_maximum_seen_vertex_x) {
			$formover_maximum_seen_vertex_x = $temp_vertex_x;
		}
		if ($temp_vertex_y > $formover_maximum_seen_vertex_y) {
			$formover_maximum_seen_vertex_y = $temp_vertex_y;
		}
		
		if ($temp_vertex_z < $formover_littlest_seen_vertex_z) {
			$formover_littlest_seen_vertex_z = $temp_vertex_z;
		}
		if ($temp_vertex_x < $formover_littlest_seen_vertex_x) {
			$formover_littlest_seen_vertex_x = $temp_vertex_x;
		}
		if ($temp_vertex_y < $formover_littlest_seen_vertex_y) {
			$formover_littlest_seen_vertex_y = $temp_vertex_y;
		}
		
	###############
	#Rotation lines
	} elsif ($isrotationline) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS) {  print("AFTEREQUALSROTATIONLINE   ***$afterequals\n"); }
		$afterequals =~ s/\(//;
		$afterequals =~ s/\)//;
				if ($DEBUGPRINTS) {  print("                      2   ***$afterequals\n\n\n"); }
			
		
		$rotation_pitch = 0;
		$rotation_yaw = 0;
		$rotation_roll = 0;
		
		@tokens = split(/,/, $afterequals);
		foreach my $token (@tokens) {
		    		if ($DEBUGPRINTS) {  print("$token\n"); }
		    ($beforeequals, $afterequals) = split("=",$token,2);
		   		if ($DEBUGPRINTS) {   print("	$beforeequals\n"); }
		   		if ($DEBUGPRINTS) {   print("	$afterequals\n"); }
				
				#Getrid of whitespaces etc to get rid of carraigertrn ##
				$afterequals =~ s/\A\s+//s;                           ##
    				$afterequals =~ s/\s+\Z//s;                           ##
				#Getrid of whitespaces etc to get rid of carraigertrn ##
			
		    if ($beforeequals eq 'Pitch') {
		    	$rotation_pitch = $afterequals;
		    } elsif ($beforeequals eq 'Yaw') {
		    	$rotation_yaw = $afterequals;
		    } elsif ($beforeequals eq 'Roll') {
		    	$rotation_roll = $afterequals;
		    }
		}
	#speed of rotation for movers and fans
	} elsif ($isrotationrateline) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS) {  print("AFTEREQUALSROTATIONRATELINE   ***$afterequals\n"); }
		$afterequals =~ s/\(//;
		$afterequals =~ s/\)//;
				if ($DEBUGPRINTS) {  print("                      2   ***$afterequals\n\n\n"); }
			
		
		$rotationrate_pitch = 0;
		$rotationrate_yaw = 0;
		$rotationrate_roll = 0;
		
		@tokens = split(/,/, $afterequals);
		foreach my $token (@tokens) {
		    		if ($DEBUGPRINTS) {  print("$token\n"); }
		    ($beforeequals, $afterequals) = split("=",$token,2);
		   		if ($DEBUGPRINTS) {   print("	$beforeequals\n"); }
		   		if ($DEBUGPRINTS) {   print("	$afterequals\n"); }
				
				#Getrid of whitespaces etc to get rid of carraigertrn ##
				$afterequals =~ s/\A\s+//s;                           ##
    				$afterequals =~ s/\s+\Z//s;                           ##
				#Getrid of whitespaces etc to get rid of carraigertrn ##
			
		    if ($beforeequals eq 'Pitch') {
		    	$rotationrate_pitch = $afterequals;
		    } elsif ($beforeequals eq 'Yaw') {
		    	$rotationrate_yaw = $afterequals;
		    } elsif ($beforeequals eq 'Roll') {
		    	$rotationrate_roll = $afterequals;
		    }
		}
	#BELOW: FOR MOVER
	} elsif ($iskeyrotline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS) {  print("AFTEREQUALSKEYROTATIONLINE   ***$afterequals\n"); }
		$afterequals =~ s/\(//;
		$afterequals =~ s/\)//;
				if ($DEBUGPRINTS) {  print("                      2   ***$afterequals\n\n\n"); }
			
		
		$moverkey_rotation_pitch = 0;
		$moverkey_rotation_yaw = 0;
		$moverkey_rotation_roll = 0;
		
		@tokens = split(/,/, $afterequals);
		foreach my $token (@tokens) {
		    		if ($DEBUGPRINTS) {  print("$token\n"); }
		    ($beforeequals, $afterequals) = split("=",$token,2);
		   		if ($DEBUGPRINTS) {   print("	$beforeequals\n"); }
		   		if ($DEBUGPRINTS) {   print("	$afterequals\n"); }
				
				#Getrid of whitespaces etc to get rid of carraigertrn ##
				$afterequals =~ s/\A\s+//s;                           ##
    				$afterequals =~ s/\s+\Z//s;                           ##
				#Getrid of whitespaces etc to get rid of carraigertrn ##
			
		    if ($beforeequals eq 'Pitch') {
		    	$moverkey_rotation_pitch = $afterequals;
		    } elsif ($beforeequals eq 'Yaw') {
		    	$moverkey_rotation_yaw = $afterequals;
		    } elsif ($beforeequals eq 'Roll') {
		    	$moverkey_rotation_roll = $afterequals;
		    }
		}
	#BELOW: FOR MOVER
	} elsif ($issavedrotline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS) {  print("AFTEREQUALSSAVEDKEYROTATIONLINE   ***$afterequals\n"); }
		$afterequals =~ s/\(//;
		$afterequals =~ s/\)//;
				if ($DEBUGPRINTS) {  print("                      2   ***$afterequals\n\n\n"); }
			
		
		$saved_moverkey_rotation_pitch = 0;
		$saved_moverkey_rotation_yaw = 0;
		$saved_moverkey_rotation_roll = 0;
		
		@tokens = split(/,/, $afterequals);
		foreach my $token (@tokens) {
		    		if ($DEBUGPRINTS) {  print("$token\n"); }
		    ($beforeequals, $afterequals) = split("=",$token,2);
		   		if ($DEBUGPRINTS) {   print("	$beforeequals\n"); }
		   		if ($DEBUGPRINTS) {   print("	$afterequals\n"); }
				
				#Getrid of whitespaces etc to get rid of carraigertrn ##
				$afterequals =~ s/\A\s+//s;                           ##
    				$afterequals =~ s/\s+\Z//s;                           ##
				#Getrid of whitespaces etc to get rid of carraigertrn ##
			
		    if ($beforeequals eq 'Pitch') {
		    	$saved_moverkey_rotation_pitch = $afterequals;
		    } elsif ($beforeequals eq 'Yaw') {
		    	$saved_moverkey_rotation_yaw = $afterequals;
		    } elsif ($beforeequals eq 'Roll') {
		    	$saved_moverkey_rotation_roll = $afterequals;
		    }
		}
	###############
	#
	} elsif ($isencroachdamageline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSENCROACHDMG  ***$afterequals\n"); }
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_encroachdamage = 0;
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$mover_encroachdamage = $afterequals;
	#
	} elsif ($isdrawscaleline) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSDRAWSCALE  ***$afterequals\n"); }
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$drawscale = 0;
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$drawscale = $afterequals;
	#
	} elsif ($isencroachtypeline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSENCROACHTYPE  ***$afterequals\n"); }
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_encroachtype = 0;
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		if ($afterequals eq 'ME_CrushWhenEncroach') {
			$mover_encroachtype = 1;
		} elsif ($afterequals eq 'ME_IgnoreWhenEncroach') {
			$mover_encroachtype = 2;
		}
	} elsif ($isbumptypeline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSBUMPTYPE  ***$afterequals\n"); }
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_bumptype = 0;
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		if ($afterequals eq 'BT_AnyBump') {
			$mover_bumptype = 1;
		} elsif ($afterequals eq 'BT_PawnBump') {
			$mover_bumptype = 2;
		}
	} elsif ($ismoverglidetypeline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSBUMPTYPE  ***$afterequals\n"); }
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_bumptype = 0;
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		if ($afterequals eq 'MV_MoveByTime') {
			$mover_moverglidetype = 1;
		}
	} elsif ($ismovetimeline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSMOVETIME  ***$afterequals\n"); }
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_movetime = 0;
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$mover_movetime = $afterequals;
		$mover_movetimewasset = 1; #sometimes it's 0, so make sure we let know it was read for some movers who have intentionally set it to 0
	} elsif ($isstayopentimeline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSMOVETIME  ***$afterequals\n"); }
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_stayopentime = 0;
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$mover_stayopentime = $afterequals;
		$mover_stayopentimewasset = 1; #sometimes it's 0, so make sure we let know it was read for some movers who have intentionally set it to 0
	} elsif ($isbdamagetriggeredline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSMOVETIME  ***$afterequals\n"); }
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_bdamagetriggered = 0;
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$mover_bdamagetriggered = $afterequals;
	} elsif ($isdamagethresholdline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSMOVETIME  ***$afterequals\n"); }
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_damagethreshold = 0;
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$mover_damagethreshold = $afterequals;
	} elsif ($istagline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSTAG  ***$afterequals\n"); }
				$afterequals =~ s/\"//g;# used g for global #get rid of "  #since set to s///g this gets rid of all "'s in string, not just first
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_tag = '';
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			######$afterequals =~ s/\"//; #Alternate if the above wasnt set to s///g (global) : have to do it again for the back one
		$mover_tag = $afterequals;
	} elsif ($isbumpeventline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSBUMPEVENT  ***$afterequals\n"); }
				$afterequals =~ s/\"//g; #get rid of " globally in string
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_bumpevent = '';
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$mover_bumpevent = $afterequals;
	} elsif ($iseventline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSBUMPEVENT  ***$afterequals\n"); }
				$afterequals =~ s/\"//g; #get rid of " globally in string
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_event = '';
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$mover_event = $afterequals;
	} elsif ($isinitialstateline_formover) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSBUMPEVENT  ***$afterequals\n"); }
				$afterequals =~ s/\"//g; #get rid of " globally in string
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$mover_initialstate = 0;
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		if ($afterequals eq 'BumpButton') {
			$mover_initialstate = 1;
		} elsif ($afterequals eq 'TriggerControl') {
			$mover_initialstate = 2;
		} elsif ($afterequals eq 'StandOpenTimed') {
			$mover_initialstate = 3;
		} elsif ($afterequals eq 'TriggerOpenTimed') {
			$mover_initialstate = 4;
		} elsif ($afterequals eq 'DamageInstigator') {
			$mover_initialstate = 5;
		} elsif ($afterequals eq 'PlaySoundEffect') {
			$mover_initialstate = 6;
		}
	###############
	#Mover sound 
	} elsif ($isopeningsoundline_formover || $isclosingsoundline_formover || $ismoveambientsoundline_formover
	                                      || $isclosingingsoundline_formover ) {
		local $myintermediaryinternoise;
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSAMBIENTSOUNDMOVER  ***$afterequals\n"); }
		$afterequals =~ s/Sound\'//;
		$afterequals =~ s/\'//;
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$myintermediaryinternoise = '';
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$myintermediarynoise = $afterequals;
		
		
			if ($CONVERT_SOME_NOISES_TO_SIMPLER_STRING) {
				if ($PRINTORIGINALSOUNDINFOASCOMMENTIFCONVERTED) {
					if ($isopeningsoundline_formover) { $originalnoisecomment_o = $afterequals; }
					elsif ($isclosingsoundline_formover) {$originalnoisecomment_c = $afterequals; }
					elsif ($ismoveambientsoundline_formover) {$originalnoisecomment_m = $afterequals; }
					elsif ($isclosingingsoundline_formover) {$originalnoisecomment_cc = $afterequals; }
				}
				$afterequals =~ s/Ambancient\.Looping\.//;
				$afterequals =~ s/Ambmodern\.Looping\.//;
				$afterequals =~ s/Amboutside\.Looping\.//;
				$afterequals =~ s/AmbModern\.Looping\.//;
				$afterequals =~ s/ambientmusic\.Package0\.//;
				$afterequals =~ s/urbansnds\.\(All\)\.//;
				
				$afterequals =~ s/AmbAncient\.Looping\.//;
				$afterequals =~ s/AmbOutside\.Looping\.//;
				
				$afterequals =~ s/DoorsAnc\.Other\.//;
				$afterequals =~ s/Doorsanc\.GenericThumps\.//;
				$afterequals =~ s/Doorsanc\.Stone\.//;
				$afterequals =~ s/DoorsAnc\.Wood\.//;
				$afterequals =~ s/Activates\.ClicksSmall\.//;
				
				$afterequals =~ s/Doorsmod\.General\.//;
				$afterequals =~ s/Activates\.ClicksBig\.//;
				
				$afterequals =~ s/DoorsAnc\.GenericThumps\.//;
				$afterequals =~ s/DoorsAnc\.Stone\.//;
				
				$myintermediarynoise = 'sound/UNR_'."$afterequals";
			}
		
		if ($isopeningsoundline_formover) {
			$openingnoise_formover = $myintermediarynoise;
		} elsif ($isclosingsoundline_formover) {
			$closingnoise_formover = $myintermediarynoise;
		} elsif ($ismoveambientsoundline_formover) {
			$moveambientnoise_formover = $myintermediarynoise;
		} elsif ($isclosingingsoundline_formover) {
			$closingingnoise_formover = $myintermediarynoise;
		}
		$myintermediaryinternoise = ''; #reset the local
	###############
	#Sound etc lines
	} elsif ($isambientsoundline) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSAMBIENTSOUND  ***$afterequals\n"); }
		$afterequals =~ s/Sound\'//;
		$afterequals =~ s/\'//;
				if ($DEBUGPRINTS)  { print("                      2   ***$afterequals\n\n\n"); }
		
		
		$noise = '';
		#$noise = chomp($afterequals);
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$noise = $afterequals;
		
		
			if ($CONVERT_SOME_NOISES_TO_SIMPLER_STRING) {
				if ($PRINTORIGINALSOUNDINFOASCOMMENTIFCONVERTED) {
					$originalnoisecomment = $afterequals;
				}
				$afterequals =~ s/Ambancient\.Looping\.//;
				$afterequals =~ s/Ambmodern\.Looping\.//;
				$afterequals =~ s/Amboutside\.Looping\.//;
				$afterequals =~ s/AmbModern\.Looping\.//;
				$afterequals =~ s/ambientmusic\.Package0\.//;
				$afterequals =~ s/urbansnds\.\(All\)\.//;
				
				$afterequals =~ s/AmbAncient\.Looping\.//;
				$afterequals =~ s/AmbOutside\.Looping\.//;
				$afterequals =~ s/AmbCity\.Looping\.//;
				$afterequals =~ s/AmbCity\.OneShot\.//;
				
				$noise = 'sound/UNR_'."$afterequals";
			}
		
		if ($dostuff == 4) { 
			$dostuff = 7; 
			$classname = 'target_speaker'; 
		} #Change to ambient sound part instead
	} elsif ($islight_hueline) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSHUE  ***$afterequals\n"); }
		$hue = 0;
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			if ($DEBUGPRINTS)  { print("Afterwhitespaceremoval **: $afterequals\n"); }
		$hue = $afterequals;
			if ($DEBUGPRINTS)  { print("huenowequals: $hue\n"); }
			
		$no_color_set_by_map = 0; #colorhasbeenset for light by the map, not defaults
	} elsif ($islight_saturationline) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSSATURATION  ***$afterequals\n"); }
		$saturation = 0;
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$saturation = $afterequals;
		#hue was erronously set to afterequals here before # if ($originalerrorsethuetosaturation) { $hue = $afterequals; } #
		#which was used on the tundra rtlights, with the old pre algo
		
		$no_color_set_by_map = 0; #colorhasbeenset for light by the map, not defaults
	} elsif ($islight_brightnessline) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSBRIGHTNESS  ***$afterequals\n"); }
		$brightness = 0;
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$brightness = $afterequals;
		
		$no_color_set_by_map = 0; #colorhasbeenset for light by the map, not defaults
	} elsif ($islightradiusline) {
		($beforeequals, $afterequals) = split("=",$thing,2);
				if ($DEBUGPRINTS)  { print("ESASAFTEREQUALSLIGHTRADIUS  ***$afterequals\n"); }
		$light_radius = 0;
			#Getrid of whitespaces etc to get rid of carraigertrn ##
			$afterequals =~ s/\A\s+//s;                           ##
    			$afterequals =~ s/\s+\Z//s;                           ##
			#Getrid of whitespaces etc to get rid of carraigertrn ##
		$light_radius = $afterequals;
		
		$no_radius_set_by_map = 0; #radiushasbeenset for light by the map, not defaults
	} else {
		#($beforeequals, $afterequals) = split("=",$thing,2);
		($beforeequals, $afterequals) = split("=",$thing);
		#print("   ***$beforeequals\n\n\n");
						if ($DEBUGPRINTS)  { print("   ***$afterequals\n\n\n"); }
		
		if ($beforeequals eq 'Begin Actor Class') {
			$classname = "";
						if ($DEBUGPRINTS)  { print("    **** Eays Begin Actor Class\n"); }
			$TWObeforespace = "";
			$TWOafterspace = "";
			
			#($TWObeforespace, $TWOafterspace) = split("\s+",$afterequals,2);
			#($TWObeforespace, $TWOafterspace) = split("/x",$afterequals,2);
			($TWObeforespace, $TWOafterspace) = split(" Name",$afterequals,2); #hack
			$classname = $TWObeforespace;
				$originalclassname = $classname; #record
				
				##############
					if ($mode == 4) {
						#set name for movers
						my $temp_namebefore;
						my $temp_nameafter;
						$temp_nameafter = '';
						($temp_namebefore, $temp_nameafter) = split(" Name",$thing,2); #hack
		
						$name = $TWOafterspace; #record but not needed
						#print("$thing\n");
						#Getrid of whitespaces etc to get rid of carraigertrn ##
						$temp_nameafter=~ s/\A\s+//s;                           ##
    						$temp_nameafter =~ s/\s+\Z//s;                           ##
						#Getrid of whitespaces etc to get rid of carraigertrn ##
						$temp_nameafter =~ s/\=//s; #get rid of equals sign
						#print("$temp_nameafter\n");
						if ($temp_nameafter eq '') {
							#do nothing
						} elsif ($temp_nameafter) {
							$name = $temp_nameafter
						}
					}
				##############
				
				
				#Light mode
				if (($mode == 1 || $mode == 2) && $classname eq 'Light')  {
					#$classname = 'fullydynamic';
					$classname = 'item_cells';$spawnflags= 1;
					$classname = 'lightsabre_spawnlight';
					#$classname = 'not_null'; #doesn't work with not null
					#$classname = 'info_notnull';  #doesn't work either
					   #some tests	
						#$cubemap = 'somecubemapsomewhere';
						#$corona = 10;
					$dostuff = 1000; #special generic
					$is_light_entity = 1;
				} elsif ($mode == 1 || $mode == 2) {
					#ignore everything else 
				
				} 
				#mover mode
				elsif (($mode == 4) && $classname eq 'Mover')  {
					#$classname = 'fullydynamic';
					#$classname = 'item_cells';$spawnflags= 1;
					#$classname = 'lightsabre_spawnlight';
					#$dostuff = 1004; #special generic
					$is_mover  = 1;
				} elsif (($mode == 4) && $classname eq 'Fan2')  {
					$is_fan  = 1;
				} elsif ($mode == 4) {
					#ignore everything else 
				
				} 
				#Normal mode
				elsif ($classname eq 'Light')
					{
						$dostuff = 4;
						$is_light_entity = 1;
					}
				elsif ($classname eq 'RocketCan')
					{
						$classname = 'item_rockets';
						$dostuff = 5;
					}
				elsif ($classname eq 'Eightball')
					{
						$classname = 'weapon_ballrktlauncher';
						$dostuff = 5;
					}
				elsif (($classname eq 'Sludge')
				|| ($classname eq 'bioammo') #UT
				|| ($classname eq 'BioAmmo')) #UT Actual
					{
						$classname = 'item_toxic';
						$dostuff = 5;
					}
				elsif ($classname eq 'GESBioRifle')
					{
						$classname = 'weapon_gbserifle';
						$dostuff = 5;
					}
				elsif ($classname eq 'Minigun')
					{
						$classname = 'weapon_cmbn9mgun';
						$dostuff = 5;
					}
				elsif ($classname eq 'AutoMag')
					{
						$classname = 'weapon_pistol';
						$dostuff = 5;
					}
				elsif ($classname eq 'Shellbox')
					{
						$classname = 'item_bullets';
						$dostuff = 5;
					}
				elsif ($classname eq 'BulletBox') #UT 
					{
						$classname = 'item_bullets'; #guess
						$dostuff = 5;
					}
				elsif ($classname eq 'Miniammo') #actual UT
					{
						$classname = 'item_bullets';
						$dostuff = 5;
					}
				elsif ($classname eq 'Rifle')
					{
						$classname = 'weapon_t17mmrifle';
						$dostuff = 5;
					}
				elsif ($classname eq 'RifleRound')
					{
						$classname = 'item_bullets';
						$dostuff = 6; #special case, more information printed
					}
				#elsif ($classname eq 'Razorjack') #not tested
				elsif ($classname eq 'RazorJack') #It's uppercase
					{
						$classname = 'weapon_razorprjctr';
						$dostuff = 5;
					}
				elsif ($classname eq 'DispersionPistol') #not tested
					{
						$classname = 'weapon_dsprsnpstl';
						$dostuff = 5;
					}
				elsif ($classname eq 'ASMD')
					{
						$classname = 'weapon_asdwrifle';
						$dostuff = 5;
					}
				elsif ($classname eq 'ASMDAmmo')
					{
						$classname = 'item_cells';
						$dostuff = 5;
					}
				elsif ($classname eq 'PAmmo') #green #UT 
					{
						if ($PAMMOUSESREGULAR) {
						$classname = 'item_cells';
						$dostuff = 5;
						} else {
							$dostuff = 1001; #special case, more information printed
							$classname = 'item_cells';
							$specialextrastuffname = 'colormap'; $specialextrastuffamnt = '1139'; #green
							$specialextrastuffname0 = 'scale'; $specialextrastuffamnt0 = '1.3';
							$model = 'models/items/item_cells_electricrifle.iqm';
						}
					}
				elsif ($classname eq 'ShockCore') #purple #UT
					{
						if ($SHOCKCOREUSESREGULAR) {
						$classname = 'item_cells';
						$dostuff = 5;
						} else {
							$dostuff = 1001; #special case, more information printed
							$classname = 'item_cells';
							$specialextrastuffname = 'colormap'; $specialextrastuffamnt = '1029'; #light blue for contrast with the rest which is purple
							$model = 'models/items/item_cells_xonlong.iqm';
						}
					}
				elsif ($classname eq 'Armor')
					{
						$classname = 'item_armor';
						$dostuff = 5;
					}
				elsif ($classname eq 'ThighPads')
					{
						$classname = 'item_armor_small';
						$dostuff = 5;
					}
				elsif ($classname eq 'NaliFruit')
					{
						$classname = 'item_health_small';
						$dostuff = 5;
					}
				elsif ($classname eq 'SuperHealth')
					{
						$classname = 'item_health_mega';
						$dostuff = 5;
					}
				elsif ($classname eq 'HealthPack') #UT
					{
						$classname = 'item_health_mega';
						$dostuff = 5;
					}
				elsif ($classname eq 'HealthVial') #UT
					{
						$classname = 'item_health_small';
						$dostuff = 5;
					}
				elsif (($classname eq 'Health')
				|| ($classname eq 'MedBox')) #UT
					{
						$classname = 'item_health';
						$dostuff = 5;
					}
				elsif (($classname eq 'ShieldBelt')
				|| ($classname eq 'ut_shieldbelt')) #UT
					{
						$classname = 'item_invincible';
						$dostuff = 5;
					}
				elsif ($classname eq 'armor2') #UT
					{
						$classname = 'item_armor_large'; #guess
						$dostuff = 5;
					}
				elsif (($classname eq 'Amplifier')
				|| ($classname eq 'UDamage')) #UT
					{
						$classname = 'item_strength';
						$dostuff = 5;
					}
				elsif ($classname eq 'FlakCannon')
					{
						$classname = 'weapon_fragmentationcannon';
						$dostuff = 5;
					}
				elsif ($classname eq 'Stinger')
					{
						$classname = 'weapon_strkr';
						$dostuff = 5;
					}
				elsif ($classname eq 'PlayerStart')
					{
						$classname = 'info_player_start';
						$dostuff = 5;
						if ($ENABLE_ADD_Z_TOPLAYERSTART) {
							if ($add_z_toplayerstart) {
								$dostuff = 500;
							}
						}
					}
				elsif ($classname eq 'AmbientSound')
					{
						$classname = 'target_speaker';
						$dostuff = 7;	#needs more info pasted
					}
				elsif ($classname eq 'PulseGun') #not tested
					{
						$classname = 'weapon_electricrifle';
						$dostuff = 5;
					}
				elsif ($classname eq 'UT_Eightball') #not tested
					{
						$classname = 'weapon_nineballlauncher';
						$dostuff = 5;
					}
				elsif ($classname eq 'RocketPack') #UT
					{
						$classname = 'item_rockets';
						$dostuff = 5;
					}
				#ammo substitutions
				elsif (($classname eq 'FlakBox') #ammo substitutions
					|| ($classname eq 'flakammo')) #UT
					{
						$classname = 'item_rockets';
						$dostuff = 5;
					}
				#Done below now
				#elsif ($classname eq 'StingerAmmo') #ammo substitutions
				#	{
				#		$classname = 'item_cells';
				#		$dostuff = 5;
				#	}
				elsif ($classname eq 'RifleAmmo') #ammo substitutions
					{
						$classname = 'item_bullets';
						$dostuff = 5;
					}
				#substitutions
				elsif ($classname eq 'UT_FlakCannon') #not tested #substitutions
					{
						$classname = 'weapon_fragmentationcannon';
						$dostuff = 5;
					}
				elsif (($classname eq 'Ripper') #not tested #substitutions
					|| ($classname eq 'ripper')) #actual UT
					{
						$classname = 'weapon_razorprjctr';
						$dostuff = 5;
					}
				elsif ($classname eq 'ShockRifle') #not tested #substitutions
					{
						$classname = 'weapon_asdwrifle';
						$dostuff = 5;
					}
				elsif ($classname eq 'Enforcer') #not tested #substitution... sort of
					{
						$classname = 'weapon_pistol';
						$dostuff = 5;
					}
				elsif (($classname eq 'UT_BioRifle') #not tested #substitutions
				|| ($classname eq 'ut_biorifle')) #actual UT
					{
						$classname = 'weapon_gbserifle';
						$dostuff = 5;
					}
				elsif ($classname eq 'SniperRifle') #not tested #substitutions
					{
						$classname = 'weapon_lrr';
						$dostuff = 5;
						if ($PICKUP_UT_SniperRifle_OPTIONS == 1) {
							$classname = 'weapon_t17mmrifle';
							$dostuff = 5;
						}
					}
				elsif (($classname eq 'Minigun2')   #not tested 
				 ||  ($classname eq 'minigun2')) #actual UT
					{
						$classname = 'weapon_minigunii';
						$dostuff = 5;
					}
				elsif ($classname eq 'WarheadLauncher') #not tested 
					{
						$classname = 'weapon_rdmrrocket';
						$dostuff = 5;
					}
				#Others
				elsif ($classname eq 'SU_1911')
					{
						$classname = 'weapon_bigpistol';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_MP5')
					{
						$classname = 'weapon_pdw';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_Aug')
					{
						$classname = 'weapon_styeraug';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_Ithaca')
					{
						$classname = 'weapon_ithacastakeout';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_Glock')
					{
						$classname = 'weapon_lightpistol';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_RPG7') 
					{
						$classname = 'weapon_rpg7launcher';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_Rem308') #substitution
					{
						$classname = 'weapon_m1903';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_Grenade') 
					{
						$classname = 'item_fragnades';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_Vest') #substitution
					{
						$classname = 'item_armor_large';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_Jacket') #substitution
					{
						$classname = 'item_health_small';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_Can') #substitution #guess
					{
						$classname = 'item_rockets';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_AmmoCan9mm') #substitution
					{
						$classname = 'item_bullets';
						$dostuff = 5;
					}
				elsif ($classname eq 'SU_AmmoSingle308')
					{
						$classname = 'item_bullets';
						$dostuff = 7; #special case, more information printed
					}
				elsif ($classname eq 'SU_AmmoLooseShells')
					{
						$classname = 'item_shells';
						$dostuff = 8; #special case, more information printed
					}
				elsif ($classname eq 'SU_AmmoClips223')
					{
						$classname = 'item_bullets';
						$dostuff = 9; #special case, more information printed
					}
				elsif ($classname eq 'SU_AmmoBox9mm')
					{
						$classname = 'item_bullets';
						$dostuff = 10; #special case, more information printed
					}
				elsif ($classname eq 'SU_AmmoClips45') #substitution
					{
						$classname = 'item_bullets';
						$dostuff = 11; #special case, more information printed
					}
				elsif ($classname eq 'SU_AmmoLoose308') #substitution
					{
						$classname = 'item_bullets';
						$dostuff = 12; #special case, more information printed
					}
				
				elsif ($classname eq 'SU_AmmoBox45')
					{
						$classname = 'item_bullets';
						$dostuff = 15; #special case, more information printed
					}
				elsif ($classname eq 'SU_AmmoBoxShells') #substitution
					{
						$classname = 'item_shells';
						$dostuff = 5; 
					}
				elsif ($classname eq 'INFIL_UTMP5')
					{
						$classname = 'weapon_submachinegun';
						$dostuff = 5;
					}
				elsif ($classname eq 'INFIL_UTM16')
					{
						$classname = 'weapon_m16a2';
						$dostuff = 5;
					}
				elsif ($classname eq 'INFIL_UTShotgun')
					{
						$classname = 'weapon_m3shotgun';
						$dostuff = 5;
					}
				elsif ($classname eq 'INFIL_UTM16Clips')
					{
						$classname = 'item_bullets';
						$dostuff = 1001; #special case, more information printed
						$specialextrastuffname = 'ammo_nails'; $specialextrastuffamnt = '30';
						$specialextrastuffname0 = 'scale'; $specialextrastuffamnt0 = '2';
						$model = 'models/misc/extendedmags/m16mag30.iqm';
					}
				elsif ($classname eq 'INFIL_UTMP5Clips') #substitution
					{
						$classname = 'item_bullets';
						$dostuff = 1001; #special case, more information printed
						$specialextrastuffname = 'ammo_nails'; $specialextrastuffamnt = '30';
						$specialextrastuffname0 = 'scale'; $specialextrastuffamnt0 = '2';
						$model = 'models/misc/extendedmags/pdwstdmag.iqm';
					}
				elsif ($classname eq 'SteelBox') #substitution
					{
						$classname = 'building_buildable_by_count';
						$dostuff = 200; 
						$count = 1772; #MTB64U_METAL
					}
				elsif ($classname eq 'SteelBarrel') #guess 
					{
						$classname = 'building_buildable_by_count';
						$dostuff = 200; 
						$count = 1819; #MTB64U_INACT_OIL
					}
				elsif ($classname eq 'TarydiumBarrel') #substitution
					{
						$classname = 'building_buildable_by_count';
						$dostuff = 200; 
						$count = 1820; #MTB64U_ACT_OIL
					}
				#Some accomadations
				elsif (($classname eq 'RazorAmmo')
				 || ($classname eq 'BladeHopper')) #UT
					{
						$classname = 'item_bullets';
						$dostuff = 1001; #special case, more information printed
						$specialextrastuffname = 'ammo_nails'; $specialextrastuffamnt = '10';
						$specialextrastuffname0 = 'scale'; $specialextrastuffamnt0 = '3';
						$model = 'models/razor_projectile_side.iqm';
					}
				elsif ($classname eq 'StingerAmmo')
					{
						$classname = 'item_cells';
						$dostuff = 1001; #special case, more information printed
						$specialextrastuffname = 'ammo_nails'; $specialextrastuffamnt = '10';
						$specialextrastuffname0 = 'scale'; $specialextrastuffamnt0 = '0.75';
						$model = 'models/bluespike.iqm';
					}
				#elsif ($classname eq 'ImpactHammer') #not tested 
				elsif ($classname eq 'NaliStatue')
					{
						$classname = 'func_wall';
						$dostuff = 100; #special case for models, more information printed
						$model = 'models/fromunreal/NaliStatueM_fortundra.basescale1.obj_from_mc';
					
						$dostuff = 1000; #special generic
					} 
				elsif ($classname eq 'Tapestry1')
					{
						$classname = 'func_wall';
						$dostuff = 100; #special case for models, more information printed
						$model = 'models/fromunreal/Tap_fortundra.basescale1.obj_from_mc';
					
						$dostuff = 1000; #special generic
					} 
				elsif ($classname eq 'Candle')
					{
						$classname = 'func_wall';
						$dostuff = 100; #special case for models, more information printed
						$model = 'models/fromunreal/CandleM_fortundra.basescale1.obj_from_mc';
					
						$dostuff = 1000; #special generic
					}  
				elsif ($classname eq 'INFIL_UTM2_50') #substitution
					{
						$classname = 'mountedgun_browning50';
						$dostuff = 1001; #special case, more information printed
						$specialextrastuffname = 'spawnflags'; 
						$specialextrastuffamnt = '32'; #pintel mount
						#$specialextrastuffname0 = 'scale'; $specialextrastuffamnt0 = '2';
						#$model = 'models/misc/extendedmags/pdwstdmag.iqm';
					}
				elsif ($classname eq 'SeaWeed')
					{
						$classname = 'foliage_dypbush'; #substitution
						$dostuff = 1001; #special generic
						$specialextrastuffname = 'scale'; $specialextrastuffamnt = '0.99';
						$specialextrastuffname0 = 'scale'; $specialextrastuffamnt0 = '0.99';
					}
				else 
					{
						if ($IGNOREPATHNODES && ($classname eq 'PathNode')) {
							#nothing
						} elsif ($IGNORELEVELINFO && ($classname eq 'LevelInfo')) {
							#nothing
						} elsif ($IGNOREZONEINFO && ($classname eq 'ZoneInfo')) {
							#nothing
						} else {
					$dostuff = 3;
						}
						$originalclassname = ''; #reset it
				}
		}
	}
	
	



if ($mode == 0 && $classname eq 'Light' && $endnow == 1) {
	#Do nothing
} elsif (($mode == 4 && $endnow == 1 && ($is_mover || $is_fan)) 
|| ($mode == 0 && $endnow == 1)) {
	#Strip out the default lightinfo etc 
	$brightness = 0;  #LightBrightness 64
	$hue = 0; 	   #LightHue	0
	$saturation = 0; #LightSaturation 255
	$light_radius = 0; #LightRadius 64
}

if ($mode == 4 && $endnow == 1 && ($is_mover || $is_fan)) {
	my $temp_mover_prefix;
	$temp_mover_prefix = '';
	$infooriginal_mover_rotation_pitch = $rotation_pitch ;
	$infooriginal_mover_rotation_yaw = $rotation_yaw;
	$infooriginal_mover_rotation_roll = $rotation_roll;
	
	#determine if we are a type of mover we know of
	#first a fan, the movers are below this block
	if ($is_fan) {
		#these are somewhat guesses
		my $tempprefixforfan = '';
		print("//#isfan, NOTE: perhaps comment out angles line and scale line if you exported from map\n");
		$classname = 'func_rotating';
		soundguessfornoiseofrotatingdoortrapmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		#less normal
		if ($rotationrate_pitch && $rotationrate_yaw) {
			$speed = &unr_rotation_to_deg ($rotationrate_pitch); #guess2
			$speed += &unr_rotation_to_deg ($rotationrate_yaw);  #guess2
			$speed += &unr_rotation_to_deg ($rotationrate_roll);  #guess2
			$spawnflags = 12; #x+y axis			     #guess2
			$tempprefixforfan = 'pitchyawroll1';
		} elsif ($rotationrate_pitch && $rotationrate_yaw) {
			$speed = &unr_rotation_to_deg ($rotationrate_pitch); #guess
			$speed += &unr_rotation_to_deg ($rotationrate_yaw);  #guess
			$spawnflags = 12; #x+y axis			     #guess
			$tempprefixforfan = 'pitchyaw1';
		#more normal
		} elsif ($rotationrate_pitch) {
			$speed = &unr_rotation_to_deg ($rotationrate_pitch); #guess
			$spawnflags = 4; #x axis? 			   #guess
			$tempprefixforfan = 'pitch1';			     #guess
		} elsif ($rotationrate_yaw) {
			$speed = &unr_rotation_to_deg ($rotationrate_yaw); #guess
			$spawnflags = 8; #y axis? 			   #guess
			$tempprefixforfan = 'yaw1';
		} elsif ($rotationrate_roll) {
			$speed = &unr_rotation_to_deg ($rotationrate_roll);
			$tempprefixforfan = 'roll1';
			
			if ($reverse_fan_roll_speed_asthetics_obj_from_mc) {
				#Multip by -1 because models are reversed in obj_from_mc because quake vs regular is reversed?
				$speed *= -1; #note: asthetic choice
			}
		}
		$model = "$tempprefixforfan".'fanexport'."$name".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		if ($drawscale) {
			$specialextrastuffname2 = 'scale';
			$specialextrastuffamnt2 = $drawscale; 
		}
		#speedguessformovers();
	#determine if we are a type of mover we know of
	} elsif ( (!($moverkey_rotation_pitch) && #not set
	!($moverkey_rotation_yaw) &&	     #not set
	$moverkey_rotation_roll)	     #set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	(($moverkey_pos_origin_x == 0) && #notset sliding 
	($moverkey_pos_origin_y == 0)   && #notset sliding 
	($moverkey_pos_origin_z == 0)) #notset sliding 
	) {
		#seems to be a trap floor rotating
		if ($comment_mover_information ) {
		print('//#');
		print("XXXX $mover_tag");
			if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
				if ($name eq '') { 
					# do nothing
				} else {
					print(' ');
					print('name: '."$name");
				}
				$did_mover_name_allready = 1;
			}
		print("\n");
		}
		
		#sets the prefix of the model to mover_tag by default, or name if there is none
		if ($mover_tag eq '') {
			if ($name eq '') {
			} else {
				#second choice
				$temp_mover_prefix = $name;
			}
		} else {	
			#first choice
			$temp_mover_prefix = $mover_tag;
		}
		
		$classname = 'func_door_rotating';
		$rotation_yaw = &rotation_convert($moverkey_rotation_roll); #angles x y z
		$rotation_yaw *= -1;
		$spawnflags = 64;
		$force_angles_rather_than_angle = 1;
		$no_angle_conversion_allready_done = 1;
		$targetname = $mover_tag;
		$model = "$temp_mover_prefix".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		#guess
		soundguessfornoiseofrotatingdoortrapmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
	}
	
	elsif ( ( $moverkey_rotation_pitch &&  #set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	(($moverkey_pos_origin_x == 0) && #notset sliding 
	($moverkey_pos_origin_y == 0)   && #notset sliding 
	($moverkey_pos_origin_z == 0)) #notset sliding 
	) {
		#seems to be a trap floor rotating
		if ($comment_mover_information ) {
		print('//#');
		print("YYYY $mover_tag");
			if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
				if ($name eq '') { 
					# do nothing
				} else {
					print(' ');
					print('name: '."$name");
				}
				$did_mover_name_allready = 1;
			}
		print("\n");
		}
		
		#sets the prefix of the model to mover_tag by default, or name if there is none
		if ($mover_tag eq '') {
			if ($name eq '') {
			} else {
				#second choice
				$temp_mover_prefix = $name;
			}
		} else {	
			#first choice
			$temp_mover_prefix = $mover_tag;
		}
		
		$classname = 'func_door_rotating';
		$rotation_yaw = &rotation_convert($moverkey_rotation_pitch); #angles x y z
		$rotation_yaw *= -1;
		$spawnflags = 128;
		$force_angles_rather_than_angle = 1;
		$no_angle_conversion_allready_done = 1;
		$targetname = $mover_tag;
		$model = "$temp_mover_prefix".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		#guess
		soundguessfornoiseofrotatingdoortrapmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
	}
	
	#button (twilight)
	elsif ( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	($mover_encroachtype == 2) #ME_IgnoreWhenEncroach
	&&
	($mover_bumptype == 1) #BT_AnyBump
	&&
	($mover_initialstate == 1) #BumpButton
	&&
	(($moverkey_pos_origin_x) || #one of these set sliding 
	($moverkey_pos_origin_y)   || #one of these set sliding 
	($moverkey_pos_origin_z)) #one of these set sliding 
	) {
		$classname = 'func_button';
		$target = $mover_bumpevent;
		
		#Some info
			if ($comment_mover_information ) {
			print('//#');
			if ($mover_bumpevent eq '') {
				print("BBBB button");
			} else {
				print("BBBB Button for $mover_bumpevent");
			}
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
			}
		#end info
		
		if ($mover_bumpevent eq '') {
			if ($name eq '') {
				$temp_mover_prefix = 'button';
			} else {
				#second choice
				$temp_mover_prefix = $name;
				$temp_mover_prefix = ('Button'."$name");
			}
		} else {	
			#first choice
			$temp_mover_prefix = ('Button'.'_for'.'_'."$mover_bumpevent");
		}
		
		$model = "$temp_mover_prefix".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		soundguessfornoiseofrotatingdoortrapmovers();
		setmovetimeifnotset();
		speedguessformovers();
		$dostuff=1001;
		
		if (($moverkey_pos_origin_x) &&   #set
		!($moverkey_pos_origin_y) &&	     #not set
		!($moverkey_pos_origin_z)) {	     #not set
			# X
			if ($moverkey_pos_origin_x < 0) { #negative
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = 180;
			}elsif ($moverkey_pos_origin_x > 0) { #positive
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = 0;
			}
		} elsif (!($moverkey_pos_origin_x) &&   #not set
		($moverkey_pos_origin_y) &&	     #set
		!($moverkey_pos_origin_z)) {	     #not set
			#Y
			if ($moverkey_pos_origin_y < 0) { #negative
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = -90;
			}elsif ($moverkey_pos_origin_y > 0) { #positive
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = 90;
			}
		#ADDED, not in the map, not tested
		} elsif (!($moverkey_pos_origin_x) &&   #not set
		!($moverkey_pos_origin_y) &&	     #not set
		($moverkey_pos_origin_z)) {	     #not set
			#Z
			if ($moverkey_pos_origin_z < 0) { #negative
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = -2; #Down
			}elsif ($moverkey_pos_origin_z > 0) { #positive
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = -1; #up
			}
		}
		#} elsif (!($moverkey_pos_origin_x) &&   #not set
		#!($moverkey_pos_origin_y) &&	     #not set
		#!($moverkey_pos_origin_z)) {	     #not set
		#
		#} elsif (!($moverkey_pos_origin_x) &&   #not set
		#!($moverkey_pos_origin_y) &&	     #not set
		#!($moverkey_pos_origin_z)) {	     #not set
		#
		#}
	}
	#crusher (twilight)
	elsif ( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	($mover_encroachtype == 1)
	&&
	($mover_initialstate == 4) #Trigger open timed
	&&
	(!($mover_bumptype))
	&&
	($mover_encroachdamage)
	&&
	($mover_tag)
	&&
	((!($moverkey_pos_origin_x)) && #notset
	(!($moverkey_pos_origin_y))  && #notset
	($moverkey_pos_origin_z)) #one of these set sliding 
	&&
	($moverkey_pos_origin_z < 0) #is negative
	&&
	($formover_maximum_seen_vertex_z || $formover_littlest_seen_vertex_z) #has a size
	) {	
		#though this really goes down
		$specialextrastuffname2 = 'angle';
		$specialextrastuffamnt2 = -1; #-1 up, -2 down
		my $tempamnt;
		$tempamnt = $formover_littlest_seen_vertex_z - $formover_maximum_seen_vertex_z;
		$specialextrastuffname3 = 'lip';
		#$specialextrastuffamnt3 = $moverkey_pos_origin_z + $tempamnt;
		$specialextrastuffamnt3 = ($moverkey_pos_origin_z + $tempamnt)*-1;
		
		$classname = 'func_door';
		$targetname = $mover_tag;
		$model = "$mover_tag".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		#guess
		soundguessfornoiseofliftmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
		
		if ($comment_mover_information ) {
			print('//#');
			print("CCCC Crusher ");
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
						print("\n//minz - maxz =\t$tempamnt");
						print("\n//key_z =\t".(0 + $moverkey_pos_origin_z)." ");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
		}
	}
	#lift (twilight)
	elsif ( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	(!($mover_encroachtype)) #none set
	&&
	#(!($mover_bumptype)) #none set #added #edit commented out to be useable by more lifts
	#&&                                    #edit commented out to be useable by more lifts
	(!($mover_encroachdamage)) #none set
	#//&&
	#//($mover_tag)
	&&
	((!($moverkey_pos_origin_x)) && #notset
	(!($moverkey_pos_origin_y))  && #notset
	($moverkey_pos_origin_z)) #one of these set sliding 
	&&
	($moverkey_pos_origin_z > 0) #is positive
	&&
	($formover_maximum_seen_vertex_z || $formover_littlest_seen_vertex_z) #has a size
	) {
		my $templiftaddedinfo = '';
		$specialextrastuffname2 = 'angle';
		$specialextrastuffamnt2 = -1; #-1 up, -2 down
		$omitangles_allready_set_angle = 1; #for movers
		my $tempamnt;
		$tempamnt = $formover_littlest_seen_vertex_z - $formover_maximum_seen_vertex_z;
		$specialextrastuffname3 = 'lip';
		$specialextrastuffamnt3 = ($moverkey_pos_origin_z*-1) - $tempamnt; #note: opposite to crusher
		
		$classname = 'func_door';
		#$targetname = $mover_tag;
		if ( (!($mover_bumptype)) ) {
			$templiftaddedinfo = '';
		} else {
			$templiftaddedinfo = $mover_bumptype.$model;
		}
		$model = "Lift"."$templiftaddedinfo".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		#guess
		soundguessfornoiseofliftmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
		
		if ($comment_mover_information ) {
			print('//#');
			print("LLLL Lift$templiftaddedinfo ");
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
						if ($mover_tag) { print(' tag: '."$mover_tag"); }
						print("\n//minz - maxz =\t$tempamnt");
						print("\n//key_z =\t".(0 + $moverkey_pos_origin_z)." ");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
		}
	}
	#door (sliding, 90 degrees) (dmelsnore)
	elsif ( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	#&&							#edit commented out to be useable by more doors
	#($mover_encroachtype == 2) #ME_IgnoreWhenEncroach	#edit commented out to be useable by more doors
	&&
	(!($mover_bumptype)) #none set #added
	&&
	(!($mover_encroachdamage)) #none set
	&&
	(  ( ($moverkey_pos_origin_x && (!($moverkey_pos_origin_y)) )  || #one of these set sliding 
	   ($moverkey_pos_origin_y && (!($moverkey_pos_origin_x)) ) )  && #one of these set sliding 
	   (!($moverkey_pos_origin_z) )) #notset
	&&
	($formover_maximum_seen_vertex_x || $formover_littlest_seen_vertex_x
	|| $formover_maximum_seen_vertex_y || $formover_littlest_seen_vertex_y) #has a size
	#doesn't have other keys after
	&& (!($moverkey_pos2_origin_x))
	&& (!($moverkey_pos2_origin_y))
	&& (!($moverkey_pos2_origin_z))
	) {
		if ($moverkey_pos_origin_y) {
			if ($moverkey_pos_origin_y < 0) { #negative
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = -90;
			} elsif ($moverkey_pos_origin_y > 0) { #positive
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = 90;
			}
		} elsif ($moverkey_pos_origin_x) { #guess
			if ($moverkey_pos_origin_x < 0) { #negative #guess
				$specialextrastuffname2 = 'angle'; #guess
				$specialextrastuffamnt2 = 180; #guess2 #guess2 #previously was 0 and was wrong
			} elsif ($moverkey_pos_origin_x > 0) { #positive #guess
				$specialextrastuffname2 = 'angle'; #guess
				$specialextrastuffamnt2 = 0; #guess2 #previously was 180 and was wrong
			}
		}
		$omitangles_allready_set_angle = 1; #for movers
		
		$classname = 'func_door';
		$model = "Door".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		soundguessfornoiseofliftmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
		
		if ($comment_mover_information ) {
			print('//#');
			print("DDDD Door ");
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
						if ($mover_tag) { print(' tag: '."$mover_tag"); }
						print("\n//minz - maxz =\t$tempamnt");
						print("\n//key_z =\t".(0 + $moverkey_pos_origin_z)." ");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
		}
	}
	#secretdoor (sliding, 90 degrees) (dmelsnore)
	elsif ( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	(!($mover_encroachtype)) #none set
	&&
	($mover_initialstate == 4) #Trigger open timed
	&&
	(!($mover_bumptype)) #none set #added
	&&
	(!($mover_encroachdamage)) #none set
	&&
	#first part
	((!($moverkey_pos_origin_x)) && #notset
	(!($moverkey_pos_origin_y))  && #notset
	($moverkey_pos_origin_z)) #one of these set sliding 
	&&
	($moverkey_pos_origin_z < 0) #is negative
	&&
	#second part
	((!($moverkey_pos2_origin_x)) && #notset
	($moverkey_pos2_origin_y)  && #one of these set sliding
	($moverkey_pos2_origin_z)) #one of these set sliding 
	&&
	($moverkey_pos2_origin_z < 0) #is negative same as before really
	&&
	($moverkey_pos2_origin_y > 0) #is positive sliding
	&&
	($formover_maximum_seen_vertex_x || $formover_littlest_seen_vertex_x
	|| $formover_maximum_seen_vertex_y || $formover_littlest_seen_vertex_y
	|| $formover_maximum_seen_vertex_z || $formover_littlest_seen_vertex_z) #has a size
	) {
		$spawnflags = 4;
		
		$classname = 'func_door_secret';
		$model = "SecretDoor".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		soundguessfornoiseofsecretdoormovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
		
		if ($comment_mover_information ) {
			print('//#');
			print("SSSS SecretDoor ");
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
						if ($mover_tag) { print(' tag: '."$mover_tag"); }
						print("\n//minz - maxz =\t$tempamnt");
						print("\n//key_z =\t".(0 + $moverkey_pos_origin_z)." ");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
		}
	}
	#secretdoor2 (sliding, should be back and up, but...) ()
	elsif ( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	(!($mover_encroachtype)) #none set
	&&
	($mover_initialstate == 4) #Trigger open timed
	&&
	(!($mover_bumptype)) #none set #added
	&&
	(!($mover_encroachdamage)) #none set
	&&
	#first part
	((($moverkey_pos_origin_x)) && #set
	(!($moverkey_pos_origin_y))  && #notset
	(!($moverkey_pos_origin_z))) #notset
	&&
	($moverkey_pos_origin_x > 0) #is positive
	&&
	#second part
	((($moverkey_pos2_origin_x)) && #set
	(!($moverkey_pos2_origin_y))  && #notset
	($moverkey_pos2_origin_z)) #one of these set sliding 
	&&
	($moverkey_pos2_origin_z > 0) #is positive
	&&
	($moverkey_pos2_origin_x> 0) #is positive sliding
	&&
	($formover_maximum_seen_vertex_x || $formover_littlest_seen_vertex_x
	|| $formover_maximum_seen_vertex_y || $formover_littlest_seen_vertex_y
	|| $formover_maximum_seen_vertex_z || $formover_littlest_seen_vertex_z) #has a size
	) {
		$spawnflags = 0;
		
		$classname = 'func_door_secret';
		$model = "SecretDoor2".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		soundguessfornoiseofsecretdoormovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
		$omitangles_allready_set_angle = 1; #for movers
		#$force_angles_rather_than_angle = 1;
		#$no_angle_conversion_allready_done = 1;
		$specialextrastuffname2 = 'angles';
		$specialextrastuffamnt2 = "-90 90 0";
		
		if ($comment_mover_information ) {
			print('//#');
			print("SSSS SecretDoor2 ");
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
						if ($mover_tag) { print(' tag: '."$mover_tag"); }
						print("\n//minz - maxz =\t$tempamnt");
						print("\n//key_z =\t".(0 + $moverkey_pos_origin_z)." ");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
		}
	###
	#button (letting)
	} elsif ( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	($mover_moverglidetype == 1) #MV_MoveByTime 
	&&
	#($mover_encroachtype == 2) #ME_IgnoreWhenEncroach 	#omitted for letting
	#&& 							#omitted for letting
	($mover_bumptype == 1 || #BT_AnyBump
	$mover_bumptype == 2) #BT_PawnBump
	&&
	#($mover_initialstate == 1) #BumpButton	#omitted for letting
	#&&					#omitted for letting
	(($moverkey_pos_origin_x) || #one of these set sliding 
	($moverkey_pos_origin_y)   || #one of these set sliding 
	($moverkey_pos_origin_z)) #one of these set sliding 
	&&
	($mover_event) #for letting
	) {
		$classname = 'func_button';
		$target = $mover_event;
		
		#Some info
			if ($comment_mover_information ) {
			print('//#');
			if ($mover_bumpevent eq '') {
				print("BBBB2 button");
			} else {
				print("BBBB2 Button for $mover_bumpevent");
			}
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
			}
		#end info
		
		if ($mover_bumpevent eq '') {
			if ($name eq '') {
				$temp_mover_prefix = 'button';
			} else {
				#second choice
				$temp_mover_prefix = $name;
				$temp_mover_prefix = ('Button'."$name");
			}
		} else {	
			#first choice
			$temp_mover_prefix = ('Button'.'_for'.'_'."$mover_bumpevent");
		}
		
		$model = "$temp_mover_prefix".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		soundguessfornoiseofrotatingdoortrapmovers();
		setmovetimeifnotset();
		speedguessformovers();
		$dostuff=1001;
		
		if (($moverkey_pos_origin_x) &&   #set
		!($moverkey_pos_origin_y) &&	     #not set
		!($moverkey_pos_origin_z)) {	     #not set
			# X
			if ($moverkey_pos_origin_x < 0) { #negative
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = 180;
			}elsif ($moverkey_pos_origin_x > 0) { #positive
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = 0;
			}
			$omitangles_allready_set_angle = 1; #for movers #not tested here
		} elsif (!($moverkey_pos_origin_x) &&   #not set
		($moverkey_pos_origin_y) &&	     #set
		!($moverkey_pos_origin_z)) {	     #not set
			#Y
			if ($moverkey_pos_origin_y < 0) { #negative
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = -90;
			}elsif ($moverkey_pos_origin_y > 0) { #positive
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = 90;
			}
			$omitangles_allready_set_angle = 1; #for movers #not tested here
		} elsif (!($moverkey_pos_origin_x) &&   #not set
		!($moverkey_pos_origin_y) &&	     #not set
		($moverkey_pos_origin_z)) {	     #not set
			#Z
			if ($moverkey_pos_origin_z < 0) { #negative
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = -2; #Down
			}elsif ($moverkey_pos_origin_z > 0) { #positive
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = -1; #up
			}
			$omitangles_allready_set_angle = 1; #for movers
		} #elsif (!($moverkey_pos_origin_x) &&   #not set
		#!($moverkey_pos_origin_y) &&	     #not set
		#!($moverkey_pos_origin_z)) {	     #not set
		#
		#}
	#crusher (sliding, 90 degrees) (letting)
	} elsif ( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	($mover_encroachtype == 1)
	&&
	($mover_initialstate == 4) #Trigger open timed
	&&
	($mover_moverglidetype == 1) #MV_MoveByTime
	&&
	($mover_encroachdamage)
	&&
	($mover_encroachdamage)
	&&
	($mover_tag)
	&&
	(  ( ($moverkey_pos_origin_x && (!($moverkey_pos_origin_y)) )  || #one of these set sliding 
	   ($moverkey_pos_origin_y && (!($moverkey_pos_origin_x)) ) )  && #one of these set sliding 
	   (!($moverkey_pos_origin_z) )) #notset
	&&
	($formover_maximum_seen_vertex_x || $formover_littlest_seen_vertex_x
	|| $formover_maximum_seen_vertex_y || $formover_littlest_seen_vertex_y) #has a size
	#doesn't have other keys after
	&& (!($moverkey_pos2_origin_x))
	&& (!($moverkey_pos2_origin_y))
	&& (!($moverkey_pos2_origin_z))
	) {
		if ($moverkey_pos_origin_y) {
			if ($moverkey_pos_origin_y < 0) { #negative
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = -90;
			} elsif ($moverkey_pos_origin_y > 0) { #positive
				$specialextrastuffname2 = 'angle';
				$specialextrastuffamnt2 = 90;
			}
			
			#Nolip for some reason...
			#my $tempamnt;
			#$tempamnt = $formover_littlest_seen_vertex_y - $formover_maximum_seen_vertex_y;
			#$specialextrastuffname3 = 'lip';
			#$specialextrastuffamnt3 = $moverkey_pos_origin_y + $tempamnt;
			##$specialextrastuffamnt3 = ($moverkey_pos_origin_y + $tempamnt)*-1;
			
		} elsif ($moverkey_pos_origin_x) { #guess
			if ($moverkey_pos_origin_x < 0) { #negative #guess
				$specialextrastuffname2 = 'angle'; #guess
				$specialextrastuffamnt2 = 180; #guess2 #guess2 #previously was 0 and was wrong
			} elsif ($moverkey_pos_origin_x > 0) { #positive #guess
				$specialextrastuffname2 = 'angle'; #guess
				$specialextrastuffamnt2 = 0; #guess2 #previously was 180 and was wrong
			}
			
			#Nolip for some reason...
			#my $tempamnt;
			#$tempamnt = $formover_littlest_seen_vertex_x - $formover_maximum_seen_vertex_x;
			#$specialextrastuffname3 = 'lip';
			#$specialextrastuffamnt3 = $moverkey_pos_origin_x + $tempamnt;
			##$specialextrastuffamnt3 = ($moverkey_pos_origin_x + $tempamnt)*-1;
		}
		$omitangles_allready_set_angle = 1; #for movers
		
		$classname = 'func_door';
		$targetname = $mover_tag;
		$model = "CrusherS".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		soundguessfornoiseofliftmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
		
		if ($comment_mover_information ) {
			print('//#');
			print("CCCC2 Crusher Sliding ");
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
						if ($mover_tag) { print(' tag: '."$mover_tag"); }
						print("\n//minz - maxz =\t$tempamnt");
						print("\n//key_z =\t".(0 + $moverkey_pos_origin_z)." ");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
		}
	###
	
	### (tall towa)
	} elsif (($ALLOW_DESTRUCTABLES_MOVERS == 1) && #we know there are destructables and have enabled searching for them
		(
		(($mover_basepos_origin_x) || #these always seem to be set, adding just in case for this mover type
		($mover_basepos_origin_y)  || #these always seem to be set, adding just in case for this mover type
		($mover_basepos_origin_z))    #these always seem to be set, adding just in case for this mover type
		&& ($moveambientnoise_formover eq '') #not set
		&& ($openingnoise_formover eq '') #not set
		&& ($closingnoise_formover eq '') #not set
		&& ($closingingnoise_formover eq '') #not set
		&&
		(!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	($mover_encroachtype == 2) #ME_IgnoreWhenEncroach
	&&
	($mover_initialstate == 4) #Trigger open timed
	&&
	#($mover_moverglidetype == 1) #MV_MoveByTime #set #commented out to allow ones that don't have this (a second error)
	#&& 					     #set #commented out to allow ones that don't have this (a second error)
	(!($mover_encroachdamage)) #not set
	&&
	#(!($mover_tag)) #not set #commented out after to allow tags (an error but...)
	#&&
	(((!($mover_movetime)) || ($mover_movetime == 0) || ($mover_movetime eq '0.000000'))  #set to 0
	&& ($mover_movetimewasset == 1))  #but was read from file
	&&
	($mover_bdamagetriggered) #set
	&&
	#($mover_damagethreshold) #set #commented out to allow ones that don't have this (a second error)
	#&&                       #set #commented out to allow ones that don't have this (a second error)
	($mover_stayopentime  		#set to something
	&& $mover_stayopentimewasset) #set (this is redundant tho as we are only looking for ones that are set
	&&
	($mover_event) #has an event set (for making the glass etc)
	&&
	(  ( ($moverkey_pos_origin_x)  ||  #one of these is set
	   ($moverkey_pos_origin_y ) ||    #one of these is set
	   ($moverkey_pos_origin_z) ))   #one of these is set
	&&
	(  ( ($moverkey_pos_origin_x - $mover_basepos_origin_x > 1000 || $moverkey_pos_origin_x - $mover_basepos_origin_x < -1000)  ||  #one of these is set to alot or a little
	   ($moverkey_pos_origin_y - $mover_basepos_origin_y > 1000 || $moverkey_pos_origin_y - $mover_basepos_origin_y < -1000) ||    #one of these is set to alot or a little
	   ($moverkey_pos_origin_z - $mover_basepos_origin_z > 1000|| $moverkey_pos_origin_y - $mover_basepos_origin_z < -1000) ))   #one of these is set to alot or a little
	&&
	($formover_maximum_seen_vertex_x || $formover_littlest_seen_vertex_x
	|| $formover_maximum_seen_vertex_y || $formover_littlest_seen_vertex_y
	|| $formover_maximum_seen_vertex_z || $formover_littlest_seen_vertex_z) #has a size
	#doesn't have other keys after
	&& (!($moverkey_pos2_origin_x))
	&& (!($moverkey_pos2_origin_y))
	&& (!($moverkey_pos2_origin_z))
		
		)
	){
	###
		$classname = 'func_breakable';
		$targetname = $mover_tag;
		$model = "Mover".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		$dostuff=1001; #since using special
		$omitangles_allready_set_angle = 1; #no angles to be set
		$specialextrastuffname0 = 'debris';
		$specialextrastuffamnt0 = 'models/glass/brokenglass1.md3 models/glass/brokenglass2.md3';
		$specialextrastuffname1 = 'debrismovetype';
		$specialextrastuffamnt1 = 'MOVETYPE_NONE';
		$specialextrastuffname2 = 'respawntime';
		$specialextrastuffamnt2 = "$mover_stayopentime";
		$specialextrastuffname3 = 'health';
		$specialextrastuffamnt3 = $mover_damagethreshold;
				
		if ($comment_mover_information ) {
			print('//#');
			print("XXXX2 Breakable ");
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
						if ($mover_event) { print(' event: '."$mover_event"); } #set to make the glass etc in the file
						if ($mover_tag) { print(' tag: '."$mover_tag"); } #shouldn't really be set but...
						print("\n//minz - maxz =\t$tempamnt");
						print("\n//key_z =\t".(0 + $moverkey_pos_origin_z)." ");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
		}
	###
	
	###
	#lift crushing (tall towa)
	} elsif (($OMIT_NEWER_MOVERS == 0) && #allow newer movers after destructables
		( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	($mover_encroachtype == 1) #crushing lift
	&&
	#(!($mover_bumptype)) #none set #added #edit commented out to be useable by more lifts
	#&&                                    #edit commented out to be useable by more lifts
	(!($mover_encroachdamage)) #none set
	#//&&
	#//($mover_tag)
	&&
	((!($moverkey_pos_origin_x)) && #notset
	(!($moverkey_pos_origin_y))  && #notset
	($moverkey_pos_origin_z)) #one of these set sliding 
	&&
	#this one was set only to positive in twilight, as those movers only went up from down
	#here these go down from up often, so it might be negative
	($moverkey_pos_origin_z-$mover_basepos_origin_z > 0 || $moverkey_pos_origin_z-$mover_basepos_origin_z < 0 ) #is ... something
	&&
	($formover_maximum_seen_vertex_z || $formover_littlest_seen_vertex_z) #has a size
	) 
	) {
		my $templiftaddedinfo = '';
		$specialextrastuffname2 = 'angle';
		$specialextrastuffamnt2 = -1; #-1 up, -2 down
		$omitangles_allready_set_angle = 1; #for movers
		my $tempamnt;
		$tempamnt = $formover_littlest_seen_vertex_z - $formover_maximum_seen_vertex_z;
		$specialextrastuffname3 = 'lip';
		$specialextrastuffamnt3 = ($moverkey_pos_origin_z*-1) - $tempamnt; #note: opposite to crusher
		
		$classname = 'func_door';
		#$targetname = $mover_tag;
		if ( (!($mover_bumptype)) ) {
			$templiftaddedinfo = '';
		} else {
			$templiftaddedinfo = $mover_bumptype.$model;
		}
		$model = "LiftCrushing"."$templiftaddedinfo".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		#guess
		soundguessfornoiseofliftmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
		
		if ($comment_mover_information ) {
			print('//#');
			print("LCLC LiftCrushing$templiftaddedinfo ");
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
						if ($mover_tag) { print(' tag: '."$mover_tag"); }
						print("\n//minz - maxz =\t$tempamnt");
						print("\n//key_z =\t".(0 + $moverkey_pos_origin_z)." ");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
		}
	###
	
	###
	#lift (twilight (reverse) (speculative))
	} elsif (($OMIT_NEWER_MOVERS == 0) && #allow newer movers after destructables
		( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	(!($mover_encroachtype)) #none set
	&&
	#(!($mover_bumptype)) #none set #added #edit commented out to be useable by more lifts
	#&&                                    #edit commented out to be useable by more lifts
	(!($mover_encroachdamage)) #none set
	#//&&
	#//($mover_tag)
	&&
	((!($moverkey_pos_origin_x)) && #notset
	(!($moverkey_pos_origin_y))  && #notset
	($moverkey_pos_origin_z)) #one of these set sliding 
	&&
	($moverkey_pos_origin_z < 0) #is negative, goes down (#not tested for lip note)
	&&
	($formover_maximum_seen_vertex_z || $formover_littlest_seen_vertex_z) #has a size
	) 
	) {
		my $templiftaddedinfo = '';
		$specialextrastuffname2 = 'angle';
		$specialextrastuffamnt2 = -1; #-1 up, -2 down
		$omitangles_allready_set_angle = 1; #for movers
		my $tempamnt;
		$tempamnt = $formover_littlest_seen_vertex_z - $formover_maximum_seen_vertex_z;
		$specialextrastuffname3 = 'lip';
		$specialextrastuffamnt3 = ($moverkey_pos_origin_z*-1) - $tempamnt; #note: opposite to crusher #(not tested for lip note)
		
		$classname = 'func_door';
		#$targetname = $mover_tag;
		if ( (!($mover_bumptype)) ) {
			$templiftaddedinfo = '';
		} else {
			$templiftaddedinfo = $mover_bumptype.$model;
		}
		$model = "LiftReverse"."$templiftaddedinfo".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		#guess
		soundguessfornoiseofliftmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
		
		if ($comment_mover_information ) {
			print('//#');
			print("LLLR LiftReverse$templiftaddedinfo ");
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
						if ($mover_tag) { print(' tag: '."$mover_tag"); }
						print("\n//minz - maxz =\t$tempamnt");
						print("\n//key_z =\t".(0 + $moverkey_pos_origin_z)." ");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
		}
	###
	
	### Door rotating (tall towa) (attempt)
	} elsif (($OMIT_NEWER_MOVERS == 0) && #allow newer movers after destructables
	( ( !($moverkey_rotation_pitch) &&  #not set
	($moverkey_rotation_yaw) &&	     # set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	(($moverkey_pos_origin_x == 0) && #notset sliding 
	($moverkey_pos_origin_y == 0)   && #notset sliding 
	($moverkey_pos_origin_z == 0)) #notset sliding 
	) 
	) {
		#rotating door it seems
		if ($comment_mover_information ) {
		print('//#');
		print("RDRD RotatingDoor $mover_tag");
			if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
				if ($name eq '') { 
					# do nothing
				} else {
					print(' ');
					print('name: '."$name");
				}
				$did_mover_name_allready = 1;
			}
		print("\n");
		}
		
		#sets the prefix of the model to mover_tag by default, or name if there is none
		if ($mover_tag eq '') {
			if ($name eq '') {
			} else {
				#second choice
				$temp_mover_prefix = $name;
			}
		} else {	
			#first choice
			$temp_mover_prefix = $mover_tag;
		}
		
		$classname = 'func_door_rotating';
		#$rotation_yaw = &rotation_convert($moverkey_rotation_yaw); #angles x y z #this made the angles too small for this rotating door
		$rotation_yaw *= -1; #not sure
		#$spawnflags = 128;
		#$force_angles_rather_than_angle = 1; #for this type we want just angle
		$no_angle_conversion_allready_done = 1;
		#$targetname = $mover_tag;
		#$model = "RotatingDoor"."$temp_mover_prefix".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$model = "RotatingDoor".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		#guess
		soundguessfornoiseofrotatingdoortrapmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
	###
	
	###
	#button (heal pod) #this was made after newer models1
	} elsif (($OMIT_NEWER_MOVERS == 0) && #allow newer movers after destructables
		($OMIT_NEWER_MOVERS2 == 0)  && #allow even newer models after Elevator E
		( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	($mover_encroachtype == 2) #ignore when encroached
	&&
	($mover_initialstate == 3) #Stand Open Timed
	&&
	($mover_moverglidetype == 1) #MV_MoveByTime
	&&
	(!($mover_bumptype)) #none set #added #edit commented out to be useable by more lifts
	&&                                    #edit commented out to be useable by more lifts
	(!($mover_encroachdamage)) #none set
	&&
	(!($mover_tag)) #doesn't have this set
	&&
	($mover_event) #this used for trigger here
	&&
	((!($moverkey_pos_origin_x)) && #notset
	(!($moverkey_pos_origin_y))  && #notset
	($moverkey_pos_origin_z)) #one of these set sliding 
	&&
	#this one was set only to positive in twilight, as those movers only went up from down
	#here these go down from up often, so it might be negative
	($moverkey_pos_origin_z-$mover_basepos_origin_z > 0 || $moverkey_pos_origin_z-$mover_basepos_origin_z < 0 ) #is ... something
	&&
	($formover_maximum_seen_vertex_z || $formover_littlest_seen_vertex_z) #has a size
	) 
	) {
		my $templiftaddedinfo = '';
		$specialextrastuffname2 = 'angle';
		$specialextrastuffamnt2 = -1; #-1 up, -2 down
		$omitangles_allready_set_angle = 1; #for movers
		my $tempamnt;
		$tempamnt = $formover_littlest_seen_vertex_z - $formover_maximum_seen_vertex_z;
		$specialextrastuffname3 = 'lip';
		$specialextrastuffamnt3 = ($moverkey_pos_origin_z*-1) - $tempamnt; #note: opposite to crusher
		
		$classname = 'func_button';
		$target = $mover_event;
		if ( (!($mover_bumptype)) ) {
			$templiftaddedinfo = '';
		} else {
			$templiftaddedinfo = $mover_bumptype.$model;
		}
		$model = "ButtonE"."$templiftaddedinfo".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		#guess
		soundguessfornoiseofliftmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
		
		if ($comment_mover_information ) {
			print('//#');
			print("ButtonE$templiftaddedinfo ");
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
						if ($mover_event) { print(' event: '."$mover_event"); } #set to make the glass etc in the file
						if ($mover_tag) { print(' tag: '."$mover_tag"); }
						print("\n//minz - maxz =\t$tempamnt");
						print("\n//key_z =\t".(0 + $moverkey_pos_origin_z)." ");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
		}
	###
	
	###
	#lift elevator glass outside (tall towa)
	} elsif (($OMIT_NEWER_MOVERS == 0) && #allow newer movers after destructables
		( (!($moverkey_rotation_pitch) &&   #not set
	!($moverkey_rotation_yaw) &&	     #not set
	!($moverkey_rotation_roll))	     #not set
	&&
	(($saved_moverkey_rotation_pitch == 123) &&
	($saved_moverkey_rotation_yaw == 456)   &&
	($saved_moverkey_rotation_roll == 789))
	&&
	(($saved_mover_basepos_origin_x == -12345.000000) &&
	($saved_mover_basepos_origin_y == -12345.000000) &&
	($saved_mover_basepos_origin_z == -12345.000000))
	&&
	($mover_encroachtype == 2) #ignore when encroached
	&&
	#(!($mover_bumptype)) #none set #added #edit commented out to be useable by more lifts
	#&&                                    #edit commented out to be useable by more lifts
	(!($mover_encroachdamage)) #none set
	#//&&
	#//($mover_tag)
	&&
	((!($moverkey_pos_origin_x)) && #notset
	(!($moverkey_pos_origin_y))  && #notset
	($moverkey_pos_origin_z)) #one of these set sliding 
	&&
	#this one was set only to positive in twilight, as those movers only went up from down
	#here these go down from up often, so it might be negative
	($moverkey_pos_origin_z-$mover_basepos_origin_z > 0 || $moverkey_pos_origin_z-$mover_basepos_origin_z < 0 ) #is ... something
	&&
	($formover_maximum_seen_vertex_z || $formover_littlest_seen_vertex_z) #has a size
	) 
	) {
		my $templiftaddedinfo = '';
		$specialextrastuffname2 = 'angle';
		$specialextrastuffamnt2 = -1; #-1 up, -2 down
		$omitangles_allready_set_angle = 1; #for movers
		my $tempamnt;
		$tempamnt = $formover_littlest_seen_vertex_z - $formover_maximum_seen_vertex_z;
		$specialextrastuffname3 = 'lip';
		$specialextrastuffamnt3 = ($moverkey_pos_origin_z*-1) - $tempamnt; #note: opposite to crusher
		
		$classname = 'func_door';
		#$targetname = $mover_tag;
		if ( (!($mover_bumptype)) ) {
			$templiftaddedinfo = '';
		} else {
			$templiftaddedinfo = $mover_bumptype.$model;
		}
		$model = "LiftE"."$templiftaddedinfo".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=1000;
		#guess
		soundguessfornoiseofliftmovers();$dostuff=1001; #since using special
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
		
		if ($comment_mover_information ) {
			print('//#');
			print("LELE LiftE$templiftaddedinfo ");
				if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
					if ($name eq '') { 
						# do nothing
					} else {
						print(' ');
						print('name: '."$name");
						if ($mover_tag) { print(' tag: '."$mover_tag"); }
						print("\n//minz - maxz =\t$tempamnt");
						print("\n//key_z =\t".(0 + $moverkey_pos_origin_z)." ");
					}
					$did_mover_name_allready = 1;
				}
			print("\n");
		}
	###
	
	###
	} else {
		print("//#UNKNOWN MOVER\n");
		if ($mover_tag) { print('//# tag: '."$mover_tag"); }
		my $tempamnt;
		$tempamnt = $formover_littlest_seen_vertex_z - $formover_maximum_seen_vertex_z;
		$specialextrastuffname3 = 'lip';
		$specialextrastuffamnt3 = ($moverkey_pos_origin_z*-1) - $tempamnt; #note: opposite to crusher
		#$specialextrastuffname4 = 'altlip';
		#$specialextrastuffamnt4 = ($moverkey_pos_origin_z + $tempamnt)*-1;
		soundguessfornoiseofliftmovers();
		othergeneralstuffformovers();
		setmovetimeifnotset();
		speedguessformovers();
		$classname = 'func_door';
		$model = "Mover".'_'.int($origin_x).'_'.int($origin_y).'_'.int($origin_z).'_.basescale1.obj_from_mc';
		$dostuff=2001;
	}
	
	#if ($mover_bumpevent eq '') { } else { 
	#$target = $mover_bumpevent = '';
	#}
	
	
}	


#Ignore if in brush
if ($ignoreingalllinesinbrush == 1) {
#First a test massage
} elsif ($dostuff == 3 && $endnow == 1 && $TESTUNKNOWNPRINTS) {
	if ($COMMENTOUTUNKNOWNSIFTESTUNKNOWNPRINTS) {
print('//'); print('#'); print('ee'); print('{'); print("\n");
print('//'); print('#'); print('ee'); print('	classname "'); print("$classname"); print('"');print(' xxxxxx'); 
		if ($ORIGINFORUNKNOWNSIFTESTUNKNOWNPRINTS == 1) {
		print("\t\t"); print('//'); print('#');  print(int($origin_x), ' ',  int($origin_y), ' ', int($origin_z));
		}print("\n");
print('//'); print('#'); print('ee'); print('}'); print("\n");
		if ($ORIGINFORUNKNOWNSIFTESTUNKNOWNPRINTS == 2) {
		print('//'); print('#'); print('Above Location:'); print(($origin_x), ' ',  ($origin_y), ' ', ($origin_z)); print("\n");
		}
	} else {
my $message = <<"END_MESSAGE";
ee{
ee	classname "$classname" xxxxxx
ee}
END_MESSAGE
print $message;
	}

 newlinebetweensections();
$classname = "";
#then another test message
} elsif ($dostuff == 4 && $endnow == 1 && $TESTLIGHTPRINTS) {
my $message = <<"ENX_MESSAGE";
**{
**	"classname" "$classname" xxxxxx
**	"origin" "$origin_x $origin_y $origin_z"
**	"spawnflags" "1" wonder what that does to a light
**}
ENX_MESSAGE
 
print $message; newlinebetweensections();
$classname = "";
#this is the real deal below
} elsif ($dostuff == 5 && $endnow == 1) {
my $message = <<"ENY_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"spawnflags" "1"
}
ENY_MESSAGE
 
print $message; newlinebetweensections();
$classname = "";
#this is for ambientsounds below
} elsif ($dostuff == 7 && $endnow == 1) {
my $message = <<"ENZ_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"noise" "$noise.wav"
}
ENZ_MESSAGE
 
print $message;
	if ($CONVERT_SOME_NOISES_TO_SIMPLER_STRING) {
		if ($PRINTORIGINALSOUNDINFOASCOMMENTIFCONVERTED) {
		print('//');
		print('#');
		print('  Above:');
		print("$originalnoisecomment");
		print("\n");
		}
	}
	 newlinebetweensections();
$classname = "";
#this is the real deal below but a special case for playerstarts if you want to add more Z 
} elsif ($dostuff == 500 && $endnow == 1) {
	if ($PRINTINFOREGARDINGADDINGZTOPLAYERSTART) {
	print('//'); print('#'); print('NOTE Added to Z Below: Original X Y Z:'); print("$origin_x $origin_y $origin_z"); print("\n");
	}
$origin_z = $origin_z + $add_z_toplayerstart;
my $message = <<"ENY_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"spawnflags" "1"
}
ENY_MESSAGE
 
print $message; newlinebetweensections();
$classname = "";
#This is a special case for a rifle round for the t17mmrifle
} elsif ($dostuff == 6 && $endnow == 1) {
my $message = <<"ENX2_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"spawnflags" "1"
	"model" "models/items/casingriflebullet.iqm"
	"scale" "1.46"
	"ammo_nails" "3"
}
ENX2_MESSAGE
 
print $message; newlinebetweensections();
$classname = "";





#This is a special case for a rifle round for the rem308
} elsif ($dostuff == 7 && $endnow == 1) {
my $message = <<"ENX3_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"spawnflags" "1"
	"model" "models/items/casingriflebullet.iqm"
	"scale" "0.66"
	"ammo_nails" "3"
}
ENX3_MESSAGE
print $message; newlinebetweensections();
$classname = "";


#This is a special case for shells for ithaca, should be 12 ga, but scale set to 8ga for now since it's a bunch of them
} elsif ($dostuff == 8 && $endnow == 1) {
my $message = <<"ENX5_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"spawnflags" "1"
	"model" "models/casing_shell.mdl"
	"scale" "1.145"
	"ammo_shells" "3"
}
ENX5_MESSAGE
print $message; newlinebetweensections();
$classname = "";

#This is a special case for a clip of 223 //Scale big to distinguish from the pickup
} elsif ($dostuff == 9 && $endnow == 1) {
my $message = <<"ENX7_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"spawnflags" "1"
	"model" "models/misc/extendedmags/styeraugmag30.iqm"
	"scale" "2"
	"ammo_nails" "30"
}
ENX7_MESSAGE
print $message; newlinebetweensections();
$classname = "";



#This is a special case for a box of 9mm //Scale down ammo can?
} elsif ($dostuff == 10 && $endnow == 1) {
my $message = <<"ENX10_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"spawnflags" "1"
	"scale" "0.66"
	"ammo_nails" "60"
}
ENX10_MESSAGE
print $message; newlinebetweensections();
$classname = "";


#This is a special case for a clips of 45 //Scale up to distinguish from the pickup
} elsif ($dostuff == 11 && $endnow == 1) {
my $message = <<"ENX11_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"spawnflags" "1"
	"model" "models/misc/extendedmags/uzimag20.iqm"
	"scale" "2"
	"ammo_nails" "12"
}
ENX11_MESSAGE
print $message; newlinebetweensections();
$classname = "";


#This is a special case for loose 203 //Scale up to distinguish from the pickup
} elsif ($dostuff == 12 && $endnow == 1) {
my $message = <<"ENX12_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"spawnflags" "1"
	"model" "models/casing_steel.mdl"
	"scale" "2"
	"ammo_nails" "3"
}
ENX12_MESSAGE
print $message; newlinebetweensections();
$classname = "";


#This is a special case for a box of 45 //Scale down ammo can?
} elsif ($dostuff == 15 && $endnow == 1) {
my $message = <<"ENX15_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"spawnflags" "1"
	"scale" "0.75"
	"ammo_nails" "70"
}
ENX15_MESSAGE
print $message; newlinebetweensections();
$classname = "";


#This is a special case for a buildablebuildingnumber by count
} elsif ($dostuff == 200 && $endnow == 1) {
my $message = <<"COUNT0_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"count" "$count"
}
COUNT0_MESSAGE
 
print $message; newlinebetweensections();
$classname = "";

#This is a special case for a model
} elsif ($dostuff == 100 && $endnow == 1) {
my $message = <<"MODEL0_MESSAGE";
{
	"classname" "$classname"
	"origin" "$origin_x $origin_y $origin_z"
	"model" "$model"
}
MODEL0_MESSAGE
 
print $message; newlinebetweensections();
$classname = "";
#This is a special generic case
} elsif (($dostuff == 1000 || $dostuff == 1001 || $dostuff == 2001) && $endnow == 1) {
	if ($mode == 2) { #rtlight
		if ($ignore_unset_lights == 1 && ($is_light_entity && $no_color_set_by_map && $no_radius_set_by_map)) {
			#ignore this light completely
		} else {
			rtlightprint();
		}
	#normal entity and or light mode below
	} elsif ($classname && ($ignore_unset_lights == 1 && ($is_light_entity && $no_color_set_by_map && $no_radius_set_by_map))) {
		#ignore this light completely
	} elsif ($classname) {
		$comment_out_noise = 0;
		if ($is_mover) {
			if ($PRINTMOVERNAMEASCOMMENTIFFOUND_FORMOVER) {
				if ($did_mover_name_allready) {
					# do nothing
				} elsif ($name eq '') { 
					# do nothing
				} else {
					print('//'); 
					print('#');
					print('name: '."$name");
					print("\n");
				}
			}
		}
		if ($is_mover && (
		$formover_maximum_seen_vertex_x ||
		$formover_maximum_seen_vertex_y ||
		$formover_maximum_seen_vertex_z ||
		$formover_littlest_seen_vertex_x ||
		$formover_littlest_seen_vertex_y ||
		$formover_littlest_seen_vertex_z)) {
			if ($PRINTMINSMAXSASCOMMENTIFFOUND_FORMOVER) {
			print('//'); 
			print('#');
			print('Maxs: '."$formover_maximum_seen_vertex_x $formover_maximum_seen_vertex_y $formover_maximum_seen_vertex_z");
			print("\n");
			print('//'); 
			print('#');
			print('mins: '."$formover_littlest_seen_vertex_x $formover_littlest_seen_vertex_y $formover_littlest_seen_vertex_z");
			print("\n");
			}
		}
		if ($rotation_pitch || $rotation_yaw || $rotation_roll) {
			if ($PRINTORIGINALROTATIONINFOASCOMMENTIFCONVERTED) {
				if ($is_mover && $force_angles_rather_than_angle && $no_angle_conversion_allready_done) { #for mover
				print('//');
				print('#');
				print('  Below: Rotation PRE CONVERTED ');
				print("Pitch $infooriginal_mover_rotation_pitch  Yaw $infooriginal_mover_rotation_yaw  Roll$infooriginal_mover_rotation_roll");
				print("\n");
				} else {
				print('//');
				print('#');
				print('  Below: Rotation Pre Conversions ');
				print("Pitch $rotation_pitch  Yaw $rotation_yaw  Roll$rotation_roll");
				print("\n");
				}
			}
			if ($is_mover && $force_angles_rather_than_angle && $no_angle_conversion_allready_done) { #for mover
				#do nothing
			} else {
				if ($rotation_pitch) { $rotation_pitch = &rotation_convert($rotation_pitch); }
				if ($rotation_yaw) { $rotation_yaw = &rotation_convert($rotation_yaw); }
				if ($rotation_roll) { $rotation_roll = &rotation_convert($rotation_roll); }
			}
		}
		
		if ($hue || $saturation || $brightness) {
			$comment_out_noise = 1;
			if ($PRINTORIGINALHUESATURATIONBRIGHTNESSINFOASCOMMENTIFCONVERTED) {
			print('//');
			print('#');
			print('  Below: HSV Pre Conversions ');
			print("Hue $hue  Saturation $saturation  Brightness $brightness\n");
			}
		}
		
		
	prc(); print('{'); print("\n");
		#print our classname, which will be the subroutine that is called or so in game
			prc(); print("\t",'"','classname','"',' '); print('"',"$classname",'"'); print("\n");
		#origin
		if ($origin_x || $origin_y || $origin_z) {
			prc(); print("\t",'"','origin','"',' '); print('"',"$origin_x $origin_y $origin_z",'"'); print("\n");
		}
		if ($model) {
			prc(); print("\t",'"','model','"',' '); print('"',"$model",'"'); print("\n");
		}
		#rotation if only around then just angle, otherwise use vector angles
				if ($is_mover && $omitangles_allready_set_angle) { #for mover
				} elsif ($is_mover && $force_angles_rather_than_angle) { #for mover
				prc(); print("\t",'"','angles','"',' '); print('"',"$rotation_pitch $rotation_yaw $rotation_roll",'"'); print("\n"); #for mover
		} elsif ($rotation_yaw && !($rotation_pitch) && !($rotation_roll)) {
			prc(); print("\t",'"','angle','"',' '); print('"',"$rotation_yaw",'"'); print("\n");
		} elsif ($rotation_pitch || $rotation_yaw || $rotation_roll) {
			prc(); print("\t",'"','angles','"',' '); print('"',"$rotation_pitch $rotation_yaw $rotation_roll",'"'); print("\n");
		}
		if ($speed) {
			prc(); print("\t",'"','speed','"',' '); print('"',"$speed",'"'); print("\n");
		}
		if ($noise) {
			prc(); 
			if ($comment_out_noise) {
			print("\t");
			print('//');
			print('#');
			}
			print("\t",'"','noise','"',' '); print('"',"$noise.wav",'"'); print("\n");
		}
		if ($light_radius) {
			prc(); print("\t",'"','light_lev','"',' '); print('"',"$light_radius",'"'); print("\n");
		}
		if ($spawnflags) {
			prc(); print("\t",'"','spawnflags','"',' '); print('"',"$spawnflags",'"'); print("\n");
		}
		#target/targetname just for movers now
		if ($is_mover) {
			if ($targetname eq '') { } else {
			prc(); print("\t",'"','targetname','"',' '); print('"',"$targetname",'"'); print("\n");
			}
			if ($target eq '') { } else {
			prc(); print("\t",'"','target','"',' '); print('"',"$target",'"'); print("\n");
			}
		}
		#other added stuff
		if ($dostuff == 1001 || $dostuff == 2001) {
			if ($specialextrastuffname) { 
				prc(); print("\t",'"',"$specialextrastuffname",'"',' '); print('"',"$specialextrastuffamnt",'"'); print("\n");
			}
			if ($specialextrastuffname0) {
				prc(); print("\t",'"',"$specialextrastuffname0",'"',' '); print('"',"$specialextrastuffamnt0",'"'); print("\n");
			}
			if ($specialextrastuffname1) {
				prc(); print("\t",'"',"$specialextrastuffname1",'"',' '); print('"',"$specialextrastuffamnt1",'"'); print("\n");
			}
			if ($specialextrastuffname2) {
				prc(); print("\t",'"',"$specialextrastuffname2",'"',' '); print('"',"$specialextrastuffamnt2",'"'); print("\n");
			}
			if ($specialextrastuffname3) {
				prc(); print("\t",'"',"$specialextrastuffname3",'"',' '); print('"',"$specialextrastuffamnt3",'"'); print("\n");
			}
			if ($specialextrastuffname4) {
				prc(); print("\t",'"',"$specialextrastuffname4",'"',' '); print('"',"$specialextrastuffamnt4",'"'); print("\n");
			}
			if ($specialextrastuffname5) {
				prc(); print("\t",'"',"$specialextrastuffname5",'"',' '); print('"',"$specialextrastuffamnt5",'"'); print("\n");
			}
		}
		###set defaults 
		##if ($mode == 1) { #lm mode
		##	if (!($hue)) { $hue = 64 }		#set defaults if not set
		##	if (!($saturation)) { $saturation = 255}#set defaults if not set
		##} #will be in time for next part
		if (($hue || $saturation || $brightness) || ($mode == 1)) {
			hsv_to_rgb();
			if ((!($color_r)) && (!($color_b)) && (!($color_g))) 
			{
				if ($Set_Default_HSV_and_Radius_At_Begining_Instead) {
					#do nothing
				} elsif ($SET_UNSET_LIGHT_COLOR) {
				$color_r = 1;
				$color_g = 1;
				$color_b = 1;
				}
			}
			prc(); print("\t",'"','color','"',' '); print('"',"$color_r $color_g $color_b",'"'); print("\n");
			prc(); print("\t",'"','pflags','"',' '); print('"','128','"'); print("\n"); #PFLAGS_FULLDYNAMIC
			prc(); print("\t",'"','style','"',' '); print('"','0','"'); print("\n");
			
			#set default light radius if none as above in the rt code
			if (!($light_radius)) { 
				if ($Set_Default_HSV_and_Radius_At_Begining_Instead) {
					#do nothing
				} elsif ($SET_UNSET_LIGHT_RADIUS) {
				$light_radius = 64;
				prc(); print("\t",'"','light_lev','"',' '); print('"',"$light_radius",'"'); print("\n");	
				}
			} #default
		}
	prc(); print('}'); print("\n");
	
		if ($PRINTORIGINALHUESATURATIONBRIGHTNESSINFOASCOMMENTIFCONVERTED) {
			if ($hue || $saturation || $brightness) {
			print('//');
			print('#');
			print('  Above: Color ');
			print(int($color_r*256),' ', int($color_g*256),' ',  int($color_b*256),' ');
			print("\n");
			}
		}
		
		if ($CONVERT_SOME_NOISES_TO_SIMPLER_STRING) {
			if ($PRINTORIGINALSOUNDINFOASCOMMENTIFCONVERTED) {
			if ($noise) {
			print('//');
			print('#');
			print('  Above:');
			print("$originalnoisecomment");
			print("\n");
			}
			if ($is_mover && $openingnoise_formover) {
			print('//');
			print('#');
			print('  Above Opening:');
			print("$originalnoisecomment_o");
			print("\n");
			}
			if ($is_mover && $closingnoise_formover) {
			print('//');
			print('#');
			print('  Above Closing:');
			print("$originalnoisecomment_c");
			print("\n");
			}
			if ($is_mover && $moveambientnoise_formover) {
			print('//');
			print('#');
			print('  Above MovingAmbient:');
			print("$originalnoisecomment_m");
			print("\n");
			}
			if ($is_mover && $closingingnoise_formover) {
			print('//');
			print('#');
			print('  Above Closinging:');
			print("$originalnoisecomment_cc");
			print("\n");
			}
			}
		}
		newlinebetweensections();
	}
$classname = "";
}
#completed

	#reset variables for the next block
	if ($endnow == 1) {
		$classname = "";
		$beforeequals = "";
		$afterequals = "";
		$endnow = 0;
		$dostuff = 0;
		$origin_x = 0;
		$origin_y = 0;
		$origin_z = 0;
		$rotation_pitch = 0;
		$rotation_yaw = 0; 
		$rotation_roll = 0; 
		$rotationrate_pitch = 0;
		$rotationrate_yaw = 0;
		$rotationrate_roll = 0;
		$noise = '';
		$model = '';
		$count = '';
		$originalnoisecomment = '';
		$originalclassname = '';
		$hue = 0;
		$saturation = 0;
		$brightness = 0;
		$light_radius = 0;
		$color_r = 0;
		$color_g = 0;
		$color_b = 0;
		$spawnflags = 0;
		$cubemap = '';
		$corona = 0;
		$coronasize = 0; #0.25; #default 0.25 but corona is off by default
		$ambient = 0;
		$diffuse = 1; #default 1
		$specular= 1; #default 1
		$specialextrastuffname = '';
		$specialextrastuffamnt = '';
		$specialextrastuffname0 = '';
		$specialextrastuffamnt0 = '';
		$specialextrastuffname1 = '';
		$specialextrastuffamnt1 = '';
		$specialextrastuffname2 = '';
		$specialextrastuffamnt2 = '';
		$specialextrastuffname3 = '';
		$specialextrastuffamnt3 = '';
		$specialextrastuffname4 = '';
		$specialextrastuffamnt4 = '';
		$specialextrastuffname5 = '';
		$specialextrastuffamnt5 = '';
		$no_color_set_by_map = 1; #for SET_UNSET_LIGHT_COLOR = 1; and ignore
		$no_radius_set_by_map = 1; #for SET_UNSET_LIGHT_RADIUS = 1;; and ignore
		$is_light_entity = 0; #so we may ignore if need be
		$is_mover = 0;
		$is_fan = 0;
		#
		$moverkey_rotation_pitch = 0;
		$moverkey_rotation_yaw = 0; 
		$moverkey_rotation_roll = 0; 
		$moverkey_pos_origin_x = 0; #dejavu (key_pos)
		$moverkey_pos_origin_y = 0; 
		$moverkey_pos_origin_z = 0;  
		$moverkey_pos2_origin_x = 0;
		$moverkey_pos2_origin_y = 0; 
		$moverkey_pos2_origin_z = 0; 
		$mover_basepos_origin_x = 0;
		$mover_basepos_origin_y = 0;
		$mover_basepos_origin_z = 0;
		$saved_moverkey_rotation_pitch = 0;
		$saved_moverkey_rotation_yaw = 0; 
		$saved_moverkey_rotation_roll = 0; 
		$saved_mover_basepos_origin_x = 0;
		$saved_mover_basepos_origin_y = 0;
		$saved_mover_basepos_origin_z = 0;
		$mover_encroachdamage = 0;
		$drawscale = 0;
		$mover_encroachtype = 0; #1 = crush
		$mover_tag = '';
		$targetname = '';
		$target = '';
		$mover_bumpevent = '';
		$mover_event = '';
		$force_angles_rather_than_angle = 0; #for movers
		$no_angle_conversion_allready_done = 0; #for movers
		$moveambientnoise_formover = '';
		$openingnoise_formover = '';
		$closingnoise_formover = '';
		$closingingnoise_formover = '';
		$originalnoisecomment_m = '';
		$originalnoisecomment_o = '';
		$originalnoisecomment_c = '';
		$originalnoisecomment_cc = '';
		$infooriginal_mover_rotation_pitch = 0; #Just for info
		$infooriginal_mover_rotation_yaw = 0; #Just for info
		$infooriginal_mover_rotation_roll = 0; #Just for info
		$mover_bumptype = 0; #1 = Any
		$mover_movetime = 0;
		$mover_movetimewasset = 0; #used to denote the line was set to something in the file, even if 0
		$mover_moverglidetype = 0;
		$mover_bdamagetriggered = 0;
		$mover_damagethreshold = 0;
		$mover_stayopentime = 0;
		$mover_stayopentimewasset = 0; #used to denote the line was set to something in the file, even if 0 #added for effect
		$speed = 0;
		$formover_maximum_seen_vertex_x = 0;
		$formover_maximum_seen_vertex_y = 0;
		$formover_maximum_seen_vertex_z = 0;
		$formover_littlest_seen_vertex_x = 0;
		$formover_littlest_seen_vertex_y = 0;
		$formover_littlest_seen_vertex_z = 0;
		$name = '';
		$did_mover_name_allready = 0;
		$mover_initialstate = 0;
		$omitangles_allready_set_angle = 0; #for movers
		#
		setdefault_light_and_radius_maybe();
	}

}

sub printcomment {
	print('//'); print('#');
}

sub printrtdebug0_maybe {
	if ($PRINTDEBUGINFOASCOMMENTFORRTLIGHTS) {
		printcomment(); print(" origin: $origin_x $origin_y $origin_z \n");
		printcomment(); print(" hue: $hue \n");
		printcomment(); print("      saturation: $saturation \n");
		printcomment(); print("      brightness: $brightness \n");
	}
}
sub printrtdebug1_maybe {
	if ($PRINTDEBUGINFOASCOMMENTFORRTLIGHTS) {
		printcomment(); print("\t",'"','color','"',' '); print('"',"$color_r $color_g $color_b",'"'); print("\n");
		printcomment(); print("\t",'"','b_Rgb','"',' '); print('"',"$b_Red $b_Green $b_Blue",'"'); print("\n");
	}
}
sub printrtdebug2_maybe {
	if ($PRINTDEBUGINFOASCOMMENTFORRTLIGHTS) {
		printcomment(); print(" saturation(0..255) brightness(0..255) hue(0..255)\n");
		printcomment(); print(" $saturation $brightness $hue\n");
	}
}
sub printrtdebug3_maybe {
	if ($PRINTDEBUGINFOASCOMMENTFORRTLIGHTS) {
		print("\n");
	}
}

#We have our color, now fit it to the map
sub setdefault_light_and_radius_maybe() {
	if ($Set_Default_HSV_and_Radius_At_Begining_Instead) {
	$brightness = 64;  #LightBrightness 64
	$hue = 0; 	   #LightHue	0
	$saturation = 255; #LightSaturation 255
	#radius
	$light_radius = 64; #LightRadius 64
	}
}
#these are for fitting to a curve
sub lightradius_affected_by_brightness() {
	$light_radius = $light_radius * ($brightness/255);
}
sub ambient_affected_by_saturation() {
	if ($saturation > 128) {
		#Do nothing, too low saturation (0 is "most saturation")
	} else {
		$ambient = 1 - ($saturation/128); #our space is 0 ... 128; 0 is the most intense light, and 128 is less so
	}
}

sub fittomycurve
{
	if ($use_curve) {
	lightradius_affected_by_brightness();
	ambient_affected_by_saturation();
	}
}

sub rtlightprint {
								printrtdebug0_maybe();
		#origin 20, -36, -240 .... radius 200 , red (1 0 0)
		#20.000000 -36.000000 -240.000000 200.000000 1.000000 0.000000 0.000000 0
		#angles 10, 90, 20
		#20.000000 -36.000000 -240.000000 200.000000 1.000000 1.000000 1.000000 0 "" 0.000000 10.000000 90.000000 20.000000
		#style 3
		#20.000000 -36.000000 -240.000000 200.000000 1.000000 1.000000 1.000000 3
		##if (!($hue)) { $hue = 64 }		#set defaults if not set
		##if (!($saturation)) { $saturation = 255}#set defaults if not set
		#0.000000 0.000000 ###-252.000000 200.000000 1.000000 1.000000 1.000000 0 "" 0.000000 270.000000 90.000000 180.000000 0.250000 0.500000 1.000000 1.000000 2
		hsv_to_rgb();
		fittomycurve();
								printrtdebug1_maybe();
								printrtdebug2_maybe();
		if ((!($color_r)) && (!($color_b)) && (!($color_g))) 
		{
			if ($Set_Default_HSV_and_Radius_At_Begining_Instead) {
					#do nothing
			} elsif ($SET_UNSET_LIGHT_COLOR) {
			$color_r = 1;
			$color_g = 1;
			$color_b = 1;
			}
		}
		if ($rtlights_add_an_exclaimation_point) {print '!';}
		print(sprintf('%.6f', $origin_x)); print ' ';
		print(sprintf('%.6f', $origin_y)); print ' ';
		print(sprintf('%.6f', $origin_z)); print ' ';
				if (!($light_radius)) { 
					if ($Set_Default_HSV_and_Radius_At_Begining_Instead) {
						#do nothing
					} elsif ($SET_UNSET_LIGHT_RADIUS) { 
						$light_radius = 64; 
					} 
				} #default
			if ($rtlight_radius_scale) { 
				print(sprintf('%.6f', $light_radius*$rtlight_radius_scale)); 
			} else { 
				print(sprintf('%.6f', $light_radius)); 
			} print ' ';
		print(sprintf('%.6f', $color_r)); print ' ';
		print(sprintf('%.6f', $color_g)); print ' ';
		print(sprintf('%.6f', $color_b)); print ' '; #$ambient = 1; #$ambient = 0.5555; #test
		print '0'; print ' '; #style
		if ($rotation_pitch || $rotation_yaw || $rotation_roll || $cubemap || $corona || $coronasize || $ambient) {
			print ('"'); print("$cubemap"); print('"'); print ' '; #cubemap
			
			if ($rotation_pitch || $rotation_yaw || $rotation_roll || $corona || $coronasize || $ambient) {
				print(sprintf('%.6f', $corona)); print ' '; #?corona
			
				if ($rotation_pitch || $rotation_yaw || $rotation_roll || $coronasize || $ambient) {
					if ($rotation_pitch) { $rotation_pitch = &rotation_convert($rotation_pitch); }
					if ($rotation_yaw) { $rotation_yaw = &rotation_convert($rotation_yaw); }
					if ($rotation_roll) { $rotation_roll = &rotation_convert($rotation_roll); }
					print(sprintf('%.6f', $rotation_pitch)); print ' ';
					print(sprintf('%.6f', $rotation_yaw)); print ' ';
					print(sprintf('%.6f', $rotation_roll)); print ' ';
					
					if ($coronasize || $ambient) {
					print(sprintf('%.6f', $coronasize)); print ' ';
						if ($ambient) {
							print(sprintf('%.6f', $ambient)); print ' '; #defualt 0
							print(sprintf('%.6f', $diffuse)); print ' '; #default 1 #diffuse
							print(sprintf('%.6f', $specular)); print ' '; #default 1 #specular (can be 0...1...more, and -1)
							print '2'; print ' '; #
						}
					}
				}
			}
		}
		print "\n";
		
		printrtdebug3_maybe();
}


if ($mode == 2) {
	#leave blank
	if ($PRINTCOMMANDARGUMENTSFORRTLIGHTS) {
	print('//');
	print('#');
	print(' Command arguments used: ');
	print("@ARGV");
	#	print(" ");
	print("\n");
	print('//');
	print('#');
	print(' HSV Algo used: ');
	print("$hsvalgo");
	print(" ");
	setstringhsvinfo();
	print("$hsvalgousedstring");
	print("\n");
	print('//');
	print('#');
	print(' Settings used: ');
	if (!($use_curve)) { print(' (did not)'); }
		print(' use_curve: ');
		print("$use_curve"); print(',');
		
	if (!($ignore_unset_lights)) { print(' (did not)'); }
		print(' ignore_unset_lights: ');
		print("$ignore_unset_lights"); print(',');
	
	if (!($Set_Default_HSV_and_Radius_At_Begining_Instead)) { print(' (did not)'); }
		print(' set default colors: ');
		print("$Set_Default_HSV_and_Radius_At_Begining_Instead");
	print("\n");
	}
} else {
print("//#FINISHED FILE\n");
	if ($mode == 4) {
		if ($ALLOW_DESTRUCTABLES_MOVERS == 0 && $OMIT_NEWER_MOVERS == 0 && $OMIT_NEWER_MOVERS2 == 0) {
			#nothing, default
		} else {
		print('//');
		print('#');
		print(' Mover Command arguments used: ');
		print("@ARGV");
		print("\n");
		}
	}
}

close (FILE); #for data mode
exit;	      #for data mode
