16068
|
1 |
unit uAI2;
|
|
2 |
|
|
3 |
interface
|
|
4 |
|
|
5 |
procedure ProcessBot;
|
|
6 |
procedure initModule;
|
|
7 |
|
|
8 |
implementation
|
|
9 |
uses uLandUtils, uFloat, uVariables, uTypes;
|
|
10 |
|
|
11 |
{$linklib hwengine_future}
|
|
12 |
|
16078
|
13 |
type TAmmoCounts = array[TAmmoType] of Longword;
|
|
14 |
PAmmoCounts = ^TAmmoCounts;
|
|
15 |
|
16068
|
16 |
function create_ai(game_field: pointer): pointer; cdecl; external;
|
|
17 |
procedure ai_clear_team(ai: pointer); cdecl; external;
|
16078
|
18 |
procedure ai_add_team_hedgehog(ai: pointer; x, y: real; ammo_counts: PAmmoCounts); cdecl; external;
|
16068
|
19 |
procedure ai_think(ai: pointer); cdecl; external;
|
16069
|
20 |
function ai_have_plan(): boolean; cdecl; external;
|
16068
|
21 |
procedure dispose_ai(ai: pointer); cdecl; external;
|
|
22 |
|
|
23 |
var ai: pointer;
|
|
24 |
|
|
25 |
procedure ProcessBot;
|
|
26 |
var currHedgehogIndex, itHedgehog: Longword;
|
16078
|
27 |
itAmmo: TAmmoType;
|
|
28 |
ammoCounts: TAmmoCounts;
|
16068
|
29 |
begin
|
|
30 |
if ai = nil then
|
|
31 |
begin
|
|
32 |
ai:= create_ai(gameField)
|
|
33 |
end;
|
|
34 |
|
|
35 |
ai_clear_team(ai);
|
|
36 |
|
|
37 |
currHedgehogIndex:= CurrentTeam^.CurrHedgehog;
|
|
38 |
itHedgehog:= currHedgehogIndex;
|
|
39 |
repeat
|
|
40 |
with CurrentTeam^.Hedgehogs[itHedgehog] do
|
|
41 |
if (Gear <> nil) and (Effects[heFrozen] = 0) then
|
|
42 |
begin
|
16078
|
43 |
for itAmmo:= Low(TAmmoType) to High(TAmmoType) do
|
|
44 |
ammoCounts[itAmmo]:= HHHasAmmo(CurrentTeam^.Hedgehogs[itHedgehog], itAmmo);
|
|
45 |
|
|
46 |
ai_add_team_hedgehog(ai, hwFloat2float(Gear^.X), hwFloat2float(Gear^.Y), ammoCounts)
|
16068
|
47 |
end;
|
|
48 |
itHedgehog:= Succ(itHedgehog) mod CurrentTeam^.HedgehogsNumber;
|
|
49 |
until (itHedgehog = currHedgehogIndex);
|
16078
|
50 |
|
|
51 |
ai_think(ai);
|
16068
|
52 |
end;
|
|
53 |
|
|
54 |
procedure initModule;
|
|
55 |
begin
|
|
56 |
ai:= nil
|
|
57 |
end;
|
|
58 |
|
|
59 |
end.
|
|
60 |
|