18 |
18 |
19 {$INCLUDE "options.inc"} |
19 {$INCLUDE "options.inc"} |
20 |
20 |
21 unit uGearsHedgehog; |
21 unit uGearsHedgehog; |
22 interface |
22 interface |
23 uses uTypes; |
23 uses uTypes, uGearsHandlersMess; |
24 |
24 |
25 procedure doStepHedgehog(Gear: PGear); |
25 procedure doStepHedgehog(Gear: PGear); |
26 procedure AfterAttack; |
26 procedure AfterAttack; |
27 procedure HedgehogStep(Gear: PGear); |
27 procedure HedgehogStep(Gear: PGear); |
28 procedure doStepHedgehogMoving(Gear: PGear); |
28 procedure doStepHedgehogMoving(Gear: PGear); |
855 exit |
855 exit |
856 end; |
856 end; |
857 isFalling:= (Gear^.dY.isNegative) or (TestCollisionYKick(Gear, 1) = 0); |
857 isFalling:= (Gear^.dY.isNegative) or (TestCollisionYKick(Gear, 1) = 0); |
858 if isFalling then |
858 if isFalling then |
859 begin |
859 begin |
860 if (Gear^.dY.isNegative) and (TestCollisionYKick(Gear, -1) <> 0) then |
860 land:= TestCollisionYKick(Gear, -1); |
861 Gear^.dY:= _0; |
861 if (Gear^.dY.isNegative) and (land <> 0) then |
|
862 begin |
|
863 if land and lfBouncy <> 0 then |
|
864 begin |
|
865 doStepFallingGear(Gear); |
|
866 Gear^.dX:= Gear^.dX * _0_8 |
|
867 end; |
|
868 if (land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0) then |
|
869 Gear^.dY:= _0 |
|
870 end; |
862 Gear^.State:= Gear^.State or gstMoving; |
871 Gear^.State:= Gear^.State or gstMoving; |
863 if (CurrentHedgehog^.Gear = Gear) and (CurrentHedgehog^.Gear^.State and gstHHDriven <> 0) and |
872 if (CurrentHedgehog^.Gear = Gear) and (CurrentHedgehog^.Gear^.State and gstHHDriven <> 0) and |
864 (not CurrentTeam^.ExtDriven) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then |
873 (not CurrentTeam^.ExtDriven) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then |
865 begin |
874 begin |
866 // TODO: why so aggressive at setting FollowGear when falling? |
875 // TODO: why so aggressive at setting FollowGear when falling? |
881 end |
890 end |
882 end |
891 end |
883 else |
892 else |
884 begin |
893 begin |
885 land:= TestCollisionYwithGear(Gear, 1); |
894 land:= TestCollisionYwithGear(Gear, 1); |
886 if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0) |
895 if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0) |
|
896 and ((land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0)) |
887 and ((Gear^.State and gstHHJumping) <> 0) then |
897 and ((Gear^.State and gstHHJumping) <> 0) then |
888 SetLittle(Gear^.dX); |
898 SetLittle(Gear^.dX); |
889 |
899 |
890 if not Gear^.dY.isNegative then |
900 if not Gear^.dY.isNegative then |
891 begin |
901 begin |
|
902 if land and lfBouncy <> 0 then |
|
903 begin |
|
904 doStepFallingGear(Gear); |
|
905 // hogs for some reason have very low friction. slippery little buggers |
|
906 Gear^.dX:= Gear^.dX * _0_8 |
|
907 end; |
|
908 |
892 CheckHHDamage(Gear); |
909 CheckHHDamage(Gear); |
893 |
910 |
894 if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) |
911 if (land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0) then |
895 and (Gear^.dX.QWordValue < _0_02.QWordValue) then |
912 begin |
896 Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump |
913 if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) |
897 Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump)); |
914 and (Gear^.dX.QWordValue < _0_02.QWordValue) then |
898 Gear^.dY:= _0; |
915 begin |
|
916 if land and lfBouncy <> 0 then |
|
917 Gear^.dY:= _0; |
|
918 Gear^.dX.isNegative:= not Gear^.dX.isNegative // landing after high jump |
|
919 end; |
|
920 Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump)); |
|
921 if (land and lfBouncy = 0) or (Gear^.dX.QWordValue < _0_02.QWordValue) then |
|
922 Gear^.dY:= _0 |
|
923 end |
899 end |
924 end |
900 else |
925 else |
901 Gear^.dY:= Gear^.dY + cGravity; |
926 Gear^.dY:= Gear^.dY + cGravity; |
902 |
927 |
903 if ((Gear^.State and gstMoving) <> 0) then |
928 if ((Gear^.State and gstMoving) <> 0) then |
1006 begin |
1031 begin |
1007 Gear^.State:= Gear^.State and (not gstAnimation); |
1032 Gear^.State:= Gear^.State and (not gstAnimation); |
1008 // ARTILLERY but not being moved by explosions |
1033 // ARTILLERY but not being moved by explosions |
1009 Gear^.X:= Gear^.X + Gear^.dX; |
1034 Gear^.X:= Gear^.X + Gear^.dX; |
1010 Gear^.Y:= Gear^.Y + Gear^.dY; |
1035 Gear^.Y:= Gear^.Y + Gear^.dY; |
1011 if (not Gear^.dY.isNegative) and (TestCollisionYKick(Gear, 1) = 0) |
1036 if (not Gear^.dY.isNegative) and (TestCollisionYKick(Gear, 1) = 0) then |
1012 and (TestCollisionYwithXYShift(Gear, 0, 1, 1) <> 0) then |
1037 begin |
1013 begin |
1038 land:= TestCollisionYwithXYShift(Gear, 0, 1, 1); |
1014 CheckHHDamage(Gear); |
1039 if land and lfBouncy <> 0 then |
1015 Gear^.dY:= _0; |
1040 doStepFallingGear(Gear); |
1016 Gear^.Y:= Gear^.Y + _1 |
1041 |
|
1042 if (land <> 0) and ((land and lfBouncy = 0) or (Gear^.State and gstCollision <> 0)) then |
|
1043 begin |
|
1044 CheckHHDamage(Gear); |
|
1045 Gear^.dY:= _0; |
|
1046 Gear^.Y:= Gear^.Y + _1 |
|
1047 end |
1017 end; |
1048 end; |
1018 |
1049 |
1019 CheckGearDrowning(Gear); |
1050 CheckGearDrowning(Gear); |
1020 // could become nil if ai's hog fails to respawn in ai survival |
1051 // could become nil if ai's hog fails to respawn in ai survival |
1021 if Gear = nil then exit; |
1052 if Gear = nil then exit; |