hedgewars/uCollisions.pas
changeset 7756 b89bd0ffb8aa
parent 7754 e81dc9bef8b8
child 7767 d1ea9b3f543e
equal deleted inserted replaced
7755:b8958e64e68d 7756:b89bd0ffb8aa
   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 (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2))
   241             and ((mx > x) xor (Dir > 0)) then
   241             and ((mx > x) xor (Dir > 0)) and
   242                 if ((cGear^.Kind in [gtHedgehog, gtMine, gtKnife]) and ((Gear^.State and gstNotKickable) = 0)) or
   242                 (
       
   243                   ((cGear^.Kind in [gtHedgehog, gtMine, gtKnife]) and ((Gear^.State and gstNotKickable) = 0)) or
   243                 // only apply X kick if the barrel is knocked over
   244                 // only apply X kick if the barrel is knocked over
   244                 ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0)) then
   245                 ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0))) then
   245                     begin
   246                     begin
   246                     with cGear^ do
   247                     with cGear^ do
   247                         begin
   248                         begin
   248                         dX:= Gear^.dX;
   249                         dX:= Gear^.dX;
   249                         dY:= Gear^.dY * _0_5;
   250                         dY:= Gear^.dY * _0_5;
   257                     end
   258                     end
   258     end
   259     end
   259 end;
   260 end;
   260 
   261 
   261 function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
   262 function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
   262 var x, y, mx, my, i: LongInt;
   263 var x, y, mx, my,  myr, i: LongInt;
   263     flag: boolean;
   264     flag: boolean;
   264 begin
   265 begin
   265 flag:= false;
   266 flag:= false;
   266 y:= hwRound(Gear^.Y);
   267 y:= hwRound(Gear^.Y);
   267 if Dir < 0 then
   268 if Dir < 0 then
   293     if (Gear^.State and gstHHJumping <> 0) and (not Gear^.dY.isNegative) and (Gear^.dY < _0_4) then
   294     if (Gear^.State and gstHHJumping <> 0) and (not Gear^.dY.isNegative) and (Gear^.dY < _0_4) then
   294         exit;
   295         exit;
   295 
   296 
   296     mx:= hwRound(Gear^.X);
   297     mx:= hwRound(Gear^.X);
   297     my:= hwRound(Gear^.Y);
   298     my:= hwRound(Gear^.Y);
       
   299     myr:= my+Gear^.Radius;
   298 
   300 
   299     for i:= 0 to Pred(Count) do
   301     for i:= 0 to Pred(Count) do
   300         with cinfos[i] do
   302         with cinfos[i] do
   301             if (Gear <> cGear) and (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2))
   303             if (Gear <> cGear) and (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2))
   302             and ((my > y) xor (Dir > 0)) then
   304             and ((myr > y) xor (Dir > 0)) and
   303                 if (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and ((Gear^.State and gstNotKickable) = 0) then
   305                 (
       
   306                  (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and 
       
   307                  ((Gear^.State and gstNotKickable) = 0)) then
   304                     begin
   308                     begin
   305                     with cGear^ do
   309                     with cGear^ do
   306                         begin
   310                         begin
   307                         if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then
   311                         if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then
   308                             dX:= Gear^.dX * _0_5;
   312                             dX:= Gear^.dX * _0_5;