changeset 48 | 0f396d0c429d |
parent 17 | a6bed8d31444 |
child 51 | b6e3ae05857f |
47:8daf1ee0b9a3 | 48:0f396d0c429d |
---|---|
35 interface |
35 interface |
36 {$INCLUDE options.inc} |
36 {$INCLUDE options.inc} |
37 procedure ProcessBot; |
37 procedure ProcessBot; |
38 |
38 |
39 implementation |
39 implementation |
40 uses uAIActions, uAIMisc, uMisc, uTeams, uConsts, uAIAmmoTests, uGears, SDLh; |
40 uses uAIActions, uAIMisc, uMisc, uTeams, uConsts, uAIAmmoTests, uGears, SDLh, uConsole; |
41 |
41 |
42 procedure Think; |
42 procedure Think; |
43 var Targets: TTargets; |
43 var Targets: TTargets; |
44 Angle, Power: integer; |
44 Angle, Power: integer; |
45 Time: Longword; |
45 Time: Longword; |
54 begin |
54 begin |
55 Me.X:= round(Gear.X); |
55 Me.X:= round(Gear.X); |
56 Me.Y:= round(Gear.Y); |
56 Me.Y:= round(Gear.Y); |
57 end; |
57 end; |
58 repeat |
58 repeat |
59 if isInMultiShoot then with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
59 if isInMultiShoot or (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].AttacksNum > 0) |
60 then with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
|
60 a:= Ammo[CurSlot, CurAmmo].AmmoType |
61 a:= Ammo[CurSlot, CurAmmo].AmmoType |
61 else a:= TAmmoType(random(ord(High(TAmmoType)))); |
62 else a:= TAmmoType(random(ord(High(TAmmoType)))); |
62 aa:= a; |
63 aa:= a; |
63 repeat |
64 repeat |
64 if Assigned(AmmoTests[a].Test) |
65 if Assigned(AmmoTests[a].Test) |
69 if Time <> 0 then AddAction(aia_Timer, Time div 1000, 400); |
70 if Time <> 0 then AddAction(aia_Timer, Time div 1000, 400); |
70 exit |
71 exit |
71 end; |
72 end; |
72 if a = High(TAmmoType) then a:= Low(TAmmoType) |
73 if a = High(TAmmoType) then a:= Low(TAmmoType) |
73 else inc(a) |
74 else inc(a) |
74 until isInMultiShoot or (a = aa); |
75 until isInMultiShoot or (a = aa) or (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].AttacksNum > 0); |
75 inc(t) |
76 inc(t) |
76 until (t >= Targets.Count) |
77 until (t >= Targets.Count) |
77 end; |
78 end; |
78 |
79 |
79 procedure TryGo(lvl, Flags: Longword); |
80 procedure TryGo(lvl, Flags: Longword); |
110 end |
111 end |
111 end; |
112 end; |
112 |
113 |
113 begin |
114 begin |
114 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
115 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
115 if ((Gear.State and (gstAttacked or gstAttacking or gstMoving or gstFalling)) <> 0) then exit; |
116 if ((Gear.State and (gstAttacked or gstAttacking or gstMoving or gstFalling)) <> 0) |
117 or isInMultiShoot then exit; |
|
116 |
118 |
117 FillTargets(Targets); |
119 FillTargets(Targets); |
118 |
120 |
119 TryGo(0, 0); |
121 TryGo(0, 0); |
120 |
122 |
123 if IsActionListEmpty then |
125 if IsActionListEmpty then |
124 TryGo(0, ctfBreach); |
126 TryGo(0, ctfBreach); |
125 |
127 |
126 if IsActionListEmpty then |
128 if IsActionListEmpty then |
127 begin |
129 begin |
128 AddAction(aia_Weapon, ord(amSkip), 1000); |
130 if CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].AttacksNum = 0 then |
129 AddAction(aia_Attack, aim_push, 1000); |
131 begin |
132 AddAction(aia_Weapon, ord(amSkip), 1000); |
|
133 AddAction(aia_Attack, aim_push, 1000); |
|
134 end else ParseCommand('skip'); |
|
130 exit |
135 exit |
131 end; |
136 end; |
132 |
137 |
133 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
138 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
134 begin |
139 begin |