author | unc0rr |
Thu, 24 Apr 2008 20:53:35 +0000 | |
changeset 869 | daddcd31ef34 |
parent 867 | dc7901b1120e |
child 870 | dd418d9c18c5 |
permissions | -rw-r--r-- |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
1 |
(* |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
2 |
* Hedgewars, a worms-like game |
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 |
|
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
19 |
unit uStats; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
20 |
interface |
829 | 21 |
uses uGears, uConsts; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
22 |
|
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
23 |
type TStatistics = record |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
24 |
DamageRecv, |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
25 |
DamageGiven: Longword; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
26 |
StepDamageRecv, |
869 | 27 |
StepDamageGiven, |
28 |
StepKills: Longword; |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
29 |
MaxStepDamageRecv, |
869 | 30 |
MaxStepDamageGiven, |
31 |
MaxStepKills: Longword; |
|
815 | 32 |
FinishedTurns: Longword; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
33 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
34 |
|
829 | 35 |
procedure AmmoUsed(am: TAmmoType); |
867 | 36 |
procedure HedgehogDamaged(Gear: PGear); |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
37 |
procedure TurnReaction; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
38 |
procedure SendStats; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
39 |
|
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
40 |
implementation |
858 | 41 |
uses uTeams, uSound, uMisc; |
815 | 42 |
var DamageGiven : Longword = 0; |
43 |
DamageClan : Longword = 0; |
|
829 | 44 |
DamageTotal : Longword = 0; |
867 | 45 |
KillsClan : LongWord = 0; |
46 |
Kills : LongWord = 0; |
|
47 |
KillsTotal : LongWord = 0; |
|
830
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
48 |
AmmoUsedCount : Longword = 0; |
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
49 |
AmmoDamagingUsed : boolean = false; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
50 |
|
867 | 51 |
procedure HedgehogDamaged(Gear: PGear); |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
52 |
begin |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
53 |
if Gear <> CurrentHedgehog^.Gear then |
867 | 54 |
inc(CurrentHedgehog^.stats.StepDamageGiven, Gear^.Damage); |
815 | 55 |
|
867 | 56 |
if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(DamageClan, Gear^.Damage); |
815 | 57 |
|
867 | 58 |
if Gear^.Health <= Gear^.Damage then |
59 |
begin |
|
869 | 60 |
inc(CurrentHedgehog^.stats.StepKills); |
867 | 61 |
inc(Kills); |
62 |
inc(KillsTotal); |
|
63 |
if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan); |
|
64 |
end; |
|
815 | 65 |
|
867 | 66 |
inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Gear^.Damage); |
67 |
inc(DamageGiven, Gear^.Damage); |
|
68 |
inc(DamageTotal, Gear^.Damage) |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
69 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
70 |
|
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
71 |
procedure TurnReaction; |
815 | 72 |
var Gear: PGear; |
869 | 73 |
i, t: LongInt; |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
74 |
begin |
815 | 75 |
inc(CurrentHedgehog^.stats.FinishedTurns); |
76 |
||
864 | 77 |
if (DamageGiven = DamageTotal) and (DamageTotal > 0) then |
78 |
PlaySound(sndFirstBlood, false) |
|
79 |
||
80 |
else if CurrentHedgehog^.stats.StepDamageRecv > 0 then |
|
81 |
PlaySound(sndStupid, false) |
|
82 |
||
815 | 83 |
else if DamageClan <> 0 then |
864 | 84 |
if DamageTotal > DamageClan then |
85 |
PlaySound(sndNutter, false) |
|
86 |
else |
|
866 | 87 |
if random(2) = 0 then |
88 |
PlaySound(sndSameTeam, false) |
|
89 |
else |
|
90 |
PlaySound(sndTraitor, false) |
|
864 | 91 |
|
867 | 92 |
else if DamageGiven <> 0 then |
93 |
if Kills > 0 then |
|
94 |
PlaySound(sndEnemyDown, false) |
|
95 |
else |
|
96 |
PlaySound(sndRegret, false) |
|
864 | 97 |
|
867 | 98 |
else if AmmoDamagingUsed then |
99 |
PlaySound(sndMissed, false); |
|
815 | 100 |
|
869 | 101 |
for t:= 0 to Pred(TeamsCount) do |
102 |
with TeamsArray[t]^ do |
|
103 |
for i:= 0 to cMaxHHIndex do |
|
104 |
with Hedgehogs[i].stats do |
|
105 |
begin |
|
106 |
inc(DamageRecv, StepDamageRecv); |
|
107 |
inc(DamageGiven, StepDamageGiven); |
|
108 |
if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv; |
|
109 |
if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven; |
|
110 |
if StepKills > MaxStepKills then MaxStepKills:= StepKills; |
|
111 |
StepDamageRecv:= 0; |
|
112 |
StepDamageGiven:= 0 |
|
113 |
end; |
|
815 | 114 |
|
867 | 115 |
Kills:= 0; |
116 |
KillsClan:= 0; |
|
815 | 117 |
DamageGiven:= 0; |
830
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
118 |
DamageClan:= 0; |
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
119 |
AmmoUsedCount:= 0; |
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
120 |
AmmoDamagingUsed:= false |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
121 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
122 |
|
829 | 123 |
procedure AmmoUsed(am: TAmmoType); |
124 |
begin |
|
830
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
125 |
inc(AmmoUsedCount); |
f07267032194
- Add statistics info for ammo used in step and whether it is damaging ammo
unc0rr
parents:
829
diff
changeset
|
126 |
AmmoDamagingUsed:= AmmoDamagingUsed or Ammoz[am].isDamaging |
829 | 127 |
end; |
128 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
129 |
procedure SendStats; |
858 | 130 |
var i, t: LongInt; |
869 | 131 |
msd, msk: Longword; msdhh, mskhh: PHedgehog; |
132 |
mskcnt: Longword; |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
133 |
begin |
858 | 134 |
msd:= 0; msdhh:= nil; |
869 | 135 |
msk:= 0; mskhh:= nil; |
136 |
mskcnt:= 0; |
|
137 |
||
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
138 |
for t:= 0 to Pred(TeamsCount) do |
869 | 139 |
with TeamsArray[t]^ do |
140 |
begin |
|
141 |
for i:= 0 to cMaxHHIndex do |
|
142 |
begin |
|
143 |
if Hedgehogs[i].stats.MaxStepDamageGiven > msd then |
|
144 |
begin |
|
145 |
msdhh:= @Hedgehogs[i]; |
|
146 |
msd:= Hedgehogs[i].stats.MaxStepDamageGiven |
|
147 |
end; |
|
148 |
if Hedgehogs[i].stats.MaxStepKills >= msk then |
|
149 |
if Hedgehogs[i].stats.MaxStepKills = msk then |
|
150 |
inc(mskcnt) |
|
151 |
else |
|
152 |
begin |
|
153 |
mskcnt:= 1; |
|
154 |
mskhh:= @Hedgehogs[i]; |
|
155 |
msk:= Hedgehogs[i].stats.MaxStepKills |
|
156 |
end; |
|
157 |
end |
|
158 |
end; |
|
159 |
if msdhh <> nil then |
|
160 |
SendStat(siMaxStepDamage, inttostr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')'); |
|
161 |
if mskcnt = 1 then |
|
162 |
SendStat(siMaxStepKills, inttostr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')'); |
|
163 |
||
858 | 164 |
if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs)); |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
165 |
end; |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
166 |
|
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
diff
changeset
|
167 |
end. |