author | nemo |
Thu, 07 Jan 2010 16:12:26 +0000 | |
changeset 2679 | b61d25fa6c53 |
parent 2630 | 079ef82eac75 |
child 2712 | 8f4527c9137c |
permissions | -rw-r--r-- |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
3 |
* Copyright (c) 2008 Andrey Korotaev <unC0Rr@gmail.com> |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
4 |
* |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
8 |
* |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
13 |
* |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
17 |
*) |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
18 |
|
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
21 |
unit uStats; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
22 |
interface |
829 | 23 |
uses uGears, uConsts; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
24 |
|
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
25 |
type TStatistics = record |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
26 |
DamageRecv, |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
27 |
DamageGiven: Longword; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
28 |
StepDamageRecv, |
869 | 29 |
StepDamageGiven, |
30 |
StepKills: Longword; |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
31 |
MaxStepDamageRecv, |
869 | 32 |
MaxStepDamageGiven, |
33 |
MaxStepKills: Longword; |
|
815 | 34 |
FinishedTurns: Longword; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
35 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
36 |
|
829 | 37 |
procedure AmmoUsed(am: TAmmoType); |
867 | 38 |
procedure HedgehogDamaged(Gear: PGear); |
871 | 39 |
procedure Skipped; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
40 |
procedure TurnReaction; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
41 |
procedure SendStats; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
42 |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1054
diff
changeset
|
43 |
var |
1070 | 44 |
TotalRounds: LongInt = -1; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1054
diff
changeset
|
45 |
FinishedTurnsTotal: LongInt = -1; |
1054 | 46 |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
47 |
implementation |
2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
1723
diff
changeset
|
48 |
uses uTeams, uSound, uMisc, uLocale, uWorld; |
815 | 49 |
var DamageGiven : Longword = 0; |
1678 | 50 |
DamageClan : Longword = 0; |
51 |
DamageTotal : Longword = 0; |
|
52 |
KillsClan : LongWord = 0; |
|
53 |
Kills : LongWord = 0; |
|
54 |
KillsTotal : LongWord = 0; |
|
55 |
AmmoUsedCount : Longword = 0; |
|
56 |
AmmoDamagingUsed : boolean = false; |
|
57 |
SkippedTurns: LongWord = 0; |
|
58 |
isTurnSkipped: boolean = false; |
|
59 |
vpHurtSameClan: PVoicepack = nil; |
|
60 |
vpHurtEnemy: PVoicepack = nil; |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
61 |
|
867 | 62 |
procedure HedgehogDamaged(Gear: PGear); |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
63 |
begin |
1678 | 64 |
if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then |
65 |
vpHurtSameClan:= CurrentHedgehog^.Team^.voicepack |
|
66 |
else |
|
1723 | 67 |
vpHurtEnemy:= PHedgehog(Gear^.Hedgehog)^.Team^.voicepack; |
1678 | 68 |
|
1054 | 69 |
if bBetweenTurns then exit; |
70 |
||
1678 | 71 |
////////////////////////// |
72 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
73 |
if Gear <> CurrentHedgehog^.Gear then |
867 | 74 |
inc(CurrentHedgehog^.stats.StepDamageGiven, Gear^.Damage); |
815 | 75 |
|
867 | 76 |
if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(DamageClan, Gear^.Damage); |
815 | 77 |
|
867 | 78 |
if Gear^.Health <= Gear^.Damage then |
79 |
begin |
|
869 | 80 |
inc(CurrentHedgehog^.stats.StepKills); |
867 | 81 |
inc(Kills); |
82 |
inc(KillsTotal); |
|
83 |
if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan); |
|
84 |
end; |
|
815 | 85 |
|
867 | 86 |
inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Gear^.Damage); |
87 |
inc(DamageGiven, Gear^.Damage); |
|
88 |
inc(DamageTotal, Gear^.Damage) |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
89 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
90 |
|
871 | 91 |
procedure Skipped; |
92 |
begin |
|
93 |
inc(SkippedTurns); |
|
94 |
isTurnSkipped:= true |
|
95 |
end; |
|
96 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
97 |
procedure TurnReaction; |
874 | 98 |
var i, t: LongInt; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
99 |
begin |
1054 | 100 |
TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true); |
101 |
||
870 | 102 |
inc(FinishedTurnsTotal); |
1625 | 103 |
if FinishedTurnsTotal <> 0 then |
104 |
begin |
|
105 |
inc(CurrentHedgehog^.stats.FinishedTurns); |
|
870 | 106 |
|
1625 | 107 |
if (DamageGiven = DamageTotal) and (DamageTotal > 0) then |
1669 | 108 |
PlaySound(sndFirstBlood, false, CurrentTeam^.voicepack) |
815 | 109 |
|
1625 | 110 |
else if CurrentHedgehog^.stats.StepDamageRecv > 0 then |
2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
1723
diff
changeset
|
111 |
begin |
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
1723
diff
changeset
|
112 |
PlaySound(sndStupid, false, PreviousTeam^.voicepack); |
2619 | 113 |
if DamageGiven = CurrentHedgehog^.stats.StepDamageRecv then AddCaption(Format(GetEventString(eidHurtSelf), CurrentHedgehog^.Name), cWhiteColor, capgrpGameState); |
2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
1723
diff
changeset
|
114 |
end |
1625 | 115 |
else if DamageClan <> 0 then |
116 |
if DamageTotal > DamageClan then |
|
117 |
if random(2) = 0 then |
|
1669 | 118 |
PlaySound(sndNutter, false, CurrentTeam^.voicepack) |
1625 | 119 |
else |
1678 | 120 |
PlaySound(sndWatchIt, false, vpHurtSameClan) |
1625 | 121 |
else |
122 |
if random(2) = 0 then |
|
1678 | 123 |
PlaySound(sndSameTeam, false, vpHurtSameClan) |
1625 | 124 |
else |
1678 | 125 |
PlaySound(sndTraitor, false, vpHurtSameClan) |
1625 | 126 |
else if DamageGiven <> 0 then |
127 |
if Kills > 0 then |
|
1669 | 128 |
PlaySound(sndEnemyDown, false, CurrentTeam^.voicepack) |
873 | 129 |
else |
1678 | 130 |
PlaySound(sndRegret, false, vpHurtEnemy) |
1625 | 131 |
|
132 |
else if AmmoDamagingUsed then |
|
1678 | 133 |
PlaySound(sndMissed, false, PreviousTeam^.voicepack) |
1625 | 134 |
else if (AmmoUsedCount > 0) and not isTurnSkipped then |
135 |
// nothing ? |
|
136 |
else if isTurnSkipped then |
|
2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
1723
diff
changeset
|
137 |
begin |
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
1723
diff
changeset
|
138 |
PlaySound(sndBoring, false, PreviousTeam^.voicepack); |
2619 | 139 |
AddCaption(Format(GetEventString(eidTurnSkipped), CurrentHedgehog^.Name), cWhiteColor, capgrpGameState); |
2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
1723
diff
changeset
|
140 |
end |
864 | 141 |
else |
1678 | 142 |
PlaySound(sndCoward, false, PreviousTeam^.voicepack); |
1625 | 143 |
end; |
870 | 144 |
|
815 | 145 |
|
1625 | 146 |
for t:= 0 to Pred(TeamsCount) do // send even on zero turn |
869 | 147 |
with TeamsArray[t]^ do |
148 |
for i:= 0 to cMaxHHIndex do |
|
149 |
with Hedgehogs[i].stats do |
|
150 |
begin |
|
151 |
inc(DamageRecv, StepDamageRecv); |
|
152 |
inc(DamageGiven, StepDamageGiven); |
|
153 |
if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv; |
|
154 |
if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven; |
|
155 |
if StepKills > MaxStepKills then MaxStepKills:= StepKills; |
|
871 | 156 |
StepKills:= 0; |
869 | 157 |
StepDamageRecv:= 0; |
158 |
StepDamageGiven:= 0 |
|
159 |
end; |
|
815 | 160 |
|
1625 | 161 |
for t:= 0 to Pred(ClansCount) do |
162 |
with ClansArray[t]^ do |
|
163 |
begin |
|
164 |
SendStat(siClanHealth, inttostr(Color) + ' ' + inttostr(ClanHealth)); |
|
165 |
end; |
|
166 |
||
867 | 167 |
Kills:= 0; |
168 |
KillsClan:= 0; |
|
815 | 169 |
DamageGiven:= 0; |
830
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
170 |
DamageClan:= 0; |
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
171 |
AmmoUsedCount:= 0; |
871 | 172 |
AmmoDamagingUsed:= false; |
173 |
isTurnSkipped:= false |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
174 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
175 |
|
829 | 176 |
procedure AmmoUsed(am: TAmmoType); |
177 |
begin |
|
830
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
178 |
inc(AmmoUsedCount); |
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
179 |
AmmoDamagingUsed:= AmmoDamagingUsed or Ammoz[am].isDamaging |
829 | 180 |
end; |
181 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
182 |
procedure SendStats; |
858 | 183 |
var i, t: LongInt; |
869 | 184 |
msd, msk: Longword; msdhh, mskhh: PHedgehog; |
185 |
mskcnt: Longword; |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
186 |
begin |
858 | 187 |
msd:= 0; msdhh:= nil; |
869 | 188 |
msk:= 0; mskhh:= nil; |
189 |
mskcnt:= 0; |
|
190 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
191 |
for t:= 0 to Pred(TeamsCount) do |
869 | 192 |
with TeamsArray[t]^ do |
193 |
begin |
|
194 |
for i:= 0 to cMaxHHIndex do |
|
195 |
begin |
|
196 |
if Hedgehogs[i].stats.MaxStepDamageGiven > msd then |
|
197 |
begin |
|
198 |
msdhh:= @Hedgehogs[i]; |
|
199 |
msd:= Hedgehogs[i].stats.MaxStepDamageGiven |
|
200 |
end; |
|
201 |
if Hedgehogs[i].stats.MaxStepKills >= msk then |
|
202 |
if Hedgehogs[i].stats.MaxStepKills = msk then |
|
203 |
inc(mskcnt) |
|
204 |
else |
|
205 |
begin |
|
206 |
mskcnt:= 1; |
|
207 |
mskhh:= @Hedgehogs[i]; |
|
208 |
msk:= Hedgehogs[i].stats.MaxStepKills |
|
209 |
end; |
|
210 |
end |
|
211 |
end; |
|
212 |
if msdhh <> nil then |
|
213 |
SendStat(siMaxStepDamage, inttostr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')'); |
|
214 |
if mskcnt = 1 then |
|
215 |
SendStat(siMaxStepKills, inttostr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')'); |
|
216 |
||
858 | 217 |
if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs)); |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
218 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
219 |
|
2619 | 220 |
end. |