77 end |
80 end |
78 |
81 |
79 for i=0, ClansCount-1 do |
82 for i=0, ClansCount-1 do |
80 clantimes[i] = 0 |
83 clantimes[i] = 0 |
81 end |
84 end |
|
85 SendAchievementsStatsOff() |
82 end |
86 end |
83 |
87 |
84 function onAmmoStoreInit() |
88 function onAmmoStoreInit() |
85 SetAmmo(amRope, 9, 1, 0) |
89 SetAmmo(amRope, 9, 1, 0) |
86 SetAmmo(amSkip, 9, 1, 0) |
90 SetAmmo(amSkip, 9, 1, 0) |
199 end |
203 end |
200 end |
204 end |
201 end |
205 end |
202 end |
206 end |
203 |
207 |
|
208 function WriteStats() |
|
209 if besthog then |
|
210 SendStat(siCustomAchievement, string.format(loc("The fastest hedgehog was %s from %s with a time of %.3fs."), besthogname, GetHogTeamName(besthog), besttime/1000)) |
|
211 else |
|
212 SendStat(siCustomAchievement, loc("Nobody managed to finish the race. What a shame!")) |
|
213 end |
|
214 |
|
215 -- Write most skips |
|
216 local mostSkips = 2 -- a minimum skip threshold is required |
|
217 local mostSkipsTeam = nil |
|
218 for i=0, TeamsCount-1 do |
|
219 local teamName = GetTeamName(i) |
|
220 local stats = GetTeamStats(teamName) |
|
221 if stats.TurnSkips > mostSkips then |
|
222 mostSkips = stats.TurnSkips |
|
223 mostSkipsTeam = teamName |
|
224 end |
|
225 end |
|
226 if mostSkipsTeam then |
|
227 SendStat(siMaxTurnSkips, tostring(mostSkips) .. " " .. mostSkipsTeam) |
|
228 end |
|
229 end |
|
230 |
204 function onGearAdd(gear) |
231 function onGearAdd(gear) |
205 if GetGearType(gear) == gtHedgehog then |
232 if GetGearType(gear) == gtHedgehog then |
206 hhs[numhhs] = gear |
233 hhs[numhhs] = gear |
207 times[numhhs] = 0 |
234 times[numhhs] = 0 |
208 numhhs = numhhs + 1 |
235 numhhs = numhhs + 1 |
|
236 local clan = GetHogClan(gear) |
|
237 if not hogsByClan[clan] then |
|
238 hogsByClan[clan] = 0 |
|
239 end |
|
240 hogsByClan[clan] = hogsByClan[clan] + 1 |
|
241 end |
|
242 end |
|
243 |
|
244 function areTwoOrMoreClansLeft() |
|
245 local clans = 0 |
|
246 for i=0, ClansCount-1 do |
|
247 if hogsByClan[i] >= 1 then |
|
248 clans = clans + 1 |
|
249 end |
|
250 if clans >= 2 then |
|
251 return true |
|
252 end |
|
253 end |
|
254 return false |
|
255 end |
|
256 |
|
257 function onGearDelete(gear) |
|
258 if GetGearType(gear) == gtHedgehog then |
|
259 local clan = GetHogClan(gear) |
|
260 |
|
261 hogsByClan[clan] = hogsByClan[clan] - 1 |
|
262 if not areTwoOrMoreClansLeft() then |
|
263 WriteStats() |
|
264 end |
209 end |
265 end |
210 end |
266 end |
211 |
267 |
212 function onAchievementsDeclaration() |
268 function onAchievementsDeclaration() |
213 for team,time in pairs(bestTimes) do |
269 for team,time in pairs(bestTimes) do |
214 DeclareAchievement("rope race", team, "TrophyRace", time) |
270 DeclareAchievement("rope race", team, "TrophyRace", time) |
215 end |
271 end |
216 end |
272 end |
|
273 |