freeslot("MT_JYATHAWK", "MT_CONQSONIC", "MT_CCONQ","MT_RWAL",
 "S_JYAT", "S_JYAT2", "S_JYAT3", "S_JYAT4", "S_JYAT5", "S_JYAT6",
 "S_CONQSONIC", "S_CONQSONIC2", "S_CONQSONIC3", "S_CONQSONIC4", "S_CONQSONIC5", "S_CONQSONIC6", 
 "S_CONQSONIC7", "S_CONQSONIC8", "S_CONQSONIC9", "S_CONQSONIC10", "S_CONQSONIC11", "S_CONQSONIC12",
 "S_CONQSONIC13", "S_CONQSONIC14", "S_CONQSONIC15", "S_CONQSONIC10SECOND", "S_CONQSONIC16", "S_CONQSONIC17",
 "S_CONQSONIC18", "S_CONQSONIC19", "S_CONQSONIC18SECOND","S_CONQSONIC19SECOND", "S_CONQSONIC20", "S_CONQSONIC21",
 "S_CONQSONIC22", "S_CONQSONIC23", "S_CONQSONIC20SECOND", "S_CONQSONIC24", "S_CONQSONIC25", "S_CONQSONIC26", "S_CONQSONIC27",
 "S_CONQSONIC28", "S_CONQSONIC29", "S_CONQSONIC30", "S_CONQSONIC31", "S_CONQSONIC32", "S_CONQSONIC33", "S_CONQSONIC34", "S_CONQSONIC35",
 "S_CONQSONIC36", "S_CONQSONIC37", "S_CONQSONIC38","S_CONQSONIC39","S_CONQSONIC40","S_CONQSONIC41","S_CONQSONIC42", "S_CONQSONIC43", "S_CONQSONIC44",
 "S_CONQSONIC45","S_CONQSONIC46", "S_CONQSONIC47",
 "S_CUTSCENECONQ2", "S_CUTSCENECONQ7", "S_CUTSCENECONQ8", "S_CUTSCENECONQ9", "S_CUTSCENECONQ10")


addHook("PlayerThink",function(player)

if player.exitingcutscene == nil
 then player.exitingcutscene = 0
  end

if mapheaderinfo[gamemap].qtestage
  and player.exitingcutscene > 26
	 then G_SetCustomExitVars(nil, 2)
           G_ExitLevel()
		    player.exitingcutscene = 0
          end
		  
		  
	if player.exiting > 1
	 then player.exitingcutscene = $ + 1
	  end
 


 if not mapheaderinfo[gamemap].cutscenestage then return end
 
 hud.disable("score") //make the player invisible (they will never know)
  hud.disable("time")
 hud.disable("rings")
 hud.disable("lives")
 player.pflags = $|PF_FULLSTASIS
 player.mo.flags = $|MF_NOGRAVITY
 player.mo.flags2 = $|MF2_DONTDRAW
 player.mo.angle = 0
 camera.chase = true
 

 
  if (player.cmd.buttons & BT_JUMP)
   then G_SetCustomExitVars(nil, 2)
         G_ExitLevel()
		  player.exitingcutscene = 0
        end
	
	
	if player.exitingcutscene >= 64
	 then G_SetCustomExitVars(nil, 2)
           G_ExitLevel()
		    player.exitingcutscene = 0
          end
		  
		  if player.exitingcutscene >= 64
		   then player.exitingcutscene = 0
		    end
	
	
	//////CONQUEST CUTSCENE STUFF
	if player.conquestcutscene == nil
	 then player.conquestcutscene = -1
	  end
	  
	 
	 
	 if player.conquestcutscene == 0 //follow sonic (front)
	   then 
		  A_FindTarget(player.mo, MT_CONQSONIC, 0)
		  P_SetOrigin(player.mo, player.mo.target.x, player.mo.target.y, player.mo.target.z)
		  SC_SetOrbitalMode(player, 0, 160*FU, ANGLE_180, 64*FU)
		 
		  
           end
		   
	 if player.conquestcutscene == 1 //camera to jet
	   then SC_SetStaticPointFixedFocusMode(player, 0, -1298*FU, -688*FU, -948*FU, ANGLE_180, 1)
		   end
			 
			 if player.conquestcutscene == 2 //camera behind the both of them
			  then SC_SetStaticPointMode(player, 0, -640*FU, -672*FU, -972*FU, ANGLE_180, 1)
			   end
			  
			  
			   if player.conquestcutscene == 3 //follow sonic (Behind)
	            then 
		        A_FindTarget(player.mo, MT_CONQSONIC, 0)
		         P_SetOrigin(player.mo, player.mo.target.x, player.mo.target.y, player.mo.target.z)
		          SC_SetOrbitalMode(player, 0, 160*FU, ANG1, 64*FU)
				  end
			  
			  
			   if player.conquestcutscene == 4 //camera to Computer
	            then SC_SetStaticPointFixedFocusMode(player, 0, 17*FU, 2080*FU, -980*FU, ANGLE_90, 1)
		         end
				 
				 
				 if player.conquestcutscene == 5 //follow sonic (Left Side)
	              then 
		          A_FindTarget(player.mo, MT_CONQSONIC, 0)
		          P_SetOrigin(player.mo, player.mo.target.x, player.mo.target.y, player.mo.target.z)
		          SC_SetOrbitalMode(player, 0, 160*FU, ANGLE_90* -1, 64*FU)
				  end
				 
			      if player.conquestcutscene == 6 //Portal Opening Camera
	              then 
		          A_FindTarget(player.mo, MT_CELLWAYPOINT, 0)
		          P_SetOrigin(player.mo, player.mo.target.x, player.mo.target.y, player.mo.target.z)
		          SC_SetOrbitalMode(player, 0, 160*FU, ANGLE_180, 64*FU)
				  P_LinedefExecute(1, player.mo)
				  end
			  
			  
			     if player.conquestcutscene == 7 //Portal Opening Camera (NO SOUND)
	              then 
		          A_FindTarget(player.mo, MT_CELLWAYPOINT, 0)
		          P_SetOrigin(player.mo, player.mo.target.x, player.mo.target.y, player.mo.target.z)
		          SC_SetOrbitalMode(player, 0, 160*FU, ANGLE_180, 64*FU)
				  end
				  
				  
				  if player.conquestcutscene == 8//At Conquest
	              then 
		          A_FindTarget(player.mo, MT_CCONQ, 0)
		          P_SetOrigin(player.mo, player.mo.target.x, player.mo.target.y, player.mo.target.z)
		          SC_SetStaticPointMode(player, 0, -1056*FU, 2400*FU, -1012*FU, 1)
				  P_LinedefExecute(5, player.mo)
				  end
				  
				  if player.conquestcutscene == 9//At Emeralds
	              then 
		          A_FindTarget(player.mo, MT_CELLWAYPOINT, 0)
		          P_SetOrigin(player.mo, player.mo.target.x, player.mo.target.y, player.mo.target.z)
		          SC_SetStaticPointMode(player, 0, -1056*FU, 2400*FU, -1012*FU, 1)
				  end
				  
	            if player.conquestcutscene == 10 //follow sonic (Right Side)
	              then 
		          A_FindTarget(player.mo, MT_CONQSONIC, 0)
		          P_SetOrigin(player.mo, player.mo.target.x, player.mo.target.y, player.mo.target.z)
		          SC_SetOrbitalMode(player, 0, 160*FU, ANGLE_90, 64*FU)
				  end
				  
				  if player.conquestcutscene == 11 //follow sonic (Behind)
	            then 
		        A_FindTarget(player.mo, MT_CONQSONIC, 0)
		         P_SetOrigin(player.mo, player.mo.target.x, player.mo.target.y, player.mo.target.z)
		          SC_SetOrbitalMode(player, 0, 160*FU, ANG1*-1, 0*FU)
				  end
				  
				  if player.conquestcutscene == 12
	              then 
		          A_FindTarget(player.mo, MT_CELLWAYPOINT5, 0)
		          P_SetOrigin(player.mo, player.mo.target.x, player.mo.target.y, player.mo.target.z)
		          SC_SetOrbitalMode(player, 0, 160*FU, ANGLE_180, 0*FU)
				  end
				  
				  if player.conquestcutscene == 13
	              then 
		          A_FindTarget(player.mo, MT_CELLWAYPOINT5, 0)
		          P_SetOrigin(player.mo, player.mo.target.x, player.mo.target.y, player.mo.target.z)
		          SC_SetOrbitalMode(player, 0, 320*FU, ANG1, 0*FU)
				  end
				  
		   end)
	 
addHook("MobjThinker", function(mo,player)
 
 if mo.valid then
  A_FindTarget(mo, MT_PLAYER, 0)
  mo.color = 87
  end
  
  if mo.state == S_CONQSONIC
   then 
   mo.target.player.conquestcutscene = 0
    end
	
	if mo.state == S_CONQSONIC3
    then	
	mo.target.player.conquestcutscene = 1
     end
	 
	 if mo.state == S_CONQSONIC4
    then	
	A_FindTracer(mo, MT_JYATHAWK, 0)
	mo.tracer.state = S_JYAT3
     end
	 
	 if mo.state == S_CONQSONIC6
	   then mo.target.player.conquestcutscene = 2
	    end
	   
	   if mo.state == S_CONQSONIC10
	   then mo.target.player.conquestcutscene = 0
	    end
		
		if mo.state == S_CONQSONIC10SECOND
	   then mo.target.player.conquestcutscene = 1
	    end
		
		if mo.state == S_CONQSONIC11
	   then mo.target.player.conquestcutscene = 0
	    end
		
		if mo.state == S_CONQSONIC12
	   then mo.target.player.conquestcutscene = 1
	    end
   
        if mo.state == S_CONQSONIC13
	   then mo.target.player.conquestcutscene = 0
	    end
		
		if mo.state == S_CONQSONIC16
	   then mo.target.player.conquestcutscene = 3
	    end
		
		if mo.state == S_CONQSONIC18
	   then mo.target.player.conquestcutscene = 4
	    end
		
		
		if mo.state == S_CONQSONIC19
	   then mo.target.player.conquestcutscene = 3
	     end
	    
		
		if mo.state == S_CONQSONIC19SECOND
		 then A_MoveAbsolute(mo, 90, 15)
		  end
		  
		  if mo.state == S_CONQSONIC20SECOND
		  then A_MoveAbsolute(mo, 90, 15)
		       mo.target.player.conquestcutscene = 5
		  end
		  
		   if mo.state == S_CONQSONIC20
		  then A_MoveAbsolute(mo, 90, 15)
		  end
		  
		 if mo.state == S_CONQSONIC23
		  then mo.target.player.conquestcutscene = 6
		   end
		   
		   if mo.state == S_CONQSONIC24
		  then mo.target.player.conquestcutscene = 7
		   end
		   
		   if mo.state == S_CONQSONIC25
		  then mo.target.player.conquestcutscene = 5
		   end
		   
		   if mo.state == S_CONQSONIC30
		  then mo.target.player.conquestcutscene = 8
		     P_SetOrigin(mo, -960*FU, 2176*FU, -1076*FU)
		   end
		   
		   if mo.state == S_CONQSONIC31
		  then mo.target.player.conquestcutscene = 9
		     P_SetOrigin(mo, -960*FU, 2176*FU, -1076*FU)
		   end
		   
		   if mo.state == S_CONQSONIC32
		  then 
		  A_FindTracer(mo, MT_CELLWAYPOINT2, 0)
		  mo.target.player.conquestcutscene = 9
		     A_HomingChase(mo, 200*FU, 1)
			 
			 end
			 
			 
			 if mo.state == S_CONQSONIC33
		  then 
		  A_FindTracer(mo, MT_CELLWAYPOINT2, 0)
		  mo.target.player.conquestcutscene = 10
		     A_HomingChase(mo, 5*FU, 1)
			 
		   end
		   
		   if mo.state == S_CONQSONIC34
		  then 
		  mo.momz = 0
		  A_MoveAbsolute(mo, 180, 170)
			 
		   end
		   
		   
		  if mo.state == S_CONQSONIC35
		  then mo.target.player.conquestcutscene = 11
		  A_FindTracer(mo, MT_CELLWAYPOINT4, 0)
		  P_SetOrigin(mo,mo.tracer.x,mo.tracer.y,mo.tracer.z)
		   end
		   
		   if mo.state == S_CONQSONIC36
		    then A_GhostMe(mo,2)
			 end
			 
		   if mo.state == S_CONQSONIC37
		    then P_StartQuake(50*FRACUNIT, 4)
			 end
		   
		   if mo.state == S_CONQSONIC40
		   then mo.target.player.conquestcutscene = 12
		    end
		   
		   if mo.state == S_CONQSONIC41
		  then mo.target.player.conquestcutscene = 13
		      A_MoveAbsolute(mo, 270, 30)
			  A_GhostMe(mo,8)
		     
		   end
        
		if mo.state == S_CONQSONIC43
		  then mo.momz = -50*FU
			   A_GhostMe(mo,2)
		      end
		
		
		if mo.state == S_CONQSONIC44
		  then mo.target.player.conquestcutscene = 11
		      mo.momz = -50*FU
			  A_GhostMe(mo,2)
		     end
			 
			 
		if mo.state == S_CONQSONIC44 and P_IsObjectOnGround(mo)
		  then mo.state = S_CONQSONIC45
		     end
           
		 if mo.state == S_CONQSONIC46
		  A_MoveAbsolute(mo, 180, 200)
			 A_GhostMe(mo,4)
			 end
			 
			 if mo.state == S_CONQSONIC47
			 G_SetCustomExitVars(nil, 2)
             G_ExitLevel()
			 end
           
 
 end,MT_CONQSONIC)
 
 
 addHook("MobjThinker", function(mo,player)
 
 if mo.state == S_CUTSCENECONQ2
  then A_FindTracer(mo, MT_CELLWAYPOINT3, 0)
       A_HomingChase(mo, 200*FU, 1)
	   A_GhostMe(mo,8)
	   end
	   
 if mo.state == S_CUTSCENECONQ7
  then A_FindTracer(mo, MT_CELLWAYPOINT6, 0)
      P_SetOrigin(mo,mo.tracer.x,mo.tracer.y,mo.tracer.z)
	  end
	  
 if mo.state == S_CUTSCENECONQ8
  then A_MoveAbsolute(mo, 180, 450)
	  end	
	  
	  if mo.state == S_CUTSCENECONQ9
		    then P_StartQuake(50*FRACUNIT, 4)
			 end
	  
	  
	  if mo.state == S_CUTSCENECONQ10
       then
	    A_FindTracer(mo, MT_RWAL, 0)
	    mo.tracer.destscale = 8*FU
		mo.tracer.scalespeed = 2*FU
		end
 
 end,MT_CCONQ)
 
 addHook("MapLoad", function()
 if mapheaderinfo[gamemap].cutscenestage then return end
 
 hud.enable("score") //reenable the hud (do they know?)
 hud.enable("time")
 hud.enable("rings")
	
	  end)
 