53 Count, Pos: Longword; |
53 Count, Pos: Longword; |
54 actions: array[0..Pred(MAXACTIONS)] of TAction; |
54 actions: array[0..Pred(MAXACTIONS)] of TAction; |
55 Score: integer; |
55 Score: integer; |
56 end; |
56 end; |
57 |
57 |
58 procedure AddAction(var Actions: TActions; Action, Param, TimeDelta: Longword; const X: integer = 0; Y: integer = 0); |
58 procedure AddAction(var Actions: TActions; Action, Param, TimeDelta: Longword; X, Y: integer); |
59 procedure ProcessAction(var Actions: TActions; Me: PGear); |
59 procedure ProcessAction(var Actions: TActions; Me: PGear); |
60 *) |
60 |
61 implementation |
61 implementation |
62 (*uses uMisc, uTeams, uConsts, uConsole, uAIMisc; |
62 uses uMisc, uTeams, uConsts, uConsole, uAIMisc; |
63 |
63 |
64 const ActionIdToStr: array[0..6] of string[16] = ( |
64 const ActionIdToStr: array[0..6] of string[16] = ( |
65 {aia_none} '', |
65 {aia_none} '', |
66 {aia_Left} 'left', |
66 {aia_Left} 'left', |
67 {aia_Right} 'right', |
67 {aia_Right} 'right', |
144 DumpAction(Actions.actions[Actions.Pos], Me); |
144 DumpAction(Actions.actions[Actions.Pos], Me); |
145 {$ENDIF} |
145 {$ENDIF} |
146 if (Action and ai_specmask) <> 0 then |
146 if (Action and ai_specmask) <> 0 then |
147 case Action of |
147 case Action of |
148 aia_Weapon: SetWeapon(TAmmoType(Param)); |
148 aia_Weapon: SetWeapon(TAmmoType(Param)); |
149 aia_WaitXL: if round(Me.X) = Param then Time:= GameTicks |
149 aia_WaitXL: if hwRound(Me^.X) = Param then Time:= GameTicks |
150 else if Round(Me.X) < Param then |
150 else if hwRound(Me^.X) < Param then |
151 begin |
151 begin |
152 OutError('AI: WaitXL assert'); |
152 OutError('AI: WaitXL assert', false); |
153 Actions.Count:= 0 |
153 Actions.Count:= 0 |
154 end |
154 end |
155 else begin CheckHang; exit end; |
155 else begin CheckHang; exit end; |
156 aia_WaitXR: if round(Me.X) = Param then Time:= GameTicks |
156 aia_WaitXR: if hwRound(Me^.X) = Param then Time:= GameTicks |
157 else if Round(Me.X) > Param then |
157 else if hwRound(Me^.X) > Param then |
158 begin |
158 begin |
159 OutError('AI: WaitXR assert'); |
159 OutError('AI: WaitXR assert', false); |
160 Actions.Count:= 0 |
160 Actions.Count:= 0 |
161 end |
161 end |
162 else begin CheckHang; exit end; |
162 else begin CheckHang; exit end; |
163 aia_LookLeft: if Me.dX >= 0 then |
163 aia_LookLeft: if not Me^.dX.isNegative then |
164 begin |
164 begin |
165 ParseCommand('+left'); |
165 ParseCommand('+left', true); |
166 exit |
166 exit |
167 end else ParseCommand('-left'); |
167 end else ParseCommand('-left', true); |
168 aia_LookRight: if Me.dX < 0 then |
168 aia_LookRight: if Me^.dX.isNegative then |
169 begin |
169 begin |
170 ParseCommand('+right'); |
170 ParseCommand('+right', true); |
171 exit |
171 exit |
172 end else ParseCommand('-right'); |
172 end else ParseCommand('-right', true); |
173 aia_AwareExpl: AwareOfExplosion(X, Y, Param); |
173 aia_AwareExpl: AwareOfExplosion(X, Y, Param); |
174 aia_HJump: ParseCommand('hjump'); |
174 aia_HJump: ParseCommand('hjump', true); |
175 aia_LJump: ParseCommand('ljump'); |
175 aia_LJump: ParseCommand('ljump', true); |
176 aia_Skip: ParseCommand('skip'); |
176 aia_Skip: ParseCommand('skip', true); |
177 end else |
177 end else |
178 begin |
178 begin |
179 s:= ActionIdToStr[Action]; |
179 s:= ActionIdToStr[Action]; |
180 if (Param and ai_specmask) <> 0 then |
180 if (Param and ai_specmask) <> 0 then |
181 case Param of |
181 case Param of |
182 aim_push: s:= '+' + s; |
182 aim_push: s:= '+' + s; |
183 aim_release: s:= '-' + s; |
183 aim_release: s:= '-' + s; |
184 end |
184 end |
185 else if Param <> 0 then s:= s + ' ' + inttostr(Param); |
185 else if Param <> 0 then s:= s + ' ' + inttostr(Param); |
186 ParseCommand(s) |
186 ParseCommand(s, true) |
187 end |
187 end |
188 end; |
188 end; |
189 inc(Actions.Pos); |
189 inc(Actions.Pos); |
190 if Actions.Pos <= Actions.Count then |
190 if Actions.Pos <= Actions.Count then |
191 inc(Actions.actions[Actions.Pos].Time, GameTicks); |
191 inc(Actions.actions[Actions.Pos].Time, GameTicks); |
192 until false |
192 until false |
193 end; |
193 end; |
194 *) |
194 |
195 end. |
195 end. |