hedgewars/uGearsHandlersMess.pas
changeset 14748 2ad6f0555e61
parent 14742 2e8213c0951f
child 14749 533ac9774279
equal deleted inserted replaced
14747:7dfc6ed13337 14748:2ad6f0555e61
  2080         end;
  2080         end;
  2081     doStepFallingGear(Gear);
  2081     doStepFallingGear(Gear);
  2082     if (TurnTimeLeft = 0) and ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) > _0_02.QWordValue) then
  2082     if (TurnTimeLeft = 0) and ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) > _0_02.QWordValue) then
  2083         AllInactive := false;
  2083         AllInactive := false;
  2084 
  2084 
       
  2085     // Disable targeting if airmine is not active yet
       
  2086     if ((Gear^.State and gsttmpFlag) = 0) then
       
  2087         begin
       
  2088         if (TurnTimeLeft = 0)
       
  2089         or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime))
       
  2090         or (CurrentHedgehog^.Gear = nil) then
       
  2091         begin
       
  2092         Gear^.FlightTime:= GameTicks;
       
  2093         Gear^.State := Gear^.State or gsttmpFlag;
       
  2094         Gear^.Hedgehog := nil;
       
  2095         end;
       
  2096         exit;
       
  2097         end;
       
  2098 
  2085     //Disable targeting while the airmine is stunned
  2099     //Disable targeting while the airmine is stunned
  2086     if Gear^.Tag <> 0 then
  2100     if Gear^.Tag <> 0 then
  2087         begin
  2101         begin
  2088         if ((Gear^.FlightTime and $FF) = 0) then
  2102         if ((Gear^.FlightTime and $FF) = 0) then
  2089             begin
  2103             begin
  2126              then
  2140              then
  2127             targ:= nil
  2141             targ:= nil
  2128         end;
  2142         end;
  2129 
  2143 
  2130     // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility)
  2144     // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility)
  2131     // or mine is inactive due to lack of gsttmpflag or hunting is disabled due to seek radius of 0
  2145     // or hunting is disabled due to seek radius of 0 then we aren't hunting
  2132     // then we aren't hunting
       
  2133     if (ReadyTimeLeft > 0) or (TurnTimeLeft = 0) or 
  2146     if (ReadyTimeLeft > 0) or (TurnTimeLeft = 0) or 
  2134         ((TurnTimeLeft < cHedgehogTurnTime) and (cHedgehogTurnTime-TurnTimeLeft < 5000)) or
  2147         ((TurnTimeLeft < cHedgehogTurnTime) and (cHedgehogTurnTime-TurnTimeLeft < 5000)) or
  2135         (Gear^.State and gsttmpFlag = 0) or
       
  2136         (Gear^.Angle = 0) then
  2148         (Gear^.Angle = 0) then
  2137         gear^.State:= gear^.State and (not gstChooseTarget)
  2149         gear^.State:= gear^.State and (not gstChooseTarget)
  2138     else if
  2150     else if
  2139     // todo, allow not finding new target, set timeout on target retention
  2151     // todo, allow not finding new target, set timeout on target retention
  2140         (Gear^.State and gstAttacking = 0) and
  2152         (Gear^.State and gstAttacking = 0) and
  2191         else if (Gear^.Y > targ^.Y) and (Gear^.dY > -_0_1) then
  2203         else if (Gear^.Y > targ^.Y) and (Gear^.dY > -_0_1) then
  2192             Gear^.dY:= Gear^.dY-trackSpeed
  2204             Gear^.dY:= Gear^.dY-trackSpeed
  2193         end
  2205         end
  2194     else Gear^.Hedgehog:= nil;
  2206     else Gear^.Hedgehog:= nil;
  2195 
  2207 
  2196     if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then
  2208     if ((Gear^.State and gstAttacking) = 0) then
  2197         begin
  2209         begin
  2198         if ((Gear^.State and gstAttacking) = 0) then
  2210         if ((GameTicks and $1F) = 0) then
  2199             begin
  2211             begin
  2200             if ((GameTicks and $1F) = 0) then
  2212             if targ <> nil then
  2201                 begin
  2213                 begin
  2202                 if targ <> nil then
  2214                 tX:=Gear^.X-targ^.X;
  2203                     begin
  2215                 tY:=Gear^.Y-targ^.Y;
  2204                     tX:=Gear^.X-targ^.X;
  2216                 if (tX.Round+tY.Round < Gear^.Boom) and
  2205                     tY:=Gear^.Y-targ^.Y;
  2217                    (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Boom)) then
  2206                     if (tX.Round+tY.Round < Gear^.Boom) and
  2218                 Gear^.State := Gear^.State or gstAttacking
  2207                        (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Boom)) then
       
  2208                     Gear^.State := Gear^.State or gstAttacking
       
  2209                     end
       
  2210                 else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Boom, Gear^.Boom) <> nil) then
       
  2211                     Gear^.State := Gear^.State or gstAttacking
       
  2212                 end
  2219                 end
       
  2220             else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Boom, Gear^.Boom) <> nil) then
       
  2221                 Gear^.State := Gear^.State or gstAttacking
  2213             end
  2222             end
  2214         else // gstAttacking <> 0
  2223         end
  2215             begin
  2224     else // gstAttacking <> 0
  2216             AllInactive := false;
  2225         begin
  2217             if (Gear^.Timer and $FF) = 0 then
  2226         AllInactive := false;
  2218                 PlaySound(sndMineTick);
  2227         if (Gear^.Timer and $FF) = 0 then
  2219             if Gear^.Timer = 0 then
  2228             PlaySound(sndMineTick);
  2220                 begin
  2229         if Gear^.Timer = 0 then
  2221                 // recheck
  2230             begin
  2222                 if targ <> nil then
  2231             // recheck
  2223                     begin
  2232             if targ <> nil then
  2224                     tX:=Gear^.X-targ^.X;
  2233                 begin
  2225                     tY:=Gear^.Y-targ^.Y;
  2234                 tX:=Gear^.X-targ^.X;
  2226                     if (tX.Round+tY.Round < Gear^.Boom) and
  2235                 tY:=Gear^.Y-targ^.Y;
  2227                        (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Boom)) then
  2236                 if (tX.Round+tY.Round < Gear^.Boom) and
  2228                         begin
  2237                    (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Boom)) then
  2229                         Gear^.Hedgehog:= CurrentHedgehog;
       
  2230                         tmpG:= FollowGear;
       
  2231                         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound);
       
  2232                         FollowGear:= tmpG;
       
  2233                         DeleteGear(Gear);
       
  2234                         exit
       
  2235                         end
       
  2236                     end
       
  2237                 else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Boom, Gear^.Boom) <> nil) then
       
  2238                     begin
  2238                     begin
  2239                     Gear^.Hedgehog:= CurrentHedgehog;
  2239                     Gear^.Hedgehog:= CurrentHedgehog;
       
  2240                     tmpG:= FollowGear;
  2240                     doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound);
  2241                     doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound);
       
  2242                     FollowGear:= tmpG;
  2241                     DeleteGear(Gear);
  2243                     DeleteGear(Gear);
  2242                     exit
  2244                     exit
  2243                     end;
  2245                     end
  2244                 Gear^.State:= Gear^.State and (not gstAttacking);
  2246                 end
  2245                 Gear^.Timer:= Gear^.WDTimer
  2247             else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Boom, Gear^.Boom) <> nil) then
       
  2248                 begin
       
  2249                 Gear^.Hedgehog:= CurrentHedgehog;
       
  2250                 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound);
       
  2251                 DeleteGear(Gear);
       
  2252                 exit
  2246                 end;
  2253                 end;
  2247             if Gear^.Timer > 0 then
  2254             Gear^.State:= Gear^.State and (not gstAttacking);
  2248                 dec(Gear^.Timer);
  2255             Gear^.Timer:= Gear^.WDTimer
  2249             end
  2256             end;
  2250         end
  2257         if Gear^.Timer > 0 then
  2251     else // gsttmpFlag = 0
  2258             dec(Gear^.Timer);
  2252         if (TurnTimeLeft = 0)
       
  2253         or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime))
       
  2254         or (CurrentHedgehog^.Gear = nil) then
       
  2255         begin
       
  2256         Gear^.FlightTime:= GameTicks;
       
  2257         Gear^.State := Gear^.State or gsttmpFlag
       
  2258         end
  2259         end
  2259 end;
  2260 end;
  2260 
  2261 
  2261 ////////////////////////////////////////////////////////////////////////////////
  2262 ////////////////////////////////////////////////////////////////////////////////
  2262 procedure doStepSMine(Gear: PGear);
  2263 procedure doStepSMine(Gear: PGear);