37 procedure HedgehogPoisoned(Gear: PGear; Attacker: PHedgehog); |
37 procedure HedgehogPoisoned(Gear: PGear; Attacker: PHedgehog); |
38 procedure HedgehogSacrificed(Hedgehog: PHedgehog); |
38 procedure HedgehogSacrificed(Hedgehog: PHedgehog); |
39 procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean); |
39 procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean); |
40 procedure TargetHit; |
40 procedure TargetHit; |
41 procedure Skipped; |
41 procedure Skipped; |
|
42 procedure TurnStats; |
42 procedure TurnReaction; |
43 procedure TurnReaction; |
43 procedure SendStats; |
44 procedure SendStats; |
44 procedure hedgehogFlight(Gear: PGear; time: Longword); |
45 procedure hedgehogFlight(Gear: PGear; time: Longword); |
45 procedure declareAchievement(id, teamname, location: shortstring; value: LongInt); |
46 procedure declareAchievement(id, teamname, location: shortstring; value: LongInt); |
46 procedure startGhostPoints(n: LongInt); |
47 procedure startGhostPoints(n: LongInt); |
133 begin |
134 begin |
134 inc(SkippedTurns); |
135 inc(SkippedTurns); |
135 isTurnSkipped:= true |
136 isTurnSkipped:= true |
136 end; |
137 end; |
137 |
138 |
138 procedure TurnReaction; |
139 procedure TurnStats; |
139 var i, t: LongInt; |
140 var i, t: LongInt; |
140 killsCheck: LongInt; |
141 begin |
141 s: ansistring; |
|
142 begin |
|
143 //TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true); |
|
144 |
|
145 inc(FinishedTurnsTotal); |
142 inc(FinishedTurnsTotal); |
146 if FinishedTurnsTotal <> 0 then |
|
147 begin |
|
148 s:= ansistring(CurrentHedgehog^.Name); |
|
149 inc(CurrentHedgehog^.stats.FinishedTurns); |
|
150 // If the hog sacrificed (=kamikaze/piano) itself, this needs to be taken into accounts for the reactions later |
|
151 if (CurrentHedgehog^.stats.Sacrificed) then |
|
152 killsCheck:= 1 |
|
153 else |
|
154 killsCheck:= 0; |
|
155 |
|
156 // First blood (first damage, poison or kill) |
|
157 if ((DamageTotal > 0) or (KillsTotal > 0) or (PoisonTotal > 0)) and ((CurrentHedgehog^.stats.DamageGiven = DamageTotal) and (CurrentHedgehog^.stats.StepKills = KillsTotal) and (PoisonTotal = PoisonTurn + PoisonClan)) then |
|
158 AddVoice(sndFirstBlood, CurrentTeam^.voicepack) |
|
159 |
|
160 // Hog hurts, poisons or kills itself (except sacrifice) |
|
161 else if (CurrentHedgehog^.stats.Sacrificed = false) and ((CurrentHedgehog^.stats.StepDamageRecv > 0) or (CurrentHedgehog^.stats.StepPoisoned) or (CurrentHedgehog^.stats.StepDied)) then |
|
162 begin |
|
163 AddVoice(sndStupid, PreviousTeam^.voicepack); |
|
164 // Message for hurting itself only (not drowning) |
|
165 if (CurrentHedgehog^.stats.DamageGiven = CurrentHedgehog^.stats.StepDamageRecv) and (CurrentHedgehog^.stats.StepDamageRecv >= 1) then |
|
166 AddCaption(FormatA(GetEventString(eidHurtSelf), s), capcolDefault, capgrpMessage); |
|
167 end |
|
168 |
|
169 // Hog hurts, poisons or kills own team/clan member. Sacrifice is taken into account |
|
170 else if (DamageClan <> 0) or (KillsClan > killsCheck) or (PoisonClan <> 0) then |
|
171 if (DamageTurn > DamageClan) or (Kills > KillsClan) then |
|
172 if random(2) = 0 then |
|
173 AddVoice(sndNutter, CurrentTeam^.voicepack) |
|
174 else |
|
175 AddVoice(sndWatchIt, vpHurtSameClan) |
|
176 else |
|
177 if random(2) = 0 then |
|
178 AddVoice(sndSameTeam, vpHurtSameClan) |
|
179 else |
|
180 AddVoice(sndTraitor, vpHurtSameClan) |
|
181 |
|
182 // Hog hurts, kills or poisons enemy |
|
183 else if (CurrentHedgehog^.stats.StepDamageGiven <> 0) or (CurrentHedgehog^.stats.StepKills > killsCheck) or (PoisonTurn <> 0) then |
|
184 if Kills > killsCheck then |
|
185 AddVoice(sndEnemyDown, CurrentTeam^.voicepack) |
|
186 else |
|
187 AddVoice(sndRegret, vpHurtEnemy) |
|
188 |
|
189 // Missed shot |
|
190 // A miss is defined as a shot with a damaging weapon with 0 kills, 0 damage, 0 hogs poisoned and 0 targets hit |
|
191 else if AmmoDamagingUsed and (Kills <= killsCheck) and (PoisonTurn = 0) and (PoisonClan = 0) and (DamageTurn = 0) and (HitTargets = 0) then |
|
192 // Chance to call hedgehog stupid if sacrificed for nothing |
|
193 if CurrentHedgehog^.stats.Sacrificed then |
|
194 if random(2) = 0 then |
|
195 AddVoice(sndMissed, PreviousTeam^.voicepack) |
|
196 else |
|
197 AddVoice(sndStupid, PreviousTeam^.voicepack) |
|
198 else |
|
199 AddVoice(sndMissed, PreviousTeam^.voicepack) |
|
200 |
|
201 // Timeout |
|
202 else if (AmmoUsedCount > 0) and (not isTurnSkipped) then |
|
203 begin end// nothing ? |
|
204 |
|
205 // Turn skipped |
|
206 else if isTurnSkipped and (not PlacingHogs) then |
|
207 begin |
|
208 AddVoice(sndCoward, PreviousTeam^.voicepack); |
|
209 AddCaption(FormatA(GetEventString(eidTurnSkipped), s), capcolDefault, capgrpMessage); |
|
210 end |
|
211 end; |
|
212 |
|
213 |
143 |
214 for t:= 0 to Pred(TeamsCount) do // send even on zero turn |
144 for t:= 0 to Pred(TeamsCount) do // send even on zero turn |
215 with TeamsArray[t]^ do |
145 with TeamsArray[t]^ do |
216 for i:= 0 to cMaxHHIndex do |
146 for i:= 0 to cMaxHHIndex do |
217 with Hedgehogs[i].stats do |
147 with Hedgehogs[i].stats do |
245 HitTargets:= 0; |
175 HitTargets:= 0; |
246 PoisonClan:= 0; |
176 PoisonClan:= 0; |
247 PoisonTurn:= 0; |
177 PoisonTurn:= 0; |
248 AmmoUsedCount:= 0; |
178 AmmoUsedCount:= 0; |
249 AmmoDamagingUsed:= false; |
179 AmmoDamagingUsed:= false; |
250 isTurnSkipped:= false |
180 isTurnSkipped:= false; |
|
181 end; |
|
182 |
|
183 procedure TurnReaction; |
|
184 var killsCheck: LongInt; |
|
185 s: ansistring; |
|
186 begin |
|
187 //TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true); |
|
188 |
|
189 if FinishedTurnsTotal <> 0 then |
|
190 begin |
|
191 s:= ansistring(CurrentHedgehog^.Name); |
|
192 inc(CurrentHedgehog^.stats.FinishedTurns); |
|
193 // If the hog sacrificed (=kamikaze/piano) itself, this needs to be taken into accounts for the reactions later |
|
194 if (CurrentHedgehog^.stats.Sacrificed) then |
|
195 killsCheck:= 1 |
|
196 else |
|
197 killsCheck:= 0; |
|
198 |
|
199 // First blood (first damage, poison or kill) |
|
200 if ((DamageTotal > 0) or (KillsTotal > 0) or (PoisonTotal > 0)) and ((CurrentHedgehog^.stats.DamageGiven = DamageTotal) and (CurrentHedgehog^.stats.StepKills = KillsTotal) and (PoisonTotal = PoisonTurn + PoisonClan)) then |
|
201 AddVoice(sndFirstBlood, CurrentTeam^.voicepack) |
|
202 |
|
203 // Hog hurts, poisons or kills itself (except sacrifice) |
|
204 else if (CurrentHedgehog^.stats.Sacrificed = false) and ((CurrentHedgehog^.stats.StepDamageRecv > 0) or (CurrentHedgehog^.stats.StepPoisoned) or (CurrentHedgehog^.stats.StepDied)) then |
|
205 begin |
|
206 AddVoice(sndStupid, PreviousTeam^.voicepack); |
|
207 // Message for hurting itself only (not drowning) |
|
208 if (CurrentHedgehog^.stats.DamageGiven = CurrentHedgehog^.stats.StepDamageRecv) and (CurrentHedgehog^.stats.StepDamageRecv >= 1) then |
|
209 AddCaption(FormatA(GetEventString(eidHurtSelf), s), capcolDefault, capgrpMessage); |
|
210 end |
|
211 |
|
212 // Hog hurts, poisons or kills own team/clan member. Sacrifice is taken into account |
|
213 else if (DamageClan <> 0) or (KillsClan > killsCheck) or (PoisonClan <> 0) then |
|
214 if (DamageTurn > DamageClan) or (Kills > KillsClan) then |
|
215 if random(2) = 0 then |
|
216 AddVoice(sndNutter, CurrentTeam^.voicepack) |
|
217 else |
|
218 AddVoice(sndWatchIt, vpHurtSameClan) |
|
219 else |
|
220 if random(2) = 0 then |
|
221 AddVoice(sndSameTeam, vpHurtSameClan) |
|
222 else |
|
223 AddVoice(sndTraitor, vpHurtSameClan) |
|
224 |
|
225 // Hog hurts, kills or poisons enemy |
|
226 else if (CurrentHedgehog^.stats.StepDamageGiven <> 0) or (CurrentHedgehog^.stats.StepKills > killsCheck) or (PoisonTurn <> 0) then |
|
227 if Kills > killsCheck then |
|
228 AddVoice(sndEnemyDown, CurrentTeam^.voicepack) |
|
229 else |
|
230 AddVoice(sndRegret, vpHurtEnemy) |
|
231 |
|
232 // Missed shot |
|
233 // A miss is defined as a shot with a damaging weapon with 0 kills, 0 damage, 0 hogs poisoned and 0 targets hit |
|
234 else if AmmoDamagingUsed and (Kills <= killsCheck) and (PoisonTurn = 0) and (PoisonClan = 0) and (DamageTurn = 0) and (HitTargets = 0) then |
|
235 // Chance to call hedgehog stupid if sacrificed for nothing |
|
236 if CurrentHedgehog^.stats.Sacrificed then |
|
237 if random(2) = 0 then |
|
238 AddVoice(sndMissed, PreviousTeam^.voicepack) |
|
239 else |
|
240 AddVoice(sndStupid, PreviousTeam^.voicepack) |
|
241 else |
|
242 AddVoice(sndMissed, PreviousTeam^.voicepack) |
|
243 |
|
244 // Timeout |
|
245 else if (AmmoUsedCount > 0) and (not isTurnSkipped) then |
|
246 begin end// nothing ? |
|
247 |
|
248 // Turn skipped |
|
249 else if isTurnSkipped and (not PlacingHogs) then |
|
250 begin |
|
251 AddVoice(sndCoward, PreviousTeam^.voicepack); |
|
252 AddCaption(FormatA(GetEventString(eidTurnSkipped), s), capcolDefault, capgrpMessage); |
|
253 end |
|
254 end; |
251 end; |
255 end; |
252 |
256 |
253 procedure AmmoUsed(am: TAmmoType); |
257 procedure AmmoUsed(am: TAmmoType); |
254 begin |
258 begin |
255 inc(AmmoUsedCount); |
259 inc(AmmoUsedCount); |