16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 *) |
17 *) |
18 |
18 |
19 unit uTeams; |
19 unit uTeams; |
20 interface |
20 interface |
21 uses SDLh, uConsts, uKeys, uGears, uRandom; |
21 uses SDLh, uConsts, uKeys, uGears, uRandom, uAmmos; |
22 {$INCLUDE options.inc} |
22 {$INCLUDE options.inc} |
23 type PHedgehog = ^THedgehog; |
23 type PHedgehog = ^THedgehog; |
24 PTeam = ^TTeam; |
24 PTeam = ^TTeam; |
25 PHHAmmo = ^THHAmmo; |
|
26 THedgehog = record |
25 THedgehog = record |
27 Name: string[MAXNAMELEN]; |
26 Name: string[MAXNAMELEN]; |
28 Gear: PGear; |
27 Gear: PGear; |
29 NameTag, HealthTag: PSDL_Surface; |
28 NameTag, HealthTag: PSDL_Surface; |
30 Ammo: PHHAmmo; |
29 Ammo: PHHAmmo; |
|
30 AmmoStore: Longword; |
31 CurSlot, CurAmmo: LongWord; |
31 CurSlot, CurAmmo: LongWord; |
32 AltSlot, AltAmmo: LongWord; |
32 AltSlot, AltAmmo: LongWord; |
33 Team: PTeam; |
33 Team: PTeam; |
34 AttacksNum: Longword; |
34 AttacksNum: Longword; |
35 visStepPos: LongWord; |
35 visStepPos: LongWord; |
36 BotLevel : LongWord; // 0 - Human player |
36 BotLevel : LongWord; // 0 - Human player |
37 end; |
37 end; |
38 THHAmmo = array[0..cMaxSlotIndex, 0..cMaxSlotAmmoIndex] of TAmmo; |
|
39 TTeam = record |
38 TTeam = record |
40 Next: PTeam; |
39 Next: PTeam; |
41 Color, AdjColor: Longword; |
40 Color, AdjColor: Longword; |
42 TeamName: string[MAXNAMELEN]; |
41 TeamName: string[MAXNAMELEN]; |
43 ExtDriven: boolean; |
42 ExtDriven: boolean; |
179 tt:= tt.Next; |
178 tt:= tt.Next; |
180 Dispose(t) |
179 Dispose(t) |
181 end; |
180 end; |
182 end; |
181 end; |
183 |
182 |
184 procedure FillAmmoGroup(Ammo: PHHAmmo); |
|
185 var mi: array[0..cMaxSlotIndex] of byte; |
|
186 a: TAmmoType; |
|
187 begin |
|
188 FillChar(mi, sizeof(mi), 0); |
|
189 for a:= Low(TAmmoType) to High(TAmmoType) do |
|
190 begin |
|
191 TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true); |
|
192 Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo; |
|
193 inc(mi[Ammoz[a].Slot]) |
|
194 end; |
|
195 end; |
|
196 |
|
197 procedure RecountAllTeamsHealth; |
183 procedure RecountAllTeamsHealth; |
198 var p: PTeam; |
184 var p: PTeam; |
199 begin |
185 begin |
200 p:= TeamsList; |
186 p:= TeamsList; |
201 while p <> nil do |
187 while p <> nil do |
212 begin |
198 begin |
213 p:= TeamsList; |
199 p:= TeamsList; |
214 while p <> nil do |
200 while p <> nil do |
215 begin |
201 begin |
216 th:= 0; |
202 th:= 0; |
217 FillAmmoGroup(@p.Ammos[0]); |
|
218 for i:= 0 to cMaxHHIndex do |
203 for i:= 0 to cMaxHHIndex do |
219 if p.Hedgehogs[i].Gear <> nil then |
204 if p.Hedgehogs[i].Gear <> nil then |
220 begin |
205 begin |
221 p.Hedgehogs[i].Gear.Health:= 100; |
206 p.Hedgehogs[i].Gear.Health:= 100; |
222 inc(th, 100); |
207 inc(th, 100); |
223 p.Hedgehogs[i].Ammo:= @p.Ammos[0] // 0 means all hedgehogs |
|
224 // will have common set of ammo |
|
225 end; |
208 end; |
226 if th > MaxTeamHealth then MaxTeamHealth:= th; |
209 if th > MaxTeamHealth then MaxTeamHealth:= th; |
227 p:= p.Next |
210 p:= p.Next |
228 end; |
211 end; |
229 RecountAllTeamsHealth |
212 RecountAllTeamsHealth |
237 with Hedgehog do |
220 with Hedgehog do |
238 begin |
221 begin |
239 if Ammo[CurSlot, CurAmmo].Count = 0 then |
222 if Ammo[CurSlot, CurAmmo].Count = 0 then |
240 begin |
223 begin |
241 CurAmmo:= 0; |
224 CurAmmo:= 0; |
242 while (CurAmmo <= cMaxSlotAmmoIndex) and (Ammo[CurSlot, CurAmmo].Count = 0) do inc(CurAmmo) |
225 CurSlot:= 0; |
|
226 while (CurSlot <= cMaxSlotIndex) and (Ammo[CurSlot, CurAmmo].Count = 0) do inc(CurSlot) |
243 end; |
227 end; |
244 |
228 |
245 with Ammo[CurSlot, CurAmmo] do |
229 with Ammo[CurSlot, CurAmmo] do |
246 begin |
230 begin |
247 s:= trammo[Ammoz[AmmoType].NameId]; |
231 s:= trammo[Ammoz[AmmoType].NameId]; |