hedgewars/uGears.pas
changeset 1689 3d0eee01f734
parent 1669 b709e061577e
child 1696 bb1e305320a1
equal deleted inserted replaced
1688:d94ac781a8e3 1689:3d0eee01f734
     1 (*
     1 (*
     2  * Hedgewars, a free turn based strategy game
     2  * Hedgewars, a free turn based strategy game
     3  * Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com>
     3  * Copyright (c) 2004-2009 Andrey Korotaev <unC0Rr@gmail.com>
     4  *
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation; version 2 of the License
     7  * the Free Software Foundation; version 2 of the License
     8  *
     8  *
    96 procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); forward;
    96 procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); forward;
    97 procedure HedgehogStep(Gear: PGear); forward;
    97 procedure HedgehogStep(Gear: PGear); forward;
    98 procedure doStepHedgehogMoving(Gear: PGear); forward;
    98 procedure doStepHedgehogMoving(Gear: PGear); forward;
    99 procedure HedgehogChAngle(Gear: PGear); forward;
    99 procedure HedgehogChAngle(Gear: PGear); forward;
   100 procedure ShotgunShot(Gear: PGear); forward;
   100 procedure ShotgunShot(Gear: PGear); forward;
       
   101 procedure PickUp(HH, Gear: PGear); forward;
   101 
   102 
   102 {$INCLUDE GSHandlers.inc}
   103 {$INCLUDE GSHandlers.inc}
   103 {$INCLUDE HHHandlers.inc}
   104 {$INCLUDE HHHandlers.inc}
   104 
   105 
   105 const doStepHandlers: array[TGearType] of TGearStepProcedure = (
   106 const doStepHandlers: array[TGearType] of TGearStepProcedure = (
   145 			@doStepBomb,
   146 			@doStepBomb,
   146 			@doStepSmokeTrace,
   147 			@doStepSmokeTrace,
   147 			@doStepWaterUp,
   148 			@doStepWaterUp,
   148 			@doStepDrill,
   149 			@doStepDrill,
   149 			@doStepBallgun,
   150 			@doStepBallgun,
   150 			@doStepBomb
   151 			@doStepBomb,
       
   152 			@doStepRCPlane
   151 			);
   153 			);
   152 
   154 
   153 procedure InsertGearToList(Gear: PGear);
   155 procedure InsertGearToList(Gear: PGear);
   154 var tmp, ptmp: PGear;
   156 var tmp, ptmp: PGear;
   155 begin
   157 begin
   356                 Result^.Elasticity:= _0_7;
   358                 Result^.Elasticity:= _0_7;
   357                 Result^.Friction:= _0_995;
   359                 Result^.Friction:= _0_995;
   358                 end;
   360                 end;
   359      gtBallgun: begin
   361      gtBallgun: begin
   360                 Result^.Timer:= 5001;
   362                 Result^.Timer:= 5001;
       
   363                 end;
       
   364      gtRCPlane: begin
       
   365                 Result^.Timer:= 15000;
       
   366                 Result^.Health:= 3;
       
   367                 Result^.Radius:= 8;
   361                 end;
   368                 end;
   362      end;
   369      end;
   363 InsertGearToList(Result);
   370 InsertGearToList(Result);
   364 AddGear:= Result
   371 AddGear:= Result
   365 end;
   372 end;
   799 	if ((Gear^.State and gstAttacked) = 0) then
   806 	if ((Gear^.State and gstAttacked) = 0) then
   800 	begin
   807 	begin
   801 		amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
   808 		amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
   802 		case amt of
   809 		case amt of
   803 			amBazooka,
   810 			amBazooka,
   804 			amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
   811 			amMortar,amRCPlane: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
   805                         amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
   812                         amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
   806                         amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle);
   813                         amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle);
   807 			amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
   814 			amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
   808 			amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   815 			amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   809 			amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
   816 			amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
  1049     end;
  1056     end;
  1050 
  1057 
  1051 begin
  1058 begin
  1052 Gear:= GearsList;
  1059 Gear:= GearsList;
  1053 while Gear<>nil do
  1060 while Gear<>nil do
  1054       begin
  1061 	begin
  1055       case Gear^.Kind of
  1062 	case Gear^.Kind of
  1056        gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1063        gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
       
  1064 
       
  1065        gtRCPlane: if (PHedgehog(Gear^.Hedgehog)^.Gear^.dX.isNegative) then
       
  1066                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, -1,  DxDy2Angle(Gear^.dX, Gear^.dY) + 90)
       
  1067                   else
       
  1068                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX));
       
  1069        
  1057        gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1070        gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX));
       
  1071        
  1058        gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1072        gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
       
  1073         
  1059         gtHedgehog: DrawHH(Gear);
  1074         gtHedgehog: DrawHH(Gear);
       
  1075     
  1060     gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1076     gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
       
  1077        
  1061        gtHealthTag: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
  1078        gtHealthTag: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
       
  1079            
  1062            gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex);
  1080            gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex);
       
  1081              
  1063              gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4);
  1082              gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4);
       
  1083       
  1064       gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0);
  1084       gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0);
  1065             gtRope: begin
  1085             gtRope: begin
  1066                     roplen:= 0;
  1086                     roplen:= 0;
  1067                     if RopePoints.Count > 0 then
  1087                     if RopePoints.Count > 0 then
  1068                        begin
  1088                        begin