hedgewars/uGears.pas
changeset 3322 80afcb97eb46
parent 3310 e6e9b811d32f
child 3331 8e05feb871c3
equal deleted inserted replaced
3321:988e39ef3c20 3322:80afcb97eb46
  1831 end;
  1831 end;
  1832 
  1832 
  1833 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord);
  1833 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord);
  1834 var Gear: PGear;
  1834 var Gear: PGear;
  1835     dmg, dmgRadius, dmgBase: LongInt;
  1835     dmg, dmgRadius, dmgBase: LongInt;
       
  1836     fX, fY: hwFloat;
  1836 begin
  1837 begin
  1837 TargetPoint.X:= NoPointX;
  1838 TargetPoint.X:= NoPointX;
  1838 {$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
  1839 {$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
  1839 if Radius > 25 then KickFlakes(Radius, X, Y);
  1840 if Radius > 25 then KickFlakes(Radius, X, Y);
  1840 
  1841 
  1848 if (Mask and EXPLAllDamageInRadius) = 0 then
  1849 if (Mask and EXPLAllDamageInRadius) = 0 then
  1849     dmgRadius:= Radius shl 1
  1850     dmgRadius:= Radius shl 1
  1850 else
  1851 else
  1851     dmgRadius:= Radius;
  1852     dmgRadius:= Radius;
  1852 dmgBase:= dmgRadius + cHHRadius div 2;
  1853 dmgBase:= dmgRadius + cHHRadius div 2;
       
  1854 fX:= int2hwFloat(X);
       
  1855 fY:= int2hwFloat(Y);
  1853 Gear:= GearsList;
  1856 Gear:= GearsList;
  1854 while Gear <> nil do
  1857 while Gear <> nil do
  1855     begin
  1858     begin
  1856     dmg:= 0;
  1859     dmg:= 0;
  1857     //dmg:= dmgRadius  + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
  1860     //dmg:= dmgRadius  + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
  1864                 gtCase,
  1867                 gtCase,
  1865                 gtTarget,
  1868                 gtTarget,
  1866                 gtFlame,
  1869                 gtFlame,
  1867                 gtExplosives: begin
  1870                 gtExplosives: begin
  1868 // Run the calcs only once we know we have a type that will need damage
  1871 // Run the calcs only once we know we have a type that will need damage
  1869                         if hwRound(hwAbs(Gear^.X-int2hwFloat(X))+hwAbs(Gear^.Y-int2hwFloat(Y))) < dmgBase then
  1872                         if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then
  1870                             dmg:= dmgBase - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
  1873                             dmg:= dmgBase - hwRound(Distance(Gear^.X - fX, Gear^.Y - fY));
  1871                         if dmg > 1 then
  1874                         if dmg > 1 then
  1872                             begin
  1875                             begin
  1873                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
  1876                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
  1874                             //{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF}
  1877                             //{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF}
  1875                             if (Mask and EXPLNoDamage) = 0 then
  1878                             if (Mask and EXPLNoDamage) = 0 then
  1880                                     Gear^.State:= Gear^.State or gstWinner;
  1883                                     Gear^.State:= Gear^.State or gstWinner;
  1881                                 end;
  1884                                 end;
  1882                             if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then
  1885                             if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then
  1883                                 begin
  1886                                 begin
  1884                                 DeleteCI(Gear);
  1887                                 DeleteCI(Gear);
  1885                                 Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X));
  1888                                 Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - fX);
  1886                                 Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y));
  1889                                 Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - fY);
  1887                                 Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser);
  1890                                 Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser);
  1888                                 if not Gear^.Invulnerable then
  1891                                 if not Gear^.Invulnerable then
  1889                                     Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
  1892                                     Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
  1890                                 Gear^.Active:= true;
  1893                                 Gear^.Active:= true;
  1891                                 FollowGear:= Gear
  1894                                 FollowGear:= Gear
  1895                             end;
  1898                             end;
  1896 
  1899 
  1897                         end;
  1900                         end;
  1898                 gtGrave: begin
  1901                 gtGrave: begin
  1899 // Run the calcs only once we know we have a type that will need damage
  1902 // Run the calcs only once we know we have a type that will need damage
  1900                         if hwRound(hwAbs(Gear^.X-int2hwFloat(X))+hwAbs(Gear^.Y-int2hwFloat(Y))) < dmgBase then
  1903                         if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then
  1901                             dmg:= dmgBase - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
  1904                             dmg:= dmgBase - hwRound(Distance(Gear^.X - fX, Gear^.Y - fY));
  1902                         if dmg > 1 then
  1905                         if dmg > 1 then
  1903                             begin
  1906                             begin
  1904                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
  1907                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
  1905                             Gear^.dY:= - _0_004 * dmg;
  1908                             Gear^.dY:= - _0_004 * dmg;
  1906                             Gear^.Active:= true
  1909                             Gear^.Active:= true