share/hedgewars/Data/Missions/Training/Basic_Training_-_Cluster_Bomb.lua
author nemo
Mon, 29 Oct 2012 14:22:29 -0400
changeset 7877 b3fb94986255
parent 7165 aad1aea05f1e
child 7889 57b117d441b9
permissions -rw-r--r--
Fix training script positions altered by variable land dimension change. issue #453
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     1
loadfile(GetDataPath() .. "Scripts/Locale.lua")()
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     2
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     3
local player = nil
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     4
local scored = 0
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     5
local end_timer = 5000
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     6
local game_lost = false
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     7
local time_goal = 0
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     8
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
     9
function spawnTarget()
6505
mikade
parents: 6501
diff changeset
    10
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    11
	gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
6505
mikade
parents: 6501
diff changeset
    12
	
7877
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    13
	if scored == 0 then x = 628 end
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    14
	if scored == 1 then x = 891 end
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    15
	if scored == 2 then x = 1309 end
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    16
	if scored == 3 then x = 1128 end
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    17
	if scored == 4 then x = 410 end
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    18
	if scored == 5 then x = 1564 end
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    19
	if scored == 6 then x = 1348 end
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    20
	if scored == 7 then x = 169 end
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    21
	if scored == 8 then x = 1720 end
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    22
	if scored == 9 then x = 1441 end
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    23
	if scored == 10 then x = 599 end
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    24
	if scored == 11 then x = 1638 end
6505
mikade
parents: 6501
diff changeset
    25
mikade
parents: 6501
diff changeset
    26
	if scored == 6 then
7877
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    27
		SetGearPosition(gear, 1248, 476)
6505
mikade
parents: 6501
diff changeset
    28
	else
7877
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    29
		SetGearPosition(gear, x, 0)
6505
mikade
parents: 6501
diff changeset
    30
	end
mikade
parents: 6501
diff changeset
    31
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    32
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    33
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    34
function onGameInit()
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    35
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    36
	Seed = 1
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    37
	GameFlags = gfDisableWind + gfInfAttack + gfOneClanMode
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    38
	TurnTime = 180 * 1000
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    39
	Map = "Trash"
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    40
	Theme = "Golf"
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    41
	Goals = "Take down all the targets|Achieve it using only Cluster Bomb"
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    42
	CaseFreq = 0
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    43
	MinesNum = 0
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    44
	Explosives = 0
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    45
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    46
	AddTeam("The Hogies", 2850005, "Statue", "Island", "Hog Islands")
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    47
6505
mikade
parents: 6501
diff changeset
    48
	player = AddHog(loc("Private Novak"), 0, 1, "war_desertGrenadier1")
7877
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 7165
diff changeset
    49
	SetGearPosition(player, 756, 370)
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    50
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    51
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    52
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    53
function onAmmoStoreInit()
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    54
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    55
	SetAmmo(amClusterBomb, 9, 0, 0, 0)
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    56
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    57
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    58
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    59
function onGameStart()
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    60
6505
mikade
parents: 6501
diff changeset
    61
	ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("You have to destroy 12 targets in 180 seconds"), -amClusterBomb, 5000)
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    62
	spawnTarget()
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    63
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    64
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    65
7165
aad1aea05f1e add onGameTick20 to basic training, extend laser sight out way more (it was visible at top when completely zoomed out), move call of new turn to after AfterSwitchHedgehog to avoid lua issues in onNewTurn - if this causes problems, lua can do delayed actions in onGameTick
nemo
parents: 6505
diff changeset
    66
function onGameTick20()
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    67
7165
aad1aea05f1e add onGameTick20 to basic training, extend laser sight out way more (it was visible at top when completely zoomed out), move call of new turn to after AfterSwitchHedgehog to avoid lua issues in onNewTurn - if this causes problems, lua can do delayed actions in onGameTick
nemo
parents: 6505
diff changeset
    68
	if TurnTimeLeft < 40 and TurnTimeLeft > 0 and scored < 12 and game_lost == false then
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    69
		game_lost = true
6505
mikade
parents: 6501
diff changeset
    70
		ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    71
		SetHealth(player, 0)
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    72
		time_goal = 1
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    73
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    74
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    75
	if scored == 12 or game_lost then
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    76
		if end_timer == 0 then
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    77
			EndGame()
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    78
		else
7165
aad1aea05f1e add onGameTick20 to basic training, extend laser sight out way more (it was visible at top when completely zoomed out), move call of new turn to after AfterSwitchHedgehog to avoid lua issues in onNewTurn - if this causes problems, lua can do delayed actions in onGameTick
nemo
parents: 6505
diff changeset
    79
			end_timer = end_timer - 20
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    80
			TurnTimeLeft = time_goal
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    81
		end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    82
	end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    83
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    84
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    85
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    86
function onNewTurn()
6505
mikade
parents: 6501
diff changeset
    87
	ParseCommand("setweap " .. string.char(amClusterBomb))
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    88
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    89
7165
aad1aea05f1e add onGameTick20 to basic training, extend laser sight out way more (it was visible at top when completely zoomed out), move call of new turn to after AfterSwitchHedgehog to avoid lua issues in onNewTurn - if this causes problems, lua can do delayed actions in onGameTick
nemo
parents: 6505
diff changeset
    90
--function onGearAdd(gear)
aad1aea05f1e add onGameTick20 to basic training, extend laser sight out way more (it was visible at top when completely zoomed out), move call of new turn to after AfterSwitchHedgehog to avoid lua issues in onNewTurn - if this causes problems, lua can do delayed actions in onGameTick
nemo
parents: 6505
diff changeset
    91
--end
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    92
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    93
function onGearDamage(gear, damage)
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    94
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    95
	if GetGearType(gear) == gtTarget then
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    96
		scored = scored + 1
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    97
		if scored < 12 then
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    98
			spawnTarget()
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
    99
		else
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   100
			if not game_lost then
6505
mikade
parents: 6501
diff changeset
   101
mikade
parents: 6501
diff changeset
   102
				if TurnTimeLeft > 90 * 10 then
mikade
parents: 6501
diff changeset
   103
					ShowMission(loc("Cluster Bomb MASTER!"), loc("Aiming Practice"), loc("Congratulations! You needed only half of time|to eliminate all targets."), 4, 0)
mikade
parents: 6501
diff changeset
   104
				else
mikade
parents: 6501
diff changeset
   105
					ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0)
mikade
parents: 6501
diff changeset
   106
				end
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   107
				PlaySound(sndVictory)
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   108
				time_goal = TurnTimeLeft
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   109
			end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   110
		end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   111
	end
6505
mikade
parents: 6501
diff changeset
   112
mikade
parents: 6501
diff changeset
   113
	if GetGearType(gear) == gtHedgehog then
mikade
parents: 6501
diff changeset
   114
		game_lost = true
mikade
parents: 6501
diff changeset
   115
		ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0)
mikade
parents: 6501
diff changeset
   116
		SetHealth(player, 0)
mikade
parents: 6501
diff changeset
   117
		time_goal = 1
mikade
parents: 6501
diff changeset
   118
	end
mikade
parents: 6501
diff changeset
   119
6501
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   120
end
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   121
4a6666deb85b Add some (slightly modified) GCI missions.
mikade
parents:
diff changeset
   122
function onGearDelete(gear)
7165
aad1aea05f1e add onGameTick20 to basic training, extend laser sight out way more (it was visible at top when completely zoomed out), move call of new turn to after AfterSwitchHedgehog to avoid lua issues in onNewTurn - if this causes problems, lua can do delayed actions in onGameTick
nemo
parents: 6505
diff changeset
   123
end