237 end; |
237 end; |
238 |
238 |
239 procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType); |
239 procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType); |
240 begin |
240 begin |
241 with Hedgehog do |
241 with Hedgehog do |
242 begin |
242 begin |
243 CurMinAngle:= Ammoz[AmmoType].minAngle; |
243 CurMinAngle:= Ammoz[AmmoType].minAngle; |
244 if Ammoz[AmmoType].maxAngle <> 0 then |
244 if Ammoz[AmmoType].maxAngle <> 0 then |
245 CurMaxAngle:= Ammoz[AmmoType].maxAngle |
245 CurMaxAngle:= Ammoz[AmmoType].maxAngle |
246 else |
246 else |
247 CurMaxAngle:= cMaxAngle; |
247 CurMaxAngle:= cMaxAngle; |
248 |
248 |
249 with Hedgehog.Gear^ do |
249 with Hedgehog.Gear^ do |
250 begin |
250 begin |
251 if Angle < CurMinAngle then Angle:= CurMinAngle; |
251 if Angle < CurMinAngle then Angle:= CurMinAngle; |
252 if Angle > CurMaxAngle then Angle:= CurMaxAngle; |
252 if Angle > CurMaxAngle then Angle:= CurMaxAngle; |
253 end |
253 end |
254 end |
254 end |
255 end; |
255 end; |
256 |
256 |
257 procedure SwitchToFirstLegalAmmo(var Hedgehog: THedgehog); |
257 procedure SwitchToFirstLegalAmmo(var Hedgehog: THedgehog); |
258 begin |
258 begin |
259 with Hedgehog do |
259 with Hedgehog do |
260 begin |
260 begin |
261 CurAmmo:= 0; |
261 CurAmmo:= 0; |
262 CurSlot:= 0; |
262 CurSlot:= 0; |
263 while (CurSlot <= cMaxSlotIndex) and |
263 while (CurSlot <= cMaxSlotIndex) and |
264 ((Ammo^[CurSlot, CurAmmo].Count = 0) or |
264 ((Ammo^[CurSlot, CurAmmo].Count = 0) or |
265 (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) |
265 (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) |
266 do |
266 do |
267 begin |
267 begin |
268 while (CurAmmo <= cMaxSlotAmmoIndex) and |
268 while (CurAmmo <= cMaxSlotAmmoIndex) and |
269 ((Ammo^[CurSlot, CurAmmo].Count = 0) or |
269 ((Ammo^[CurSlot, CurAmmo].Count = 0) or |
270 (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) |
270 (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) |
271 do inc(CurAmmo); |
271 do inc(CurAmmo); |
272 |
272 |
273 if (CurAmmo > cMaxSlotAmmoIndex) then |
273 if (CurAmmo > cMaxSlotAmmoIndex) then |
274 begin |
274 begin |
275 CurAmmo:= 0; |
275 CurAmmo:= 0; |
276 inc(CurSlot) |
276 inc(CurSlot) |
277 end |
277 end |
278 end; |
278 end; |
279 TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true) |
279 TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true) |
280 end |
280 end |
281 end; |
281 end; |
282 |
282 |
283 procedure ApplyAmmoChanges(var Hedgehog: THedgehog); |
283 procedure ApplyAmmoChanges(var Hedgehog: THedgehog); |
284 var s: shortstring; |
284 var s: shortstring; |
285 begin |
285 begin |
286 TargetPoint.X:= NoPointX; |
286 TargetPoint.X:= NoPointX; |
287 |
287 |
288 with Hedgehog do |
288 with Hedgehog do |
289 begin |
289 begin |
290 |
290 |
291 if (Ammo^[CurSlot, CurAmmo].Count = 0) then |
291 if (Ammo^[CurSlot, CurAmmo].Count = 0) then |
292 SwitchToFirstLegalAmmo(Hedgehog); |
292 SwitchToFirstLegalAmmo(Hedgehog); |
293 |
293 |
294 //bad things could happen here in case CurSlot is overflowing |
294 //bad things could happen here in case CurSlot is overflowing |
295 ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType); |
295 ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType); |
296 |
296 |
297 with Ammo^[CurSlot, CurAmmo] do |
297 with Ammo^[CurSlot, CurAmmo] do |
298 begin |
298 begin |
299 if AmmoType <> amNothing then |
299 if AmmoType <> amNothing then |
300 begin |
300 begin |
301 s:= trammo[Ammoz[AmmoType].NameId]; |
301 s:= trammo[Ammoz[AmmoType].NameId]; |
302 if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then |
302 if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then |
303 s:= s + ' (' + IntToStr(Count) + ')'; |
303 s:= s + ' (' + IntToStr(Count) + ')'; |
304 if (Propz and ammoprop_Timerable) <> 0 then |
304 if (Propz and ammoprop_Timerable) <> 0 then |
305 s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds]; |
305 s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds]; |
306 AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo); |
306 AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo); |
307 end; |
307 end; |
308 if (Propz and ammoprop_NeedTarget) <> 0 |
308 if (Propz and ammoprop_NeedTarget) <> 0 |
309 then begin |
309 then begin |
310 Gear^.State:= Gear^.State or gstHHChooseTarget; |
310 Gear^.State:= Gear^.State or gstHHChooseTarget; |
311 isCursorVisible:= true |
311 isCursorVisible:= true |
312 end else begin |
312 end else begin |
313 Gear^.State:= Gear^.State and not gstHHChooseTarget; |
313 Gear^.State:= Gear^.State and not gstHHChooseTarget; |
314 isCursorVisible:= false |
314 isCursorVisible:= false |
315 end; |
315 end; |
316 ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0 |
316 ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0 |
317 end |
317 end |
318 end |
318 end |
319 end; |
319 end; |
320 |
320 |
321 procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog); |
321 procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog); |
322 begin |
322 begin |
323 with Hedgehog do |
323 with Hedgehog do |
324 if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or |
324 if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or |
325 (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then |
325 (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then |
326 SwitchToFirstLegalAmmo(Hedgehog); |
326 SwitchToFirstLegalAmmo(Hedgehog); |
327 end; |
327 end; |
328 |
328 |
329 procedure SetWeapon(weap: TAmmoType); |
329 procedure SetWeapon(weap: TAmmoType); |
330 begin |
330 begin |
331 ParseCommand('/setweap ' + char(weap), true) |
331 ParseCommand('/setweap ' + char(weap), true) |
332 end; |
332 end; |
333 |
333 |
334 procedure DisableSomeWeapons; |
334 procedure DisableSomeWeapons; |
335 var i, slot, a: Longword; |
335 var i, slot, a: Longword; |
336 t: TAmmoType; |
336 t: TAmmoType; |
337 begin |
337 begin |
338 for i:= 0 to Pred(StoreCnt) do |
338 for i:= 0 to Pred(StoreCnt) do |
339 for slot:= 0 to cMaxSlotIndex do |
339 for slot:= 0 to cMaxSlotIndex do |
340 begin |
340 begin |
341 for a:= 0 to cMaxSlotAmmoIndex do |
341 for a:= 0 to cMaxSlotAmmoIndex do |
342 with StoresList[i]^[slot, a] do |
342 with StoresList[i]^[slot, a] do |
343 if (Propz and ammoprop_NotBorder) <> 0 then Count:= 0; |
343 if (Propz and ammoprop_NotBorder) <> 0 then Count:= 0; |
344 |
344 |
345 PackAmmo(StoresList[i], slot) |
345 PackAmmo(StoresList[i], slot) |
346 end; |
346 end; |
347 |
347 |
348 for t:= Low(TAmmoType) to High(TAmmoType) do |
348 for t:= Low(TAmmoType) to High(TAmmoType) do |
349 if (Ammoz[t].Ammo.Propz and ammoprop_NotBorder) <> 0 then Ammoz[t].Probability:= 0 |
349 if (Ammoz[t].Ammo.Propz and ammoprop_NotBorder) <> 0 then Ammoz[t].Probability:= 0 |
350 end; |
350 end; |
351 |
351 |
352 // Restore indefinitely disabled weapons and initial weapon counts. Only used for hog placement right now |
352 // Restore indefinitely disabled weapons and initial weapon counts. Only used for hog placement right now |
353 procedure ResetWeapons; |
353 procedure ResetWeapons; |
354 var i, slot, a: Longword; |
354 var i, slot, a: Longword; |
355 t: TAmmoType; |
355 t: TAmmoType; |
356 begin |
356 begin |
357 for i:= 0 to Pred(StoreCnt) do |
357 for i:= 0 to Pred(StoreCnt) do |
358 for slot:= 0 to cMaxSlotIndex do |
358 for slot:= 0 to cMaxSlotIndex do |
359 begin |
359 begin |
360 for a:= 0 to cMaxSlotAmmoIndex do |
360 for a:= 0 to cMaxSlotAmmoIndex do |
361 with StoresList[i]^[slot, a] do |
361 with StoresList[i]^[slot, a] do |
362 Count:= InitialCount; |
362 Count:= InitialCount; |
363 |
363 |
364 PackAmmo(StoresList[i], slot) |
364 PackAmmo(StoresList[i], slot) |
365 end; |
365 end; |
366 for t:= Low(TAmmoType) to High(TAmmoType) do |
366 for t:= Low(TAmmoType) to High(TAmmoType) do |
367 if Ammoz[t].SkipTurns >= 10000 then dec(Ammoz[t].SkipTurns,10000); |
367 if Ammoz[t].SkipTurns >= 10000 then dec(Ammoz[t].SkipTurns,10000); |
368 end; |
368 end; |
369 |
369 |
370 procedure init_uAmmos; |
370 procedure init_uAmmos; |
371 begin |
371 begin |
372 shoppa:= false; |
372 shoppa:= false; |
373 StoreCnt:= 0 |
373 StoreCnt:= 0 |
374 end; |
374 end; |
375 |
375 |
376 procedure free_uAmmos; |
376 procedure free_uAmmos; |
377 var i: LongWord; |
377 var i: LongWord; |
378 begin |
378 begin |
379 if StoreCnt > 0 then |
379 if StoreCnt > 0 then |
380 for i:= 0 to Pred(StoreCnt) do Dispose(StoresList[i]); |
380 for i:= 0 to Pred(StoreCnt) do Dispose(StoresList[i]); |
381 StoreCnt:= 0 |
381 StoreCnt:= 0 |
382 end; |
382 end; |
383 |
383 |
384 end. |
384 end. |