68 uses uAIMisc, uAI, uAmmos, uVariables, uCommands, uUtils, uDebug, uIO{$IFDEF TRACEAIACTIONS}, uConsole{$ENDIF}; |
69 uses uAIMisc, uAI, uAmmos, uVariables, uCommands, uUtils, uDebug, uIO{$IFDEF TRACEAIACTIONS}, uConsole{$ENDIF}; |
69 |
70 |
70 var PrevX: LongInt = 0; |
71 var PrevX: LongInt = 0; |
71 timedelta: Longword = 0; |
72 timedelta: Longword = 0; |
72 |
73 |
73 const ActionIdToStr: array[0..7] of string[16] = ( |
74 const ActionIdToStr: array[0..8] of string[16] = ( |
74 {aia_none} '', |
75 {aia_none} '', |
75 {aia_Left} 'left', |
76 {aia_Left} 'left', |
76 {aia_Right} 'right', |
77 {aia_Right} 'right', |
77 {aia_Timer} 'timer', |
78 {aia_Timer} 'timer', |
78 {aia_attack} 'attack', |
79 {aia_attack} 'attack', |
79 {aia_Up} 'up', |
80 {aia_Up} 'up', |
80 {aia_Down} 'down', |
81 {aia_Down} 'down', |
81 {aia_Switch} 'switch' |
82 {aia_Switch} 'switch', |
|
83 {aia_waitAngle} 'waitAngle' |
82 ); |
84 ); |
83 |
85 |
84 {$IFDEF TRACEAIACTIONS} |
86 {$IFDEF TRACEAIACTIONS} |
85 const SpecActionIdToStr: array[$8000..$8009] of string[16] = ( |
87 const SpecActionIdToStr: array[$8000..$8009] of string[16] = ( |
86 {aia_Weapon} 'aia_Weapon', |
88 {aia_Weapon} 'aia_Weapon', |
148 procedure ProcessAction(var Actions: TActions; Me: PGear); |
150 procedure ProcessAction(var Actions: TActions; Me: PGear); |
149 var s: shortstring; |
151 var s: shortstring; |
150 begin |
152 begin |
151 repeat |
153 repeat |
152 if Actions.Pos >= Actions.Count then exit; |
154 if Actions.Pos >= Actions.Count then exit; |
|
155 |
153 with Actions.actions[Actions.Pos] do |
156 with Actions.actions[Actions.Pos] do |
154 begin |
157 begin |
155 if Time > GameTicks then |
158 if Time > GameTicks then |
156 exit; |
159 exit; |
157 {$IFDEF TRACEAIACTIONS} |
160 {$IFDEF TRACEAIACTIONS} |
158 DumpAction(Actions.actions[Actions.Pos], Me); |
161 DumpAction(Actions.actions[Actions.Pos], Me); |
159 {$ENDIF} |
162 {$ENDIF} |
160 if (Action and ai_specmask) <> 0 then |
163 if (Action and ai_specmask) <> 0 then |
161 case Action of |
164 case Action of |
162 aia_Weapon: |
165 aia_Weapon: |
163 SetWeapon(TAmmoType(Param)); |
166 SetWeapon(TAmmoType(Param)); |
164 |
167 |
165 aia_WaitXL: |
168 aia_WaitXL: |
166 if hwRound(Me^.X) = Param then |
169 if hwRound(Me^.X) = Param then |
167 begin |
170 begin |
168 Action:= aia_LookLeft; |
171 Action:= aia_LookLeft; |
169 Time:= GameTicks; |
172 Time:= GameTicks; |
170 exit |
173 exit |
171 end |
174 end |
172 else if hwRound(Me^.X) < Param then |
175 else if hwRound(Me^.X) < Param then |
173 begin |
176 begin |
174 //OutError('AI: WaitXL assert (' + IntToStr(hwRound(Me^.X)) + ' < ' + IntToStr(Param) + ')', false); |
177 //OutError('AI: WaitXL assert (' + IntToStr(hwRound(Me^.X)) + ' < ' + IntToStr(Param) + ')', false); |
175 FreeActionsList; |
178 FreeActionsList; |
176 exit |
179 exit |
177 end |
180 end |
178 else |
181 else |
179 begin |
182 begin |
180 CheckHang(Me); |
183 CheckHang(Me); |
181 exit |
184 exit |
182 end; |
185 end; |
183 |
186 |
184 aia_WaitXR: |
187 aia_WaitXR: |
185 if hwRound(Me^.X) = Param then |
188 if hwRound(Me^.X) = Param then |
186 begin |
189 begin |
187 Action:= aia_LookRight; |
190 Action:= aia_LookRight; |
188 Time:= GameTicks; |
191 Time:= GameTicks; |
189 exit |
192 exit |
190 end |
193 end |
191 else if hwRound(Me^.X) > Param then |
194 else if hwRound(Me^.X) > Param then |
192 begin |
195 begin |
193 //OutError('AI: WaitXR assert (' + IntToStr(hwRound(Me^.X)) + ' > ' + IntToStr(Param) + ')', false); |
196 //OutError('AI: WaitXR assert (' + IntToStr(hwRound(Me^.X)) + ' > ' + IntToStr(Param) + ')', false); |
194 FreeActionsList; |
197 FreeActionsList; |
|
198 exit |
|
199 end |
|
200 else |
|
201 begin |
|
202 CheckHang(Me); |
|
203 exit |
|
204 end; |
|
205 aia_LookLeft: |
|
206 if not Me^.dX.isNegative then |
|
207 begin |
|
208 ParseCommand('+left', true); |
195 exit |
209 exit |
196 end |
210 end |
197 else |
211 else |
198 begin |
212 ParseCommand('-left', true); |
199 CheckHang(Me); |
|
200 exit |
|
201 end; |
|
202 aia_LookLeft: |
|
203 if not Me^.dX.isNegative then |
|
204 begin |
|
205 ParseCommand('+left', true); |
|
206 exit |
|
207 end |
|
208 else |
|
209 ParseCommand('-left', true); |
|
210 aia_LookRight: |
213 aia_LookRight: |
211 if Me^.dX.isNegative then |
214 if Me^.dX.isNegative then |
212 begin |
215 begin |
213 ParseCommand('+right', true); |
216 ParseCommand('+right', true); |
214 exit |
217 exit |
215 end |
218 end |
216 else ParseCommand('-right', true); |
219 else ParseCommand('-right', true); |
217 aia_AwareExpl: |
220 aia_AwareExpl: |
218 AwareOfExplosion(X, Y, Param); |
221 AwareOfExplosion(X, Y, Param); |
219 |
222 |
220 aia_HJump: |
223 aia_HJump: |
221 ParseCommand('hjump', true); |
224 ParseCommand('hjump', true); |
222 |
225 |
223 aia_LJump: |
226 aia_LJump: |
224 ParseCommand('ljump', true); |
227 ParseCommand('ljump', true); |
225 |
228 |
226 aia_Skip: |
229 aia_Skip: |
227 ParseCommand('skip', true); |
230 ParseCommand('skip', true); |
228 |
231 |
229 aia_Put: |
232 aia_Put: |
230 doPut(X, Y, true); |
233 doPut(X, Y, true); |
|
234 |
|
235 aia_waitAngle: |
|
236 if Me^.Angle <> Abs(Param) then exit; |
231 end |
237 end |
232 else |
238 else |
233 begin |
239 begin |
234 s:= ActionIdToStr[Action]; |
240 s:= ActionIdToStr[Action]; |
235 if (Param and ai_specmask) <> 0 then |
241 if (Param and ai_specmask) <> 0 then |