33 procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean); |
33 procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean); |
34 procedure Skipped; |
34 procedure Skipped; |
35 procedure TurnReaction; |
35 procedure TurnReaction; |
36 procedure SendStats; |
36 procedure SendStats; |
37 procedure hedgehogFlight(Gear: PGear; time: Longword); |
37 procedure hedgehogFlight(Gear: PGear; time: Longword); |
|
38 procedure declareAchievement(id, teamname, location: shortstring; value: LongInt); |
38 |
39 |
39 implementation |
40 implementation |
40 uses uSound, uLocale, uVariables, uUtils, uIO, uCaptions, uDebug, uMisc, uConsole; |
41 uses uSound, uLocale, uVariables, uUtils, uIO, uCaptions, uDebug, uMisc, uConsole, uScript; |
41 |
42 |
42 var DamageClan : Longword = 0; |
43 var DamageClan : Longword = 0; |
43 DamageTotal : Longword = 0; |
44 DamageTotal : Longword = 0; |
44 DamageTurn : Longword = 0; |
45 DamageTurn : Longword = 0; |
45 KillsClan : LongWord = 0; |
46 KillsClan : LongWord = 0; |
208 maxTeamDamage : Longword; |
209 maxTeamDamage : Longword; |
209 maxTeamDamageName : shortstring; |
210 maxTeamDamageName : shortstring; |
210 winnersClan : PClan; |
211 winnersClan : PClan; |
211 begin |
212 begin |
212 if SendHealthStatsOn then |
213 if SendHealthStatsOn then |
213 msd:= 0; msdhh:= nil; |
214 msd:= 0; msdhh:= nil; |
214 msk:= 0; mskhh:= nil; |
215 msk:= 0; mskhh:= nil; |
215 mskcnt:= 0; |
216 mskcnt:= 0; |
216 maxTeamKills := 0; |
217 maxTeamKills := 0; |
217 maxTurnSkips := 0; |
218 maxTurnSkips := 0; |
218 maxTeamDamage := 0; |
219 maxTeamDamage := 0; |
219 winnersClan:= nil; |
220 winnersClan:= nil; |
220 |
221 |
221 for t:= 0 to Pred(TeamsCount) do |
222 for t:= 0 to Pred(TeamsCount) do |
222 with TeamsArray[t]^ do |
223 with TeamsArray[t]^ do |
223 begin |
224 begin |
224 if not ExtDriven then |
225 if not ExtDriven then |
225 SendStat(siTeamStats, GetTeamStatString(TeamsArray[t])); |
226 SendStat(siTeamStats, GetTeamStatString(TeamsArray[t])); |
226 for i:= 0 to cMaxHHIndex do |
227 for i:= 0 to cMaxHHIndex do |
227 begin |
228 begin |
228 if Hedgehogs[i].stats.MaxStepDamageGiven > msd then |
229 if Hedgehogs[i].stats.MaxStepDamageGiven > msd then |
229 begin |
230 begin |
230 msdhh:= @Hedgehogs[i]; |
231 msdhh:= @Hedgehogs[i]; |
231 msd:= Hedgehogs[i].stats.MaxStepDamageGiven |
232 msd:= Hedgehogs[i].stats.MaxStepDamageGiven |
232 end; |
233 end; |
233 if Hedgehogs[i].stats.MaxStepKills >= msk then |
234 if Hedgehogs[i].stats.MaxStepKills >= msk then |
234 if Hedgehogs[i].stats.MaxStepKills = msk then |
235 if Hedgehogs[i].stats.MaxStepKills = msk then |
235 inc(mskcnt) |
236 inc(mskcnt) |
236 else |
237 else |
237 begin |
238 begin |
238 mskcnt:= 1; |
239 mskcnt:= 1; |
239 mskhh:= @Hedgehogs[i]; |
240 mskhh:= @Hedgehogs[i]; |
240 msk:= Hedgehogs[i].stats.MaxStepKills |
241 msk:= Hedgehogs[i].stats.MaxStepKills |
241 end; |
242 end; |
242 end; |
243 end; |
243 |
244 |
244 { send player stats for winner teams } |
245 { send player stats for winner teams } |
245 if Clan^.ClanHealth > 0 then |
246 if Clan^.ClanHealth > 0 then |
246 begin |
247 begin |
247 winnersClan:= Clan; |
248 winnersClan:= Clan; |
248 SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' + |
249 SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' + |
249 IntToStr(stats.Kills) + ' ' + TeamName); |
250 IntToStr(stats.Kills) + ' ' + TeamName); |
250 end; |
251 end; |
251 |
252 |
252 { determine maximum values of TeamKills, TurnSkips, TeamDamage } |
253 { determine maximum values of TeamKills, TurnSkips, TeamDamage } |
253 if stats.TeamKills > maxTeamKills then |
254 if stats.TeamKills > maxTeamKills then |
254 begin |
255 begin |
255 maxTeamKills := stats.TeamKills; |
256 maxTeamKills := stats.TeamKills; |
256 maxTeamKillsName := TeamName; |
257 maxTeamKillsName := TeamName; |
257 end; |
258 end; |
258 if stats.TurnSkips > maxTurnSkips then |
259 if stats.TurnSkips > maxTurnSkips then |
259 begin |
260 begin |
260 maxTurnSkips := stats.TurnSkips; |
261 maxTurnSkips := stats.TurnSkips; |
261 maxTurnSkipsName := TeamName; |
262 maxTurnSkipsName := TeamName; |
262 end; |
263 end; |
263 if stats.TeamDamage > maxTeamDamage then |
264 if stats.TeamDamage > maxTeamDamage then |
264 begin |
265 begin |
265 maxTeamDamage := stats.TeamDamage; |
266 maxTeamDamage := stats.TeamDamage; |
266 maxTeamDamageName := TeamName; |
267 maxTeamDamageName := TeamName; |
267 end; |
268 end; |
268 |
269 |
269 end; |
270 end; |
270 |
271 |
271 { now send player stats for loser teams } |
272 { now send player stats for loser teams } |
272 for t:= 0 to Pred(TeamsCount) do |
273 for t:= 0 to Pred(TeamsCount) do |
273 begin |
274 begin |
274 with TeamsArray[t]^ do |
275 with TeamsArray[t]^ do |
275 begin |
276 begin |
276 if Clan^.ClanHealth = 0 then |
277 if Clan^.ClanHealth = 0 then |
277 begin |
278 begin |
278 SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' + |
279 SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' + |
279 IntToStr(stats.Kills) + ' ' + TeamName); |
280 IntToStr(stats.Kills) + ' ' + TeamName); |
280 end; |
281 end; |
281 end; |
282 end; |
282 end; |
283 end; |
283 |
284 |
284 if msdhh <> nil then |
285 if msdhh <> nil then |
285 SendStat(siMaxStepDamage, IntToStr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')'); |
286 SendStat(siMaxStepDamage, IntToStr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')'); |
286 if mskcnt = 1 then |
287 if mskcnt = 1 then |
287 SendStat(siMaxStepKills, IntToStr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')'); |
288 SendStat(siMaxStepKills, IntToStr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')'); |
288 |
289 |
289 if maxTeamKills > 1 then |
290 if maxTeamKills > 1 then |
290 SendStat(siMaxTeamKills, IntToStr(maxTeamKills) + ' ' + maxTeamKillsName); |
291 SendStat(siMaxTeamKills, IntToStr(maxTeamKills) + ' ' + maxTeamKillsName); |
291 if maxTurnSkips > 2 then |
292 if maxTurnSkips > 2 then |
292 SendStat(siMaxTurnSkips, IntToStr(maxTurnSkips) + ' ' + maxTurnSkipsName); |
293 SendStat(siMaxTurnSkips, IntToStr(maxTurnSkips) + ' ' + maxTurnSkipsName); |
293 if maxTeamDamage > 30 then |
294 if maxTeamDamage > 30 then |
294 SendStat(siMaxTeamDamage, IntToStr(maxTeamDamage) + ' ' + maxTeamDamageName); |
295 SendStat(siMaxTeamDamage, IntToStr(maxTeamDamage) + ' ' + maxTeamDamageName); |
295 |
296 |
296 if KilledHHs > 0 then |
297 if KilledHHs > 0 then |
297 SendStat(siKilledHHs, IntToStr(KilledHHs)); |
298 SendStat(siKilledHHs, IntToStr(KilledHHs)); |
298 |
299 |
299 // now to console |
300 // now to console |
300 if winnersClan <> nil then |
301 if winnersClan <> nil then |
301 begin |
302 begin |
302 WriteLnToConsole('WINNERS'); |
303 WriteLnToConsole('WINNERS'); |
303 for t:= 0 to winnersClan^.TeamsNumber - 1 do |
304 WriteLnToConsole(inttostr(winnersClan^.TeamsNumber)); |
304 WriteLnToConsole(winnersClan^.Teams[t]^.TeamName); |
305 for t:= 0 to winnersClan^.TeamsNumber - 1 do |
305 end |
306 WriteLnToConsole(winnersClan^.Teams[t]^.TeamName); |
306 else |
307 end |
307 WriteLnToConsole('DRAW'); |
308 else |
308 |
309 WriteLnToConsole('DRAW'); |
309 WriteLnToConsole(''); |
310 |
|
311 ScriptCall('onAchievementsDeclaration'); |
|
312 end; |
|
313 |
|
314 procedure declareAchievement(id, teamname, location: shortstring; value: LongInt); |
|
315 begin |
|
316 if (length(id) = 0) or (length(teamname) = 0) or (length(location) = 0) then exit; |
|
317 WriteLnToConsole('ACHIEVEMENT'); |
|
318 WriteLnToConsole(id); |
|
319 WriteLnToConsole(teamname); |
|
320 WriteLnToConsole(location); |
|
321 WriteLnToConsole(inttostr(value)); |
310 end; |
322 end; |
311 |
323 |
312 procedure initModule; |
324 procedure initModule; |
313 begin |
325 begin |
314 TotalRounds:= -1; |
326 TotalRounds:= -1; |