48 function GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo; |
48 function GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo; |
49 |
49 |
50 var StoreCnt: Longword; |
50 var StoreCnt: Longword; |
51 |
51 |
52 implementation |
52 implementation |
53 uses uLocale, uVariables, uCommands, uUtils, uCaptions, uDebug; |
53 uses uVariables, uCommands, uUtils, uCaptions, uDebug; |
54 |
54 |
55 type TAmmoCounts = array[TAmmoType] of Longword; |
55 type TAmmoCounts = array[TAmmoType] of Longword; |
56 TAmmoArray = array[TAmmoType] of TAmmo; |
56 TAmmoArray = array[TAmmoType] of TAmmo; |
57 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo; |
57 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo; |
58 ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring; |
58 ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring; |
130 and (a <> amTeleport) and (a <> amSkip) |
130 and (a <> amTeleport) and (a <> amSkip) |
131 and (Ammoz[a].SkipTurns < 10000) then |
131 and (Ammoz[a].SkipTurns < 10000) then |
132 inc(Ammoz[a].SkipTurns,10000); |
132 inc(Ammoz[a].SkipTurns,10000); |
133 if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then |
133 if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then |
134 ammos[a]:= AMMO_INFINITE |
134 ammos[a]:= AMMO_INFINITE |
135 end |
135 end |
136 |
136 |
137 else |
137 else |
138 ammos[a]:= AMMO_INFINITE; |
138 ammos[a]:= AMMO_INFINITE; |
139 if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then |
139 if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then |
140 InitialCounts[Pred(StoreCnt)][a]:= cnt |
140 InitialCounts[Pred(StoreCnt)][a]:= cnt |
141 else |
141 else |
142 InitialCounts[Pred(StoreCnt)][a]:= ammos[a]; |
142 InitialCounts[Pred(StoreCnt)][a]:= ammos[a]; |
143 end; |
143 end; |
144 |
144 |
145 for a:= Low(TAmmoType) to High(TAmmoType) do |
145 for a:= Low(TAmmoType) to High(TAmmoType) do |
146 begin |
146 begin |
147 newAmmos[a]:= Ammoz[a].Ammo; |
147 newAmmos[a]:= Ammoz[a].Ammo; |
148 newAmmos[a].Count:= ammos[a] |
148 newAmmos[a].Count:= ammos[a] |
149 end; |
149 end; |
150 |
150 |
151 FillAmmoStore(StoresList[Pred(StoreCnt)], newAmmos) |
151 FillAmmoStore(StoresList[Pred(StoreCnt)], newAmmos) |
152 end; |
152 end; |
153 |
153 |
154 function GetAmmoByNum(num: Longword): PHHAmmo; |
154 function GetAmmoByNum(num: Longword): PHHAmmo; |
155 begin |
155 begin |
270 if b then // there is a free item in ammo stack |
270 if b then // there is a free item in ammo stack |
271 begin |
271 begin |
272 Ammo^[Slot, ami]:= Ammo^[Slot, ami + 1]; |
272 Ammo^[Slot, ami]:= Ammo^[Slot, ami + 1]; |
273 Ammo^[Slot, ami + 1].Count:= 0 |
273 Ammo^[Slot, ami + 1].Count:= 0 |
274 end; |
274 end; |
275 until not b; |
275 until (not b); |
276 AmmoMenuInvalidated:= true; |
276 AmmoMenuInvalidated:= true; |
277 end; |
277 end; |
278 |
278 |
279 procedure OnUsedAmmo(var Hedgehog: THedgehog); |
279 procedure OnUsedAmmo(var Hedgehog: THedgehog); |
280 var CurWeapon: PAmmo; |
280 var CurWeapon: PAmmo; |
480 for i:= 0 to cMaxHHIndex do |
480 for i:= 0 to cMaxHHIndex do |
481 Hedgehogs[i].CurAmmoType:= amNothing; |
481 Hedgehogs[i].CurAmmoType:= amNothing; |
482 |
482 |
483 for a:= Low(TAmmoType) to High(TAmmoType) do |
483 for a:= Low(TAmmoType) to High(TAmmoType) do |
484 newAmmos[a]:= Ammoz[a].Ammo; |
484 newAmmos[a]:= Ammoz[a].Ammo; |
485 |
485 |
486 for i:= 0 to Pred(StoreCnt) do |
486 for i:= 0 to Pred(StoreCnt) do |
487 begin |
487 begin |
488 for a:= Low(TAmmoType) to High(TAmmoType) do |
488 for a:= Low(TAmmoType) to High(TAmmoType) do |
489 newAmmos[a].Count:= InitialCounts[i][a]; |
489 newAmmos[a].Count:= InitialCounts[i][a]; |
490 FillAmmoStore(StoresList[i], newAmmos); |
490 FillAmmoStore(StoresList[i], newAmmos); |