hedgewars/HHHandlers.inc
branchhedgeroid
changeset 6224 42b256eca362
parent 6131 4e8816cf9459
child 6244 23801d8b83d5
equal deleted inserted replaced
6055:88cfcd9161d3 6224:42b256eca362
   371                       amJetpack, amBirdy,
   371                       amJetpack, amBirdy,
   372                  amFlamethrower, amLandGun,
   372                  amFlamethrower, amLandGun,
   373                   amResurrector, amStructure,
   373                   amResurrector, amStructure,
   374                        amTardis: CurAmmoGear:= newGear;
   374                        amTardis: CurAmmoGear:= newGear;
   375                   end;
   375                   end;
       
   376               if (CurAmmoType = amMine) or (CurAmmoType = amSMine) and (GameFlags and gfInfAttack <> 0) then newGear^.FlightTime:= GameTicks + 1000;
   376         if Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then
   377         if Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then
   377             begin
   378             begin
   378             newGear^.Target.X:= TargetPoint.X;
   379             newGear^.Target.X:= TargetPoint.X;
   379             newGear^.Target.Y:= TargetPoint.Y
   380             newGear^.Target.Y:= TargetPoint.Y
   380             end;
   381             end;
   636 
   637 
   637    if ((Gear^.Message and gmLJump ) <> 0) then
   638    if ((Gear^.Message and gmLJump ) <> 0) then
   638       begin
   639       begin
   639       Gear^.Message:= Gear^.Message and not gmLJump;
   640       Gear^.Message:= Gear^.Message and not gmLJump;
   640       DeleteCI(Gear);
   641       DeleteCI(Gear);
   641       if not TestCollisionYwithGear(Gear, -1) then
   642       if TestCollisionYwithGear(Gear, -1) = 0 then
   642          if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else
   643          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;
   644          if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1;
   644       if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX))
   645       if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX))
   645          or   TestCollisionYwithGear(Gear, -1)) then
   646          or   (TestCollisionYwithGear(Gear, -1) <> 0)) then
   646          begin
   647          begin
   647          Gear^.dY:= -_0_15;
   648          Gear^.dY:= -_0_15;
   648          if not cArtillery then Gear^.dX:= SignAs(_0_15, Gear^.dX);
   649          if not cArtillery then Gear^.dX:= SignAs(_0_15, Gear^.dX);
   649          Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   650          Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   650          PlaySound(sndJump1, Gear^.Hedgehog^.Team^.voicepack);
   651          PlaySound(sndJump1, Gear^.Hedgehog^.Team^.voicepack);
   683 
   684 
   684    Gear^.Hedgehog^.visStepPos:= (Gear^.Hedgehog^.visStepPos + 1) and 7;
   685    Gear^.Hedgehog^.visStepPos:= (Gear^.Hedgehog^.visStepPos + 1) and 7;
   685    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
   686    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
   686       begin
   687       begin
   687       if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX))
   688       if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX))
   688          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   689          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   689       if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX))
   690       if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX))
   690          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   691          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   691       if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX))
   692       if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX))
   692          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   693          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   693       if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX))
   694       if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX))
   694          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   695          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   695       if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX))
   696       if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX))
   696          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   697          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   697       if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
   698       if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
   698          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   699          or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1;
   699       end;
   700       end;
   700 
   701 
   701    if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then
   702    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);
   703       Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX);
   703 
   704 
   704    SetAllHHToActive;
   705    SetAllHHToActive;
   705 
   706 
   706    if not TestCollisionYwithGear(Gear, 1) then
   707    if TestCollisionYwithGear(Gear, 1) = 0 then
   707    begin
   708    begin
   708    Gear^.Y:= Gear^.Y + _1;
   709    Gear^.Y:= Gear^.Y + _1;
   709    if not TestCollisionYwithGear(Gear, 1) then
   710    if TestCollisionYwithGear(Gear, 1) = 0 then
   710    begin
   711    begin
   711    Gear^.Y:= Gear^.Y + _1;
   712    Gear^.Y:= Gear^.Y + _1;
   712    if not TestCollisionYwithGear(Gear, 1) then
   713    if TestCollisionYwithGear(Gear, 1) = 0 then
   713    begin
   714    begin
   714    Gear^.Y:= Gear^.Y + _1;
   715    Gear^.Y:= Gear^.Y + _1;
   715    if not TestCollisionYwithGear(Gear, 1) then
   716    if TestCollisionYwithGear(Gear, 1) = 0 then
   716    begin
   717    begin
   717    Gear^.Y:= Gear^.Y + _1;
   718    Gear^.Y:= Gear^.Y + _1;
   718    if not TestCollisionYwithGear(Gear, 1) then
   719    if TestCollisionYwithGear(Gear, 1) = 0 then
   719    begin
   720    begin
   720    Gear^.Y:= Gear^.Y + _1;
   721    Gear^.Y:= Gear^.Y + _1;
   721    if not TestCollisionYwithGear(Gear, 1) then
   722    if TestCollisionYwithGear(Gear, 1) = 0 then
   722    begin
   723    begin
   723    Gear^.Y:= Gear^.Y + _1;
   724    Gear^.Y:= Gear^.Y + _1;
   724    if not TestCollisionYwithGear(Gear, 1) then
   725    if TestCollisionYwithGear(Gear, 1) = 0 then
   725       begin
   726       begin
   726       Gear^.Y:= Gear^.Y - _6;
   727       Gear^.Y:= Gear^.Y - _6;
   727       Gear^.dY:= _0;
   728       Gear^.dY:= _0;
   728       Gear^.State:= Gear^.State or gstMoving;
   729       Gear^.State:= Gear^.State or gstMoving;
   729       exit
   730       exit
   756 
   757 
   757 procedure doStepHedgehog(Gear: PGear); forward;
   758 procedure doStepHedgehog(Gear: PGear); forward;
   758 ////////////////////////////////////////////////////////////////////////////////
   759 ////////////////////////////////////////////////////////////////////////////////
   759 procedure doStepHedgehogMoving(Gear: PGear);
   760 procedure doStepHedgehogMoving(Gear: PGear);
   760 var isFalling, isUnderwater: boolean;
   761 var isFalling, isUnderwater: boolean;
   761 begin
   762     land: Word;
       
   763 begin
       
   764 land:= 0;
   762 isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius;
   765 isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius;
   763 if Gear^.dX.QWordValue > 8160437862 then Gear^.dX.QWordValue:= 8160437862;
   766 if Gear^.dX.QWordValue > 8160437862 then Gear^.dX.QWordValue:= 8160437862;
   764 if Gear^.dY.QWordValue > 8160437862 then Gear^.dY.QWordValue:= 8160437862;
   767 if Gear^.dY.QWordValue > 8160437862 then Gear^.dY.QWordValue:= 8160437862;
   765 
   768 
   766 if Gear^.Hedgehog^.Unplaced then
   769 if Gear^.Hedgehog^.Unplaced then
   794           then Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density
   797           then Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density
   795        end
   798        end
   796    end 
   799    end 
   797 else
   800 else
   798    begin
   801    begin
   799    if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue)
   802    land:= TestCollisionYwithGear(Gear, 1);
       
   803    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);
   804       and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX);
   801 
   805 
   802    if not Gear^.dY.isNegative then
   806    if not Gear^.dY.isNegative then
   803       begin
   807       begin
   804       CheckHHDamage(Gear);
   808       CheckHHDamage(Gear);
   808 
   812 
   809       Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump);
   813       Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump);
   810       Gear^.dY:= _0;
   814       Gear^.dY:= _0;
   811       end else Gear^.dY:= Gear^.dY + cGravity;
   815       end else Gear^.dY:= Gear^.dY + cGravity;
   812 
   816 
   813    if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction
   817    if ((Gear^.State and gstMoving) <> 0) then
       
   818        begin
       
   819        if land and lfIce <> 0 then Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2)
       
   820        else Gear^.dX:= Gear^.dX * Gear^.Friction;
       
   821        end
   814    end;
   822    end;
   815 
   823 
   816 if (Gear^.State <> 0) then DeleteCI(Gear);
   824 if (Gear^.State <> 0) then DeleteCI(Gear);
   817 
   825 
   818 if isUnderwater then
   826 if isUnderwater then
   892 var t: PGear;
   900 var t: PGear;
   893     wasJumping: boolean;
   901     wasJumping: boolean;
   894     Hedgehog: PHedgehog;
   902     Hedgehog: PHedgehog;
   895 begin
   903 begin
   896 Hedgehog:= HHGear^.Hedgehog;
   904 Hedgehog:= HHGear^.Hedgehog;
   897 if not isInMultiShoot then
   905 if isInMultiShoot then
   898    AllInactive:= false
       
   899 else
       
   900    HHGear^.Message:= 0;
   906    HHGear^.Message:= 0;
       
   907 
       
   908 if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then 
       
   909     AllInactive:= true
       
   910 else if not isInMultiShoot then AllInactive:= false;
   901 
   911 
   902 if (TurnTimeLeft = 0) or (HHGear^.Damage > 0) then
   912 if (TurnTimeLeft = 0) or (HHGear^.Damage > 0) then
   903     begin
   913     begin
   904     if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft;
   914     if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft;
   905     TurnTimeLeft:= 0;
   915     TurnTimeLeft:= 0;
  1072     Gear^.Timer:= 150
  1082     Gear^.Timer:= 150
  1073     end else
  1083     end else
  1074     begin
  1084     begin
  1075     if Gear^.Timer = 0 then
  1085     if Gear^.Timer = 0 then
  1076         begin
  1086         begin
  1077         Gear^.State:= Gear^.State and not (gstWait or gstLoser or gstWinner);
  1087         Gear^.State:= Gear^.State and not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable);
  1078         Gear^.Active:= false;
  1088         Gear^.Active:= false;
  1079         AddGearCI(Gear);
  1089         AddGearCI(Gear);
  1080         exit
  1090         exit
  1081         end else dec(Gear^.Timer)
  1091         end else dec(Gear^.Timer)
  1082     end;
  1092     end;
  1084 AllInactive:= false
  1094 AllInactive:= false
  1085 end;
  1095 end;
  1086 
  1096 
  1087 ////////////////////////////////////////////////////////////////////////////////
  1097 ////////////////////////////////////////////////////////////////////////////////
  1088 procedure doStepHedgehog(Gear: PGear);
  1098 procedure doStepHedgehog(Gear: PGear);
       
  1099 (*
       
  1100 var x,y,tx,ty: LongInt;
       
  1101     tdX, tdY, slope: hwFloat; *)
  1089 begin
  1102 begin
  1090 if (Gear^.Message and gmDestroy) <> 0 then
  1103 if (Gear^.Message and gmDestroy) <> 0 then
  1091     begin
  1104     begin
  1092     DeleteGear(Gear);
  1105     DeleteGear(Gear);
  1093     exit
  1106     exit
  1101         if Team^.hasGone then
  1114         if Team^.hasGone then
  1102             TeamGoneEffect(Team^)
  1115             TeamGoneEffect(Team^)
  1103         else
  1116         else
  1104             doStepHedgehogDriven(Gear)
  1117             doStepHedgehogDriven(Gear)
  1105     end;
  1118     end;
  1106 end;
  1119 
       
  1120 if ((GameTicks mod 50) = 0) and (Gear^.State and (gstMoving or gstHHJumping or gstHHHJump) = 0) and ((Gear^.Message and gmAllStoppable) = 0) and 
       
  1121     (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then
       
  1122     begin
       
  1123     if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y)+cHHRadius, lfIce) then
       
  1124         begin
       
  1125         Gear^.dX.QWordValue:= Gear^.dX.QWordValue + cGravity.QWordValue * 75;
       
  1126         Gear^.State:= Gear^.State or gstMoving;
       
  1127         end
       
  1128 (*
       
  1129     // check land slope, and impart a dX based on it
       
  1130     tdX:= Gear^.dX;
       
  1131     tdY:= Gear^.dY;
       
  1132     Gear^.dX:= _0;
       
  1133     Gear^.dY:= _1;
       
  1134     x := hwRound(Gear^.X);
       
  1135     y := hwRound(Gear^.Y);
       
  1136     tx := 0;
       
  1137     ty := 0;
       
  1138     if not CalcSlopeTangent(Gear, x, y+cHHRadius, tx, ty, 255) then
       
  1139         begin
       
  1140         slope:= _1/DistanceI(tx,ty);
       
  1141         AddFileLog(FloatToStr(tdX)+ ' == '+FloatToStr(slope));
       
  1142         tdX:= tdX + (cGravity * slope / _10)  // this will need tuning 
       
  1143         end;
       
  1144     Gear^.dX:= tdX;
       
  1145     Gear^.dY:= tdY  *)
       
  1146     end;
       
  1147 end;