share/hedgewars/Data/Missions/Training/Basic_Training_-_Flying_Saucer.lua
changeset 14668 38836d6c5c8a
parent 14649 e7b2542c4d28
child 14928 4c5fb1ee75b7
equal deleted inserted replaced
14667:6b70c109389f 14668:38836d6c5c8a
    25 HedgewarsScriptLoad("/Scripts/Tracker.lua")
    25 HedgewarsScriptLoad("/Scripts/Tracker.lua")
    26 
    26 
    27 local Player = nil -- Pointer to hog created in: onGameInit
    27 local Player = nil -- Pointer to hog created in: onGameInit
    28 local Target = nil -- Pointer to target hog
    28 local Target = nil -- Pointer to target hog
    29 local Objective = false -- Get to the target
    29 local Objective = false -- Get to the target
       
    30 local Flawless = true -- Track flawless victory
    30 
    31 
    31 local TargetNumber = 0 -- The current target number
    32 local TargetNumber = 0 -- The current target number
    32 local GrenadeThrown = false -- Used for the Boom Target
    33 local GrenadeThrown = false -- Used for the Boom Target
    33 local BazookasLeft = 0 -- Used by the Launch Target and the Unterwater Attack Target
    34 local BazookasLeft = 0 -- Used by the Launch Target and the Unterwater Attack Target
    34 
    35 
   202 	if SaucerGear ~= nil then
   203 	if SaucerGear ~= nil then
   203 		DeleteGear(SaucerGear)
   204 		DeleteGear(SaucerGear)
   204 	end
   205 	end
   205 	SetState(Player, band(GetState(Player), bnot(gstHHDriven)))
   206 	SetState(Player, band(GetState(Player), bnot(gstHHDriven)))
   206 	SetState(Player, bor(GetState(Player), gstWinner))
   207 	SetState(Player, bor(GetState(Player), gstWinner))
   207 	PlaySound(sndVictory, Player)
   208 	if Flawless then
       
   209 		PlaySound(sndFlawless, Player)
       
   210 	else
       
   211 		PlaySound(sndVictory, Player)
       
   212 	end
   208 	SaveMissionVar("Won", "true")
   213 	SaveMissionVar("Won", "true")
   209 
   214 
   210 	SendStat(siGameResult, loc("You have finished the Flying Saucer Training!"))
   215 	SendStat(siGameResult, loc("You have finished the Flying Saucer Training!"))
   211 	SendStat(siCustomAchievement, loc("Good job!"))
   216 	SendStat(siCustomAchievement, loc("Good job!"))
   212 	SendStat(siPlayerKills, "0", GetHogTeamName(Player))
   217 	SendStat(siPlayerKills, "0", GetHogTeamName(Player))
   562 	end
   567 	end
   563 end
   568 end
   564 
   569 
   565 function onGearDamage(Gear)
   570 function onGearDamage(Gear)
   566 	if Gear == Player then
   571 	if Gear == Player then
       
   572 		Flawless = false
   567 		CleanUpGears()
   573 		CleanUpGears()
   568 		GrenadeThrown = false
   574 		GrenadeThrown = false
   569 		Check = false
   575 		Check = false
   570 	end
   576 	end
   571 end
   577 end
   572 
   578 
   573 function onGearResurrect(Gear, VGear)
   579 function onGearResurrect(Gear, VGear)
   574 	if Gear == Player then
   580 	if Gear == Player then
       
   581 		Flawless = false
   575 		AddCaption(loc("Oh no! You have died. Try again!"), capcolDefault, capgrpMessage2)
   582 		AddCaption(loc("Oh no! You have died. Try again!"), capcolDefault, capgrpMessage2)
   576 		ResetCurrentTarget()
   583 		ResetCurrentTarget()
   577 		if VGear then
   584 		if VGear then
   578 			SetVisualGearValues(VGear, GetX(Gear), GetY(Gear))
   585 			SetVisualGearValues(VGear, GetX(Gear), GetY(Gear))
   579 		end
   586 		end
   580 	end
   587 	end
   581 end
   588 end
   582 
   589 
   583 function onSkipTurn()
   590 function onSkipTurn()
       
   591 	Flawless = false
   584 	AddCaption(loc("Try again!"), capcolDefault, capgrpMessage2)
   592 	AddCaption(loc("Try again!"), capcolDefault, capgrpMessage2)
   585 	ResetCurrentTarget()
   593 	ResetCurrentTarget()
   586 end
   594 end