share/hedgewars/Data/Missions/Training/Basic_Training_-_Cluster_Bomb.lua
changeset 6501 4a6666deb85b
child 6505 b005fbba039e
equal deleted inserted replaced
6500:c9eaf1dd16c8 6501:4a6666deb85b
       
     1 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
       
     2 
       
     3 local player = nil
       
     4 local scored = 0
       
     5 local end_timer = 5000
       
     6 local game_lost = false
       
     7 local time_goal = 0
       
     8 
       
     9 function spawnTarget()
       
    10 	gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
       
    11 	FindPlace(gear, true, 0, LAND_WIDTH)
       
    12 	x, y = GetGearPosition(gear)
       
    13 	SetGearPosition(gear, x, 500)
       
    14 end
       
    15 
       
    16 function onGameInit()
       
    17 
       
    18 	Seed = 1
       
    19 	GameFlags = gfDisableWind + gfInfAttack + gfOneClanMode
       
    20 	TurnTime = 180 * 1000
       
    21 	Map = "Trash"
       
    22 	Theme = "Golf"
       
    23 	Goals = "Take down all the targets|Achieve it using only Cluster Bomb"
       
    24 	CaseFreq = 0
       
    25 	MinesNum = 0
       
    26 	Explosives = 0
       
    27 
       
    28 	AddTeam("The Hogies", 2850005, "Statue", "Island", "Hog Islands")
       
    29 
       
    30 	player = AddHog("Private Novak", 0, 100, "war_desertGrenadier1")
       
    31 	SetGearPosition(player, 1780, 1300)
       
    32 
       
    33 end
       
    34 
       
    35 function onAmmoStoreInit()
       
    36 
       
    37 	SetAmmo(amClusterBomb, 9, 0, 0, 0)
       
    38 	SetAmmo(amGrenade, 9, 0, 0, 0)
       
    39 
       
    40 end
       
    41 
       
    42 function onGameStart()
       
    43 
       
    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)
       
    45 	spawnTarget()
       
    46 
       
    47 end
       
    48 
       
    49 function onGameTick()
       
    50 
       
    51 	if TurnTimeLeft == 1 and scored < 12 then
       
    52 		game_lost = true
       
    53 		ShowMission("Cluster Bomb Training", loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
       
    54 		SetHealth(player, 0)
       
    55 		time_goal = 1
       
    56 	end
       
    57 
       
    58 	if scored == 12 or game_lost then
       
    59 		if end_timer == 0 then
       
    60 			EndGame()
       
    61 		else
       
    62 			end_timer = end_timer - 1
       
    63 			TurnTimeLeft = time_goal
       
    64 		end
       
    65 	end
       
    66 
       
    67 end
       
    68 
       
    69 function onNewTurn()
       
    70 end
       
    71 
       
    72 function onGearAdd(gear)
       
    73 end
       
    74 
       
    75 function onGearDamage(gear, damage)
       
    76 
       
    77 	if GetGearType(gear) == gtTarget then
       
    78 		scored = scored + 1
       
    79 		if scored < 12 then
       
    80 			spawnTarget()
       
    81 		else
       
    82 			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)
       
    84 				PlaySound(sndVictory)
       
    85 				time_goal = TurnTimeLeft
       
    86 			end
       
    87 		end
       
    88 	end
       
    89 end
       
    90 
       
    91 function onGearDelete(gear)
       
    92 end