hedgewars/uGearsUtils.pas
changeset 14593 34e810295d08
parent 14592 1d3dc553829c
child 14595 6e5cda26f676
equal deleted inserted replaced
14592:1d3dc553829c 14593:34e810295d08
   116     if vg <> nil then
   116     if vg <> nil then
   117         vg^.Tint:= Tint;
   117         vg^.Tint:= Tint;
   118     end;
   118     end;
   119 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion);
   119 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion);
   120 
   120 
   121 (*if (Mask and EXPLAllDamageInRadius) = 0 then
       
   122     dmgRadius:= Radius shl 1
       
   123 else
       
   124     dmgRadius:= Radius;
       
   125 dmgBase:= dmgRadius + cHHRadius div 2;*)
       
   126 dmgBase:= Radius shl 1 + cHHRadius div 2;
   121 dmgBase:= Radius shl 1 + cHHRadius div 2;
   127 
   122 
   128 // we might have to run twice if weWrap is enabled
   123 // we might have to run twice if weWrap is enabled
   129 wrap:= false;
   124 wrap:= false;
   130 repeat
   125 repeat
   134 Gear:= GearsList;
   129 Gear:= GearsList;
   135 
   130 
   136 while Gear <> nil do
   131 while Gear <> nil do
   137     begin
   132     begin
   138     dmg:= 0;
   133     dmg:= 0;
   139     //dmg:= dmgRadius  + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
       
   140     //if (dmg > 1) and
       
   141     if (Gear^.State and gstNoDamage) = 0 then
   134     if (Gear^.State and gstNoDamage) = 0 then
   142         begin
   135         begin
   143         case Gear^.Kind of
   136         case Gear^.Kind of
   144             gtHedgehog,
   137             gtHedgehog,
   145                 gtMine,
   138                 gtMine,
   146                 gtBall,
   139                 gtBall,
   147                 gtMelonPiece,
   140                 gtMelonPiece,
   148                 gtGrenade,
   141                 gtGrenade,
   149                 gtClusterBomb,
   142                 gtClusterBomb,
   150             //    gtCluster, too game breaking I think
       
   151                 gtSMine,
   143                 gtSMine,
   152                 gtAirMine,
   144                 gtAirMine,
   153                 gtCase,
   145                 gtCase,
   154                 gtTarget,
   146                 gtTarget,
   155                 gtFlame,
   147                 gtFlame,
   324 			dx:= 0.001 * (random(100)+10);
   316 			dx:= 0.001 * (random(100)+10);
   325 			dy:= 0.001 * (random(100)+10);
   317 			dy:= 0.001 * (random(100)+10);
   326 			tdy:= -cGravityf;
   318 			tdy:= -cGravityf;
   327 			if random(2) = 0 then
   319 			if random(2) = 0 then
   328 			    dx := -dx;
   320 			    dx := -dx;
   329 			//if random(2) = 0 then
       
   330 			//    dy := -dy;
       
   331 			FrameTicks:= random(500) + 1000;
   321 			FrameTicks:= random(500) + 1000;
   332 			State:= ord(sprBubbles);
   322 			State:= ord(sprBubbles);
   333 			//Tint:= $bd2f03ff
       
   334 			Tint:= $ff0000ff
   323 			Tint:= $ff0000ff
   335 			end
   324 			end
   336 	end
   325 	end
   337     end else
   326     end else
   338         Gear^.Hedgehog:= AttackerHog;
   327         Gear^.Hedgehog:= AttackerHog;
   467         end;
   456         end;
   468 
   457 
   469     if ((Gear^.Hedgehog^.Effects[heInvulnerable] <> 0)) then
   458     if ((Gear^.Hedgehog^.Effects[heInvulnerable] <> 0)) then
   470         exit;
   459         exit;
   471 
   460 
   472     //if _0_6 < Gear^.dY then
       
   473     //    PlaySound(sndOw4, Gear^.Hedgehog^.Team^.voicepack)
       
   474     //else
       
   475     //    PlaySound(sndOw1, Gear^.Hedgehog^.Team^.voicepack);
       
   476 
       
   477     if Gear^.LastDamage <> nil then
   461     if Gear^.LastDamage <> nil then
   478         ApplyDamage(Gear, Gear^.LastDamage, dmg, dsFall)
   462         ApplyDamage(Gear, Gear^.LastDamage, dmg, dsFall)
   479     else
   463     else
   480         ApplyDamage(Gear, CurrentHedgehog, dmg, dsFall);
   464         ApplyDamage(Gear, CurrentHedgehog, dmg, dsFall);
   481     end
   465     end
   485 procedure CalcRotationDirAngle(Gear: PGear);
   469 procedure CalcRotationDirAngle(Gear: PGear);
   486 var
   470 var
   487     dAngle: real;
   471     dAngle: real;
   488 begin
   472 begin
   489     // Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64
   473     // Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64
   490     //dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000;
       
   491     dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac/$100000000+Gear^.dY.Frac/$100000000);
   474     dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac/$100000000+Gear^.dY.Frac/$100000000);
   492     if not Gear^.dX.isNegative then
   475     if not Gear^.dX.isNegative then
   493         Gear^.DirAngle := Gear^.DirAngle + dAngle
   476         Gear^.DirAngle := Gear^.DirAngle + dAngle
   494     else
   477     else
   495         Gear^.DirAngle := Gear^.DirAngle - dAngle;
   478         Gear^.DirAngle := Gear^.DirAngle - dAngle;
  1786                AddBounceEffectForGear(Gear);
  1769                AddBounceEffectForGear(Gear);
  1787             end;
  1770             end;
  1788         end
  1771         end
  1789     else
  1772     else
  1790         WorldWrap:= true;
  1773         WorldWrap:= true;
  1791 {  else if WorldEdge = weSea then
       
  1792         begin
       
  1793         if (hwRound(Gear^.Y) > cWaterLine) and (Gear^.State and gstSubmersible <> 0) then
       
  1794             Gear^.State:= Gear^.State and (not gstSubmersible)
       
  1795         else
       
  1796             begin
       
  1797             Gear^.State:= Gear^.State or gstSubmersible;
       
  1798             Gear^.X:= int2hwFloat(PlayWidth)*int2hwFloat(min(max(0,hwRound(Gear^.Y)),PlayHeight))/PlayHeight;
       
  1799             Gear^.Y:= int2hwFloat(cWaterLine+cVisibleWater+Gear^.Radius*2);
       
  1800             tdx:= Gear^.dX;
       
  1801             Gear^.dX:= -Gear^.dY;
       
  1802             Gear^.dY:= tdx;
       
  1803             Gear^.dY.isNegative:= true
       
  1804             end
       
  1805         end;
       
  1806 
       
  1807 ---
       
  1808 
       
  1809 * Window in the sky (Gear moved high into the sky, Y is used to determine X) [unfortunately, not a safe thing to do. shame, I thought aerial bombardment would be kinda neat
       
  1810 This one would be really easy to freeze game unless it was flagged unfortunately.
       
  1811 
       
  1812     else
       
  1813         begin
       
  1814         Gear^.X:= int2hwFloat(PlayWidth)*int2hwFloat(min(max(0,hwRound(Gear^.Y)),PlayHeight))/PlayHeight;
       
  1815         Gear^.Y:= -_2048-_256-_256;
       
  1816         tdx:= Gear^.dX;
       
  1817         Gear^.dX:= Gear^.dY;
       
  1818         Gear^.dY:= tdx;
       
  1819         Gear^.dY.isNegative:= false
       
  1820         end
       
  1821 }
       
  1822     end;
  1774     end;
  1823 end;
  1775 end;
  1824 
  1776 
  1825 (*
  1777 (*
  1826 Applies wrap-around logic for the target of homing gears.
  1778 Applies wrap-around logic for the target of homing gears.