hedgewars/uGears.pas
changeset 3097 6fa39c1c41b9
parent 3094 97c8406acc85
child 3098 e5a1bc4e56fd
equal deleted inserted replaced
3096:9330eead14fa 3097:6fa39c1c41b9
  1756     cArtillery:= true
  1756     cArtillery:= true
  1757 end;
  1757 end;
  1758 
  1758 
  1759 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord);
  1759 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord);
  1760 var Gear: PGear;
  1760 var Gear: PGear;
  1761     dmg, dmgRadius: LongInt;
  1761     dmg, dmgRadius, dmgBase: LongInt;
  1762 begin
  1762 begin
  1763 TargetPoint.X:= NoPointX;
  1763 TargetPoint.X:= NoPointX;
  1764 {$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
  1764 {$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
  1765 if Radius > 25 then KickFlakes(Radius, X, Y);
  1765 if Radius > 25 then KickFlakes(Radius, X, Y);
  1766 
  1766 
  1773 
  1773 
  1774 if (Mask and EXPLAllDamageInRadius) = 0 then
  1774 if (Mask and EXPLAllDamageInRadius) = 0 then
  1775     dmgRadius:= Radius shl 1
  1775     dmgRadius:= Radius shl 1
  1776 else
  1776 else
  1777     dmgRadius:= Radius;
  1777     dmgRadius:= Radius;
  1778 
  1778 dmgBase:= dmgRadius + cHHRadius div 2;
  1779 Gear:= GearsList;
  1779 Gear:= GearsList;
  1780 while Gear <> nil do
  1780 while Gear <> nil do
  1781     begin
  1781     begin
  1782     dmg:= dmgRadius  + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
  1782     dmg:= 0;
  1783     if (dmg > 1) and
  1783     //dmg:= dmgRadius  + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
  1784         ((Gear^.State and gstNoDamage) = 0) then
  1784     //if (dmg > 1) and
  1785         begin
  1785     if (Gear^.State and gstNoDamage) = 0 then
  1786         dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
  1786         begin
  1787         case Gear^.Kind of
  1787         case Gear^.Kind of
  1788             gtHedgehog,
  1788             gtHedgehog,
  1789                 gtMine,
  1789                 gtMine,
  1790                 gtCase,
  1790                 gtCase,
  1791                 gtTarget,
  1791                 gtTarget,
  1792                 gtFlame,
  1792                 gtFlame,
  1793                 gtExplosives: begin
  1793                 gtExplosives: begin
  1794                         //{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF}
  1794 // Run the calcs only once we know we have a type that will need damage
  1795                         if (Mask and EXPLNoDamage) = 0 then
  1795                         if hwRound(hwAbs(Gear^.X-int2hwFloat(X))+hwAbs(Gear^.Y-int2hwFloat(Y))) < dmgBase then
       
  1796                             dmg:= dmgBase - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
       
  1797                         if dmg > 1 then
  1796                             begin
  1798                             begin
  1797                             if not Gear^.Invulnerable then
  1799                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
  1798                                 ApplyDamage(Gear, dmg)
  1800                             //{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF}
  1799                             else
  1801                             if (Mask and EXPLNoDamage) = 0 then
  1800                                 Gear^.State:= Gear^.State or gstWinner;
  1802                                 begin
  1801                             end;
  1803                                 if not Gear^.Invulnerable then
  1802                         if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then
  1804                                     ApplyDamage(Gear, dmg)
  1803                             begin
  1805                                 else
  1804                             DeleteCI(Gear);
  1806                                     Gear^.State:= Gear^.State or gstWinner;
  1805                             Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X));
  1807                                 end;
  1806                             Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y));
  1808                             if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then
  1807                             Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser);
  1809                                 begin
  1808                             if not Gear^.Invulnerable then
  1810                                 DeleteCI(Gear);
  1809                                 Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
  1811                                 Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X));
  1810                             Gear^.Active:= true;
  1812                                 Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y));
  1811                             FollowGear:= Gear
  1813                                 Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser);
  1812                             end;
  1814                                 if not Gear^.Invulnerable then
       
  1815                                     Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
       
  1816                                 Gear^.Active:= true;
       
  1817                                 FollowGear:= Gear
       
  1818                                 end
       
  1819                             end
  1813                         end;
  1820                         end;
  1814                 gtGrave: begin
  1821                 gtGrave: begin
  1815                         Gear^.dY:= - _0_004 * dmg;
  1822 // Run the calcs only once we know we have a type that will need damage
  1816                         Gear^.Active:= true;
  1823                         if hwRound(hwAbs(Gear^.X-int2hwFloat(X))+hwAbs(Gear^.Y-int2hwFloat(Y))) < dmgBase then
       
  1824                             dmg:= dmgBase - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
       
  1825                         if dmg > 1 then
       
  1826                             begin
       
  1827                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
       
  1828                             Gear^.dY:= - _0_004 * dmg;
       
  1829                             Gear^.Active:= true
       
  1830                             end
  1817                         end;
  1831                         end;
  1818             end;
  1832             end;
  1819         end;
  1833         end;
  1820     Gear:= Gear^.NextGear
  1834     Gear:= Gear^.NextGear
  1821     end;
  1835     end;