207 if Angle > CurMaxAngle then Angle:= CurMaxAngle; |
207 if Angle > CurMaxAngle then Angle:= CurMaxAngle; |
208 end |
208 end |
209 end |
209 end |
210 end; |
210 end; |
211 |
211 |
|
212 procedure SwitchToFirstLegalAmmo(var Hedgehog: THedgehog); |
|
213 begin |
|
214 with Hedgehog do |
|
215 begin |
|
216 CurAmmo:= 0; |
|
217 CurSlot:= 0; |
|
218 while (CurSlot <= cMaxSlotIndex) and |
|
219 ((Ammo^[CurSlot, CurAmmo].Count = 0) or |
|
220 (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) |
|
221 do |
|
222 begin |
|
223 while (CurAmmo <= cMaxSlotAmmoIndex) and |
|
224 ((Ammo^[CurSlot, CurAmmo].Count = 0) or |
|
225 (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) |
|
226 do inc(CurAmmo); |
|
227 |
|
228 if (CurAmmo > cMaxSlotAmmoIndex) then |
|
229 begin |
|
230 CurAmmo:= 0; |
|
231 inc(CurSlot) |
|
232 end |
|
233 end; |
|
234 TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true) |
|
235 end |
|
236 end; |
|
237 |
212 procedure ApplyAmmoChanges(var Hedgehog: THedgehog); |
238 procedure ApplyAmmoChanges(var Hedgehog: THedgehog); |
213 var s: shortstring; |
239 var s: shortstring; |
214 begin |
240 begin |
215 TargetPoint.X:= NoPointX; |
241 TargetPoint.X:= NoPointX; |
216 |
242 |
217 with Hedgehog do |
243 with Hedgehog do |
218 begin |
244 begin |
219 |
245 |
220 if (Ammo^[CurSlot, CurAmmo].Count = 0) then |
246 if (Ammo^[CurSlot, CurAmmo].Count = 0) then |
221 begin |
247 SwitchToFirstLegalAmmo(Hedgehog); |
222 CurAmmo:= 0; |
|
223 CurSlot:= 0; |
|
224 while (CurSlot <= cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do inc(CurSlot); |
|
225 TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true) |
|
226 end; |
|
227 |
248 |
228 //bad things could happen here in case CurSlot is overflowing |
249 //bad things could happen here in case CurSlot is overflowing |
229 ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType); |
250 ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType); |
230 |
251 |
231 with Ammo^[CurSlot, CurAmmo] do |
252 with Ammo^[CurSlot, CurAmmo] do |
255 procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog); |
276 procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog); |
256 begin |
277 begin |
257 with Hedgehog do |
278 with Hedgehog do |
258 if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or |
279 if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or |
259 (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then |
280 (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then |
260 begin |
281 SwitchToFirstLegalAmmo(Hedgehog); |
261 CurAmmo:= 0; |
|
262 CurSlot:= 0; |
|
263 while (CurSlot <= cMaxSlotIndex) and |
|
264 ((Ammo^[CurSlot, CurAmmo].Count = 0) or |
|
265 (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) |
|
266 do |
|
267 inc(CurSlot); |
|
268 TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true) |
|
269 end |
|
270 end; |
282 end; |
271 |
283 |
272 procedure SetWeapon(weap: TAmmoType); |
284 procedure SetWeapon(weap: TAmmoType); |
273 begin |
285 begin |
274 ParseCommand('/setweap ' + char(weap), true) |
286 ParseCommand('/setweap ' + char(weap), true) |