51 uses uMisc, uGears, uWorld, uLocale, uConsole, uMobile; |
51 uses uMisc, uGears, uWorld, uLocale, uConsole, uMobile; |
52 |
52 |
53 type TAmmoCounts = array[TAmmoType] of Longword; |
53 type TAmmoCounts = array[TAmmoType] of Longword; |
54 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo; |
54 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo; |
55 ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring; |
55 ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring; |
|
56 InitialCounts: array[0..Pred(cMaxHHs)] of TAmmoCounts; |
56 |
57 |
57 procedure FillAmmoStore(Ammo: PHHAmmo; var cnts: TAmmoCounts); |
58 procedure FillAmmoStore(Ammo: PHHAmmo; var cnts: TAmmoCounts); |
58 var mi: array[0..cMaxSlotIndex] of byte; |
59 var mi: array[0..cMaxSlotIndex] of byte; |
59 a: TAmmoType; |
60 a: TAmmoType; |
60 begin |
61 begin |
66 begin |
67 begin |
67 if cnts[a] > 0 then |
68 if cnts[a] > 0 then |
68 begin |
69 begin |
69 TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true); |
70 TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true); |
70 Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo; |
71 Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo; |
71 |
72 with Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]] do |
72 Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].Count:= cnts[a]; |
73 begin |
73 Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].InitialCount:= cnts[a]; |
74 Count:= cnts[a]; |
74 |
75 if (TotalRounds < 0) and ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then Count:= AMMO_INFINITE; |
75 if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then |
76 end; |
76 Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].Count:= AMMO_INFINITE; |
|
77 inc(mi[Ammoz[a].Slot]) |
77 inc(mi[Ammoz[a].Slot]) |
78 end |
78 end |
79 else if (TotalRounds < 0) and ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then |
79 else if (TotalRounds < 0) and ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then |
80 begin |
80 begin |
81 TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true); |
81 TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true); |
82 Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo; |
82 Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo; |
83 |
83 |
84 Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].Count:= AMMO_INFINITE; |
84 Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].Count:= AMMO_INFINITE; |
85 Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].InitialCount:= 0; |
|
86 |
85 |
87 inc(mi[Ammoz[a].Slot]) |
86 inc(mi[Ammoz[a].Slot]) |
88 end |
87 end |
89 end |
88 end |
90 end; |
89 end; |
142 Ammoz[a].SkipTurns:= 1; |
141 Ammoz[a].SkipTurns:= 1; |
143 |
142 |
144 if ((GameFlags and gfPlaceHog) <> 0) and |
143 if ((GameFlags and gfPlaceHog) <> 0) and |
145 (a <> amTeleport) and (a <> amSkip) and |
144 (a <> amTeleport) and (a <> amSkip) and |
146 (Ammoz[a].SkipTurns < 10000) then inc(Ammoz[a].SkipTurns,10000) |
145 (Ammoz[a].SkipTurns < 10000) then inc(Ammoz[a].SkipTurns,10000) |
147 end else |
146 end |
148 ammos[a]:= AMMO_INFINITE |
147 else ammos[a]:= AMMO_INFINITE; |
|
148 InitialCounts[Pred(StoreCnt)][a]:= ammos[a]; |
149 end; |
149 end; |
150 |
150 FillAmmoStore(StoresList[Pred(StoreCnt)], ammos); |
151 FillAmmoStore(StoresList[Pred(StoreCnt)], ammos) |
151 for cnt:= 0 to cMaxSlotIndex do |
|
152 PackAmmo(StoresList[Pred(StoreCnt)], cnt) |
152 end; |
153 end; |
153 |
154 |
154 function GetAmmoByNum(num: Longword): PHHAmmo; |
155 function GetAmmoByNum(num: Longword): PHHAmmo; |
155 begin |
156 begin |
156 TryDo(num < StoreCnt, 'Invalid store number', true); |
157 TryDo(num < StoreCnt, 'Invalid store number', true); |
383 for a:= 0 to cMaxSlotAmmoIndex do |
384 for a:= 0 to cMaxSlotAmmoIndex do |
384 with StoresList[i]^[slot, a] do |
385 with StoresList[i]^[slot, a] do |
385 if (Propz and ammoprop_NotBorder) <> 0 then |
386 if (Propz and ammoprop_NotBorder) <> 0 then |
386 begin |
387 begin |
387 Count:= 0; |
388 Count:= 0; |
388 InitialCount:= 0 |
389 InitialCounts[i][AmmoType]:= 0 |
389 end; |
390 end; |
390 |
391 |
391 PackAmmo(StoresList[i], slot) |
392 PackAmmo(StoresList[i], slot) |
392 end; |
393 end; |
393 |
394 |
423 for i:= 0 to Pred(StoreCnt) do |
424 for i:= 0 to Pred(StoreCnt) do |
424 for slot:= 0 to cMaxSlotIndex do |
425 for slot:= 0 to cMaxSlotIndex do |
425 begin |
426 begin |
426 for a:= 0 to cMaxSlotAmmoIndex do |
427 for a:= 0 to cMaxSlotAmmoIndex do |
427 with StoresList[i]^[slot, a] do |
428 with StoresList[i]^[slot, a] do |
428 Count:= InitialCount; |
429 if AmmoType <> amNothing then Count:= InitialCounts[i][AmmoType]; |
429 |
430 |
430 PackAmmo(StoresList[i], slot) |
431 PackAmmo(StoresList[i], slot) |
431 end; |
432 end; |
432 for t:= Low(TAmmoType) to High(TAmmoType) do |
433 for t:= Low(TAmmoType) to High(TAmmoType) do |
433 if Ammoz[t].SkipTurns >= 10000 then dec(Ammoz[t].SkipTurns,10000); |
434 if Ammoz[t].SkipTurns >= 10000 then dec(Ammoz[t].SkipTurns,10000); |