47 aia_WaitX = $80000001; |
48 aia_WaitX = $80000001; |
48 aia_WaitY = $80000002; |
49 aia_WaitY = $80000002; |
49 aia_LookLeft = $80000003; |
50 aia_LookLeft = $80000003; |
50 aia_LookRight = $80000004; |
51 aia_LookRight = $80000004; |
51 aia_AwareExpl = $80000005; |
52 aia_AwareExpl = $80000005; |
|
53 aia_HJump = $80000006; |
|
54 aia_LJump = $80000007; |
52 |
55 |
53 aim_push = $80000000; |
56 aim_push = $80000000; |
54 aim_release = $80000001; |
57 aim_release = $80000001; |
55 ai_specmask = $80000000; |
58 ai_specmask = $80000000; |
56 |
59 |
79 {aia_attack} 'attack', |
82 {aia_attack} 'attack', |
80 {aia_Up} 'up', |
83 {aia_Up} 'up', |
81 {aia_Down} 'down' |
84 {aia_Down} 'down' |
82 ); |
85 ); |
83 |
86 |
|
87 {$IFDEF TRACEAIACTIONS} |
|
88 const SpecActionIdToStr: array[$80000000..$80000006] of string[16] = ( |
|
89 {aia_Weapon} 'aia_Weapon', |
|
90 {aia_WaitX} 'aia_WaitX', |
|
91 {aia_WaitY} 'aia_WaitY', |
|
92 {aia_LookLeft} 'aia_LookLeft', |
|
93 {aia_LookRight} 'aia_LookRight', |
|
94 {aia_AwareExpl} 'aia_AwareExpl', |
|
95 {aia_HJump} 'aia_HJump', |
|
96 {aia_LJump} 'aia_LJump' |
|
97 ); |
|
98 |
|
99 procedure DumpAction(Action: TAction; Me: PGear); |
|
100 begin |
|
101 if (Action.Action and ai_specmask) = 0 then |
|
102 WriteLnToConsole('AI action: '+ActionIdToStr[Action.Action]) |
|
103 else begin |
|
104 WriteLnToConsole('AI action: '+SpecActionIdToStr[Action.Action]); |
|
105 if Action.Action = aia_WaitX then |
|
106 WriteLnToConsole('AI action Wait X = '+inttostr(Action.Param)+', current X = '+inttostr(round(Me.X))); |
|
107 end |
|
108 end; |
|
109 {$ENDIF} |
|
110 |
84 procedure AddAction(var Actions: TActions; Action, Param, TimeDelta: Longword; const X: integer = 0; Y: integer = 0); |
111 procedure AddAction(var Actions: TActions; Action, Param, TimeDelta: Longword; const X: integer = 0; Y: integer = 0); |
85 begin |
112 begin |
86 with Actions do |
113 with Actions do |
87 begin |
114 begin |
88 actions[Count].Action:= Action; |
115 actions[Count].Action:= Action; |
109 begin |
136 begin |
110 if Actions.Pos >= Actions.Count then exit; |
137 if Actions.Pos >= Actions.Count then exit; |
111 with Actions.actions[Actions.Pos] do |
138 with Actions.actions[Actions.Pos] do |
112 begin |
139 begin |
113 if Time > GameTicks then exit; |
140 if Time > GameTicks then exit; |
|
141 {$IFDEF TRACEAIACTIONS} |
|
142 DumpAction(Actions.actions[Actions.Pos], Me); |
|
143 {$ENDIF} |
114 if (Action and ai_specmask) <> 0 then |
144 if (Action and ai_specmask) <> 0 then |
115 case Action of |
145 case Action of |
116 aia_Weapon: SetWeapon(Param); |
146 aia_Weapon: SetWeapon(Param); |
117 aia_WaitX: if round(Me.X) = Param then Time:= GameTicks |
147 aia_WaitX: if round(Me.X) = Param then Time:= GameTicks |
118 else exit; |
148 else exit; |
127 begin |
157 begin |
128 ParseCommand('+right'); |
158 ParseCommand('+right'); |
129 exit |
159 exit |
130 end else ParseCommand('-right'); |
160 end else ParseCommand('-right'); |
131 aia_AwareExpl: AwareOfExplosion(X, Y, Param); |
161 aia_AwareExpl: AwareOfExplosion(X, Y, Param); |
|
162 aia_HJump: ParseCommand('hjump'); |
|
163 aia_LJump: ParseCommand('ljump'); |
132 end else |
164 end else |
133 begin |
165 begin |
134 s:= ActionIdToStr[Action]; |
166 s:= ActionIdToStr[Action]; |
135 if (Param and ai_specmask) <> 0 then |
167 if (Param and ai_specmask) <> 0 then |
136 case Param of |
168 case Param of |