hedgewars/uCollisions.pas
changeset 9305 8e5140875ab5
parent 9291 15f7bb217b66
child 9521 8054d9d775fd
child 9706 5178d2263521
equal deleted inserted replaced
9304:3f4c3fc146c2 9305:8e5140875ab5
   235     mx:= hwRound(Gear^.X);
   235     mx:= hwRound(Gear^.X);
   236     my:= hwRound(Gear^.Y);
   236     my:= hwRound(Gear^.Y);
   237 
   237 
   238     for i:= 0 to Pred(Count) do
   238     for i:= 0 to Pred(Count) do
   239         with cinfos[i] do
   239         with cinfos[i] do
   240             if (Gear <> cGear) and (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2))
   240             if  (Gear <> cGear) and 
   241             and ((mx > x) xor (Dir > 0)) and
   241                 ((mx > x) xor (Dir > 0)) and
   242                 (
   242                 (
   243                   ((cGear^.Kind in [gtHedgehog, gtMine, gtKnife]) and ((Gear^.State and gstNotKickable) = 0)) or
   243                   ((cGear^.Kind in [gtHedgehog, gtMine, gtKnife]) and ((Gear^.State and gstNotKickable) = 0)) or
   244                 // only apply X kick if the barrel is knocked over
   244                 // only apply X kick if the barrel is knocked over
   245                 ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0))) then
   245                   ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0))
       
   246                 ) and
       
   247                 (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then
   246                     begin
   248                     begin
   247                     with cGear^ do
   249                     with cGear^ do
   248                         begin
   250                         begin
   249                         dX:= Gear^.dX;
   251                         dX:= Gear^.dX;
   250                         dY:= Gear^.dY * _0_5;
   252                         dY:= Gear^.dY * _0_5;
   298     my:= hwRound(Gear^.Y);
   300     my:= hwRound(Gear^.Y);
   299     myr:= my+Gear^.Radius;
   301     myr:= my+Gear^.Radius;
   300 
   302 
   301     for i:= 0 to Pred(Count) do
   303     for i:= 0 to Pred(Count) do
   302         with cinfos[i] do
   304         with cinfos[i] do
   303             if (Gear <> cGear) and (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2))
   305             if (Gear <> cGear) and
   304             and ((myr > y) xor (Dir > 0)) and
   306                ((myr > y) xor (Dir > 0)) and
   305                 (
   307                (Gear^.State and gstNotKickable = 0) and
   306                  (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and 
   308                (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and 
   307                  ((Gear^.State and gstNotKickable) = 0)) then
   309                (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then
   308                     begin
   310                     begin
   309                     with cGear^ do
   311                     with cGear^ do
   310                         begin
   312                         begin
   311                         if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then
   313                         if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then
   312                             dX:= Gear^.dX * _0_5;
   314                             dX:= Gear^.dX * _0_5;