hedgewars/uGears.pas
changeset 2911 cd355befa683
parent 2909 f982208e7f21
child 2914 7db64c269a5b
equal deleted inserted replaced
2910:d5051cc8a313 2911:cd355befa683
   175 			@doStepBallgun,
   175 			@doStepBallgun,
   176 			@doStepBomb,
   176 			@doStepBomb,
   177 			@doStepRCPlane,
   177 			@doStepRCPlane,
   178 			@doStepSniperRifleShot,
   178 			@doStepSniperRifleShot,
   179 			@doStepJetpack,
   179 			@doStepJetpack,
   180 			@doStepMolotov
   180 			@doStepMolotov,
       
   181 			@doStepCase
   181 			);
   182 			);
   182 
   183 
   183 procedure InsertGearToList(Gear: PGear);
   184 procedure InsertGearToList(Gear: PGear);
   184 var tmp, ptmp: PGear;
   185 var tmp, ptmp: PGear;
   185 begin
   186 begin
   322                     gear^.Timer:= cMinesTime*1;
   323                     gear^.Timer:= cMinesTime*1;
   323                 end;
   324                 end;
   324         gtCase: begin
   325         gtCase: begin
   325                 gear^.Radius:= 16;
   326                 gear^.Radius:= 16;
   326                 gear^.Elasticity:= _0_3
   327                 gear^.Elasticity:= _0_3
       
   328                 end;
       
   329   gtExplosives: begin
       
   330                 gear^.Radius:= 16;
       
   331                 gear^.Elasticity:= _0_3;
       
   332                 gear^.Health:= cBarrelHealth
   327                 end;
   333                 end;
   328   gtDEagleShot: begin
   334   gtDEagleShot: begin
   329                 gear^.Radius:= 1;
   335                 gear^.Radius:= 1;
   330                 gear^.Health:= 50
   336                 gear^.Health:= 50
   331                 end;
   337                 end;
  1574                                         if i > 23 then i:= 0;
  1580                                         if i > 23 then i:= 0;
  1575                                         i:= i mod 12;
  1581                                         i:= i mod 12;
  1576                                         DrawSprite(sprUtility, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i);
  1582                                         DrawSprite(sprUtility, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i);
  1577                                         end;
  1583                                         end;
  1578                          end;
  1584                          end;
       
  1585       gtExplosives: begin
       
  1586                     i:= (GameTicks shr 6) mod 64;
       
  1587                     if i > 18 then i:= 0;
       
  1588                     DrawSprite(sprExplosives, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i);
       
  1589                     end;
  1579         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1);
  1590         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1);
  1580      gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1591      gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1581          gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0);
  1592          gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0);
  1582            gtFlame: DrawTextureF(SpritesData[sprFlame].Texture, 2 / (Gear^.Tag mod 3 + 2), hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 128 + LongWord(Gear^.Tag)) mod 8, 1, 16, 16);
  1593            gtFlame: DrawTextureF(SpritesData[sprFlame].Texture, 2 / (Gear^.Tag mod 3 + 2), hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 128 + LongWord(Gear^.Tag)) mod 8, 1, 16, 16);
  1583        gtParachute: begin
  1594        gtParachute: begin
  1631 var i: LongInt;
  1642 var i: LongInt;
  1632 	Gear: PGear;
  1643 	Gear: PGear;
  1633 begin
  1644 begin
  1634 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
  1645 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
  1635 
  1646 
       
  1647 // HACK: just for testing explosives!
       
  1648 if (GameFlags and gfMines) <> 0 then
       
  1649 	GameFlags:= (GameFlags or gfExplosives) and not gfMines;
       
  1650 
  1636 if (TrainingFlags and tfSpawnTargets) <> 0 then
  1651 if (TrainingFlags and tfSpawnTargets) <> 0 then
  1637 	begin
  1652 	begin
  1638 	TrainingTargetGear:= AddGear(0, 0, gtTarget, 0, _0, _0, 0);
  1653 	TrainingTargetGear:= AddGear(0, 0, gtTarget, 0, _0, _0, 0);
  1639 	FindPlace(TrainingTargetGear, false, 0, LAND_WIDTH);
  1654 	FindPlace(TrainingTargetGear, false, 0, LAND_WIDTH);
  1640 	end;
  1655 	end;
  1641 
  1656 
  1642 if ((GameFlags and gfForts) = 0) and ((GameFlags and gfMines) <> 0) then
  1657 if ((GameFlags and gfForts) = 0) then
  1643 	for i:= 0 to Pred(cLandAdditions) do
  1658 	begin
  1644 		begin
  1659 	// TODO: exclude each other or allow both, mines and explosives, on same map?
  1645 		Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0);
  1660 	if ((GameFlags and gfMines) <> 0) then
  1646 		Gear^.TriggerId:= i + 1;
  1661 		for i:= 0 to Pred(cLandAdditions) do
  1647 		FindPlace(Gear, false, 0, LAND_WIDTH);
  1662 			begin
  1648 {		if(Gear <> nil) then
  1663 			Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0);
  1649 			ParseCommand('addtrig s' + inttostr(Gear^.TriggerId) + ' 1 5 11 ' +
  1664 			Gear^.TriggerId:= i + 1;
  1650 				inttostr(hwRound(Gear^.X)) + ' ' + inttostr(hwRound(Gear^.Y)) +
  1665 			FindPlace(Gear, false, 0, LAND_WIDTH);
  1651 				' ' + inttostr(Gear^.TriggerId), true);
  1666 			end;
  1652 }		end;
  1667 	if ((GameFlags and gfExplosives) <> 0) then
       
  1668 		for i:= 0 to Pred(cLandAdditions) do
       
  1669 			begin
       
  1670 			Gear:= AddGear(0, 0, gtExplosives, 0, _0, _0, 0);
       
  1671 			Gear^.TriggerId:= i + 1;
       
  1672 			FindPlace(Gear, false, 0, LAND_WIDTH);
       
  1673 			end;
       
  1674 	end;
  1653 
  1675 
  1654 if (GameFlags and gfLowGravity) <> 0 then
  1676 if (GameFlags and gfLowGravity) <> 0 then
  1655     cGravity:= cMaxWindSpeed / 2;
  1677     cGravity:= cMaxWindSpeed / 2;
  1656 
  1678 
  1657 if (GameFlags and gfVampiric) <> 0 then
  1679 if (GameFlags and gfVampiric) <> 0 then
  1697 		case Gear^.Kind of
  1719 		case Gear^.Kind of
  1698 			gtHedgehog,
  1720 			gtHedgehog,
  1699 				gtMine,
  1721 				gtMine,
  1700 				gtCase,
  1722 				gtCase,
  1701 				gtTarget,
  1723 				gtTarget,
  1702 				gtFlame: begin
  1724 				gtFlame,
       
  1725 				gtExplosives: begin
  1703 						//{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF}
  1726 						//{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF}
  1704 						if (Mask and EXPLNoDamage) = 0 then
  1727 						if (Mask and EXPLNoDamage) = 0 then
  1705 							begin
  1728 							begin
  1706 							if not Gear^.Invulnerable then
  1729 							if not Gear^.Invulnerable then
  1707                                 ApplyDamage(Gear, dmg)
  1730                                 ApplyDamage(Gear, dmg)
  1747 	if dmg > 0 then
  1770 	if dmg > 0 then
  1748 	case t^.Kind of
  1771 	case t^.Kind of
  1749 		gtHedgehog,
  1772 		gtHedgehog,
  1750 			gtMine,
  1773 			gtMine,
  1751 			gtCase,
  1774 			gtCase,
  1752 			gtTarget: begin
  1775 			gtTarget,
       
  1776 			gtExplosives: begin
  1753                     if (not t^.Invulnerable) then
  1777                     if (not t^.Invulnerable) then
  1754                         ApplyDamage(t, dmg)
  1778                         ApplyDamage(t, dmg)
  1755                     else
  1779                     else
  1756                         Gear^.State:= Gear^.State or gstWinner;
  1780                         Gear^.State:= Gear^.State or gstWinner;
  1757 
  1781 
  1792 		
  1816 		
  1793 		case Gear^.Kind of
  1817 		case Gear^.Kind of
  1794 			gtHedgehog,
  1818 			gtHedgehog,
  1795 			gtMine,
  1819 			gtMine,
  1796 			gtTarget,
  1820 			gtTarget,
  1797 			gtCase: begin
  1821 			gtCase,
       
  1822 			gtExplosives: begin
  1798 					if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end;
  1823 					if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end;
  1799                     if (not Gear^.Invulnerable) then
  1824                     if (not Gear^.Invulnerable) then
  1800                         ApplyDamage(Gear, tmpDmg)
  1825                         ApplyDamage(Gear, tmpDmg)
  1801                     else
  1826                     else
  1802                         Gear^.State:= Gear^.State or gstWinner;
  1827                         Gear^.State:= Gear^.State or gstWinner;
  2095 				inc(y);
  2120 				inc(y);
  2096 			until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) <> 0);
  2121 			until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) <> 0);
  2097 
  2122 
  2098 			if (y - sy > Gear^.Radius * 2)
  2123 			if (y - sy > Gear^.Radius * 2)
  2099 				and (y < LAND_HEIGHT)
  2124 				and (y < LAND_HEIGHT)
  2100 				and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase], 110, 110) = nil) then
  2125 				and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 110, 110) = nil) then
  2101 				begin
  2126 				begin
  2102 				ar[cnt].X:= x;
  2127 				ar[cnt].X:= x;
  2103 				if withFall then ar[cnt].Y:= sy + Gear^.Radius
  2128 				if withFall then ar[cnt].Y:= sy + Gear^.Radius
  2104 							else ar[cnt].Y:= y - Gear^.Radius;
  2129 							else ar[cnt].Y:= y - Gear^.Radius;
  2105 				inc(cnt)
  2130 				inc(cnt)