hedgewars/uStats.pas
changeset 12292 93434ab299a0
parent 12291 e2b30aba00e1
child 12332 657a8d63c99d
equal deleted inserted replaced
12291:e2b30aba00e1 12292:93434ab299a0
    29 procedure initModule;
    29 procedure initModule;
    30 procedure freeModule;
    30 procedure freeModule;
    31 
    31 
    32 procedure AmmoUsed(am: TAmmoType);
    32 procedure AmmoUsed(am: TAmmoType);
    33 procedure HedgehogPoisoned(Gear: PGear; Attacker: PHedgehog);
    33 procedure HedgehogPoisoned(Gear: PGear; Attacker: PHedgehog);
       
    34 procedure HedgehogSacrificed(Hedgehog: PHedgehog);
    34 procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean);
    35 procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean);
    35 procedure Skipped;
    36 procedure Skipped;
    36 procedure TurnReaction;
    37 procedure TurnReaction;
    37 procedure SendStats;
    38 procedure SendStats;
    38 procedure hedgehogFlight(Gear: PGear; time: Longword);
    39 procedure hedgehogFlight(Gear: PGear; time: Longword);
    73         end;
    74         end;
    74     Gear^.Hedgehog^.stats.StepPoisoned:= true;
    75     Gear^.Hedgehog^.stats.StepPoisoned:= true;
    75     inc(PoisonTotal)
    76     inc(PoisonTotal)
    76 end;
    77 end;
    77 
    78 
       
    79 procedure HedgehogSacrificed(Hedgehog: PHedgehog);
       
    80 begin
       
    81     Hedgehog^.stats.Sacrificed:= true
       
    82 end;
       
    83 
    78 procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean);
    84 procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean);
    79 begin
    85 begin
    80 if Attacker^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then
    86 if Attacker^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then
    81     vpHurtSameClan:= CurrentHedgehog^.Team^.voicepack
    87     vpHurtSameClan:= CurrentHedgehog^.Team^.voicepack
    82 else
    88 else
   117 isTurnSkipped:= true
   123 isTurnSkipped:= true
   118 end;
   124 end;
   119 
   125 
   120 procedure TurnReaction;
   126 procedure TurnReaction;
   121 var i, t: LongInt;
   127 var i, t: LongInt;
       
   128     killsCheck: LongInt;
   122     s: ansistring;
   129     s: ansistring;
   123 begin
   130 begin
   124 //TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true);
   131 //TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true);
   125 
   132 
   126 inc(FinishedTurnsTotal);
   133 inc(FinishedTurnsTotal);
   127 if FinishedTurnsTotal <> 0 then
   134 if FinishedTurnsTotal <> 0 then
   128     begin
   135     begin
   129     s:= ansistring(CurrentHedgehog^.Name);
   136     s:= ansistring(CurrentHedgehog^.Name);
   130     inc(CurrentHedgehog^.stats.FinishedTurns);
   137     inc(CurrentHedgehog^.stats.FinishedTurns);
       
   138     // If the hog sacrificed (=kamikaze/piano) itself, this needs to be taken into accounts for the reactions later
       
   139     if (CurrentHedgehog^.stats.Sacrificed) then
       
   140         killsCheck:= 1
       
   141     else
       
   142         killsCheck:= 0;
   131 
   143 
   132     // First blood (first damage, poison or kill)
   144     // First blood (first damage, poison or kill)
   133     if ((DamageTotal > 0) or (KillsTotal > 0) or (PoisonTotal > 0)) and ((CurrentHedgehog^.stats.DamageGiven = DamageTotal) and (CurrentHedgehog^.stats.StepKills = KillsTotal) and (PoisonTotal = PoisonTurn + PoisonClan)) then
   145     if ((DamageTotal > 0) or (KillsTotal > 0) or (PoisonTotal > 0)) and ((CurrentHedgehog^.stats.DamageGiven = DamageTotal) and (CurrentHedgehog^.stats.StepKills = KillsTotal) and (PoisonTotal = PoisonTurn + PoisonClan)) then
   134         AddVoice(sndFirstBlood, CurrentTeam^.voicepack)
   146         AddVoice(sndFirstBlood, CurrentTeam^.voicepack)
   135 
   147 
   136     // Hog hurts, poisons or kills itself
   148     // Hog hurts, poisons or kills itself (except sacrifice)
   137     else if (CurrentHedgehog^.stats.StepDamageRecv > 0) or (CurrentHedgehog^.stats.StepPoisoned) or (CurrentHedgehog^.Gear = nil) then
   149     else if (CurrentHedgehog^.stats.Sacrificed = false) and ((CurrentHedgehog^.stats.StepDamageRecv > 0) or (CurrentHedgehog^.stats.StepPoisoned) or (CurrentHedgehog^.Gear = nil)) then
   138         begin
   150         begin
   139         AddVoice(sndStupid, PreviousTeam^.voicepack);
   151         AddVoice(sndStupid, PreviousTeam^.voicepack);
   140         // Message for hurting itself only (not drowning)
   152         // Message for hurting itself only (not drowning)
   141         if (CurrentHedgehog^.stats.DamageGiven = CurrentHedgehog^.stats.StepDamageRecv) and (CurrentHedgehog^.stats.StepDamageRecv >= 1) then
   153         if (CurrentHedgehog^.stats.DamageGiven = CurrentHedgehog^.stats.StepDamageRecv) and (CurrentHedgehog^.stats.StepDamageRecv >= 1) then
   142             AddCaption(FormatA(GetEventString(eidHurtSelf), s), cWhiteColor, capgrpMessage);
   154             AddCaption(FormatA(GetEventString(eidHurtSelf), s), cWhiteColor, capgrpMessage);
   143         end
   155         end
   144 
   156 
   145     // Hog hurts, poisons or kills own team/clan member
   157     // Hog hurts, poisons or kills own team/clan member. Sacrifice is taken into account
   146     else if (DamageClan <> 0) or (KillsClan <> 0) or (PoisonClan <> 0) then
   158     else if (DamageClan <> 0) or (KillsClan > killsCheck) or (PoisonClan <> 0) then
   147         if (DamageTurn > DamageClan) or (Kills > KillsClan) then
   159         if (DamageTurn > DamageClan) or (Kills > KillsClan) then
   148             if random(2) = 0 then
   160             if random(2) = 0 then
   149                 AddVoice(sndNutter, CurrentTeam^.voicepack)
   161                 AddVoice(sndNutter, CurrentTeam^.voicepack)
   150             else
   162             else
   151                 AddVoice(sndWatchIt, vpHurtSameClan)
   163                 AddVoice(sndWatchIt, vpHurtSameClan)
   154                 AddVoice(sndSameTeam, vpHurtSameClan)
   166                 AddVoice(sndSameTeam, vpHurtSameClan)
   155             else
   167             else
   156                 AddVoice(sndTraitor, vpHurtSameClan)
   168                 AddVoice(sndTraitor, vpHurtSameClan)
   157 
   169 
   158     // Hog hurts, kills or poisons enemy
   170     // Hog hurts, kills or poisons enemy
   159     else if (CurrentHedgehog^.stats.StepDamageGiven <> 0) or (CurrentHedgehog^.stats.StepKills <> 0) or (PoisonTurn <> 0) then
   171     else if (CurrentHedgehog^.stats.StepDamageGiven <> 0) or (CurrentHedgehog^.stats.StepKills > killsCheck) or (PoisonTurn <> 0) then
   160         if Kills > 0 then
   172         if Kills > killsCheck then
   161             AddVoice(sndEnemyDown, CurrentTeam^.voicepack)
   173             AddVoice(sndEnemyDown, CurrentTeam^.voicepack)
   162         else
   174         else
   163             AddVoice(sndRegret, vpHurtEnemy)
   175             AddVoice(sndRegret, vpHurtEnemy)
   164 
   176 
   165     // Missed shot
   177     // Missed shot
   166     else if AmmoDamagingUsed and (Kills = 0) and (PoisonTurn = 0) and (PoisonClan = 0) and (DamageTurn = 0) then
   178     else if AmmoDamagingUsed and (Kills <= killsCheck) and (PoisonTurn = 0) and (PoisonClan = 0) and (DamageTurn = 0) then
   167         AddVoice(sndMissed, PreviousTeam^.voicepack)
   179         // Chance to call hedgehog stupid if sacrificed for nothing
       
   180         if CurrentHedgehog^.stats.Sacrificed then
       
   181             if random(2) = 0 then
       
   182                 AddVoice(sndMissed, PreviousTeam^.voicepack)
       
   183             else
       
   184                 AddVoice(sndStupid, PreviousTeam^.voicepack)
       
   185         else
       
   186             AddVoice(sndMissed, PreviousTeam^.voicepack)
   168 
   187 
   169     // Timeout
   188     // Timeout
   170     else if (AmmoUsedCount > 0) and (not isTurnSkipped) then
   189     else if (AmmoUsedCount > 0) and (not isTurnSkipped) then
   171         begin end// nothing ?
   190         begin end// nothing ?
   172 
   191