freeslot(
	"sfx_FORGE",
	"MT_QUIZGAME",
	"S_QUIZ1",
	"S_QUIZ2",
	"S_QUIZ3",
	"MT_QUIZSPOTA",
	"S_QSPOTA",
	"SPR_QSPT",
	"S_QSPOTB",
	"S_QSPOTC",
	"S_QSPOTD"
)


----------Questions/Choices
local QuizQuestNum = CV_RegisterVar({
	name = "Quiz Question Amount",
	defaultvalue = "5",
	description = "Set how many questions there are, from 0 to 100 (0 = Endless)",
	flags = CV_NETVAR | CV_SHOWMODIF,
	PossibleValue = {MIN=0,MAX=100}
})

--######################

addHook("MapLoad", do
	for p in players.iterate
		if not (p.mo and p.mo.valid and mapheaderinfo[gamemap].fortuneforge) return end
		
		p.quizwinner = nil
		p.quizstart = false
		p.getready	= 0
		p.questiontime	= 0
		p.mo.answercorrect = nil
		p.answersgot = 0
		p.questionnum = 0
		p.answeroption = 0
		p.quizbooting = nil
		p.quegameitem = 0
		p.quegearname = 0
		p.querankcolor = 0
		p.quemapcupzone = 0
		p.quemapcupzoneb = 0
		p.quecupnum = 0
		p.quegametype = 0
		p.queringdebt = 0
		p.kartmap = 0
	end
end
)
--######################

--p.quizstart			boolean checks if quiz is active
--p.getready			int 	time before next question
--p.questiontime		int 	time during the question
--p.mo.answercorrect	boolean checks if the answer is right or not
--p.answersgot			int 	how many questions got right
--p.quizwinner 			boolean checks if you won the quiz
--p.questionnum			int 	current question number
--p.answeroption		int		which color tile has the right answer
--								also chooses the set of answers
--p.quizbooting			boolean	checks if quiz is beginning or not
--p.quegameitem			int		used for making selective answers work

--MT_BATTLEBUMPERDEBRIS

--######################

addHook("MobjThinker", function(mobj)
	if not (mobj and mobj.valid and mapheaderinfo[gamemap].fortuneforge) return end
	mobj.flags = $|MF_ENEMY
	
end,MT_ORBINAUT)

--######################

addHook("PlayerThink", function(p)

	local readytime = 10*TICRATE //10*TICRATE 
	local questiontime = 15*TICRATE //15*TICRATE
	local numofquestions = 27	//How many questions appear, counting [0]
	local wintime = 15*TICRATE				--time to show win result
	local losetime = 7*TICRATE/2			--time before you leave after losing
	local sfx_question = 939 //sfx_SSA120
	local sfx_correct = 945 //sfx_SSA126
	local sfx_correct2 = 813 //sfx_MBV91
	local sfx_wrong = 946 //sfx_SSA127
	local sfx_wrong2 = 943 //sfx_SSA124
	local sfx_hurry = 365 //sfx_S26A
	local sfx_ready = 489 //sfx_S3KA7
	local sfx_losetheme = 775 //sfx_MBS59
	local sfx_wintheme = 938 //sfx_SSA119
	local nocontrolenter = 11*TICRATE/2		--time to disable player control

	--######################
	if not (p.mo and p.mo.valid and mapheaderinfo[gamemap].fortuneforge) return end

		p.realtime = 0 //freeze numbers in HUD, doesnt actually stop the counting
		p.mo.flags = $ & MF_NOCLIPTHING
		p.roundscore = p.answersgot
		p.nocontrol = 0
		
		--######################
		local answerstowin = QuizQuestNum.value
		
		if leveltime < nocontrolenter
			p.nocontrol = 1
		return end
		
		--######################
		local checktimescale = CV_FindVar("timescale")
		
		if (checktimescale.value != 65536
		and checktimescale.value != 1)
			
			print("Timescale has\x85 NOT\x80 been changed.\x85 NO CHEATING.\x80")
			
			S_StartSound(nil,sfx_wrong,p)
			K_SpinPlayer(p,nil,nil,1)
			p.mo.health = $ - 1
					
			if p.mo.health > 0
				P_SpawnMobj(p.mo.x, p.mo.y, p.mo.z, MT_KURAGENBOMB)
				COM_BufInsertText(p,"timescale 1")
			end
			
			if p.mo.health == 0
				COM_BufInsertText(p,"timescale 1")
				P_KillMobj(p.mo,nil,nil,999)
				S_StartSound(nil,sfx_wrong2,p)
				p.quizwinner = false
				K_SpawnMineExplosion(p.mo,SKINCOLOR_YELLOW,1) --spawn explosion
			end
					
		return end
		//print(checktimescale.value)
		--######################
		
		if p.quizwinner == true
			p.exiting = $ + 1
			if p.exiting == losetime
				//S_StartSound(nil,sfx_wintheme,p)
			end				
			if p.exiting > wintime
				G_ExitLevel()
			end				
		return end	

		--######################
			
		if p.quizwinner == false
			p.exiting = $ + 1
			p.pflags = $1 & (PF_NOCONTEST|PF_ELIMINATED)
			//p.awayviewtics = INT32_MAX
			p.nocontrol = INT32_MAX -- prevent control of any kind
			
			if p.exiting == losetime/5
				//S_StartSound(nil,sfx_losetheme,p)
			end					
			
			if p.exiting > losetime
				//K_ExplodePlayer(p,nil,nil) --tosses player upwards
				//
				G_ExitLevel()
				//p.spectator = true
				P_MoveOrigin(p.mo,-3008*FRACUNIT,-3520*FRACUNIT,2500*FRACUNIT)
			end
		return end	
			
		--######################
		//if ( not (p.mo and p.mo.valid) or p.spectator == true or p.mo.markedfordeath == true) --or lose
		//return end	
		
		if p.quizstart != true
		and p.quizwinner == nil

			if p.mo.x >= -3264*FRACUNIT and p.mo.x <= -2752*FRACUNIT
			and p.mo.y <= -3264*FRACUNIT and p.mo.y >= -3776*FRACUNIT
			and P_IsObjectOnGround(p.mo)
			and p.quizbooting != true
			
				//P_SpawnMobj(-3136*FRACUNIT, -3392*FRACUNIT, 1300*FRACUNIT, MT_PATROLBUG)
				//P_SpawnMobj(-3744*FRACUNIT, -1120*FRACUNIT, 0, MT_DUELBOMB)
				p.getready = readytime
				p.quizbooting = true
				p.questionnum = P_RandomRange(1,numofquestions)
			return end

			if (p.mo.x < -3264*FRACUNIT or p.mo.x > -2752*FRACUNIT
			or p.mo.y > -3264*FRACUNIT or p.mo.y < -3776*FRACUNIT)
			and p.quizbooting == true
				p.quizbooting = false
			end
			
		end
			
		--######################
		
		if p.frostycircuit != true //lock in if coming from Frosty Circuit
			if QuizQuestNum.value == 0
				local answerstowin = 9999
			end
			if QuizQuestNum.value > 0
				local answerstowin = QuizQuestNum.value
			end
		end
		
		--######################
		if p.frostycircuit == true //lock in if coming from Frosty Circuit
			--print ("A134567")
			local answerstowin = 5
			if QuizQuestNum.value != 5
				print ("The amount of questions cannot be changed in Grand Prix.")
			end
		end
			
		--######################

			
		if (p.quizstart == true or p.quizbooting == true)
		and p.quizwinner != true 
			

			if p.getready > 0
				p.getready = $ - 1
				if p.questionnum > numofquestions
					p.questionnum = 0
				end
				---copied some of the bottom code to fix a lower question bug
				if p.answersgot >= answerstowin
				or (p.frostycircuit == true and p.answersgot >= 5)
					p.quizwinner = true
				end
				
				if p.getready == 35
				or p.getready == 70
				or p.getready == 105
				or p.getready == 140
				or p.getready == 175
					S_StartSound(nil,sfx_ready,p)
				end
				
			end
			
			
			if p.getready == 2
				p.quizstart = true
				p.questionnum = $ + P_RandomRange(1,25)
				-- generated questions:  0,1,2,4,5,6,7,10,21,26
				
				--p.questionnum = 26 --debug: question to start/stay on
				
				p.answeroption = P_RandomRange(1,4)
				p.quegameitem = P_RandomRange(0,2) 		//we do +1 on Ans_GameItem
				p.quegearname = P_RandomRange(0,2) 		//we do +1 on Ans_GameItem
				p.querankcolor = P_RandomRange(0,3) 		//we do +1 on Ans_GameItem
				p.quemapcupzone = P_RandomRange(0,23) 		//we do +1 on Ans_GameItem
				p.quemapcupzoneb = P_RandomRange(1,23) 		//we do +1 on Ans_GameItem
				p.quecupnum = P_RandomRange(0,3) 		//we do +1 on Ans_GameItem
				p.quegametype = P_RandomRange(0,2) 		//we do +1 on Ans_GameItem
				p.queringdebt = P_RandomRange(0,1) 		//we do +1 on Ans_GameItem
				p.kartmap  = P_RandomRange(0,23)
			end
			if p.getready == 1
				p.questiontime = questiontime
				S_StartSound(nil,sfx_question,p)
			end
			
				
			if p.questiontime > 0
				p.realtime = p.questiontime
				p.questiontime = $ - 1
				if p.questiontime == 35
				or p.questiontime == 70
				or p.questiontime == 105
				or p.questiontime == 140
				or p.questiontime == 175
					S_StartSound(nil,sfx_hurry,p)
				end
			end
				
			if p.questiontime == 1
			
				p.getready = readytime
				
				
				-----These are where the tile checking code is
				p.mo.answercorrect = false
				
				if (p.answeroption == 1
				and (p.mo.x > -3264*FRACUNIT and p.mo.x < -3008*FRACUNIT
				and p.mo.y > -3776*FRACUNIT and p.mo.y < -3520*FRACUNIT ))
				or (p.answeroption == 2
				and (p.mo.x > -3264*FRACUNIT + 256*FRACUNIT and p.mo.x < -3008*FRACUNIT + 256*FRACUNIT
				and p.mo.y > -3776*FRACUNIT and p.mo.y < -3520*FRACUNIT ))
				or (p.answeroption == 3
				and (p.mo.x > -3264*FRACUNIT + 256*FRACUNIT and p.mo.x < -3008*FRACUNIT + 256*FRACUNIT
				and p.mo.y > -3776*FRACUNIT + 256*FRACUNIT and p.mo.y < -3520*FRACUNIT + 256*FRACUNIT))
				or (p.answeroption == 4
				and (p.mo.x > -3264*FRACUNIT and p.mo.x < -3008*FRACUNIT
				and p.mo.y > -3776*FRACUNIT + 256*FRACUNIT and p.mo.y < -3520*FRACUNIT + 256*FRACUNIT))
					
					p.mo.answercorrect = true
					p.superring = $ + 1
				end
								
				if p.mo.answercorrect == true
					S_StartSound(nil,sfx_correct,p)
					S_StartSound(nil,sfx_correct2,p)
					p.answersgot = $ + 1
					p.totalring = $ + p.answersgot*10
					
					if p.answersgot >= answerstowin
					or (p.frostycircuit == true and p.answersgot >= 5)
						p.quizwinner = true
					end
				end
				
				if p.mo.answercorrect == false
					S_StartSound(nil,sfx_wrong,p)
					K_SpinPlayer(p,nil,nil,1)
					p.mo.health = $ - 1
					
					if p.mo.health > 0
					
						P_SpawnMobj(p.mo.x, p.mo.y, p.mo.z, MT_KURAGENBOMB)
					end
					if p.mo.health == 0
					
						P_KillMobj(p.mo,nil,nil,999)
						S_StartSound(nil,sfx_wrong2,p)
						p.quizwinner = false
						K_SpawnMineExplosion(p.mo,SKINCOLOR_YELLOW,1) --spawn explosion
					end
				end
			end	
		end
end
)

--######################

local function HornHUD(v, p)
	if not (mapheaderinfo[gamemap].fortuneforge) return end

	local AnswerHUD_Xoff = 0
	local AnswerHUD_Yoff = -24
	local TextCenter_Xoff = 160

	
	if not (p.mo and p.mo.valid)
	or p.spectator
		v.drawString(90, 10,"\x82#"+p.quizwinner+"\x85 Spectating",1,"center")
	return end

	//V_PARAMMASK	--negative effect	
	

	if p.questiontime <= 15*TICRATE
		v.drawFill(180, 30, p.questiontime/4, 2, 112 | (V_SLIDEIN | V_SNAPTORIGHT))	
	end
	if p.questiontime <= 10*TICRATE
		v.drawFill(180, 30, p.questiontime/4, 2, 72 | (V_SLIDEIN | V_SNAPTORIGHT))	
	end	
	if p.questiontime <= 5*TICRATE
		v.drawFill(180, 30, p.questiontime/4, 2, 36 | (V_SLIDEIN | V_SNAPTORIGHT))	
	end	

	//v.drawString(120, 10,"\x82#"+p.quizwinner+"\x84 Quiz Winner",1)
	//v.drawString(120, 20,"\x82#"+p.getready+"\x84 Get Ready",1)
	//v.drawString(120, 30,"\x82#"+p.quizstart+"\x84 Quizstart",1)
	//v.drawString(120, 40,"\x82#"+p.questiontime+"\x84 Questiontime",1)
	//v.drawString(120, 50,"\x82#"+p.mo.answercorrect+"\x84 Answer Correct!",1)
	//v.drawString(120, 60,"\x82#"+p.answersgot+"\x84 Answers Got!",1)
	//v.drawString(120, 70,"\x82#"+p.questionnum+"\x84 Question Number!",1)
	//v.drawString(120, 80,"\x82#"+p.mo.health+"\x84 Health!",1)
	//v.drawString(120, 90,"\x82#"+p.quizbooting+"\x84 quizbooting!",1)
	//v.drawString(120, 100,"\x82#"+player.mo.x+"\x84 numplayers!",1)
	//v.drawString(120, 110,"\x82#"+answerstowin+"\x84 answerstowin!",1)
	//v.drawString(120, 120,"\x82#"+QuizQuestNum.value+"\x84 QuizQuestNum!",1)
	//v.drawString(120, 130,"\x82#"+p.querankcolor+"\x84 querankcolor!",1)
	//v.drawString(120, 140,"\x82#"+QuizQuestNum.value+"\x84 QuizQuestNum!",1)
	
	
--######################	
	if p.exiting > 0
		if p.quizwinner == true
			v.drawString(TextCenter_Xoff, 140,"\x80 You good! Player smart!",1,"center")
			v.drawString(TextCenter_Xoff, 160,"\x83\x02 YOU WIN \x80!",1,"center")
		end
		if p.quizwinner == false
			v.drawString(TextCenter_Xoff, 140,"\x80 Player luck go boom...",1,"center")
			v.drawString(TextCenter_Xoff, 160,"\x85\x03 GAME OVER ",1,"center")
		end			
	end
	
--######################
	if p.exiting == 0
		v.draw(10, 160+AnswerHUD_Yoff, v.cachePatch("ANSHUD2"), V_HUDTRANS | V_SLIDEIN | V_SNAPTOLEFT | V_SNAPTOBOTTOM, v.getColormap(p.mo.skin, p.mo.color))
		v.draw(10, 160+AnswerHUD_Yoff, v.cachePatch("ANSHUD"), V_HUDTRANS/2 | V_SLIDEIN | V_SNAPTOLEFT | V_SNAPTOBOTTOM, v.getColormap(p.mo.skin, p.mo.color))
		if p.quizstart == true
		and p.questiontime == 0
			v.draw(10, 160+AnswerHUD_Yoff, v.cachePatch("ANSHUD"), V_HUDTRANS | V_SLIDEIN | V_SNAPTOLEFT | V_SNAPTOBOTTOM, v.getColormap(p.mo.skin, p.mo.color))
		end	
	end

--######################
	if leveltime > 7*TICRATE/2
	and p.exiting == 0 

		local answerstowin = QuizQuestNum.value
		
		if p.frostycircuit == true //lock in if coming from Frosty Circuit
			local answerstowin = 5
		end
		--######################
		v.drawString(26, 165+AnswerHUD_Yoff,"\x86 Correct Answers",1,"thin")
		if p.frostycircuit == true //lock in if coming from Frosty Circuit
			v.drawString(44, 180+AnswerHUD_Yoff,"\x86"+p.answersgot+" /\x83 5",1)
		end
		--######################
		if p.frostycircuit != true //lock in if coming from Frosty Circuit
			if QuizQuestNum.value > 0
				v.drawString(44, 180+AnswerHUD_Yoff,"\x86"+p.answersgot+" /\x83 "+answerstowin,1)
			end
			if QuizQuestNum.value == 0
				
				v.drawString(32, 174+AnswerHUD_Yoff,"\x8e Endless Game",1,"thin")
				v.drawString(56, 184+AnswerHUD_Yoff,"\x86"+p.answersgot,1)
			end
		end
		--######################
		if p.quizstart == true
		and p.questiontime == 0
		
			v.drawString(26, 165+AnswerHUD_Yoff," Correct Answers",1,"thin")
			if p.frostycircuit == true //lock in if coming from Frosty Circuit
				v.drawString(44, 180+AnswerHUD_Yoff,p.answersgot+" /\x83 5",1)
			end
			if p.frostycircuit != true //lock in if coming from Frosty Circuit
				if QuizQuestNum.value > 0
					v.drawString(44, 180+AnswerHUD_Yoff,p.answersgot+" /\x83 "+answerstowin,1)
				end
				if QuizQuestNum.value == 0
					v.drawString(32, 174+AnswerHUD_Yoff,"\x87 Endless Game",1,"thin")
					v.drawString(56, 184+AnswerHUD_Yoff,p.answersgot,1)
				end
			end
		end	
	end
--######################	

	if p.quizbooting == false
		v.drawString(TextCenter_Xoff, 168,"Take your time and enter the platform when you're ready.",1,"thin-center")
	end
	
--######################	
	if (p.quizstart == true or p.quizbooting == true)
	and p.quizwinner == nil
		if p.getready > 0
			if p.mo.answercorrect == true
				v.drawString(TextCenter_Xoff, 140,"\x83\x02 CORRECT \x80",1,"center")
			end
			if p.mo.answercorrect == false
				v.drawString(TextCenter_Xoff, 140," \x85\x03 INCORRECT \x80",1,"center")
			end			
			v.drawString(TextCenter_Xoff, 160,"\x82Question begins in...",1,"center")
			v.drawString(TextCenter_Xoff, 170,"\x82"+p.getready/35,1,"center")
		end

--######################

		if p.questiontime > 0

----------Selective Questions/Answers on certain questions

local Que_GameItem = {
[0] = "Rhythm Badge",
[1] = "Garden Top",
[2] = "Super Flicky",
[3] = "Hyudoro",
[4] = "Drop Target",
[5] = "Jawz",
[6] = "Self-Propelled Bomb",
[7] = "#7 This should not display",
[8] = "#8 This should not display",
[9] = "#9 This should not display"
}

--######################
local Ans_GameItem = {
[1] = "Sonic Adventure",
[2] = "Sonic Adventure 2",
[3] = "Sonic the Hedgehog CD",
[4] = "Sonic the Hedgehog 3",

[5] = "Sonic the Hedgehog 3",
[6] = "Sonic the Hedgehog",
[7] = "Sonic the Hedgehog 2",
[8] = "Sonic & Knuckles",

[9] = "Sonic the Hedgehog 3",
[10] = "Sonic 3D Blast",
[11] = "Sonic the Hedgehog CD",
[12] = "Sonic the Hedgehog 2",

[13] = "Sonic the Hedgehog 3",
[14] = "Sonic the Hedgehog CD",
[15] = "Sonic & Knuckles",
[16] = "Sonic the Hedgehog 2",

[17] = "Sonic the Hedgehog 2",
[18] = "Sonic the Hedgehog CD",
[19] = "Sonic the Hedgehog",
[20] = "Sonic 3D Blast",

[21] = "Sonic the Hedgehog 3",
[22] = "Sonic the Hedgehog 2",
[23] = "Sonic & Knuckles",
[24] = "Sonic the Hedgehog CD",

[25] = "Sonic the Hedgehog 3",
[26] = "Sonic the Hedgehog CD",
[27] = "Sonic the Hedgehog 2",
[28] = "Sonic the Hedgehog",

[29] = "#29 This should not display",
[30] = "#30 This should not display"
}

--######################
local Que_GearName = {
[0] = "Gear 1",
[1] = "Gear 2",
[2] = "Gear 3",
[3] = "Gear 3 Plus"
}

--######################
local Ans_GearName = { //Because there's so many answers I have to do it like this
[1] = "Relaxed",
[2] = "Intense",
[3] = "Vicious",
[4] = "Master",

[5] = "Intense",
[6] = "Vicious",
[7] = "Master",
[8] = "Relaxed",

[9] = "Vicious",
[10] = "Master",
[11] = "Relaxed",
[12] = "Intense",

[13] = "Master",
[14] = "Relaxed",
[15] = "Intense",
[16] = "Vicious"
}

--######################
local Que_RankColor = {
[0] = "E",
[1] = "D",
[2] = "C",
[4] = "B",
[5] = "A",
[6] = "S"
}

--######################
local Ans_RankColor = { //Because there's so many answers I have to do it like this
[1] = "Blue",
[2] = "Purple",
[3] = "Green",
[4] = "Gray",

[5] = "Green",
[6] = "Yellow",
[7] = "Blue",
[8] = "Red",

[9] = "Yellow",
[10] = "Red",
[11] = "Blue",
[12] = "Orange",

[13] = "Red",
[14] = "Orange",
[15] = "Yellow",
[16] = "Green",

[17] = "Pink",
[18] = "Red",
[19] = "Orange",
[20] = "Gray",

[21] = "Gray",
[22] = "Black",
[23] = "Red",
[24] = "Pink"
}

--######################
local Que_MapCupZone = {
[0] = "Steeple",

[1] = "Municipal Meadow",
[2] = "Tinkerer's Arena",
[3] = "Lucid Pass",
[4] = "Withering Chateau",

[5] = "Mystery Gate",
[6] = "Rusty Rig",
[7] = "Bronze Lake",
[8] = "Obsidian Oasis",

[9] = "Electra Clacker",
[10] = "Marble Foyer",
[11] = "Azure Lake",
[12] = "Hardhat Havoc",

[13] = "Frigid Cove",
[14] = "Gizmo Bastion",
[15] = "Palmtree Panic",
[16] = "Star Light",

[17] = "Honeycomb Hollow",
[18] = "Security Hall",
[19] = "Aqueduct Crystal",
[20] = "Metropolis",

[21] = "Fountain",
[22] = "Roulette",
[23] = "Villa",
[24] = "Steeple",

[17] = "Tropic Theatre",
[18] = "Arrow Avenue",
[19] = "Passageway",
[20] = "Buildings",

[21] = "Pasture",
[22] = "Slide",
[23] = "Castle",
[24] = "Sky Deck"
}

--######################
local Ans_MapCupZone = {
[1] = "Sealed Star",
[2] = "Prison Break",
[3] = "Race",
[4] = "(Not a default level)",

[5] = "Prison Break",
[6] = "Race",
[7] = "Sealed Star",
[8] = "(Not a default level)",


[9] = "Prison Break",
[10] = "Race",
[11] = "Sealed Star",
[12] = "(Not a default level)",

[13] = "Race",
[14] = "Prison Break",
[15] = "Sealed Star",
[16] = "(Not a default level)",

[17] = "Race",
[18] = "Prison Break",
[19] = "Sealed Star",
[20] = "(Not a default level)",

[21] = "Prison Break",
[22] = "Race",
[23] = "Sealed Star",
[24] = "(Not a default level)",

[25] = "Prison Break",
[26] = "Race",
[27] = "Sealed Star",
[28] = "(Not a default level)",

[29] = "Race",
[30] = "Prison Break",
[31] = "Sealed Star",
[32] = "(Not a default level)",

[33] = "Race",
[34] = "Prison Break",
[35] = "Sealed Star",
[36] = "(Not a default level)",

[37] = "Prison Break",
[38] = "Race",
[39] = "Sealed Star",
[40] = "(Not a default level)",

[41] = "Prison Break",
[42] = "Race",
[43] = "Sealed Star",
[44] = "(Not a default level)",

[45] = "Race",
[46] = "Prison Break",
[47] = "Sealed Star",
[48] = "(Not a default level)",

[49] = "Race",
[50] = "Prison Break",
[51] = "Sealed Star",
[52] = "(Not a default level)",

[53] = "Prison Break",
[54] = "Race",
[55] = "Sealed Star",
[56] = "(Not a default level)",

[57] = "Prison Break",
[58] = "Race",
[59] = "Sealed Star",
[60] = "(Not a default level)",

[61] = "Race",
[62] = "Prison Break",
[63] = "Sealed Star",
[64] = "(Not a default map)",

[65] = "Race",
[66] = "Prison Break",
[67] = "Sealed Star",
[68] = "(Not a default map)",

[69] = "(Not a default map)",
[70] = "Race",
[71] = "Prison Break",
[72] = "Sealed Star",

[73] = "(Not a default map)",
[74] = "Race",
[75] = "Prison Break",
[76] = "Sealed Star",

[77] = "(Not a default map)",
[78] = "Race",
[79] = "Prison Break",
[80] = "Sealed Star",

[81] = "(Not a default map)",
[82] = "Race",
[83] = "Prison Break",
[84] = "Sealed Star",

[85] = "(Not a default map)",
[86] = "Race",
[87] = "Prison Break",
[88] = "Sealed Star",

[89] = "(Not a default map)",
[90] = "Race",
[91] = "Prison Break",
[92] = "Sealed Star",

[93] = "(Not a default map)",
[94] = "Race",
[95] = "Prison Break",
[96] = "Sealed Star",

[97] = "(Not a default map)",
[98] = "Race",
[99] = "Prison Break",
[100] = "Sealed Star"
}

--######################
local Que_CupNum = {
[0] = "1st",
[1] = "2nd",
[2] = "5th",
[3] = "7th"
}

--######################
local Ans_CupNum = { 
[1] = "Ring",
[2] = "Sneaker",
[3] = "Spring",
[4] = "Barrier",

[5] = "Sneaker",
[6] = "Barrier",
[7] = "Emerald",
[8] = "Invincible",

[9] = "Invincible",
[10] = "Emerald",
[11] = "Extra",
[12] = "Sneaker",

[13] = "Extra",
[14] = "Spring",
[15] = "Barrier",
[16] = "Ring"
}

--######################
local Que_GameType = {
[0] = "Race",
[1] = "Prison Break",
[2] = "Sealed Star"
}

--######################
local Ans_GameType = {
[1] = "233",
[2] = "207",
[3] = "215",
[4] = "240",

[5] = "60",
[6] = "55",
[7] = "50",
[8] = "70",

[9] = "14",
[10] = "10",
[11] = "15",
[12] = "7"
}

--######################
local Que_RingDebt = {
[0] = "Lowest",
[1] = "Highest"
}

--######################
local Ans_RingDebt = {
[1] = "-20",
[2] = "-10",
[3] = "-15",
[4] = "0",

[5] = "20",
[6] = "10",
[7] = "25",
[8] = "30"
}

--######################
local Ans_KartMap = {
[1] = "Northern District",
[2] = "Robotnik Coaster",
[3] = "Tree Ring",
[4] = "Emerald Coast",

[5] = "Sonic Speedway",
[6] = "Storm Rig",
[7] = "Lucid Pass",
[8] = "Azure Lake",

[9] = "Green Hills",
[10] = "Withering Chateau",
[11] = "Popcorn Workshop",
[12] = "Mystery Gate",

[13] = "Tricircle Marina",
[14] = "Frigid Cove",
[15] = "Cadillac Cascade",
[16] = "Rumble Ridge",

[17] = "Rusty Rig",
[18] = "Launch Base",
[19] = "Angel Island",
[20] = "Chrome Gadget",

[21] = "Municipal Meadow",
[22] = "Endless Mine Act 1",
[23] = "Mirage Saloon",
[24] = "Rock World",

[25] = "Opulence",
[26] = "Regal Ruin",
[27] = "Isolated Island",
[28] = "Gigapolis",

[29] = "Marble Foyer",
[30] = "World 1 Map",
[31] = "Bronze Lake",
[32] = "Collision Chaos",

[33] = "Silvercloud Island",
[34] = "Emerald Hill",
[35] = "Azure City",
[36] = "SEGA Saturn",

[37] = "Sub-Zero Peak",
[38] = "Gust Planet",
[39] = "Mystic Cave",
[40] = "Electra Clacker",

[41] = "Darkvile Castle Act 1",
[42] = "Joypolis",
[43] = "Marble Garden",
[44] = "Thunder Top",

[45] = "Aqueduct Crystal",
[46] = "Hard-Boiled Stadium",
[47] = "Hardhat Havoc",
[48] = "Carbon Crucible",

[49] = "Gizmo Bastion",
[50] = "Press Garden",
[51] = "Pico Park",
[52] = "Security Hall",

[53] = "Virtual Highway",
[54] = "City Escape",
[55] = "Palmtree Panic",
[56] = "(Not a default level)",

[57] = "Hot Shelter",
[58] = "Darkvile Castle Act 2",
[59] = "Gems Museum",
[60] = "Media Studio",

[61] = "Scarlet Gardens",
[62] = "Star Light",
[63] = "Metropolis",
[64] = "Honeycomb Hollow",

[65] = "Tails' Lab",
[66] = "Nova Shore",
[67] = "Wood",
[68] = "Hydrocity",

[69] = "Power Plant",
[70] = "Trap Tower",
[71] = "Diamond Dust",
[72] = "Brawl Fort",

[73] = "City Skyline",
[74] = "Blue Mountain Act 2",
[75] = "Crystal Island",
[76] = "Speed Highway",

[77] = "Aurora Atoll",
[78] = "Carnival Night",
[79] = "Lost Colony",
[80] = "Neon Resort",

[81] = "Daytona Speedway",
[82] = "Labyrinth",
[83] = "Spring Yard",
[84] = "Sky Sanctuary",

[85] = "Lake Margorite",
[86] = "Meteor Herd",
[87] = "Dark Fortess",
[88] = "Death Egg",

[89] = "Abyss Garden",
[90] = "Green Triangle",
[91] = "Sunset Hill",
[92] = "Savannah Citadel",

[93] = "Abyss Gate",
[94] = "Bigtime Breakdown",
[95] = "Vantablack Atrium",
[96] = "Dead Simple",

[97] = "Coastal Temple",
[98] = "Vantablack Violet",
[99] = "Martian Matrix",
[100] = "Turquoise Hill",

[101] = "Ramp Park",
[102] = "Weiss Waterway",
[103] = "Ice Paradise",
[104] = "Dark Chao Garden",

[105] = "Crimson Core",
[106] = "Sunsplashed Getaway",
[107] = "Fae Falls",
[108] = "Azure Axiom",

[109] = "Kodachrome Void",
[110] = "Aerial Highlands",
[111] = "Whirl Waters",
[112] = "Operator's Overspace",

[113] = "Barren Badlands",
[114] = "Hanagumi Hall",
[115] = "Deluged Metroplex",
[116] = "Espresso Lane",

[117] = "Clucky Farms",
[118] = "Chaos Seraph",
[119] = "Leaf Storm",
[120] = "Toy Kingdom",

[121] = "Dried Battledune",
[122] = "Endless Mine Act 2",
[123] = "Quartz Quadrant",
[124] = "Aqua Tunnel",

[125] = "Chemical Facility",
[126] = "Water Palace",
[127] = "Pestilence",
[128] = "Record Attack"
}

--######################

----------Questions/Choices

local Questions = {
[0] = "Q: What game does the '"+Que_GameItem[p.quegameitem]+"' originate from?",
[1] = "Q: What is the nickname given for '"+Que_GearName[p.quegearname]+"'?",
[2] = "Q: What color is the grading badge for '"+Que_RankColor[p.querankcolor]+"' rank?",
[3] = "Q: Which item is known to 'turn pursuers into pinballs'?",
[4] = "Q: Which gametype is played in '"+Que_MapCupZone[p.quemapcupzone]+"'?",
[5] = "Q: Which of the following maps are present in 'Sonic Robo Blast 2 Kart'?",
[6] = "Q: Which gametype is played in '"+Que_MapCupZone[p.quemapcupzone]+"'?",
[7] = "Q: Which of the following maps are present in 'Sonic Robo Blast 2 Kart'?",
[8] = "Q: When booting the game for the first time, who is seen in the backdrop?",
[9] = "Q: What month did 'Dr. Robotnik's Ring Racers' debut?",
[10] = "Q: What is the name of the "+Que_CupNum[p.quecupnum]+" Grand Prix Cup?",
[11] = "Q: Which default map has the most amount of laps?",
[12] = "Q: What game engine is 'Dr. Robotnik's Ring Racers' built in?",
[13] = "Q: What Gear does Time Trial mode use by default?",
[14] = "Q: As of version 2.3, how many points are required to earn an S Rank?",
[15] = "Q: How many spray cans are there in total to be collected?",
[16] = "Q: What is the name of the ghost who steals items from other racers?",
[17] = "Q: What does the acronym 'SPB' stand for?",
[18] = "Q: A 'hyudoro' must steal what item to give back a 'Kitchen Sink'?",
[19] = "Q: How many points in Battle mode does the 'Bonus' item give?",
[20] = "Q: What is the name of the creature who hosts this quiz?",
[21] = "Q: As of Version 2.3, how many "+Que_GameType[p.quegametype]+" maps are there in total?",
[22] = "Q: How many base roster characters does a New File start with?",
[23] = "Q: How many rings does the 'Jackpot' item give out?",
[24] = "Q: What is the name of the food stand seen in 'Robotnik Coaster Zone'?",
[25] = "Q: What is the name of the 'Mod Pack' that this map is from?",
[26] = "Q: What is the "+Que_RingDebt[p.queringdebt]+" amount of rings per player?",
[27] = "Q: Which gametype is played in '"+Que_MapCupZone[p.quemapcupzone]+"'?",
[28] = "Q: ---------?"
}

--######################

local Answer = {
[1] = Ans_GameItem[(p.quegameitem*4)+1],
[2] = Ans_GameItem[(p.quegameitem*4)+2],
[3] = Ans_GameItem[(p.quegameitem*4)+3],
[4] = Ans_GameItem[(p.quegameitem*4)+4],

[5] = Ans_GearName[(p.quegearname*4)+1],
[6] = Ans_GearName[(p.quegearname*4)+2],
[7] = Ans_GearName[(p.quegearname*4)+3],
[8] = Ans_GearName[(p.quegearname*4)+4],

[9] = Ans_RankColor[(p.querankcolor*4)+1],
[10] = Ans_RankColor[(p.querankcolor*4)+2],
[11] = Ans_RankColor[(p.querankcolor*4)+3],
[12] = Ans_RankColor[(p.querankcolor*4)+4],

[13] = "Drop Target",
[14] = "Springs",
[15] = "Jawz",
[16] = "Orbinaut",

[17] = Ans_MapCupZone[(p.quemapcupzone*4)+1],
[18] = Ans_MapCupZone[(p.quemapcupzone*4)+2],
[19] = Ans_MapCupZone[(p.quemapcupzone*4)+3],
[20] = Ans_MapCupZone[(p.quemapcupzone*4)+4],

[21] = Ans_KartMap[(p.kartmap*4)+1],
[22] = Ans_KartMap[(p.kartmap*4)+2],
[23] = Ans_KartMap[(p.kartmap*4)+3],
[24] = Ans_KartMap[(p.kartmap*4)+4],

[25] = Ans_MapCupZone[(p.quemapcupzone*4)+1],
[26] = Ans_MapCupZone[(p.quemapcupzone*4)+2],
[27] = Ans_MapCupZone[(p.quemapcupzone*4)+3],
[28] = Ans_MapCupZone[(p.quemapcupzone*4)+4],

[29] = Ans_KartMap[(p.kartmap*4)+1],
[30] = Ans_KartMap[(p.kartmap*4)+2],
[31] = Ans_KartMap[(p.kartmap*4)+3],
[32] = Ans_KartMap[(p.kartmap*4)+4],

[33] = "Metal Sonic",
[34] = "Sonic",
[35] = "Tails",
[36] = "Dr. Eggman",

[37] = "April",
[38] = "March",
[39] = "June",
[40] = "May",

[41] = Ans_CupNum[(p.quecupnum*4)+1],
[42] = Ans_CupNum[(p.quecupnum*4)+2],
[43] = Ans_CupNum[(p.quecupnum*4)+3],
[44] = Ans_CupNum[(p.quecupnum*4)+4],

[45] = "Death Egg Zone",
[46] = "Pico Park Zone",
[47] = "Roundabout Zone",
[48] = "Desert Bus Zone",

[49] = "Doom",
[50] = "Quake",
[51] = "Sonic Robo Blast 2",
[52] = "Sonic Robo Blast 2 Kart",

[53] = "Vicious",
[54] = "Intense",
[55] = "Relaxed",
[56] = "Master",

[57] = "526",
[58] = "496",
[59] = "505",
[60] = "510",

[61] = "100",
[62] = "120",
[63] = "150",
[64] = "80",

[65] = "Hyudoro",
[66] = "Horodou",
[67] = "Hudoryu",
[68] = "Hydouro",

[69] = "Self-Propelled Bomb",
[70] = "Super-Propelled Bomb",
[71] = "Self-Powered Bomb",
[72] = "Super-Powered Bomb",

[73] = "Self-Propelled Bomb",
[74] = "Invincibility",
[75] = "Orbinaut",
[76] = "(None of the Above)",

[77] = "6",
[78] = "5",
[79] = "1",
[80] = "3",

[81] = "Baphomoar",
[82] = "Maphoboar",
[83] = "Bamophoar",
[84] = "Ramoboar",

[85] = Ans_GameType[(p.quegametype*4)+1],
[86] = Ans_GameType[(p.quegametype*4)+2],
[87] = Ans_GameType[(p.quegametype*4)+3],
[88] = Ans_GameType[(p.quegametype*4)+4],

[89] = "9",
[90] = "10",
[91] = "5",
[92] = "7",

[93] = "100",
[94] = "50",
[95] = "120",
[96] = "150",

[97] = "Lunch Base",
[98] = "Meal Harbor",
[99] = "Munchroom Hill",
[100] = "Wing Wafers",

[101] = "RuberPack",
[102] = "RubberPack",
[103] = "RumblePack",
[104] = "RumberPack",

[105] = Ans_RingDebt[(p.queringdebt*4)+1],
[106] = Ans_RingDebt[(p.queringdebt*4)+2],
[107] = Ans_RingDebt[(p.queringdebt*4)+3],
[108] = Ans_RingDebt[(p.queringdebt*4)+4],

[109] = Ans_MapCupZone[(p.quemapcupzone*4)+1],
[110] = Ans_MapCupZone[(p.quemapcupzone*4)+2],
[111] = Ans_MapCupZone[(p.quemapcupzone*4)+3],
[112] = Ans_MapCupZone[(p.quemapcupzone*4)+4]
}

--######################

		v.drawFill(0, 128, 999, 2, 152 | (V_50TRANS))
		v.drawFill(0, 130, 999, 2, 153 | (V_50TRANS))
		v.drawFill(0, 132, 999, 2, 154 | (V_50TRANS))
		v.drawFill(0, 134, 999, 2, 155 | (V_50TRANS))
		v.drawFill(0, 136, 999, 2, 156 | (V_50TRANS))
		v.drawFill(0, 138, 999, 2, 157 | (V_50TRANS))
		v.drawFill(0, 140, 999, 2, 158 | (V_50TRANS))
		v.drawFill(0, 142, 999, 2, 159 | (V_50TRANS))

		v.drawFill(0, 150, 999, 2, 155 | (V_50TRANS))
		v.drawFill(0, 152, 999, 2, 156 | (V_50TRANS))
		v.drawFill(0, 154, 999, 2, 157 | (V_50TRANS))
		v.drawFill(0, 156, 999, 2, 158 | (V_50TRANS))
		v.drawFill(0, 158, 999, 2, 159 | (V_50TRANS))
		
		v.drawFill(0, 160, 999, 2, 36 | (V_50TRANS))
		v.drawFill(0, 162, 999, 2, 37 | (V_50TRANS))
		v.drawFill(0, 164, 999, 2, 38 | (V_50TRANS))
		v.drawFill(0, 166, 999, 2, 39 | (V_50TRANS))
		v.drawFill(0, 168, 999, 2, 40 | (V_50TRANS))

		v.drawFill(0, 170, 999, 2, 75 | (V_50TRANS))
		v.drawFill(0, 172, 999, 2, 76 | (V_50TRANS))
		v.drawFill(0, 174, 999, 2, 77 | (V_50TRANS))
		v.drawFill(0, 176, 999, 2, 78 | (V_50TRANS))
		v.drawFill(0, 178, 999, 2, 79 | (V_50TRANS))
		
		v.drawFill(0, 180, 999, 2, 115 | (V_50TRANS))
		v.drawFill(0, 182, 999, 2, 116 | (V_50TRANS))
		v.drawFill(0, 184, 999, 2, 117 | (V_50TRANS))
		v.drawFill(0, 186, 999, 2, 118 | (V_50TRANS))
		v.drawFill(0, 188, 999, 2, 119 | (V_50TRANS))
		
--######################
		
			if (not menuactive) --if game is paused and the menu shows
			
				v.drawString(TextCenter_Xoff, 130,"\x80"+Questions[p.questionnum],1,"thin-center")

				if p.answeroption == 1
					v.drawString(TextCenter_Xoff, 150,"\x80"+Answer[((p.questionnum)*4)+1],1,"thin-center")
					v.drawString(TextCenter_Xoff, 160,"\x80"+Answer[((p.questionnum)*4)+2],1,"thin-center")
					v.drawString(TextCenter_Xoff, 170,"\x80"+Answer[((p.questionnum)*4)+3],1,"thin-center")
					v.drawString(TextCenter_Xoff, 180,"\x80"+Answer[((p.questionnum)*4)+4],1,"thin-center")
				end		
				if p.answeroption == 2
					v.drawString(TextCenter_Xoff, 150,"\x80"+Answer[((p.questionnum)*4)+3],1,"thin-center")
					v.drawString(TextCenter_Xoff, 160,"\x80"+Answer[((p.questionnum)*4)+1],1,"thin-center")
					v.drawString(TextCenter_Xoff, 170,"\x80"+Answer[((p.questionnum)*4)+4],1,"thin-center")
					v.drawString(TextCenter_Xoff, 180,"\x80"+Answer[((p.questionnum)*4)+2],1,"thin-center")
				end			
				if p.answeroption == 3
					v.drawString(TextCenter_Xoff, 150,"\x80"+Answer[((p.questionnum)*4)+2],1,"thin-center")
					v.drawString(TextCenter_Xoff, 160,"\x80"+Answer[((p.questionnum)*4)+4],1,"thin-center")
					v.drawString(TextCenter_Xoff, 170,"\x80"+Answer[((p.questionnum)*4)+3],1,"thin-center")
					v.drawString(TextCenter_Xoff, 180,"\x80"+Answer[((p.questionnum)*4)+1],1,"thin-center")
				end		
				if p.answeroption == 4
					v.drawString(TextCenter_Xoff, 150,"\x80"+Answer[((p.questionnum)*4)+4],1,"thin-center")
					v.drawString(TextCenter_Xoff, 160,"\x80"+Answer[((p.questionnum)*4)+3],1,"thin-center")
					v.drawString(TextCenter_Xoff, 170,"\x80"+Answer[((p.questionnum)*4)+1],1,"thin-center")
					v.drawString(TextCenter_Xoff, 180,"\x80"+Answer[((p.questionnum)*4)+2],1,"thin-center")
				end	
			end
		end	
	end

--######################
			if (p.answeroption == 1
			and (p.mo.x > -3264*FRACUNIT and p.mo.x < -3008*FRACUNIT
			and p.mo.y > -3776*FRACUNIT and p.mo.y < -3520*FRACUNIT ))
			or (p.answeroption == 2
			and (p.mo.x > -3264*FRACUNIT + 256*FRACUNIT and p.mo.x < -3008*FRACUNIT + 256*FRACUNIT
			and p.mo.y > -3776*FRACUNIT and p.mo.y < -3520*FRACUNIT ))
			or (p.answeroption == 3
			and (p.mo.x > -3264*FRACUNIT + 256*FRACUNIT and p.mo.x < -3008*FRACUNIT + 256*FRACUNIT
			and p.mo.y > -3776*FRACUNIT + 256*FRACUNIT and p.mo.y < -3520*FRACUNIT + 256*FRACUNIT))
			or (p.answeroption == 4
			and (p.mo.x > -3264*FRACUNIT and p.mo.x < -3008*FRACUNIT
			and p.mo.y > -3776*FRACUNIT + 256*FRACUNIT and p.mo.y < -3520*FRACUNIT + 256*FRACUNIT))
				
					--v.drawString(120, 50,"\x82This is right!",1) --debug: find show and test correct answer
			end	
end
hud.add(HornHUD)

--######################



mobjinfo[MT_QUIZSPOTA] = {
	doomednum = 4602,
	spawnstate = S_QSPOTA,
	seestate = S_QSPOTA,
	reactiontime = TICRATE,
	speed = 0*FRACUNIT,
	radius = 32*FRACUNIT,
	height = 32*FRACUNIT,
	flags = MF_SCENERY|MF_NOGRAVITY
}

states[S_QSPOTA] = {SPR_QSPT, FF_TRANS20|FF_PAPERSPRITE|A, 1, A_None, 0, 0, S_QSPOTA}
states[S_QSPOTB] = {SPR_QSPT, FF_TRANS20|FF_PAPERSPRITE|B, 1, A_None, 0, 0, S_QSPOTB}
states[S_QSPOTC] = {SPR_QSPT, FF_TRANS20|FF_PAPERSPRITE|C, 1, A_None, 0, 0, S_QSPOTC}
states[S_QSPOTD] = {SPR_QSPT, FF_TRANS20|FF_PAPERSPRITE|D, 1, A_None, 0, 0, S_QSPOTD}

--copied from the quizgame object
	local AnswerA_x1 = -3136*FRACUNIT + 32*FRACUNIT
	local AnswerA_x2 = -3136*FRACUNIT  - 32*FRACUNIT
	local AnswerA_y1 = -3664*FRACUNIT  + 32*FRACUNIT
	local AnswerA_y2 = -3664*FRACUNIT  - 32*FRACUNIT
	
	local AnswerButtonXDiv = 256*FRACUNIT
	local AnswerButtonYDiv = 256*FRACUNIT
	
addHook("MobjThinker", function(mobj,p)
	
	if not (mobj and mobj.valid)
		return end	
	for p in players.iterate
		if not (p.mo and p.mo.valid and mapheaderinfo[gamemap].fortuneforge) return end
		
		local mobjlook = R_PointToAngle2(mobj.x, mobj.y, p.mo.x, p.mo.y)

		mobj.angle = mobjlook	---stare at the player
			
		mobj.renderflags =  $|RF_FLOORSPRITE
		mobj.blendmode = AST_ADD
		mobj.scale = 2*FRACUNIT
			if mobj.x < AnswerA_x1
			and mobj.x > AnswerA_x2
			and mobj.y < AnswerA_y1
			and mobj.y > AnswerA_y2
				mobj.state = S_QSPOTA
			end

			if mobj.x < AnswerA_x1 + AnswerButtonXDiv
			and mobj.x > AnswerA_x2 + AnswerButtonXDiv
			and mobj.y < AnswerA_y1
			and mobj.y > AnswerA_y2
				mobj.state = S_QSPOTB
			end

			if mobj.x < AnswerA_x1
			and mobj.x > AnswerA_x2
			and mobj.y < AnswerA_y1 + AnswerButtonYDiv
			and mobj.y > AnswerA_y2 + AnswerButtonYDiv
				mobj.state = S_QSPOTC
			end
			
			if mobj.x < AnswerA_x1 + AnswerButtonXDiv
			and mobj.x > AnswerA_x2 + AnswerButtonXDiv
			and mobj.y < AnswerA_y1 + AnswerButtonYDiv
			and mobj.y > AnswerA_y2 + AnswerButtonYDiv
				mobj.state = S_QSPOTD
			end
	end
end,MT_QUIZSPOTA
)