15 * along with this program; if not, write to the Free Software |
15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 *) |
17 *) |
18 |
18 |
19 //////////////////////////////////////////////////////////////////////////////// |
19 //////////////////////////////////////////////////////////////////////////////// |
|
20 procedure ChangeAmmo(Gear: PGear); |
|
21 var slot: Longword; |
|
22 caSlot, caAmmo: PLongword; |
|
23 begin |
|
24 slot:= Gear^.MsgParam; |
|
25 |
|
26 with PHedgehog(Gear^.Hedgehog)^ do |
|
27 begin |
|
28 if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
|
29 or ((Gear^.State and gstHHDriven) = 0) then exit; |
|
30 |
|
31 Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump or gm_Slot); |
|
32 |
|
33 if CurAmmoGear = nil then begin caSlot:= @CurSlot; caAmmo:= @CurAmmo end |
|
34 else begin caSlot:= @AltSlot; caAmmo:= @AltAmmo end; |
|
35 |
|
36 if caSlot^ = slot then |
|
37 begin |
|
38 inc(caAmmo^); |
|
39 if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo^[slot, caAmmo^].Count = 0) then caAmmo^:= 0 |
|
40 end else |
|
41 if Ammo^[slot, 0].Count > 0 then |
|
42 begin |
|
43 caSlot^:= slot; |
|
44 caAmmo^:= 0; |
|
45 end; |
|
46 end; |
|
47 ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^) |
|
48 end; |
|
49 |
|
50 procedure HHSetWeapon(Gear: PGear); |
|
51 var t: LongInt; |
|
52 weap: TAmmoType; |
|
53 begin |
|
54 weap:= TAmmoType(Gear^.MsgParam); |
|
55 Gear^.MsgParam:= Ammoz[weap].Slot; |
|
56 |
|
57 t:= cMaxSlotAmmoIndex; |
|
58 |
|
59 Gear^.Message:= Gear^.Message and not gm_Weapon; |
|
60 |
|
61 with PHedgehog(Gear^.Hedgehog)^ do |
|
62 while (Ammo^[CurSlot, CurAmmo].AmmoType <> weap) and (t >= 0) do |
|
63 begin |
|
64 ChangeAmmo(Gear); |
|
65 dec(t) |
|
66 end |
|
67 end; |
|
68 |
20 procedure Attack(Gear: PGear); |
69 procedure Attack(Gear: PGear); |
21 var xx, yy: hwFloat; |
70 var xx, yy: hwFloat; |
22 begin |
71 begin |
23 with Gear^, |
72 with Gear^, |
24 PHedgehog(Gear^.Hedgehog)^ do |
73 PHedgehog(Gear^.Hedgehog)^ do |
280 |
329 |
281 if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction |
330 if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction |
282 end; |
331 end; |
283 |
332 |
284 if (Gear^.State <> 0) then DeleteCI(Gear); |
333 if (Gear^.State <> 0) then DeleteCI(Gear); |
285 |
334 |
286 if (Gear^.State and gstMoving) <> 0 then |
335 if (Gear^.State and gstMoving) <> 0 then |
287 if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
336 if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
288 if not isFalling then |
337 if not isFalling then |
289 if hwAbs(Gear^.dX) > _0_01 then |
338 if hwAbs(Gear^.dX) > _0_01 then |
290 if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_96; Gear^.Y:= Gear^.Y - _1 end else |
339 if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_96; Gear^.Y:= Gear^.Y - _1 end else |
360 begin |
409 begin |
361 CurAmmoGear^.Message:= Gear^.Message; |
410 CurAmmoGear^.Message:= Gear^.Message; |
362 exit |
411 exit |
363 end; |
412 end; |
364 |
413 |
|
414 if ((Gear^.Message and gm_Slot) <> 0) then ChangeAmmo(Gear); |
|
415 |
|
416 if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear); |
|
417 |
365 if ((Gear^.Message and gm_Attack) <> 0) or |
418 if ((Gear^.Message and gm_Attack) <> 0) or |
366 ((Gear^.State and gstAttacking) <> 0) then Attack(Gear); |
419 ((Gear^.State and gstAttacking) <> 0) then Attack(Gear); |
367 |
420 |
368 if (Gear^.State and gstMoving) <> 0 then |
421 if (Gear^.State and gstMoving) <> 0 then |
369 begin |
422 begin |