# HG changeset patch # User Wuzzy # Date 1554289205 -7200 # Node ID 2ad6f0555e6137395cfd8075a0481adea9958c11 # Parent 7dfc6ed13337cae8bf42784cf2d9bfa50582f972 Fix air mine not colliding with crates initially (bug 679) diff -r 7dfc6ed13337 -r 2ad6f0555e61 ChangeLog.txt --- a/ChangeLog.txt Tue Apr 02 23:14:31 2019 +0200 +++ b/ChangeLog.txt Wed Apr 03 13:00:05 2019 +0200 @@ -10,6 +10,7 @@ + Most target practices now highlight position of next target (must be unlocked first) * Fix hedgehogs being pushed around (and other collision bugs) when they overlap * Fix homing bee flying weird if passing wrap world edge or target was placed beyond it + * Fix air mine not colliding with crates initially * Fix poison damage not working in first round * Use player-chosen team identity in campaigns and singleplayer missions * Fix player-chosen teams ignoring custom team controls in campaigns diff -r 7dfc6ed13337 -r 2ad6f0555e61 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Tue Apr 02 23:14:31 2019 +0200 +++ b/hedgewars/uGearsHandlersMess.pas Wed Apr 03 13:00:05 2019 +0200 @@ -2082,6 +2082,20 @@ if (TurnTimeLeft = 0) and ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) > _0_02.QWordValue) then AllInactive := false; + // Disable targeting if airmine is not active yet + if ((Gear^.State and gsttmpFlag) = 0) then + begin + if (TurnTimeLeft = 0) + or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) + or (CurrentHedgehog^.Gear = nil) then + begin + Gear^.FlightTime:= GameTicks; + Gear^.State := Gear^.State or gsttmpFlag; + Gear^.Hedgehog := nil; + end; + exit; + end; + //Disable targeting while the airmine is stunned if Gear^.Tag <> 0 then begin @@ -2128,11 +2142,9 @@ end; // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility) - // or mine is inactive due to lack of gsttmpflag or hunting is disabled due to seek radius of 0 - // then we aren't hunting + // or hunting is disabled due to seek radius of 0 then we aren't hunting if (ReadyTimeLeft > 0) or (TurnTimeLeft = 0) or ((TurnTimeLeft < cHedgehogTurnTime) and (cHedgehogTurnTime-TurnTimeLeft < 5000)) or - (Gear^.State and gsttmpFlag = 0) or (Gear^.Angle = 0) then gear^.State:= gear^.State and (not gstChooseTarget) else if @@ -2193,68 +2205,57 @@ end else Gear^.Hedgehog:= nil; - if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then - begin - if ((Gear^.State and gstAttacking) = 0) then - begin - if ((GameTicks and $1F) = 0) then + if ((Gear^.State and gstAttacking) = 0) then + begin + if ((GameTicks and $1F) = 0) then + begin + if targ <> nil then begin - if targ <> nil then - begin - tX:=Gear^.X-targ^.X; - tY:=Gear^.Y-targ^.Y; - if (tX.Round+tY.Round < Gear^.Boom) and - (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Boom)) then - Gear^.State := Gear^.State or gstAttacking - end - else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Boom, Gear^.Boom) <> nil) then - Gear^.State := Gear^.State or gstAttacking + tX:=Gear^.X-targ^.X; + tY:=Gear^.Y-targ^.Y; + if (tX.Round+tY.Round < Gear^.Boom) and + (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Boom)) then + Gear^.State := Gear^.State or gstAttacking end + else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Boom, Gear^.Boom) <> nil) then + Gear^.State := Gear^.State or gstAttacking end - else // gstAttacking <> 0 - begin - AllInactive := false; - if (Gear^.Timer and $FF) = 0 then - PlaySound(sndMineTick); - if Gear^.Timer = 0 then + end + else // gstAttacking <> 0 + begin + AllInactive := false; + if (Gear^.Timer and $FF) = 0 then + PlaySound(sndMineTick); + if Gear^.Timer = 0 then + begin + // recheck + if targ <> nil then begin - // recheck - if targ <> nil then - begin - tX:=Gear^.X-targ^.X; - tY:=Gear^.Y-targ^.Y; - if (tX.Round+tY.Round < Gear^.Boom) and - (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Boom)) then - begin - Gear^.Hedgehog:= CurrentHedgehog; - tmpG:= FollowGear; - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); - FollowGear:= tmpG; - DeleteGear(Gear); - exit - end - end - else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Boom, Gear^.Boom) <> nil) then + tX:=Gear^.X-targ^.X; + tY:=Gear^.Y-targ^.Y; + if (tX.Round+tY.Round < Gear^.Boom) and + (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Boom)) then begin Gear^.Hedgehog:= CurrentHedgehog; + tmpG:= FollowGear; doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); + FollowGear:= tmpG; DeleteGear(Gear); exit - end; - Gear^.State:= Gear^.State and (not gstAttacking); - Gear^.Timer:= Gear^.WDTimer + end + end + else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Boom, Gear^.Boom) <> nil) then + begin + Gear^.Hedgehog:= CurrentHedgehog; + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); + DeleteGear(Gear); + exit end; - if Gear^.Timer > 0 then - dec(Gear^.Timer); - end - end - else // gsttmpFlag = 0 - if (TurnTimeLeft = 0) - or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) - or (CurrentHedgehog^.Gear = nil) then - begin - Gear^.FlightTime:= GameTicks; - Gear^.State := Gear^.State or gsttmpFlag + Gear^.State:= Gear^.State and (not gstAttacking); + Gear^.Timer:= Gear^.WDTimer + end; + if Gear^.Timer > 0 then + dec(Gear^.Timer); end end; diff -r 7dfc6ed13337 -r 2ad6f0555e61 hedgewars/uGearsHedgehog.pas --- a/hedgewars/uGearsHedgehog.pas Tue Apr 02 23:14:31 2019 +0200 +++ b/hedgewars/uGearsHedgehog.pas Wed Apr 03 13:00:05 2019 +0200 @@ -535,7 +535,6 @@ amRubber, amMinigun: CurAmmoGear:= newGear; end; if CurAmmoType = amCake then FollowGear:= newGear; - if CurAmmoType = amAirMine then newGear^.Hedgehog:= nil; if ((CurAmmoType = amMine) or (CurAmmoType = amSMine) or (CurAmmoType = amAirMine)) and (GameFlags and gfInfAttack <> 0) then newGear^.FlightTime:= GameTicks + min(TurnTimeLeft,1000)