hedgewars/HHHandlers.inc
changeset 6081 537bbd5c1a62
parent 6014 b432c4b9cc9b
child 6092 fd602b5838ab
equal deleted inserted replaced
6080:ce02ddfe8aa1 6081:537bbd5c1a62
   636 
   636 
   637    if ((Gear^.Message and gmLJump ) <> 0) then
   637    if ((Gear^.Message and gmLJump ) <> 0) then
   638       begin
   638       begin
   639       Gear^.Message:= Gear^.Message and not gmLJump;
   639       Gear^.Message:= Gear^.Message and not gmLJump;
   640       DeleteCI(Gear);
   640       DeleteCI(Gear);
   641       if not TestCollisionYwithGear(Gear, -1) then
   641       if TestCollisionYwithGear(Gear, -1) = 0 then
   642          if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else
   642          if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else
   643          if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1;
   643          if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1;
   644       if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX))
   644       if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX))
   645          or   TestCollisionYwithGear(Gear, -1)) then
   645          or   (TestCollisionYwithGear(Gear, -1) <> 0)) then
   646          begin
   646          begin
   647          Gear^.dY:= -_0_15;
   647          Gear^.dY:= -_0_15;
   648          if not cArtillery then Gear^.dX:= SignAs(_0_15, Gear^.dX);
   648          if not cArtillery then Gear^.dX:= SignAs(_0_15, Gear^.dX);
   649          Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   649          Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   650          PlaySound(sndJump1, Gear^.Hedgehog^.Team^.voicepack);
   650          PlaySound(sndJump1, Gear^.Hedgehog^.Team^.voicepack);
   683 
   683 
   684    Gear^.Hedgehog^.visStepPos:= (Gear^.Hedgehog^.visStepPos + 1) and 7;
   684    Gear^.Hedgehog^.visStepPos:= (Gear^.Hedgehog^.visStepPos + 1) and 7;
   685    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
   685    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
   686       begin
   686       begin
   687       if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX))
   687       if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX))
   688          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   688          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   689       if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX))
   689       if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX))
   690          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   690          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   691       if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX))
   691       if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX))
   692          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   692          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   693       if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX))
   693       if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX))
   694          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   694          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   695       if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX))
   695       if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX))
   696          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   696          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   697       if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
   697       if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
   698          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   698          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   699       end;
   699       end;
   700 
   700 
   701    if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then
   701    if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then
   702       Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX);
   702       Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX);
   703 
   703 
   704    SetAllHHToActive;
   704    SetAllHHToActive;
   705 
   705 
   706    if not TestCollisionYwithGear(Gear, 1) then
   706    if TestCollisionYwithGear(Gear, 1) = 0 then
   707    begin
   707    begin
   708    Gear^.Y:= Gear^.Y + _1;
   708    Gear^.Y:= Gear^.Y + _1;
   709    if not TestCollisionYwithGear(Gear, 1) then
   709    if TestCollisionYwithGear(Gear, 1) = 0 then
   710    begin
   710    begin
   711    Gear^.Y:= Gear^.Y + _1;
   711    Gear^.Y:= Gear^.Y + _1;
   712    if not TestCollisionYwithGear(Gear, 1) then
   712    if TestCollisionYwithGear(Gear, 1) = 0 then
   713    begin
   713    begin
   714    Gear^.Y:= Gear^.Y + _1;
   714    Gear^.Y:= Gear^.Y + _1;
   715    if not TestCollisionYwithGear(Gear, 1) then
   715    if TestCollisionYwithGear(Gear, 1) = 0 then
   716    begin
   716    begin
   717    Gear^.Y:= Gear^.Y + _1;
   717    Gear^.Y:= Gear^.Y + _1;
   718    if not TestCollisionYwithGear(Gear, 1) then
   718    if TestCollisionYwithGear(Gear, 1) = 0 then
   719    begin
   719    begin
   720    Gear^.Y:= Gear^.Y + _1;
   720    Gear^.Y:= Gear^.Y + _1;
   721    if not TestCollisionYwithGear(Gear, 1) then
   721    if TestCollisionYwithGear(Gear, 1) = 0 then
   722    begin
   722    begin
   723    Gear^.Y:= Gear^.Y + _1;
   723    Gear^.Y:= Gear^.Y + _1;
   724    if not TestCollisionYwithGear(Gear, 1) then
   724    if TestCollisionYwithGear(Gear, 1) = 0 then
   725       begin
   725       begin
   726       Gear^.Y:= Gear^.Y - _6;
   726       Gear^.Y:= Gear^.Y - _6;
   727       Gear^.dY:= _0;
   727       Gear^.dY:= _0;
   728       Gear^.State:= Gear^.State or gstMoving;
   728       Gear^.State:= Gear^.State or gstMoving;
   729       exit
   729       exit
   756 
   756 
   757 procedure doStepHedgehog(Gear: PGear); forward;
   757 procedure doStepHedgehog(Gear: PGear); forward;
   758 ////////////////////////////////////////////////////////////////////////////////
   758 ////////////////////////////////////////////////////////////////////////////////
   759 procedure doStepHedgehogMoving(Gear: PGear);
   759 procedure doStepHedgehogMoving(Gear: PGear);
   760 var isFalling, isUnderwater: boolean;
   760 var isFalling, isUnderwater: boolean;
   761 begin
   761     land: Word;
       
   762 begin
       
   763 land:= 0;
   762 isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius;
   764 isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius;
   763 if Gear^.dX.QWordValue > 8160437862 then Gear^.dX.QWordValue:= 8160437862;
   765 if Gear^.dX.QWordValue > 8160437862 then Gear^.dX.QWordValue:= 8160437862;
   764 if Gear^.dY.QWordValue > 8160437862 then Gear^.dY.QWordValue:= 8160437862;
   766 if Gear^.dY.QWordValue > 8160437862 then Gear^.dY.QWordValue:= 8160437862;
   765 
   767 
   766 if Gear^.Hedgehog^.Unplaced then
   768 if Gear^.Hedgehog^.Unplaced then
   794           then Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density
   796           then Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density
   795        end
   797        end
   796    end 
   798    end 
   797 else
   799 else
   798    begin
   800    begin
   799    if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue)
   801    land:= TestCollisionYwithGear(Gear, 1);
       
   802    if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0)
   800       and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX);
   803       and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX);
   801 
   804 
   802    if not Gear^.dY.isNegative then
   805    if not Gear^.dY.isNegative then
   803       begin
   806       begin
   804       CheckHHDamage(Gear);
   807       CheckHHDamage(Gear);
   808 
   811 
   809       Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump);
   812       Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump);
   810       Gear^.dY:= _0;
   813       Gear^.dY:= _0;
   811       end else Gear^.dY:= Gear^.dY + cGravity;
   814       end else Gear^.dY:= Gear^.dY + cGravity;
   812 
   815 
   813    if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction
   816    if ((Gear^.State and gstMoving) <> 0) then
       
   817        begin
       
   818        if land and lfIce <> 0 then Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2)
       
   819        else Gear^.dX:= Gear^.dX * Gear^.Friction;
       
   820        end
   814    end;
   821    end;
   815 
   822 
   816 if (Gear^.State <> 0) then DeleteCI(Gear);
   823 if (Gear^.State <> 0) then DeleteCI(Gear);
   817 
   824 
   818 if isUnderwater then
   825 if isUnderwater then