101 - goalText: A short string explaining the goal of the mission |
101 - goalText: A short string explaining the goal of the mission |
102 (default: "Destroy all targets within the time!") |
102 (default: "Destroy all targets within the time!") |
103 - shootText: A string which says how many times the player shot, ā%dā is replaced |
103 - shootText: A string which says how many times the player shot, ā%dā is replaced |
104 by the number of shots. (default: "You have shot %d times.") |
104 by the number of shots. (default: "You have shot %d times.") |
105 ]] |
105 ]] |
|
106 |
|
107 |
|
108 local getTargetsScore = function() |
|
109 return scored * math.ceil(6000/#targets) |
|
110 end |
|
111 |
106 function TargetPracticeMission(params) |
112 function TargetPracticeMission(params) |
107 if params.hogHat == nil then params.hogHat = "NoHat" end |
113 if params.hogHat == nil then params.hogHat = "NoHat" end |
108 if params.hogName == nil then params.hogName = loc("Trainee") end |
114 if params.hogName == nil then params.hogName = loc("Trainee") end |
109 if params.teamName == nil then params.teamName = loc("Training Team") end |
115 if params.teamName == nil then params.teamName = loc("Training Team") end |
110 if params.goalText == nil then params.goalText = loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission.") end |
116 if params.goalText == nil then params.goalText = loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission.") end |
149 end |
155 end |
150 |
156 |
151 _G.onGameStart = function() |
157 _G.onGameStart = function() |
152 SendHealthStatsOff() |
158 SendHealthStatsOff() |
153 ShowMission(params.missionTitle, loc("Aiming practice"), params.goalText, -params.ammoType, 5000) |
159 ShowMission(params.missionTitle, loc("Aiming practice"), params.goalText, -params.ammoType, 5000) |
|
160 SetTeamLabel(params.teamName, "0") |
154 spawnTarget() |
161 spawnTarget() |
155 end |
162 end |
156 |
163 |
157 _G.onNewTurn = function() |
164 _G.onNewTurn = function() |
158 SetWeapon(params.ammoType) |
165 SetWeapon(params.ammoType) |
203 end |
210 end |
204 |
211 |
205 _G.onGearDamage = function(gear, damage) |
212 _G.onGearDamage = function(gear, damage) |
206 if GetGearType(gear) == gtTarget then |
213 if GetGearType(gear) == gtTarget then |
207 scored = scored + 1 |
214 scored = scored + 1 |
|
215 SetTeamLabel(params.teamName, tostring(getTargetsScore())) |
208 if scored < total_targets then |
216 if scored < total_targets then |
209 AddCaption(string.format(loc("Targets left: %d"), (total_targets-scored)), 0xFFFFFFFF, capgrpMessage) |
217 AddCaption(string.format(loc("Targets left: %d"), (total_targets-scored)), 0xFFFFFFFF, capgrpMessage) |
210 spawnTarget() |
218 spawnTarget() |
211 else |
219 else |
212 if not game_lost then |
220 if not game_lost then |
247 end |
255 end |
248 end |
256 end |
249 |
257 |
250 _G.generateStats = function() |
258 _G.generateStats = function() |
251 local accuracy = (scored/shots)*100 |
259 local accuracy = (scored/shots)*100 |
252 local end_score_targets = scored * math.ceil(6000/#targets) |
260 local end_score_targets = getTargetsScore() |
253 local end_score_overall |
261 local end_score_overall |
254 if not game_lost then |
262 if not game_lost then |
255 local end_score_time = math.ceil(time_goal/(params.time/6000)) |
263 local end_score_time = math.ceil(time_goal/(params.time/6000)) |
256 local end_score_accuracy = math.ceil(accuracy * 60) |
264 local end_score_accuracy = math.ceil(accuracy * 60) |
257 end_score_overall = end_score_time + end_score_targets + end_score_accuracy |
265 end_score_overall = end_score_time + end_score_targets + end_score_accuracy |
|
266 SetTeamLabel(params.teamName, tostring(end_score_overall)) |
258 |
267 |
259 SendStat(siGameResult, loc("You have finished the target practice!")) |
268 SendStat(siGameResult, loc("You have finished the target practice!")) |
260 |
269 |
261 SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), scored, total_targets, end_score_targets)) |
270 SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), scored, total_targets, end_score_targets)) |
262 SendStat(siCustomAchievement, string.format(params.shootText, shots)) |
271 SendStat(siCustomAchievement, string.format(params.shootText, shots)) |