equal
deleted
inserted
replaced
50 var StoreCnt: LongInt; |
50 var StoreCnt: LongInt; |
51 |
51 |
52 implementation |
52 implementation |
53 uses uVariables, uCommands, uUtils, uCaptions, uDebug, uScript; |
53 uses uVariables, uCommands, uUtils, uCaptions, uDebug, uScript; |
54 |
54 |
55 type TAmmoCounts = array[TAmmoType] of Longword; |
55 type TAmmoArray = array[TAmmoType] of TAmmo; |
56 TAmmoArray = array[TAmmoType] of TAmmo; |
|
57 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo; |
56 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo; |
58 ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring; |
57 ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring; |
59 InitialCounts: array[0..Pred(cMaxHHs)] of TAmmoCounts; |
58 InitialCountsLocal: array[0..Pred(cMaxHHs)] of TAmmoCounts; |
60 |
59 |
61 procedure FillAmmoStore(Ammo: PHHAmmo; var newAmmo: TAmmoArray); |
60 procedure FillAmmoStore(Ammo: PHHAmmo; var newAmmo: TAmmoArray); |
62 var mi: array[0..cMaxSlotIndex] of byte; |
61 var mi: array[0..cMaxSlotIndex] of byte; |
63 a: TAmmoType; |
62 a: TAmmoType; |
64 begin |
63 begin |
77 end; |
76 end; |
78 AmmoMenuInvalidated:= true; |
77 AmmoMenuInvalidated:= true; |
79 end; |
78 end; |
80 |
79 |
81 procedure AddAmmoStore; |
80 procedure AddAmmoStore; |
82 const probability: array [0..8] of LongWord = (0,20,30,60,100,200,400,600,800); |
|
83 var cnt: Longword; |
81 var cnt: Longword; |
84 a: TAmmoType; |
82 a: TAmmoType; |
85 ammos: TAmmoCounts; |
83 ammos: TAmmoCounts; |
86 newAmmos: TAmmoArray; |
84 newAmmos: TAmmoArray; |
87 begin |
85 begin |
97 |
95 |
98 for a:= Low(TAmmoType) to High(TAmmoType) do |
96 for a:= Low(TAmmoType) to High(TAmmoType) do |
99 begin |
97 begin |
100 if a <> amNothing then |
98 if a <> amNothing then |
101 begin |
99 begin |
102 Ammoz[a].Probability:= probability[byte(ammoProbability[ord(a)]) - byte('0')]; |
100 Ammoz[a].Probability:= probabilityLevels[byte(ammoProbability[ord(a)]) - byte('0')]; |
103 Ammoz[a].SkipTurns:= (byte(ammoDelay[ord(a)]) - byte('0')); |
101 Ammoz[a].SkipTurns:= (byte(ammoDelay[ord(a)]) - byte('0')); |
104 Ammoz[a].NumberInCase:= (byte(ammoReinforcement[ord(a)]) - byte('0')); |
102 Ammoz[a].NumberInCase:= (byte(ammoReinforcement[ord(a)]) - byte('0')); |
105 cnt:= byte(ammoLoadout[ord(a)]) - byte('0'); |
103 cnt:= byte(ammoLoadout[ord(a)]) - byte('0'); |
106 // avoid things we already have infinite number |
104 // avoid things we already have infinite number |
107 if cnt = 9 then |
105 if cnt = 9 then |
138 end |
136 end |
139 |
137 |
140 else |
138 else |
141 ammos[a]:= AMMO_INFINITE; |
139 ammos[a]:= AMMO_INFINITE; |
142 if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then |
140 if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then |
143 InitialCounts[Pred(StoreCnt)][a]:= cnt |
141 begin |
|
142 InitialCountsLocal[Pred(StoreCnt)][a]:= cnt; |
|
143 InitialAmmoCounts[a]:= cnt; |
|
144 end |
144 else |
145 else |
145 InitialCounts[Pred(StoreCnt)][a]:= ammos[a]; |
146 begin |
|
147 InitialCountsLocal[Pred(StoreCnt)][a]:= ammos[a]; |
|
148 InitialAmmoCounts[a]:= ammos[a]; |
|
149 end |
146 end; |
150 end; |
147 |
151 |
148 for a:= Low(TAmmoType) to High(TAmmoType) do |
152 for a:= Low(TAmmoType) to High(TAmmoType) do |
149 begin |
153 begin |
150 newAmmos[a]:= Ammoz[a].Ammo; |
154 newAmmos[a]:= Ammoz[a].Ammo; |
456 for a:= 0 to cMaxSlotAmmoIndex do |
460 for a:= 0 to cMaxSlotAmmoIndex do |
457 with StoresList[i]^[slot, a] do |
461 with StoresList[i]^[slot, a] do |
458 if (Propz and ammoprop_NotBorder) <> 0 then |
462 if (Propz and ammoprop_NotBorder) <> 0 then |
459 begin |
463 begin |
460 Count:= 0; |
464 Count:= 0; |
461 InitialCounts[i][AmmoType]:= 0 |
465 InitialCountsLocal[i][AmmoType]:= 0 |
462 end; |
466 end; |
463 |
467 |
464 PackAmmo(StoresList[i], slot) |
468 PackAmmo(StoresList[i], slot) |
465 end; |
469 end; |
466 |
470 |
504 newAmmos[a]:= Ammoz[a].Ammo; |
508 newAmmos[a]:= Ammoz[a].Ammo; |
505 |
509 |
506 for i:= 0 to Pred(StoreCnt) do |
510 for i:= 0 to Pred(StoreCnt) do |
507 begin |
511 begin |
508 for a:= Low(TAmmoType) to High(TAmmoType) do |
512 for a:= Low(TAmmoType) to High(TAmmoType) do |
509 newAmmos[a].Count:= InitialCounts[i][a]; |
513 newAmmos[a].Count:= InitialCountsLocal[i][a]; |
510 FillAmmoStore(StoresList[i], newAmmos); |
514 FillAmmoStore(StoresList[i], newAmmos); |
511 end; |
515 end; |
512 |
516 |
513 for a:= Low(TAmmoType) to High(TAmmoType) do |
517 for a:= Low(TAmmoType) to High(TAmmoType) do |
514 if Ammoz[a].SkipTurns >= 10000 then |
518 if Ammoz[a].SkipTurns >= 10000 then |
544 ammoLoadout:= ammoLoadout + '0'; |
548 ammoLoadout:= ammoLoadout + '0'; |
545 ammoProbability:= ammoProbability + '0'; |
549 ammoProbability:= ammoProbability + '0'; |
546 ammoDelay:= ammoDelay + '0'; |
550 ammoDelay:= ammoDelay + '0'; |
547 ammoReinforcement:= ammoReinforcement + '0' |
551 ammoReinforcement:= ammoReinforcement + '0' |
548 end; |
552 end; |
549 FillChar(InitialCounts, sizeof(InitialCounts), 0) |
553 FillChar(InitialCountsLocal, sizeof(InitialCountsLocal), 0) |
550 end; |
554 end; |
551 |
555 |
552 procedure freeModule; |
556 procedure freeModule; |
553 var i: LongWord; |
557 var i: LongWord; |
554 begin |
558 begin |