hedgewars/uStats.pas
changeset 867 dc7901b1120e
parent 866 ac6f6c95c23f
child 869 daddcd31ef34
equal deleted inserted replaced
866:ac6f6c95c23f 867:dc7901b1120e
    29                    MaxStepDamageGiven: Longword;
    29                    MaxStepDamageGiven: Longword;
    30                    FinishedTurns: Longword;
    30                    FinishedTurns: Longword;
    31                    end;
    31                    end;
    32 
    32 
    33 procedure AmmoUsed(am: TAmmoType);
    33 procedure AmmoUsed(am: TAmmoType);
    34 procedure HedgehogDamaged(Gear: PGear; Damage: Longword);
    34 procedure HedgehogDamaged(Gear: PGear);
    35 procedure TurnReaction;
    35 procedure TurnReaction;
    36 procedure SendStats;
    36 procedure SendStats;
    37 
    37 
    38 implementation
    38 implementation
    39 uses uTeams, uSound, uMisc;
    39 uses uTeams, uSound, uMisc;
    40 var DamageGiven : Longword = 0;
    40 var DamageGiven : Longword = 0;
    41     DamageClan  : Longword = 0;
    41     DamageClan  : Longword = 0;
    42     DamageTotal : Longword = 0;
    42     DamageTotal : Longword = 0;
       
    43     KillsClan   : LongWord = 0;
       
    44     Kills       : LongWord = 0;
       
    45     KillsTotal  : LongWord = 0;
    43     AmmoUsedCount : Longword = 0;
    46     AmmoUsedCount : Longword = 0;
    44     AmmoDamagingUsed : boolean = false;
    47     AmmoDamagingUsed : boolean = false;
    45 
    48 
    46 procedure HedgehogDamaged(Gear: PGear; Damage: Longword);
    49 procedure HedgehogDamaged(Gear: PGear);
    47 begin
    50 begin
    48 if Gear <> CurrentHedgehog^.Gear then
    51 if Gear <> CurrentHedgehog^.Gear then
    49    inc(CurrentHedgehog^.stats.StepDamageGiven, Damage);
    52 	inc(CurrentHedgehog^.stats.StepDamageGiven, Gear^.Damage);
    50 
    53 
    51 if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(DamageClan, Damage);
    54 if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(DamageClan, Gear^.Damage);
    52 
    55 
       
    56 if Gear^.Health <= Gear^.Damage then
       
    57 	begin
       
    58 	inc(Kills);
       
    59 	inc(KillsTotal);
       
    60 	if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan);
       
    61 	end;
    53 
    62 
    54 inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Damage);
    63 inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Gear^.Damage);
    55 inc(DamageGiven, Damage);
    64 inc(DamageGiven, Gear^.Damage);
    56 inc(DamageTotal, Damage)
    65 inc(DamageTotal, Gear^.Damage)
    57 end;
    66 end;
    58 
    67 
    59 procedure TurnReaction;
    68 procedure TurnReaction;
    60 var Gear: PGear;
    69 var Gear: PGear;
    61 begin
    70 begin
    74 		if random(2) = 0 then
    83 		if random(2) = 0 then
    75 			PlaySound(sndSameTeam, false)
    84 			PlaySound(sndSameTeam, false)
    76 		else
    85 		else
    77 			PlaySound(sndTraitor, false)
    86 			PlaySound(sndTraitor, false)
    78 
    87 
    79 else if DamageGiven <> 0 then PlaySound(sndRegret, false)
    88 else if DamageGiven <> 0 then
       
    89 	if Kills > 0 then
       
    90 		PlaySound(sndEnemyDown, false)
       
    91 	else
       
    92 		PlaySound(sndRegret, false)
    80 
    93 
    81 else if AmmoDamagingUsed then PlaySound(sndMissed, false);
    94 else if AmmoDamagingUsed then
       
    95 	PlaySound(sndMissed, false);
    82 
    96 
    83 Gear:= GearsList;
    97 Gear:= GearsList;
    84 while Gear <> nil do
    98 while Gear <> nil do
    85   begin
    99   begin
    86   if Gear^.Kind = gtHedgehog then
   100   if Gear^.Kind = gtHedgehog then
    94       StepDamageGiven:= 0
   108       StepDamageGiven:= 0
    95       end;
   109       end;
    96   Gear:= Gear^.NextGear
   110   Gear:= Gear^.NextGear
    97   end;
   111   end;
    98 
   112 
       
   113 Kills:= 0;
       
   114 KillsClan:= 0;
    99 DamageGiven:= 0;
   115 DamageGiven:= 0;
   100 DamageClan:= 0;
   116 DamageClan:= 0;
   101 AmmoUsedCount:= 0;
   117 AmmoUsedCount:= 0;
   102 AmmoDamagingUsed:= false
   118 AmmoDamagingUsed:= false
   103 end;
   119 end;