share/hedgewars/Data/Missions/Training/Basic_Training_-_Sniper_Rifle.lua
changeset 11528 8826ee0afe01
parent 11017 16c47a5573e4
equal deleted inserted replaced
11527:44e646598e6a 11528:8826ee0afe01
    34 local time_goal = 0
    34 local time_goal = 0
    35 
    35 
    36 local target = nil
    36 local target = nil
    37 
    37 
    38 local last_hit_time = 0
    38 local last_hit_time = 0
       
    39 
       
    40 local cinematic = false
       
    41 
    39 -- This is a custom function to make it easier to
    42 -- This is a custom function to make it easier to
    40 -- spawn more targets with just one line of code
    43 -- spawn more targets with just one line of code
    41 -- You may define as many custom functions as you
    44 -- You may define as many custom functions as you
    42 -- like.
    45 -- like.
    43 function spawnTarget(x, y)
    46 function spawnTarget(x, y)
    46 	-- have the camera move to the target so the player knows where it is
    49 	-- have the camera move to the target so the player knows where it is
    47 	FollowGear(target)
    50 	FollowGear(target)
    48 end
    51 end
    49 
    52 
    50 function blowUp(x, y)
    53 function blowUp(x, y)
       
    54     if cinematic == false then
       
    55         cinematic = true
       
    56         SetCinematicMode(true)
       
    57     end
    51 	-- adds some TNT
    58 	-- adds some TNT
    52 	gear = AddGear(x, y, gtDynamite, 0, 0, 0, 0)
    59 	gear = AddGear(x, y, gtDynamite, 0, 0, 0, 0)
    53 end
    60 end
    54 
    61 
    55 function onNewTurn()
    62 function onNewTurn()
   176 end
   183 end
   177 
   184 
   178 -- This function is called before a gear is destroyed.
   185 -- This function is called before a gear is destroyed.
   179 -- We use it to count the number of targets destroyed.
   186 -- We use it to count the number of targets destroyed.
   180 function onGearDelete(gear)
   187 function onGearDelete(gear)
   181 
   188 	local gt = GetGearType(gear)
   182 	if GetGearType(gear) == gtCase then
   189 
       
   190 	if gt == gtCase then
   183 		game_lost = true
   191 		game_lost = true
   184 		return
   192 		return
   185 	end
   193 	end
   186 
   194 
   187 	if (GetGearType(gear) == gtTarget) then
   195 	if (gt == gtDynamite) and cinematic then
       
   196 		cinematic = false
       
   197 		SetCinematicMode(false)
       
   198 		return
       
   199 	end
       
   200 
       
   201 	if gt == gtTarget then
   188 		-- remember when the target was hit for adjusting the camera
   202 		-- remember when the target was hit for adjusting the camera
   189 		last_hit_time = TurnTimeLeft
   203 		last_hit_time = TurnTimeLeft
   190 		-- Add one point to our score/counter
   204 		-- Add one point to our score/counter
   191 		score = score + 1
   205 		score = score + 1
   192 		-- If we haven't reached the goal ...
   206 		-- If we haven't reached the goal ...