share/hedgewars/Data/Missions/Training/Basic_Training_-_Cluster_Bomb.lua
author sheepluva
Thu, 12 Jun 2014 20:47:11 +0200
changeset 10289 c3a77ff02a23
parent 8679 a8bdcf7bec20
permissions -rw-r--r--
lua api: SetWeapon(ammoType)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8043
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 7889
diff changeset
     1
HedgewarsScriptLoad("/Scripts/Locale.lua")
7889
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
     2
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
     3
local player = nil
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
     4
local scored = 0
8679
a8bdcf7bec20 fix fade to black in training
nemo
parents: 8043
diff changeset
     5
local end_timer = 1000
7889
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
     6
local game_lost = false
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
     7
local time_goal = 0
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
     8
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
     9
function spawnTarget()
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    10
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    11
	gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    12
	
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    13
	if scored == 0 then x = 628 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    14
	if scored == 1 then x = 891 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    15
	if scored == 2 then x = 1309 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    16
	if scored == 3 then x = 1128 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    17
	if scored == 4 then x = 410 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    18
	if scored == 5 then x = 1564 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    19
	if scored == 6 then x = 1348 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    20
	if scored == 7 then x = 169 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    21
	if scored == 8 then x = 1720 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    22
	if scored == 9 then x = 1441 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    23
	if scored == 10 then x = 599 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    24
	if scored == 11 then x = 1638 end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    25
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    26
	if scored == 6 then
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    27
		SetGearPosition(gear, 1248, 476)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    28
	else
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    29
		SetGearPosition(gear, x, 0)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    30
	end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    31
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    32
end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    33
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    34
function onGameInit()
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    35
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    36
	Seed = 1
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    37
	GameFlags = gfDisableWind + gfInfAttack + gfOneClanMode
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    38
	TurnTime = 180 * 1000
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    39
	Map = "Trash"
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    40
	Theme = "Golf"
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    41
	Goals = "Take down all the targets|Achieve it using only Cluster Bomb"
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    42
	CaseFreq = 0
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    43
	MinesNum = 0
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    44
	Explosives = 0
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    45
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    46
	AddTeam("The Hogies", 2850005, "Statue", "Island", "Hog Islands")
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    47
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    48
	player = AddHog(loc("Private Novak"), 0, 1, "war_desertGrenadier1")
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    49
	SetGearPosition(player, 756, 370)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    50
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    51
end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    52
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    53
function onAmmoStoreInit()
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    54
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    55
	SetAmmo(amClusterBomb, 9, 0, 0, 0)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    56
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    57
end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    58
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    59
function onGameStart()
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    60
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    61
	ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("You have to destroy 12 targets in 180 seconds"), -amClusterBomb, 5000)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    62
	spawnTarget()
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    63
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    64
end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    65
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    66
function onGameTick20()
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    67
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    68
	if TurnTimeLeft < 40 and TurnTimeLeft > 0 and scored < 12 and game_lost == false then
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    69
		game_lost = true
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    70
		ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    71
		SetHealth(player, 0)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    72
		time_goal = 1
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    73
	end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    74
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    75
	if scored == 12 or game_lost then
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    76
		if end_timer == 0 then
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    77
			EndGame()
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    78
		else
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    79
			TurnTimeLeft = time_goal
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    80
		end
8679
a8bdcf7bec20 fix fade to black in training
nemo
parents: 8043
diff changeset
    81
        end_timer = end_timer - 20
7889
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    82
	end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    83
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    84
end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    85
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    86
function onNewTurn()
10289
c3a77ff02a23 lua api: SetWeapon(ammoType)
sheepluva
parents: 8679
diff changeset
    87
	SetWeapon(amClusterBomb)
7889
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    88
end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    89
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    90
--function onGearAdd(gear)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    91
--end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    92
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    93
function onGearDamage(gear, damage)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    94
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    95
	if GetGearType(gear) == gtTarget then
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    96
		scored = scored + 1
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    97
		if scored < 12 then
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    98
			spawnTarget()
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
    99
		else
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   100
			if not game_lost then
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   101
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   102
				if TurnTimeLeft > 90 * 10 then
57b117d441b9 consistent line endings
nemo
parents: 7877
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)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   104
				else
57b117d441b9 consistent line endings
nemo
parents: 7877
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)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   106
				end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   107
				PlaySound(sndVictory)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   108
				time_goal = TurnTimeLeft
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   109
			end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   110
		end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   111
	end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   112
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   113
	if GetGearType(gear) == gtHedgehog then
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   114
		game_lost = true
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   115
		ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   116
		SetHealth(player, 0)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   117
		time_goal = 1
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   118
	end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   119
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   120
end
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   121
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   122
function onGearDelete(gear)
57b117d441b9 consistent line endings
nemo
parents: 7877
diff changeset
   123
end