author | Wuzzy <Wuzzy2@mail.ru> |
Tue, 07 Jul 2020 00:07:40 +0200 | |
changeset 15717 | eeab5b90c082 |
parent 15624 | 30ad3fd974f1 |
child 15908 | 014f4edd0421 |
permissions | -rw-r--r-- |
71 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
71 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
71 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
71 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
10017
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
71 | 17 |
*) |
18 |
||
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
4 | 21 |
unit uAIActions; |
22 |
interface |
|
4357
a1fcfc341a52
Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents:
3407
diff
changeset
|
23 |
uses uFloat, uTypes; |
2630 | 24 |
|
3165
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
2630
diff
changeset
|
25 |
const MAXACTIONS = 96; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
26 |
aia_none = 0; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
27 |
aia_Left = 1; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
28 |
aia_Right = 2; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
29 |
aia_Timer = 3; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
30 |
aia_attack = 4; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
31 |
aia_Up = 5; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
32 |
aia_Down = 6; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
33 |
aia_Switch = 7; |
15624
30ad3fd974f1
Teach AI to set minimum mine bounce for improved aiming
Wuzzy <Wuzzy2@mail.ru>
parents:
15412
diff
changeset
|
34 |
aia_Precise = 8; |
4 | 35 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
36 |
aia_Weapon = $8000; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
37 |
aia_WaitXL = $8001; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
38 |
aia_WaitXR = $8002; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
39 |
aia_LookLeft = $8003; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
40 |
aia_LookRight = $8004; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
41 |
aia_AwareExpl = $8005; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
42 |
aia_HJump = $8006; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
43 |
aia_LJump = $8007; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
44 |
aia_Skip = $8008; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
45 |
aia_Wait = $8009; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
46 |
aia_Put = $800A; |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
47 |
aia_waitAngle = $800B; |
7416
2f2f78fc65a3
AI uses cake! Known issues: AI could damage itself for no reason, could let cake go looping in a hole with exit closed by AI hog.
unc0rr
parents:
7197
diff
changeset
|
48 |
aia_waitAmmoXY = $800C; |
10017 | 49 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
50 |
aim_push = $8000; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
51 |
aim_release = $8001; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
52 |
ai_specmask = $8000; |
4 | 53 |
|
64 | 54 |
type TAction = record |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
55 |
Action: Longword; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
56 |
X, Y, Param: LongInt; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
57 |
Time: Longword; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
58 |
end; |
10017 | 59 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
60 |
TActions = record |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
61 |
Count, Pos: Longword; |
14528 | 62 |
ticks: Longword; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
63 |
actions: array[0..Pred(MAXACTIONS)] of TAction; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
64 |
Score: LongInt; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
65 |
isWalkingToABetterPlace: boolean; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
66 |
end; |
4 | 67 |
|
371 | 68 |
procedure AddAction(var Actions: TActions; Action: Longword; Param: LongInt; TimeDelta: Longword; X, Y: LongInt); |
64 | 69 |
procedure ProcessAction(var Actions: TActions; Me: PGear); |
369 | 70 |
|
4 | 71 |
implementation |
15412 | 72 |
uses uAIMisc, uAI, uAmmos, uVariables, uCommands, uConsts, uUtils, uIO{$IFDEF TRACEAIACTIONS}, uConsole{$ENDIF}; |
4 | 73 |
|
7028 | 74 |
var PrevX: LongInt = 0; |
75 |
timedelta: Longword = 0; |
|
76 |
||
15624
30ad3fd974f1
Teach AI to set minimum mine bounce for improved aiming
Wuzzy <Wuzzy2@mail.ru>
parents:
15412
diff
changeset
|
77 |
const ActionIdToStr: array[0..8] of string[16] = ( |
4 | 78 |
{aia_none} '', |
79 |
{aia_Left} 'left', |
|
80 |
{aia_Right} 'right', |
|
81 |
{aia_Timer} 'timer', |
|
82 |
{aia_attack} 'attack', |
|
83 |
{aia_Up} 'up', |
|
6393 | 84 |
{aia_Down} 'down', |
15624
30ad3fd974f1
Teach AI to set minimum mine bounce for improved aiming
Wuzzy <Wuzzy2@mail.ru>
parents:
15412
diff
changeset
|
85 |
{aia_Switch} 'switch', |
30ad3fd974f1
Teach AI to set minimum mine bounce for improved aiming
Wuzzy <Wuzzy2@mail.ru>
parents:
15412
diff
changeset
|
86 |
{aia_Precise} 'precise' |
64 | 87 |
); |
4 | 88 |
|
80 | 89 |
{$IFDEF TRACEAIACTIONS} |
7901 | 90 |
const SpecActionIdToStr: array[$8000..$800C] of string[16] = ( |
80 | 91 |
{aia_Weapon} 'aia_Weapon', |
92 |
{aia_WaitX} 'aia_WaitX', |
|
93 |
{aia_WaitY} 'aia_WaitY', |
|
94 |
{aia_LookLeft} 'aia_LookLeft', |
|
95 |
{aia_LookRight} 'aia_LookRight', |
|
96 |
{aia_AwareExpl} 'aia_AwareExpl', |
|
97 |
{aia_HJump} 'aia_HJump', |
|
144 | 98 |
{aia_LJump} 'aia_LJump', |
193 | 99 |
{aia_Skip} 'aia_Skip', |
7901 | 100 |
{aia_Wait} 'aia_Wait', |
101 |
{aia_Put} 'aia_Put', |
|
102 |
{aia_waitAngle} 'aia_waitAngle', |
|
103 |
{aia_waitAmmoXY} 'aia_waitAmmoXY' |
|
80 | 104 |
); |
105 |
||
106 |
procedure DumpAction(Action: TAction; Me: PGear); |
|
107 |
begin |
|
108 |
if (Action.Action and ai_specmask) = 0 then |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
109 |
WriteLnToConsole('AI action: '+ActionIdToStr[Action.Action]) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
110 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
111 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
112 |
WriteLnToConsole('AI action: '+SpecActionIdToStr[Action.Action]); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
113 |
if (Action.Action = aia_WaitXL) or (Action.Action = aia_WaitXR) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
114 |
WriteLnToConsole('AI action Wait X = '+IntToStr(Action.Param)+', current X = '+IntToStr(hwRound(Me^.X))) |
10017 | 115 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
116 |
else if (Action.Action = aia_AwareExpl) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
117 |
WriteLnToConsole('Aware X = ' + IntToStr(Action.X) + ', Y = ' + IntToStr(Action.Y)); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
118 |
end |
80 | 119 |
end; |
120 |
{$ENDIF} |
|
121 |
||
371 | 122 |
procedure AddAction(var Actions: TActions; Action: Longword; Param: LongInt; TimeDelta: Longword; X, Y: LongInt); |
4 | 123 |
begin |
7433
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
124 |
if Actions.Count < MAXACTIONS then |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
125 |
with Actions do |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
126 |
begin |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
127 |
actions[Count].Action:= Action; |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
128 |
actions[Count].Param:= Param; |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
129 |
actions[Count].X:= X; |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
130 |
actions[Count].Y:= Y; |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
131 |
if Count > 0 then |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
132 |
actions[Count].Time:= TimeDelta |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
133 |
else |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
134 |
actions[Count].Time:= GameTicks + TimeDelta; |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
135 |
inc(Count); |
c7fff3e61d49
- Implement AI land marks which only used to tracks visited areas on the map for now. Significantly reduces wasting of cpu time by AI checking same place several times (10x or even more in rare cases)
unc0rr
parents:
7416
diff
changeset
|
136 |
end |
4 | 137 |
end; |
138 |
||
6474
42e9773eedfd
- Improve renderer a bit, disallow nested functions
unc0rr
parents:
6395
diff
changeset
|
139 |
procedure CheckHang(Me: PGear); |
42e9773eedfd
- Improve renderer a bit, disallow nested functions
unc0rr
parents:
6395
diff
changeset
|
140 |
begin |
42e9773eedfd
- Improve renderer a bit, disallow nested functions
unc0rr
parents:
6395
diff
changeset
|
141 |
if hwRound(Me^.X) <> PrevX then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
142 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
143 |
PrevX:= hwRound(Me^.X); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
144 |
timedelta:= 0 |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
145 |
end else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
146 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
147 |
inc(timedelta); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
148 |
if timedelta > 1700 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
149 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
150 |
timedelta:= 0; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
151 |
FreeActionsList |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
152 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
153 |
end |
6474
42e9773eedfd
- Improve renderer a bit, disallow nested functions
unc0rr
parents:
6395
diff
changeset
|
154 |
end; |
42e9773eedfd
- Improve renderer a bit, disallow nested functions
unc0rr
parents:
6395
diff
changeset
|
155 |
|
64 | 156 |
procedure ProcessAction(var Actions: TActions; Me: PGear); |
4 | 157 |
var s: shortstring; |
158 |
begin |
|
194 | 159 |
repeat |
64 | 160 |
if Actions.Pos >= Actions.Count then exit; |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
161 |
|
64 | 162 |
with Actions.actions[Actions.Pos] do |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
163 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
164 |
if Time > GameTicks then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
165 |
exit; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
166 |
{$IFDEF TRACEAIACTIONS} |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
167 |
DumpAction(Actions.actions[Actions.Pos], Me); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
168 |
{$ENDIF} |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
169 |
if (Action and ai_specmask) <> 0 then |
4 | 170 |
case Action of |
10017 | 171 |
aia_Weapon: |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
172 |
SetWeapon(TAmmoType(Param)); |
10017 | 173 |
|
174 |
aia_WaitXL: |
|
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
175 |
if hwRound(Me^.X) = Param then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
176 |
begin |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
177 |
Action:= aia_LookLeft; |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
178 |
Time:= GameTicks; |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
179 |
exit |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
180 |
end |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
181 |
else if hwRound(Me^.X) < Param then |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
182 |
begin |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
183 |
//OutError('AI: WaitXL assert (' + IntToStr(hwRound(Me^.X)) + ' < ' + IntToStr(Param) + ')', false); |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
184 |
FreeActionsList; |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
185 |
exit |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
186 |
end |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
187 |
else |
10017 | 188 |
begin |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
189 |
CheckHang(Me); |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
190 |
exit |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
191 |
end; |
10017 | 192 |
|
193 |
aia_WaitXR: |
|
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
194 |
if hwRound(Me^.X) = Param then |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
195 |
begin |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
196 |
Action:= aia_LookRight; |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
197 |
Time:= GameTicks; |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
198 |
exit |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
199 |
end |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
200 |
else if hwRound(Me^.X) > Param then |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
201 |
begin |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
202 |
//OutError('AI: WaitXR assert (' + IntToStr(hwRound(Me^.X)) + ' > ' + IntToStr(Param) + ')', false); |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
203 |
FreeActionsList; |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
204 |
exit |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
205 |
end |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
206 |
else |
10017 | 207 |
begin |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
208 |
CheckHang(Me); |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
209 |
exit |
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
210 |
end; |
15411 | 211 |
aia_LookLeft: begin |
212 |
if (Me^.State and gstMoving) <> 0 then |
|
213 |
exit; |
|
214 |
||
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
215 |
if not Me^.dX.isNegative then |
15411 | 216 |
begin |
217 |
if (Me^.Message and gmLeft) = 0 then |
|
218 |
ParseCommand('+left', true); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
219 |
exit |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
220 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
221 |
else |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
222 |
ParseCommand('-left', true); |
15411 | 223 |
end; |
224 |
aia_LookRight: begin |
|
225 |
if (Me^.State and gstMoving) <> 0 then |
|
226 |
exit; |
|
227 |
||
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
228 |
if Me^.dX.isNegative then |
15411 | 229 |
begin |
230 |
if (Me^.Message and gmRight) = 0 then |
|
231 |
ParseCommand('+right', true); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
232 |
exit |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
233 |
end |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
234 |
else ParseCommand('-right', true); |
15411 | 235 |
end; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
236 |
aia_AwareExpl: |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
237 |
AwareOfExplosion(X, Y, Param); |
10017 | 238 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
239 |
aia_HJump: |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
240 |
ParseCommand('hjump', true); |
10017 | 241 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
242 |
aia_LJump: |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
243 |
ParseCommand('ljump', true); |
10017 | 244 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
245 |
aia_Skip: |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
246 |
ParseCommand('skip', true); |
10017 | 247 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
248 |
aia_Put: |
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
249 |
doPut(X, Y, true); |
10017 | 250 |
|
7197
5a9775b97c7e
- TestSniperRifle ftw (still needs some consts adjustments, because AI seems to love sniper rifle too much)
unc0rr
parents:
7132
diff
changeset
|
251 |
aia_waitAngle: |
7721 | 252 |
if LongInt(Me^.Angle) <> Abs(Param) then exit; |
7416
2f2f78fc65a3
AI uses cake! Known issues: AI could damage itself for no reason, could let cake go looping in a hole with exit closed by AI hog.
unc0rr
parents:
7197
diff
changeset
|
253 |
|
2f2f78fc65a3
AI uses cake! Known issues: AI could damage itself for no reason, could let cake go looping in a hole with exit closed by AI hog.
unc0rr
parents:
7197
diff
changeset
|
254 |
aia_waitAmmoXY: |
10017 | 255 |
if (CurAmmoGear <> nil) and ((hwRound(CurAmmoGear^.X) <> X) or (hwRound(CurAmmoGear^.Y) <> Y)) then |
7901 | 256 |
exit; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
257 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
258 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
259 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
260 |
s:= ActionIdToStr[Action]; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
261 |
if (Param and ai_specmask) <> 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
262 |
case Param of |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
263 |
aim_push: |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
264 |
s:= '+' + s; |
10017 | 265 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
266 |
aim_release: |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
267 |
s:= '-' + s; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
268 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
269 |
else if Param <> 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
270 |
s:= s + ' ' + IntToStr(Param); |
369 | 271 |
ParseCommand(s, true) |
4 | 272 |
end |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
273 |
end; |
66
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
274 |
inc(Actions.Pos); |
9643d75baf1e
Many AI improvements, bots do think in separate thread
unc0rr
parents:
64
diff
changeset
|
275 |
if Actions.Pos <= Actions.Count then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6535
diff
changeset
|
276 |
inc(Actions.actions[Actions.Pos].Time, GameTicks); |
194 | 277 |
until false |
4 | 278 |
end; |
369 | 279 |
|
4 | 280 |
end. |