47 procedure SendStats; |
47 procedure SendStats; |
48 |
48 |
49 implementation |
49 implementation |
50 uses uTeams, uSound, uMisc, uLocale, uWorld; |
50 uses uTeams, uSound, uMisc, uLocale, uWorld; |
51 var DamageGiven : Longword = 0; |
51 var DamageGiven : Longword = 0; |
52 DamageClan : Longword = 0; |
52 DamageClan : Longword = 0; |
53 DamageTotal : Longword = 0; |
53 DamageTotal : Longword = 0; |
54 KillsClan : LongWord = 0; |
54 KillsClan : LongWord = 0; |
55 Kills : LongWord = 0; |
55 Kills : LongWord = 0; |
56 KillsTotal : LongWord = 0; |
56 KillsTotal : LongWord = 0; |
57 AmmoUsedCount : Longword = 0; |
57 AmmoUsedCount : Longword = 0; |
58 AmmoDamagingUsed : boolean = false; |
58 AmmoDamagingUsed : boolean = false; |
59 SkippedTurns: LongWord = 0; |
59 SkippedTurns: LongWord = 0; |
60 isTurnSkipped: boolean = false; |
60 isTurnSkipped: boolean = false; |
61 vpHurtSameClan: PVoicepack = nil; |
61 vpHurtSameClan: PVoicepack = nil; |
62 vpHurtEnemy: PVoicepack = nil; |
62 vpHurtEnemy: PVoicepack = nil; |
63 |
63 |
64 procedure HedgehogDamaged(Gear: PGear); |
64 procedure HedgehogDamaged(Gear: PGear); |
65 begin |
65 begin |
66 if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then |
66 if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then |
67 vpHurtSameClan:= CurrentHedgehog^.Team^.voicepack |
67 vpHurtSameClan:= CurrentHedgehog^.Team^.voicepack |
68 else |
68 else |
69 vpHurtEnemy:= PHedgehog(Gear^.Hedgehog)^.Team^.voicepack; |
69 vpHurtEnemy:= PHedgehog(Gear^.Hedgehog)^.Team^.voicepack; |
70 |
70 |
71 if bBetweenTurns then exit; |
71 if bBetweenTurns then exit; |
72 |
72 |
73 ////////////////////////// |
73 ////////////////////////// |
74 |
74 |
75 if Gear <> CurrentHedgehog^.Gear then |
75 if Gear <> CurrentHedgehog^.Gear then |
76 inc(CurrentHedgehog^.stats.StepDamageGiven, Gear^.Damage); |
76 inc(CurrentHedgehog^.stats.StepDamageGiven, Gear^.Damage); |
77 |
77 |
78 if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(DamageClan, Gear^.Damage); |
78 if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(DamageClan, Gear^.Damage); |
79 |
79 |
80 if Gear^.Health <= Gear^.Damage then |
80 if Gear^.Health <= Gear^.Damage then |
81 begin |
81 begin |
82 inc(CurrentHedgehog^.stats.StepKills); |
82 inc(CurrentHedgehog^.stats.StepKills); |
83 inc(Kills); |
83 inc(Kills); |
84 inc(KillsTotal); |
84 inc(KillsTotal); |
85 if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan); |
85 if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan); |
86 end; |
86 end; |
87 |
87 |
88 inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Gear^.Damage); |
88 inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Gear^.Damage); |
89 inc(DamageGiven, Gear^.Damage); |
89 inc(DamageGiven, Gear^.Damage); |
90 inc(DamageTotal, Gear^.Damage) |
90 inc(DamageTotal, Gear^.Damage) |
91 end; |
91 end; |
101 begin |
101 begin |
102 TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true); |
102 TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true); |
103 |
103 |
104 inc(FinishedTurnsTotal); |
104 inc(FinishedTurnsTotal); |
105 if FinishedTurnsTotal <> 0 then |
105 if FinishedTurnsTotal <> 0 then |
106 begin |
106 begin |
107 inc(CurrentHedgehog^.stats.FinishedTurns); |
107 inc(CurrentHedgehog^.stats.FinishedTurns); |
108 |
108 |
109 if (DamageGiven = DamageTotal) and (DamageTotal > 0) then |
109 if (DamageGiven = DamageTotal) and (DamageTotal > 0) then |
110 PlaySound(sndFirstBlood, CurrentTeam^.voicepack) |
110 PlaySound(sndFirstBlood, CurrentTeam^.voicepack) |
111 |
111 |
112 else if CurrentHedgehog^.stats.StepDamageRecv > 0 then |
112 else if CurrentHedgehog^.stats.StepDamageRecv > 0 then |
113 begin |
113 begin |
114 PlaySound(sndStupid, PreviousTeam^.voicepack); |
114 PlaySound(sndStupid, PreviousTeam^.voicepack); |
115 if DamageGiven = CurrentHedgehog^.stats.StepDamageRecv then AddCaption(Format(GetEventString(eidHurtSelf), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage); |
115 if DamageGiven = CurrentHedgehog^.stats.StepDamageRecv then AddCaption(Format(GetEventString(eidHurtSelf), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage); |
116 end |
116 end |
117 else if DamageClan <> 0 then |
117 else if DamageClan <> 0 then |
118 if DamageTotal > DamageClan then |
118 if DamageTotal > DamageClan then |
119 if random(2) = 0 then |
119 if random(2) = 0 then |
120 PlaySound(sndNutter, CurrentTeam^.voicepack) |
120 PlaySound(sndNutter, CurrentTeam^.voicepack) |
121 else |
121 else |
122 PlaySound(sndWatchIt, vpHurtSameClan) |
122 PlaySound(sndWatchIt, vpHurtSameClan) |
123 else |
123 else |
124 if random(2) = 0 then |
124 if random(2) = 0 then |
125 PlaySound(sndSameTeam, vpHurtSameClan) |
125 PlaySound(sndSameTeam, vpHurtSameClan) |
126 else |
126 else |
127 PlaySound(sndTraitor, vpHurtSameClan) |
127 PlaySound(sndTraitor, vpHurtSameClan) |
128 else if DamageGiven <> 0 then |
128 else if DamageGiven <> 0 then |
129 if Kills > 0 then |
129 if Kills > 0 then |
130 PlaySound(sndEnemyDown, CurrentTeam^.voicepack) |
130 PlaySound(sndEnemyDown, CurrentTeam^.voicepack) |
131 else |
131 else |
132 PlaySound(sndRegret, vpHurtEnemy) |
132 PlaySound(sndRegret, vpHurtEnemy) |
133 |
133 |
134 else if AmmoDamagingUsed then |
134 else if AmmoDamagingUsed then |
135 PlaySound(sndMissed, PreviousTeam^.voicepack) |
135 PlaySound(sndMissed, PreviousTeam^.voicepack) |
136 else if (AmmoUsedCount > 0) and not isTurnSkipped then |
136 else if (AmmoUsedCount > 0) and not isTurnSkipped then |
137 // nothing ? |
137 // nothing ? |
138 else if isTurnSkipped then |
138 else if isTurnSkipped then |
139 begin |
139 begin |
140 PlaySound(sndBoring, PreviousTeam^.voicepack); |
140 PlaySound(sndBoring, PreviousTeam^.voicepack); |
141 AddCaption(Format(GetEventString(eidTurnSkipped), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage); |
141 AddCaption(Format(GetEventString(eidTurnSkipped), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage); |
142 end |
142 end |
143 else if not PlacingHogs then |
143 else if not PlacingHogs then |
144 PlaySound(sndCoward, PreviousTeam^.voicepack); |
144 PlaySound(sndCoward, PreviousTeam^.voicepack); |
145 end; |
145 end; |
146 |
146 |
147 |
147 |
148 for t:= 0 to Pred(TeamsCount) do // send even on zero turn |
148 for t:= 0 to Pred(TeamsCount) do // send even on zero turn |
149 with TeamsArray[t]^ do |
149 with TeamsArray[t]^ do |
150 for i:= 0 to cMaxHHIndex do |
150 for i:= 0 to cMaxHHIndex do |
151 with Hedgehogs[i].stats do |
151 with Hedgehogs[i].stats do |
152 begin |
152 begin |
153 inc(DamageRecv, StepDamageRecv); |
153 inc(DamageRecv, StepDamageRecv); |
154 inc(DamageGiven, StepDamageGiven); |
154 inc(DamageGiven, StepDamageGiven); |
155 if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv; |
155 if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv; |
156 if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven; |
156 if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven; |
157 if StepKills > MaxStepKills then MaxStepKills:= StepKills; |
157 if StepKills > MaxStepKills then MaxStepKills:= StepKills; |
158 StepKills:= 0; |
158 StepKills:= 0; |
159 StepDamageRecv:= 0; |
159 StepDamageRecv:= 0; |
160 StepDamageGiven:= 0 |
160 StepDamageGiven:= 0 |
161 end; |
161 end; |
162 |
162 |
163 for t:= 0 to Pred(ClansCount) do |
163 for t:= 0 to Pred(ClansCount) do |
164 with ClansArray[t]^ do |
164 with ClansArray[t]^ do |
165 begin |
165 begin |
166 SendStat(siClanHealth, inttostr(Color) + ' ' + inttostr(ClanHealth)); |
166 SendStat(siClanHealth, inttostr(Color) + ' ' + inttostr(ClanHealth)); |
167 end; |
167 end; |
168 |
168 |
169 Kills:= 0; |
169 Kills:= 0; |
170 KillsClan:= 0; |
170 KillsClan:= 0; |
171 DamageGiven:= 0; |
171 DamageGiven:= 0; |
172 DamageClan:= 0; |
172 DamageClan:= 0; |
189 msd:= 0; msdhh:= nil; |
189 msd:= 0; msdhh:= nil; |
190 msk:= 0; mskhh:= nil; |
190 msk:= 0; mskhh:= nil; |
191 mskcnt:= 0; |
191 mskcnt:= 0; |
192 |
192 |
193 for t:= 0 to Pred(TeamsCount) do |
193 for t:= 0 to Pred(TeamsCount) do |
194 with TeamsArray[t]^ do |
194 with TeamsArray[t]^ do |
195 begin |
195 begin |
196 for i:= 0 to cMaxHHIndex do |
196 for i:= 0 to cMaxHHIndex do |
197 begin |
197 begin |
198 if Hedgehogs[i].stats.MaxStepDamageGiven > msd then |
198 if Hedgehogs[i].stats.MaxStepDamageGiven > msd then |
199 begin |
199 begin |
200 msdhh:= @Hedgehogs[i]; |
200 msdhh:= @Hedgehogs[i]; |
201 msd:= Hedgehogs[i].stats.MaxStepDamageGiven |
201 msd:= Hedgehogs[i].stats.MaxStepDamageGiven |
202 end; |
202 end; |
203 if Hedgehogs[i].stats.MaxStepKills >= msk then |
203 if Hedgehogs[i].stats.MaxStepKills >= msk then |
204 if Hedgehogs[i].stats.MaxStepKills = msk then |
204 if Hedgehogs[i].stats.MaxStepKills = msk then |
205 inc(mskcnt) |
205 inc(mskcnt) |
206 else |
206 else |
207 begin |
207 begin |
208 mskcnt:= 1; |
208 mskcnt:= 1; |
209 mskhh:= @Hedgehogs[i]; |
209 mskhh:= @Hedgehogs[i]; |
210 msk:= Hedgehogs[i].stats.MaxStepKills |
210 msk:= Hedgehogs[i].stats.MaxStepKills |
211 end; |
211 end; |
212 end |
212 end |
213 end; |
213 end; |
214 if msdhh <> nil then |
214 if msdhh <> nil then |
215 SendStat(siMaxStepDamage, inttostr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')'); |
215 SendStat(siMaxStepDamage, inttostr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')'); |
216 if mskcnt = 1 then |
216 if mskcnt = 1 then |
217 SendStat(siMaxStepKills, inttostr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')'); |
217 SendStat(siMaxStepKills, inttostr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')'); |
218 |
218 |
219 if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs)); |
219 if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs)); |
220 end; |
220 end; |
221 |
221 |
222 procedure init_uStats; |
222 procedure init_uStats; |
223 begin |
223 begin |
224 TotalRounds:= -1; |
224 TotalRounds:= -1; |
225 FinishedTurnsTotal:= -1; |
225 FinishedTurnsTotal:= -1; |
226 end; |
226 end; |
227 |
227 |
228 procedure free_uStats; |
228 procedure free_uStats; |
229 begin |
229 begin |
230 |
230 |