share/hedgewars/Data/Missions/Training/Basic_Training_-_Cluster_Bomb.lua
changeset 6505 b005fbba039e
parent 6501 4a6666deb85b
child 7165 aad1aea05f1e
equal deleted inserted replaced
6504:81d4c369b714 6505:b005fbba039e
     5 local end_timer = 5000
     5 local end_timer = 5000
     6 local game_lost = false
     6 local game_lost = false
     7 local time_goal = 0
     7 local time_goal = 0
     8 
     8 
     9 function spawnTarget()
     9 function spawnTarget()
       
    10 
    10 	gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
    11 	gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
    11 	FindPlace(gear, true, 0, LAND_WIDTH)
    12 	
    12 	x, y = GetGearPosition(gear)
    13 	if scored == 0 then x = 1652 end
    13 	SetGearPosition(gear, x, 500)
    14 	if scored == 1 then x = 1915 end
       
    15 	if scored == 2 then x = 2333 end
       
    16 	if scored == 3 then x = 2152 end
       
    17 	if scored == 4 then x = 1434 end
       
    18 	if scored == 5 then x = 2588 end
       
    19 	if scored == 6 then x = 2372 end
       
    20 	if scored == 7 then x = 1193 end
       
    21 	if scored == 8 then x = 2744 end
       
    22 	if scored == 9 then x = 2465 end
       
    23 	if scored == 10 then x = 1623 end
       
    24 	if scored == 11 then x = 2662 end
       
    25 
       
    26 	if scored == 6 then
       
    27 		SetGearPosition(gear, 2272, 1500)
       
    28 	else
       
    29 		SetGearPosition(gear, x, 1000)
       
    30 	end
       
    31 
    14 end
    32 end
    15 
    33 
    16 function onGameInit()
    34 function onGameInit()
    17 
    35 
    18 	Seed = 1
    36 	Seed = 1
    25 	MinesNum = 0
    43 	MinesNum = 0
    26 	Explosives = 0
    44 	Explosives = 0
    27 
    45 
    28 	AddTeam("The Hogies", 2850005, "Statue", "Island", "Hog Islands")
    46 	AddTeam("The Hogies", 2850005, "Statue", "Island", "Hog Islands")
    29 
    47 
    30 	player = AddHog("Private Novak", 0, 100, "war_desertGrenadier1")
    48 	player = AddHog(loc("Private Novak"), 0, 1, "war_desertGrenadier1")
    31 	SetGearPosition(player, 1780, 1300)
    49 	SetGearPosition(player, 1780, 1300)
    32 
    50 
    33 end
    51 end
    34 
    52 
    35 function onAmmoStoreInit()
    53 function onAmmoStoreInit()
    36 
    54 
    37 	SetAmmo(amClusterBomb, 9, 0, 0, 0)
    55 	SetAmmo(amClusterBomb, 9, 0, 0, 0)
    38 	SetAmmo(amGrenade, 9, 0, 0, 0)
       
    39 
    56 
    40 end
    57 end
    41 
    58 
    42 function onGameStart()
    59 function onGameStart()
    43 
    60 
    44 	ShowMission("Cluster Bomb Training", loc("Aiming Practice"), "You have to destroy 12 targets in 120 seconds|Timer is set to 3 seconds", -amClusterBomb, 5000)
    61 	ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("You have to destroy 12 targets in 180 seconds"), -amClusterBomb, 5000)
    45 	spawnTarget()
    62 	spawnTarget()
    46 
    63 
    47 end
    64 end
    48 
    65 
    49 function onGameTick()
    66 function onGameTick()
    50 
    67 
    51 	if TurnTimeLeft == 1 and scored < 12 then
    68 	if TurnTimeLeft == 1 and scored < 12 and game_lost == false then
    52 		game_lost = true
    69 		game_lost = true
    53 		ShowMission("Cluster Bomb Training", loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
    70 		ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
    54 		SetHealth(player, 0)
    71 		SetHealth(player, 0)
    55 		time_goal = 1
    72 		time_goal = 1
    56 	end
    73 	end
    57 
    74 
    58 	if scored == 12 or game_lost then
    75 	if scored == 12 or game_lost then
    65 	end
    82 	end
    66 
    83 
    67 end
    84 end
    68 
    85 
    69 function onNewTurn()
    86 function onNewTurn()
       
    87 	ParseCommand("setweap " .. string.char(amClusterBomb))
    70 end
    88 end
    71 
    89 
    72 function onGearAdd(gear)
    90 function onGearAdd(gear)
    73 end
    91 end
    74 
    92 
    78 		scored = scored + 1
    96 		scored = scored + 1
    79 		if scored < 12 then
    97 		if scored < 12 then
    80 			spawnTarget()
    98 			spawnTarget()
    81 		else
    99 		else
    82 			if not game_lost then
   100 			if not game_lost then
    83 				ShowMission("Cluster Bomb Training", loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0)
   101 
       
   102 				if TurnTimeLeft > 90 * 10 then
       
   103 					ShowMission(loc("Cluster Bomb MASTER!"), loc("Aiming Practice"), loc("Congratulations! You needed only half of time|to eliminate all targets."), 4, 0)
       
   104 				else
       
   105 					ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0)
       
   106 				end
    84 				PlaySound(sndVictory)
   107 				PlaySound(sndVictory)
    85 				time_goal = TurnTimeLeft
   108 				time_goal = TurnTimeLeft
    86 			end
   109 			end
    87 		end
   110 		end
    88 	end
   111 	end
       
   112 
       
   113 	if GetGearType(gear) == gtHedgehog then
       
   114 		game_lost = true
       
   115 		ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0)
       
   116 		SetHealth(player, 0)
       
   117 		time_goal = 1
       
   118 	end
       
   119 
    89 end
   120 end
    90 
   121 
    91 function onGearDelete(gear)
   122 function onGearDelete(gear)
    92 end
   123 end