hedgewars/uGears.pas
changeset 2023 41d3afaa20c7
parent 2020 f8cd566204ef
child 2025 692308790912
equal deleted inserted replaced
2022:9bbf8af42ace 2023:41d3afaa20c7
   161 			@doStepWaterUp,
   161 			@doStepWaterUp,
   162 			@doStepDrill,
   162 			@doStepDrill,
   163 			@doStepBallgun,
   163 			@doStepBallgun,
   164 			@doStepBomb,
   164 			@doStepBomb,
   165 			@doStepRCPlane,
   165 			@doStepRCPlane,
   166 			@doStepSpeechBubble
   166 			@doStepSpeechBubble,
       
   167 			@doStepSniperRifleShot
   167 			);
   168 			);
   168 
   169 
   169 procedure InsertGearToList(Gear: PGear);
   170 procedure InsertGearToList(Gear: PGear);
   170 var tmp, ptmp: PGear;
   171 var tmp, ptmp: PGear;
   171 begin
   172 begin
   302         gtCase: begin
   303         gtCase: begin
   303                 Result^.Radius:= 16;
   304                 Result^.Radius:= 16;
   304                 Result^.Elasticity:= _0_3
   305                 Result^.Elasticity:= _0_3
   305                 end;
   306                 end;
   306   gtDEagleShot: begin
   307   gtDEagleShot: begin
       
   308                 Result^.Radius:= 1;
       
   309                 Result^.Health:= 50
       
   310                 end;
       
   311   gtSniperRifleShot: begin
   307                 Result^.Radius:= 1;
   312                 Result^.Radius:= 1;
   308                 Result^.Health:= 50
   313                 Result^.Health:= 50
   309                 end;
   314                 end;
   310     gtDynamite: begin
   315     gtDynamite: begin
   311                 Result^.Radius:= 3;
   316                 Result^.Radius:= 3;
   634 
   639 
   635     cDamageModifier:= _1;
   640     cDamageModifier:= _1;
   636 
   641 
   637     if (GameFlags and gfLaserSight) = 0 then
   642     if (GameFlags and gfLaserSight) = 0 then
   638         cLaserSighting:= false;
   643         cLaserSighting:= false;
       
   644 
       
   645     if (GameFlags and gfArtillery) = 0 then
       
   646         cArtillery:= false;
       
   647 
   639     // have to sweep *all* current team hedgehogs since it is theoretically possible if you have enough invulnerabilities and switch turns to make your entire team invulnerable
   648     // have to sweep *all* current team hedgehogs since it is theoretically possible if you have enough invulnerabilities and switch turns to make your entire team invulnerable
   640 
   649     if (CurrentTeam <> nil) then
   641    if (GameFlags and gfInvulnerable) = 0 then
   650        with CurrentTeam^ do
   642        if (CurrentTeam <> nil) then
   651           for i:= 0 to cMaxHHIndex do
   643           with CurrentTeam^ do
   652               with Hedgehogs[i] do
   644              for i:= 0 to cMaxHHIndex do
   653                   begin
   645                  with Hedgehogs[i] do
   654                   if (SpeechGear <> nil) then DeleteGear(SpeechGear);  // remove to restore persisting beyond end of turn. Tiy says was too much of a gameplay issue
   646                      if (Gear <> nil) then
   655                   if (Gear <> nil) then
   647                          Gear^.Invulnerable:= false;
   656                      if (GameFlags and gfInvulnerable) = 0 then
       
   657                         Gear^.Invulnerable:= false;
       
   658                   end;
   648 end;
   659 end;
   649 procedure ApplyDamage(Gear: PGear; Damage: Longword);
   660 procedure ApplyDamage(Gear: PGear; Damage: Longword);
   650 var s: shortstring;
   661 var s: shortstring;
   651     vampDmg: Longword;
   662     vampDmg: Longword;
   652 begin
   663 begin
   714 	t:= t^.NextGear
   725 	t:= t^.NextGear
   715 	end
   726 	end
   716 end;
   727 end;
   717 
   728 
   718 procedure DrawHH(Gear: PGear);
   729 procedure DrawHH(Gear: PGear);
   719 var t: LongInt;
   730 var i, t: LongInt;
   720 	amt: TAmmoType;
   731 	amt: TAmmoType;
   721 	hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
   732 	hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
   722 	lx, ly, dx, dy, ax, ay, aAngle, dAngle: real;  // laser, change
   733 	lx, ly, dx, dy, ax, ay, aAngle, dAngle: real;  // laser, change
   723 	defaultPos, HatVisible: boolean;
   734 	defaultPos, HatVisible: boolean;
   724     VertexBuffer: array [0..1] of TVertex2f;
   735     VertexBuffer: array [0..1] of TVertex2f;
   780 						DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle)
   791 						DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle)
   781 					else
   792 					else
   782 						DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   793 						DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   783 				end;
   794 				end;
   784 			gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle);
   795 			gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle);
       
   796 			gtSniperRifleShot: begin
       
   797 					if (CurAmmoGear^.State and gstAnimation <> 0) then
       
   798 			            DrawRotatedF(sprSniperRifle, hx, hy, 1, hwSign(Gear^.dX), aangle)
       
   799 					else
       
   800 			            DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle)
       
   801 				end;
   785 			gtBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
   802 			gtBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
   786 			gtRCPlane: begin
   803 			gtRCPlane: begin
   787 				DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0);
   804 				DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0);
   788 				defaultPos:= false
   805 				defaultPos:= false
   789 				end;
   806 				end;
   790 			gtRope: begin
   807 			gtRope: begin
   791 				if Gear^.X < CurAmmoGear^.X then
   808 				if Gear^.X < CurAmmoGear^.X then
   792 					begin
   809 					begin
   793 					dAngle:= 0;
   810 					dAngle:= 0;
   794 					m:= 1
   811 					i:= 1
   795 					end else
   812 					end else
   796 					begin
   813 					begin
   797 					dAngle:= 180;
   814 					dAngle:= 180;
   798 					m:= -1
   815 					i:= -1
   799 					end;
   816 					end;
   800                 sx:= hwRound(Gear^.X) + WorldDx;
   817                 sx:= hwRound(Gear^.X) + WorldDx;
   801                 sy:= hwRound(Gear^.Y) + WorldDy;
   818                 sy:= hwRound(Gear^.Y) + WorldDy;
   802 				DrawHedgehog(sx, sy,
   819 				DrawHedgehog(sx, sy,
   803 						m,
   820 						i,
   804 						1,
   821 						1,
   805 						0,
   822 						0,
   806 						DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
   823 						DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
   807 				defaultPos:= false
   824 				defaultPos:= false
   808 				end;
   825 				end;
   876 		end;
   893 		end;
   877 
   894 
   878 		case CurAmmoGear^.Kind of
   895 		case CurAmmoGear^.Kind of
   879 			gtShotgunShot,
   896 			gtShotgunShot,
   880 			gtDEagleShot,
   897 			gtDEagleShot,
       
   898 			gtSniperRifleShot,
   881 			gtShover: begin
   899 			gtShover: begin
   882 				DrawHedgehog(sx, sy,
   900 				DrawHedgehog(sx, sy,
   883 						hwSign(Gear^.dX),
   901 						hwSign(Gear^.dX),
   884 						0,
   902 						0,
   885 						4,
   903 						4,
   934 			amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
   952 			amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
   935 			amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle);
   953 			amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle);
   936 			amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
   954 			amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
   937 			amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   955 			amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   938 			amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
   956 			amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
       
   957 			amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle);
   939 			amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
   958 			amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
   940 			amRCPlane: begin
   959 			amRCPlane: begin
   941 				DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0);
   960 				DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0);
   942 				defaultPos:= false
   961 				defaultPos:= false
   943 				end;
   962 				end;
  1399        Gear^.Invulnerable:= true;  // this is only checked on hogs right now, so no need for gear type check
  1418        Gear^.Invulnerable:= true;  // this is only checked on hogs right now, so no need for gear type check
  1400        Gear:= Gear^.NextGear
  1419        Gear:= Gear^.NextGear
  1401        end;
  1420        end;
  1402 
  1421 
  1403 if (GameFlags and gfLaserSight) <> 0 then
  1422 if (GameFlags and gfLaserSight) <> 0 then
  1404     cLaserSighting:= true
  1423     cLaserSighting:= true;
       
  1424 
       
  1425 if (GameFlags and gfArtillery) <> 0 then
       
  1426     cArtillery:= true
  1405 end;
  1427 end;
  1406 
  1428 
  1407 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord);
  1429 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord);
  1408 var Gear: PGear;
  1430 var Gear: PGear;
  1409     dmg, dmgRadius: LongInt;
  1431     dmg, dmgRadius: LongInt;