share/hedgewars/Data/Missions/Training/Basic_Training_-_Sniper_Rifle.lua
author mikade <redgrinner@gmail.com>
Thu, 11 Dec 2014 20:38:03 +0900
changeset 10655 1c85a442bd56
parent 10289 c3a77ff02a23
child 11015 7a905f0070ce
permissions -rw-r--r--
Wuzzy's changes to stats for some of the training missions.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10655
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
     1
-- Hedgewars SniperRifle Training
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
     2
-- Scripting Example
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
     3
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
     4
-- Lines such as this one are comments - they are ignored
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
     5
-- by the game, no matter what kind of text is in there.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
     6
-- It's also possible to place a comment after some real
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
     7
-- instruction as you see below. In short, everything
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
     8
-- following "--" is ignored.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
     9
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    10
---------------------------------------------------------------
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    11
-- At first we implement the localization library using loadfile.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    12
-- This allows us to localize strings without needing to think
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    13
-- about translations.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    14
-- We can use the function loc(text) to localize a string.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    15
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    16
HedgewarsScriptLoad("/Scripts/Locale.lua")
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    17
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    18
-- This variable will hold the number of destroyed targets.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    19
local score = 0
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    20
-- This variable will hold the number of shots from the sniper rifle
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    21
local shots = 0
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    22
-- This variable represents the number of targets to destroy.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    23
local score_goal = 31
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    24
-- This variable controls how many milliseconds/ticks we'd
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    25
-- like to wait before we end the round once all targets
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    26
-- have been destroyed.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    27
local end_timer = 1000 -- 1000 ms = 1 s
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    28
-- This variable is set to true if the game is lost (i.e.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    29
-- time runs out).
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    30
local game_lost = false
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    31
-- This variable will point to the hog's gear
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    32
local player = nil
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    33
-- This variable will grab the time left at the end of the round
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    34
local time_goal = 0
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    35
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    36
local target = nil
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    37
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    38
local last_hit_time = 0
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    39
-- This is a custom function to make it easier to
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    40
-- spawn more targets with just one line of code
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    41
-- You may define as many custom functions as you
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    42
-- like.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    43
function spawnTarget(x, y)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    44
	-- add a new target gear
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    45
	target = AddGear(x, y, gtTarget, 0, 0, 0, 0)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    46
	-- have the camera move to the target so the player knows where it is
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    47
	FollowGear(target)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    48
end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    49
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    50
function blowUp(x, y)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    51
	-- adds some TNT
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    52
	gear = AddGear(x, y, gtDynamite, 0, 0, 0, 0)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    53
end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    54
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    55
function onNewTurn()
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    56
	SetWeapon(amSniperRifle)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    57
end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    58
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    59
-- This function is called before the game loads its
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    60
-- resources.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    61
-- It's one of the predefined function names that will
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    62
-- be called by the game. They give you entry points
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    63
-- where you're able to call your own code using either
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    64
-- provided instructions or custom functions.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    65
function onGameInit()
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    66
	-- At first we have to overwrite/set some global variables
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    67
	-- that define the map, the game has to load, as well as
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    68
	-- other things such as the game rules to use, etc.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    69
	-- Things we don't modify here will use their default values.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    70
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    71
	-- The base number for the random number generator
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    72
	Seed = 0
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    73
	-- Game settings and rules
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    74
	GameFlags = gfMultiWeapon + gfOneClanMode + gfArtillery
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    75
	-- The time the player has to move each round (in ms)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    76
	TurnTime = 150000
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    77
	-- The frequency of crate drops
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    78
	CaseFreq = 0
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    79
	-- The number of mines being placed
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    80
	MinesNum = 0
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    81
	-- The number of explosives being placed
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    82
	Explosives = 0
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    83
	-- The delay between each round
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    84
	Delay = 0
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    85
	-- The map to be played
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    86
	Map = "Ropes"
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    87
	-- The theme to be used
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    88
	Theme = "City"
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    89
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    90
	-- Create the player team
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    91
	AddTeam(loc("Sniperz"), 14483456, "Simple", "Island", "Default")
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    92
	-- And add a hog to it
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    93
	player = AddHog(loc("Hunter"), 0, 1, "Sniper")
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    94
	SetGearPosition(player, 602, 1465)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    95
end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    96
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    97
-- This function is called when the round starts
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    98
-- it spawns the first target that has to be destroyed.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
    99
-- In addition it shows the scenario goal(s).
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   100
function onGameStart()
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   101
	-- Disable graph in stats screen
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   102
	SendHealthStatsOff()
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   103
	-- Spawn the first target.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   104
	spawnTarget(860,1020)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   105
	
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   106
	-- Show some nice mission goals.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   107
	-- Parameters are: caption, sub caption, description,
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   108
	-- extra text, icon and time to show.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   109
	-- A negative icon parameter (-n) represents the n-th weapon icon
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   110
	-- A positive icon paramter (n) represents the (n+1)-th mission icon
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   111
	-- A timeframe of 0 is replaced with the default time to show.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   112
	ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission."), -amSniperRifle, 0)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   113
end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   114
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   115
-- This function is called every game tick.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   116
-- Note that there are 1000 ticks within one second.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   117
-- You shouldn't try to calculate too complicated
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   118
-- code here as this might slow down your game.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   119
function onGameTick20()
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   120
	if game_lost then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   121
		return
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   122
	end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   123
	-- after a target is destroyed, show hog, then target
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   124
	if (target ~= nil) and (TurnTimeLeft + 1300 < last_hit_time) then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   125
		-- move camera to the target
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   126
		FollowGear(target)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   127
	elseif TurnTimeLeft + 300 < last_hit_time then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   128
		-- move camera to the hog
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   129
		FollowGear(player)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   130
	end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   131
	-- If time's up, set the game to be lost.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   132
	-- We actually check the time to be "1 ms" as it
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   133
	-- will be at "0 ms" right at the start of the game.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   134
	if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal and game_lost == false then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   135
		game_lost = true
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   136
		-- ... and show a short message.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   137
		AddCaption(loc("Time's up!"))
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   138
		ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   139
		-- and generate the stats and go to the stats screen
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   140
		generateStats()
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   141
		EndGame()
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   142
		-- Just to be sure set the goal time to 1 ms
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   143
		time_goal = 1
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   144
	end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   145
	-- If the goal is reached or we've lost ...
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   146
	if score == score_goal or game_lost then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   147
		-- ... check to see if the time we'd like to
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   148
		-- wait has passed and then ...
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   149
		if end_timer == 0 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   150
			-- ... end the game ...
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   151
			generateStats()
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   152
			EndGame()
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   153
		else
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   154
			-- ... or just lower the timer by 1.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   155
			-- Reset the time left to stop the timer
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   156
			TurnTimeLeft = time_goal
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   157
		end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   158
        end_timer = end_timer - 20
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   159
	end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   160
end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   161
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   162
-- This function is called when the game is initialized
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   163
-- to request the available ammo and probabilities
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   164
function onAmmoStoreInit()
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   165
	-- add an unlimited supply of shotgun ammo
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   166
	SetAmmo(amSniperRifle, 9, 0, 0, 0)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   167
end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   168
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   169
-- This function is called when a new gear is added.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   170
-- We use it to count the number of shots, which we
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   171
-- in turn use to calculate the final score and stats
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   172
function onGearAdd(gear)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   173
	if GetGearType(gear) == gtSniperRifleShot then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   174
		shots = shots + 1
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   175
	end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   176
end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   177
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   178
-- This function is called before a gear is destroyed.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   179
-- We use it to count the number of targets destroyed.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   180
function onGearDelete(gear)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   181
    
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   182
	if GetGearType(gear) == gtCase then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   183
		game_lost = true
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   184
		return
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   185
	end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   186
	
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   187
	if (GetGearType(gear) == gtTarget) then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   188
		-- remember when the target was hit for adjusting the camera
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   189
		last_hit_time = TurnTimeLeft
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   190
		-- Add one point to our score/counter
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   191
		score = score + 1
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   192
		-- If we haven't reached the goal ...
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   193
		if score < score_goal then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   194
			-- ... spawn another target.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   195
			if score == 1 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   196
				spawnTarget(1520,1350)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   197
			elseif score == 2 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   198
				spawnTarget(1730,1040)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   199
			elseif score == 3 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   200
				spawnTarget(2080,780)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   201
			elseif score == 4 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   202
				AddCaption(loc("Good so far!") .. " " .. loc("Keep it up!"));
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   203
				blowUp(1730,1226)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   204
				blowUp(1440,1595)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   205
				blowUp(1527,1575)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   206
				blowUp(1614,1595)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   207
				blowUp(1420,1675)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   208
				blowUp(1527,1675)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   209
				blowUp(1634,1675)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   210
				blowUp(1440,1755)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   211
				blowUp(1527,1775)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   212
				blowUp(1614,1755)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   213
				spawnTarget(1527,1667)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   214
			elseif score == 5 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   215
				spawnTarget(1527,1667)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   216
			elseif score == 6 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   217
				spawnTarget(2175,1300)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   218
			elseif score == 7 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   219
				spawnTarget(2250,940)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   220
			elseif score == 8 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   221
				spawnTarget(2665,1540)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   222
			elseif score == 9 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   223
				spawnTarget(3040,1160)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   224
			elseif score == 10 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   225
				spawnTarget(2930,1500)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   226
			elseif score == 11 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   227
				AddCaption(loc("This one's tricky."));
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   228
				spawnTarget(700,720)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   229
			elseif score == 12 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   230
				AddCaption(loc("Well done."));
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   231
				blowUp(914,1222)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   232
				blowUp(1050,1222)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   233
				blowUp(1160,1008)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   234
				blowUp(1160,1093)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   235
				blowUp(1160,1188)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   236
				blowUp(375,911)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   237
				blowUp(510,911)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   238
				blowUp(640,911)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   239
				blowUp(780,911)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   240
				blowUp(920,911)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   241
				blowUp(1060,913)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   242
				blowUp(1198,913)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   243
				spawnTarget(1200,730)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   244
			elseif score == 13 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   245
				spawnTarget(1200,830)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   246
			elseif score == 14 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   247
				spawnTarget(1430,450)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   248
			elseif score == 15 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   249
				spawnTarget(796,240)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   250
			elseif score == 16 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   251
				spawnTarget(300,10)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   252
			elseif score == 17 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   253
				spawnTarget(2080,820)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   254
			elseif score == 18 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   255
				AddCaption(loc("Demolition is fun!"));
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   256
				blowUp(2110,920)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   257
				blowUp(2210,920)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   258
				blowUp(2200,305)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   259
				blowUp(2300,305)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   260
				blowUp(2300,400)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   261
				blowUp(2300,500)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   262
				blowUp(2300,600)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   263
				blowUp(2300,700)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   264
				blowUp(2300,800)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   265
				blowUp(2300,900)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   266
				blowUp(2401,305)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   267
				blowUp(2532,305)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   268
				blowUp(2663,305)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   269
				spawnTarget(2300,760)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   270
			elseif score == 19 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   271
				spawnTarget(2300,760)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   272
			elseif score == 20 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   273
				spawnTarget(2738,190)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   274
			elseif score == 21 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   275
				spawnTarget(2590,-100)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   276
			elseif score == 22 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   277
				AddCaption(loc("Will this ever end?"));
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   278
				blowUp(2790,305)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   279
				blowUp(2930,305)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   280
				blowUp(3060,305)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   281
				blowUp(3190,305)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   282
				blowUp(3310,305)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   283
				blowUp(3393,613)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   284
				blowUp(2805,370)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   285
				blowUp(2805,500)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   286
				blowUp(2805,630)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   287
				blowUp(2805,760)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   288
				blowUp(2805,890)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   289
				blowUp(3258,370)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   290
				blowUp(3258,475)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   291
				blowUp(3264,575)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   292
				spawnTarget(3230,240)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   293
			elseif score == 23 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   294
				spawnTarget(3230,290)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   295
			elseif score == 24 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   296
				spawnTarget(3670,250)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   297
			elseif score == 25 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   298
				spawnTarget(2620,-100)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   299
			elseif score == 26 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   300
				spawnTarget(2870,300)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   301
			elseif score == 27 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   302
				spawnTarget(3850,900)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   303
			elseif score == 28 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   304
				spawnTarget(3780,300)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   305
			elseif score == 29 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   306
				spawnTarget(3670,0)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   307
			elseif score == 30 then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   308
				AddCaption(loc("Last Target!"));
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   309
				spawnTarget(3480,1200)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   310
			end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   311
		else
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   312
			if not game_lost then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   313
			-- Otherwise show that the goal was accomplished
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   314
			ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   315
			-- Also let the hogs shout "victory!"
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   316
			PlaySound(sndVictory)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   317
			-- Save the time left so we may keep it.
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   318
			time_goal = TurnTimeLeft
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   319
			end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   320
		end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   321
	end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   322
end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   323
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   324
-- This function calculates the final score of the player and provides some texts and
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   325
-- data for the final stats screen
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   326
function generateStats()
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   327
	local accuracy = (score/shots)*100
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   328
	local end_score_targets = (score * 200)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   329
	local end_score_overall
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   330
	if not game_lost then
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   331
		local end_score_time = math.ceil(time_goal/5)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   332
		local end_score_accuracy = math.ceil(accuracy * 100)
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   333
		end_score_overall = end_score_time + end_score_targets + end_score_accuracy
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   334
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   335
		SendStat(siGameResult, loc("You have successfully finished the sniper rifle training!"))
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   336
		SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), score, score_goal, end_score_targets))
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   337
		SendStat(siCustomAchievement, string.format(loc("You have made %d shots."), shots))
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   338
		SendStat(siCustomAchievement, string.format(loc("Accuracy bonus: +%d points"), end_score_accuracy))
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   339
		SendStat(siCustomAchievement, string.format(loc("You had %.2fs remaining on the clock (+%d points)."), (time_goal/1000), end_score_time))
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   340
	else
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   341
		SendStat(siGameResult, loc("You lose!"))
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   342
	
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   343
		SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), score, score_goal, end_score_targets))
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   344
		SendStat(siCustomAchievement, string.format(loc("You have made %d shots."), shots))
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   345
		end_score_overall = end_score_targets
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   346
	end
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   347
	SendStat(siPlayerKills, tostring(end_score_overall), loc("Sniperz"))
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   348
	SendStat(siPointType, loc("points"))
1c85a442bd56 Wuzzy's changes to stats for some of the training missions.
mikade <redgrinner@gmail.com>
parents: 10289
diff changeset
   349
end