68 amBaseballBat: AddGear(round(X) + hwSign(dX) * 10, round(Y), gtShover, 0, xx * 0.5, yy * 0.5).Radius:= 20; |
68 amBaseballBat: AddGear(round(X) + hwSign(dX) * 10, round(Y), gtShover, 0, xx * 0.5, yy * 0.5).Radius:= 20; |
69 amFirePunch: CurAmmoGear:= AddGear(round(X) + hwSign(dX) * 10, round(Y), gtFirePunch, 0); |
69 amFirePunch: CurAmmoGear:= AddGear(round(X) + hwSign(dX) * 10, round(Y), gtFirePunch, 0); |
70 amParachute: CurAmmoGear:= AddGear(round(X), round(Y), gtParachute, 0); |
70 amParachute: CurAmmoGear:= AddGear(round(X), round(Y), gtParachute, 0); |
71 amAirAttack: AddGear(0, 0, gtAirAttack, 0); |
71 amAirAttack: AddGear(0, 0, gtAirAttack, 0); |
72 amMineStrike: AddGear(0, 0, gtAirAttack, 1); |
72 amMineStrike: AddGear(0, 0, gtAirAttack, 1); |
|
73 amBlowTorch: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtBlowTorch, 0, hwSign(Gear.dX) * 0.5); |
73 end; |
74 end; |
74 Power:= 0; |
75 Power:= 0; |
75 if CurAmmoGear <> nil then |
76 if CurAmmoGear <> nil then |
76 begin |
77 begin |
77 Message:= Message or gm_Attack; |
78 Message:= Message or gm_Attack; |
124 RecountTeamHealth(PHedgehog(HH.Hedgehog)^.Team) |
125 RecountTeamHealth(PHedgehog(HH.Hedgehog)^.Team) |
125 end; |
126 end; |
126 end; |
127 end; |
127 end; |
128 end; |
128 |
129 |
|
130 const StepTicks: LongWord = 0; |
|
131 |
|
132 procedure HedgehogStep(Gear: PGear); |
|
133 var PrevdX: integer; |
|
134 begin |
|
135 if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0) then |
|
136 begin |
|
137 if ((Gear.Message and gm_LJump ) <> 0) then |
|
138 begin |
|
139 Gear.Message:= 0; |
|
140 if not TestCollisionYwithGear(Gear, -1) then |
|
141 if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
|
142 if not TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
|
143 if not (TestCollisionXwithGear(Gear, hwSign(Gear.dX)) |
|
144 or TestCollisionYwithGear(Gear, -1)) then |
|
145 begin |
|
146 Gear.dY:= -0.15; |
|
147 Gear.dX:= hwSign(Gear.dX) * 0.15; |
|
148 Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
149 exit |
|
150 end; |
|
151 end; |
|
152 if ((Gear.Message and gm_HJump ) <> 0) then |
|
153 begin |
|
154 Gear.Message:= 0; |
|
155 if not TestCollisionYwithGear(Gear, -1) then |
|
156 begin |
|
157 Gear.dY:= -0.20; |
|
158 Gear.dX:= 0.0000001 * hwSign(Gear.dX); |
|
159 Gear.X:= Gear.X - hwSign(Gear.dX)*0.00008; // shift compensation |
|
160 Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
161 exit |
|
162 end; |
|
163 end; |
|
164 PrevdX:= hwSign(Gear.dX); |
|
165 if (Gear.Message and gm_Left )<>0 then Gear.dX:= -cLittle else |
|
166 if (Gear.Message and gm_Right )<>0 then Gear.dX:= cLittle else exit; |
|
167 StepTicks:= cHHStepTicks; |
|
168 if PrevdX <> hwSign(Gear.dX) then exit; |
|
169 PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
|
170 if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then |
|
171 begin |
|
172 if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear.dX)) |
|
173 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
174 if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear.dX)) |
|
175 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
176 if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear.dX)) |
|
177 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
178 if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear.dX)) |
|
179 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
180 if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) |
|
181 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
182 if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) |
|
183 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
184 end; |
|
185 if not TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then Gear.X:= Gear.X + hwSign(Gear.dX); |
|
186 |
|
187 SetAllHHToActive; |
|
188 |
|
189 if not TestCollisionYwithGear(Gear, 1) then |
|
190 begin |
|
191 Gear.Y:= Gear.Y + 1; |
|
192 if not TestCollisionYwithGear(Gear, 1) then |
|
193 begin |
|
194 Gear.Y:= Gear.Y + 1; |
|
195 if not TestCollisionYwithGear(Gear, 1) then |
|
196 begin |
|
197 Gear.Y:= Gear.Y + 1; |
|
198 if not TestCollisionYwithGear(Gear, 1) then |
|
199 begin |
|
200 Gear.Y:= Gear.Y + 1; |
|
201 if not TestCollisionYwithGear(Gear, 1) then |
|
202 begin |
|
203 Gear.Y:= Gear.Y + 1; |
|
204 if not TestCollisionYwithGear(Gear, 1) then |
|
205 begin |
|
206 Gear.Y:= Gear.Y + 1; |
|
207 if not TestCollisionYwithGear(Gear, 1) then |
|
208 begin |
|
209 Gear.Y:= Gear.Y - 6; |
|
210 Gear.dY:= 0; |
|
211 Gear.State:= Gear.State or gstFalling |
|
212 end; |
|
213 end |
|
214 end |
|
215 end |
|
216 end |
|
217 end |
|
218 end |
|
219 end |
|
220 end; |
|
221 |
129 procedure doStepHedgehog(Gear: PGear); forward; |
222 procedure doStepHedgehog(Gear: PGear); forward; |
130 //////////////////////////////////////////////////////////////////////////////// |
223 //////////////////////////////////////////////////////////////////////////////// |
131 procedure doStepHedgehogDriven(Gear: PGear); |
224 procedure doStepHedgehogDriven(Gear: PGear); |
132 const StepTicks: LongWord = 0; |
|
133 var t: PGear; |
225 var t: PGear; |
134 PrevdX: integer; |
|
135 begin |
226 begin |
136 if isInMultiShoot and (Gear.Damage = 0) then |
227 if isInMultiShoot and (Gear.Damage = 0) then |
137 begin |
228 begin |
138 exit |
229 exit |
139 end; |
230 end; |
192 end; |
283 end; |
193 CheckGearDrowning(Gear); |
284 CheckGearDrowning(Gear); |
194 exit |
285 exit |
195 end ;//else if Gear.CollIndex = High(Longword) then AddIntersectorsCR(Gear); |
286 end ;//else if Gear.CollIndex = High(Longword) then AddIntersectorsCR(Gear); |
196 |
287 |
197 if StepTicks > 0 then dec(StepTicks); |
288 if ((Gear.State and (gstMoving or gstFalling)) = 0) then |
198 |
289 if (Gear.Message and gm_Up )<>0 then if Gear.Angle > 0 then dec(Gear.Angle) |
199 if ((Gear.State and (gstMoving or gstFalling)) = 0) then |
290 else else |
200 if (Gear.Message and gm_Up )<>0 then if Gear.Angle > 0 then dec(Gear.Angle) |
291 if (Gear.Message and gm_Down )<>0 then if Gear.Angle < cMaxAngle then inc(Gear.Angle); |
201 else else |
292 |
202 if (Gear.Message and gm_Down )<>0 then if Gear.Angle < cMaxAngle then inc(Gear.Angle); |
293 if StepTicks > 0 then dec(StepTicks); |
203 |
294 if (StepTicks = 0) then HedgehogStep(Gear) |
204 if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0)and(StepTicks = 0) then |
|
205 begin |
|
206 if ((Gear.Message and gm_LJump ) <> 0) then |
|
207 begin |
|
208 Gear.Message:= 0; |
|
209 if not TestCollisionYwithGear(Gear, -1) then |
|
210 if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
|
211 if not TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
|
212 if not (TestCollisionXwithGear(Gear, hwSign(Gear.dX)) |
|
213 or TestCollisionYwithGear(Gear, -1)) then |
|
214 begin |
|
215 Gear.dY:= -0.15; |
|
216 Gear.dX:= hwSign(Gear.dX) * 0.15; |
|
217 Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
218 exit |
|
219 end; |
|
220 end; |
|
221 if ((Gear.Message and gm_HJump ) <> 0) then |
|
222 begin |
|
223 Gear.Message:= 0; |
|
224 if not TestCollisionYwithGear(Gear, -1) then |
|
225 begin |
|
226 Gear.dY:= -0.20; |
|
227 Gear.dX:= 0.0000001 * hwSign(Gear.dX); |
|
228 Gear.X:= Gear.X - hwSign(Gear.dX)*0.00008; // shift compensation |
|
229 Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
230 exit |
|
231 end; |
|
232 end; |
|
233 PrevdX:= hwSign(Gear.dX); |
|
234 if (Gear.Message and gm_Left )<>0 then Gear.dX:= -cLittle else |
|
235 if (Gear.Message and gm_Right )<>0 then Gear.dX:= cLittle else exit; |
|
236 StepTicks:= cHHStepTicks; |
|
237 if PrevdX <> hwSign(Gear.dX) then exit; |
|
238 PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
|
239 if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then |
|
240 begin |
|
241 if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear.dX)) |
|
242 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
243 if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear.dX)) |
|
244 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
245 if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear.dX)) |
|
246 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
247 if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear.dX)) |
|
248 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
249 if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) |
|
250 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
251 if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) |
|
252 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
253 end; |
|
254 if not TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then Gear.X:= Gear.X + hwSign(Gear.dX); |
|
255 |
|
256 SetAllHHToActive; |
|
257 |
|
258 if not TestCollisionYwithGear(Gear, 1) then |
|
259 begin |
|
260 Gear.Y:= Gear.Y + 1; |
|
261 if not TestCollisionYwithGear(Gear, 1) then |
|
262 begin |
|
263 Gear.Y:= Gear.Y + 1; |
|
264 if not TestCollisionYwithGear(Gear, 1) then |
|
265 begin |
|
266 Gear.Y:= Gear.Y + 1; |
|
267 if not TestCollisionYwithGear(Gear, 1) then |
|
268 begin |
|
269 Gear.Y:= Gear.Y + 1; |
|
270 if not TestCollisionYwithGear(Gear, 1) then |
|
271 begin |
|
272 Gear.Y:= Gear.Y + 1; |
|
273 if not TestCollisionYwithGear(Gear, 1) then |
|
274 begin |
|
275 Gear.Y:= Gear.Y + 1; |
|
276 if not TestCollisionYwithGear(Gear, 1) then |
|
277 begin |
|
278 Gear.Y:= Gear.Y - 6; |
|
279 Gear.dY:= 0; |
|
280 Gear.State:= Gear.State or gstFalling |
|
281 end; |
|
282 end |
|
283 end |
|
284 end |
|
285 end |
|
286 end |
|
287 end |
|
288 end |
|
289 end; |
295 end; |
290 |
296 |
291 //////////////////////////////////////////////////////////////////////////////// |
297 //////////////////////////////////////////////////////////////////////////////// |
292 procedure doStepHedgehogFree(Gear: PGear); |
298 procedure doStepHedgehogFree(Gear: PGear); |
293 begin |
299 begin |