56 inc(mi[Ammoz[a].Slot]) |
56 inc(mi[Ammoz[a].Slot]) |
57 end |
57 end |
58 end; |
58 end; |
59 |
59 |
60 procedure AddAmmoStore(s: shortstring); |
60 procedure AddAmmoStore(s: shortstring); |
61 // [0,20,30,60,100,150,200,400,600] |
61 const probability: array [0..8] of LongWord = (0,20,30,60,100,150,200,400,600); |
62 var cnt: Longword; |
62 var cnt: Longword; |
63 a: TAmmoType; |
63 a: TAmmoType; |
64 ammos: TAmmoCounts; |
64 ammos: TAmmoCounts; |
65 substr: shortstring; // TEMPORARY |
65 begin |
66 begin |
66 TryDo(byte(s[0]) = byte(ord(High(TAmmoType))) * 2, 'Invalid ammo scheme (incompatible frontend)', true); |
67 TryDo(byte(s[0]) = byte(ord(High(TAmmoType))), 'Invalid ammo scheme (incompatible frontend)', true); |
67 |
68 |
|
69 // FIXME - TEMPORARY hardcoded check on shoppa pending creation of probability editor |
|
70 substr:= Copy(s,1,15); |
|
71 if (substr = '000000990000009') or |
|
72 (substr = '000000990000000') then |
|
73 shoppa:= true; |
|
74 for a:= Low(TAmmoType) to High(TAmmoType) do |
|
75 if (ord(a) > 14) and (s[ord(a)] <> '0') then shoppa:= false; // TEMPORARY etc - this just avoids updating every time new wep is added |
|
76 inc(StoreCnt); |
68 inc(StoreCnt); |
77 TryDo(StoreCnt <= cMaxHHs, 'Ammo stores overflow', true); |
69 TryDo(StoreCnt <= cMaxHHs, 'Ammo stores overflow', true); |
78 |
70 |
79 new(StoresList[Pred(StoreCnt)]); |
71 new(StoresList[Pred(StoreCnt)]); |
80 |
72 |
81 for a:= Low(TAmmoType) to High(TAmmoType) do |
73 for a:= Low(TAmmoType) to High(TAmmoType) do |
82 begin |
74 begin |
83 if a <> amNothing then |
75 if a <> amNothing then |
84 begin |
76 begin |
|
77 Ammoz[a].Probability:= probability[byte(s[ord(a) + ord(High(TAmmoType))]) - byte('0')]; |
85 cnt:= byte(s[ord(a)]) - byte('0'); |
78 cnt:= byte(s[ord(a)]) - byte('0'); |
|
79 // avoid things we already have infinite number |
86 if cnt = 9 then |
80 if cnt = 9 then |
87 begin |
81 begin |
88 cnt:= AMMO_INFINITE; |
82 cnt:= AMMO_INFINITE; |
89 Ammoz[a].Probability:= 0 |
83 Ammoz[a].Probability:= 0 |
90 end; |
84 end; |
|
85 // avoid things we already have by scheme |
91 if ((a = amLowGravity) and ((GameFlags and gfLowGravity) <> 0)) or |
86 if ((a = amLowGravity) and ((GameFlags and gfLowGravity) <> 0)) or |
92 ((a = amInvulnerable) and ((GameFlags and gfInvulnerable) <> 0)) or |
87 ((a = amInvulnerable) and ((GameFlags and gfInvulnerable) <> 0)) or |
93 ((a = amLaserSight) and ((GameFlags and gfLaserSight) <> 0)) or |
88 ((a = amLaserSight) and ((GameFlags and gfLaserSight) <> 0)) or |
94 ((a = amVampiric) and ((GameFlags and gfVampiric) <> 0)) then |
89 ((a = amVampiric) and ((GameFlags and gfVampiric) <> 0)) then |
95 begin |
90 begin |
96 cnt:= 0; |
91 cnt:= 0; |
97 Ammoz[a].Probability:= 0 |
92 Ammoz[a].Probability:= 0 |
98 end |
93 end; |
99 else if shoppa then // FIXME - TEMPORARY REMOVE WHEN CRATE PROBABILITY IS ADDED |
|
100 if cnt <> AMMO_INFINITE then |
|
101 begin |
|
102 if a = amGirder then |
|
103 Ammoz[a].Probability:= 0 |
|
104 else |
|
105 begin |
|
106 Ammoz[a].Probability:= 100; |
|
107 Ammoz[a].NumberInCase:= 1; |
|
108 end |
|
109 end; |
|
110 ammos[a]:= cnt |
94 ammos[a]:= cnt |
111 end else |
95 end else |
112 ammos[a]:= AMMO_INFINITE |
96 ammos[a]:= AMMO_INFINITE |
113 end; |
97 end; |
114 |
98 |
115 FillAmmoStore(StoresList[Pred(StoreCnt)], ammos) |
99 FillAmmoStore(StoresList[Pred(StoreCnt)], ammos) |
116 end; |
100 end; |
117 |
101 |