hedgewars/GearDrawing.inc
changeset 3387 733f4001b8b9
child 3390 1d4926d10a9e
equal deleted inserted replaced
3386:3fa24f5776c3 3387:733f4001b8b9
       
     1 procedure DrawHH(Gear: PGear);
       
     2 var i, t: LongInt;
       
     3     amt: TAmmoType;
       
     4     hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
       
     5     lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
       
     6     defaultPos, HatVisible: boolean;
       
     7     VertexBuffer: array [0..1] of TVertex2f;
       
     8     HH: PHedgehog;
       
     9 begin
       
    10 HH:= PHedgehog(Gear^.Hedgehog);
       
    11 if HH^.Unplaced then exit;
       
    12 m:= 1;
       
    13 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
       
    14 if (Gear^.State and gstHHDeath) <> 0 then
       
    15     begin
       
    16     DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos);
       
    17     exit
       
    18     end
       
    19 else if (Gear^.State and gstHHGone) <> 0 then
       
    20     begin
       
    21     DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(Gear^.dX), 0);
       
    22     exit
       
    23     end;
       
    24 
       
    25 defaultPos:= true;
       
    26 HatVisible:= false;
       
    27 
       
    28 sx:= hwRound(Gear^.X) + 1 + WorldDx;
       
    29 sy:= hwRound(Gear^.Y) - 3 + WorldDy;
       
    30 
       
    31 if HH^.Effects[hePoisoned] then
       
    32     begin
       
    33     Tint($4040FF00);
       
    34     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360);
       
    35     Tint($FFFFFFFF)
       
    36     end;
       
    37 
       
    38 if ((Gear^.State and gstWinner) <> 0) and
       
    39    ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
       
    40     begin
       
    41     DrawHedgehog(sx, sy,
       
    42             hwSign(Gear^.dX),
       
    43             2,
       
    44             0,
       
    45             0);
       
    46     defaultPos:= false
       
    47     end;
       
    48 if (Gear^.State and gstDrowning) <> 0 then
       
    49     begin
       
    50     DrawHedgehog(sx, sy,
       
    51             hwSign(Gear^.dX),
       
    52             1,
       
    53             7,
       
    54             0);
       
    55     defaultPos:= false
       
    56     end else
       
    57 if (Gear^.State and gstLoser) <> 0 then
       
    58     begin
       
    59     DrawHedgehog(sx, sy,
       
    60             hwSign(Gear^.dX),
       
    61             2,
       
    62             3,
       
    63             0);
       
    64     defaultPos:= false
       
    65     end else
       
    66 
       
    67 if (Gear^.State and gstHHDriven) <> 0 then
       
    68     begin
       
    69     if ((Gear^.State and gstHHThinking) = 0) and
       
    70        (ShowCrosshair  or ((CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtRope))) and
       
    71        ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then
       
    72         begin
       
    73 (* These calculations are a little complex for a few reasons:
       
    74    1: I need to draw the laser from weapon origin to nearest land
       
    75    2: I need to start the beam outside the hedgie for attractiveness.
       
    76    3: I need to extend the beam beyond land.
       
    77    This routine perhaps should be pushed into uStore or somesuch instead of continuuing the increase in size of this function.
       
    78 *)
       
    79         dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle);
       
    80         dy:= - Cos(Gear^.Angle * pi / cMaxAngle);
       
    81         if cLaserSighting then
       
    82             begin
       
    83             lx:= hwRound(Gear^.X);
       
    84             ly:= hwRound(Gear^.Y);
       
    85             lx:= lx + dx * 16;
       
    86             ly:= ly + dy * 16;
       
    87 
       
    88             ax:= dx * 4;
       
    89             ay:= dy * 4;
       
    90 
       
    91             tx:= round(lx);
       
    92             ty:= round(ly);
       
    93             hx:= tx;
       
    94             hy:= ty;
       
    95             while ((ty and LAND_HEIGHT_MASK) = 0) and
       
    96                 ((tx and LAND_WIDTH_MASK) = 0) and
       
    97                 (Land[ty, tx] = 0) do
       
    98                 begin
       
    99                 lx:= lx + ax;
       
   100                 ly:= ly + ay;
       
   101                 tx:= round(lx);
       
   102                 ty:= round(ly)
       
   103                 end;
       
   104             // reached edge of land. assume infinite beam. Extend it way out past camera
       
   105             if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
       
   106                 begin
       
   107                 tx:= round(lx + ax * (LAND_WIDTH div 4));
       
   108                 ty:= round(ly + ay * (LAND_WIDTH div 4));
       
   109                 end;
       
   110 
       
   111             //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
       
   112                 begin
       
   113                 glDisable(GL_TEXTURE_2D);
       
   114                 glEnable(GL_LINE_SMOOTH);
       
   115 
       
   116                 glLineWidth(1.0);
       
   117 
       
   118                 Tint($C0FF0000);
       
   119                 VertexBuffer[0].X:= hx + WorldDx;
       
   120                 VertexBuffer[0].Y:= hy + WorldDy;
       
   121                 VertexBuffer[1].X:= tx + WorldDx;
       
   122                 VertexBuffer[1].Y:= ty + WorldDy;
       
   123 
       
   124                 glEnableClientState(GL_VERTEX_ARRAY);
       
   125                 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
       
   126                 glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
       
   127                 Tint($FFFFFFFF);
       
   128                 glEnable(GL_TEXTURE_2D);
       
   129                 glDisable(GL_LINE_SMOOTH);
       
   130                 end;
       
   131             end;
       
   132         // draw crosshair
       
   133         cx:= Round(hwRound(Gear^.X) + dx * 80);
       
   134         cy:= Round(hwRound(Gear^.Y) + dy * 80);
       
   135         DrawRotatedTex(HH^.Team^.CrosshairTex,
       
   136                 12, 12, cx + WorldDx, cy + WorldDy, 0,
       
   137                 hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle);
       
   138         end;
       
   139     hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx;
       
   140     hy:= hwRound(Gear^.Y) - 2 + WorldDy;
       
   141     aangle:= Gear^.Angle * 180 / cMaxAngle - 90;
       
   142 
       
   143     if CurAmmoGear <> nil then
       
   144     begin
       
   145         case CurAmmoGear^.Kind of
       
   146             gtShotgunShot: begin
       
   147                     if (CurAmmoGear^.State and gstAnimation <> 0) then
       
   148                         DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle)
       
   149                     else
       
   150                         DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
       
   151                 end;
       
   152             gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle);
       
   153             gtSniperRifleShot: begin
       
   154                     if (CurAmmoGear^.State and gstAnimation <> 0) then
       
   155                         DrawRotatedF(sprSniperRifle, hx, hy, 1, hwSign(Gear^.dX), aangle)
       
   156                     else
       
   157                         DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle)
       
   158                 end;
       
   159             gtBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
       
   160             gtRCPlane: begin
       
   161                 DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0);
       
   162                 defaultPos:= false
       
   163                 end;
       
   164             gtRope: begin
       
   165                 if Gear^.X < CurAmmoGear^.X then
       
   166                     begin
       
   167                     dAngle:= 0;
       
   168                     hAngle:= 180;
       
   169                     i:= 1
       
   170                     end else
       
   171                     begin
       
   172                     dAngle:= 180;
       
   173                     hAngle:= 0;
       
   174                     i:= -1
       
   175                     end;
       
   176                 sx:= hwRound(Gear^.X) + WorldDx;
       
   177                 sy:= hwRound(Gear^.Y) + WorldDy;
       
   178                if ((Gear^.State and gstWinner) = 0) then
       
   179                    begin
       
   180                    DrawHedgehog(sx, sy,
       
   181                            i,
       
   182                            1,
       
   183                            0,
       
   184                            DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
       
   185                    with HH^ do
       
   186                        if (HatTex <> nil) then
       
   187                            DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 0, i, 32, 32,
       
   188                                i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
       
   189                    end;
       
   190                 DrawAltWeapon(Gear, sx, sy);
       
   191                 defaultPos:= false
       
   192                 end;
       
   193             gtBlowTorch: begin
       
   194                 DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
       
   195                 DrawHedgehog(sx, sy,
       
   196                         hwSign(Gear^.dX),
       
   197                         3,
       
   198                         HH^.visStepPos div 2,
       
   199                         0);
       
   200                 with HH^ do
       
   201                     if (HatTex <> nil) then
       
   202                        DrawTextureF(HatTex,
       
   203                            1,
       
   204                            sx,
       
   205                            hwRound(Gear^.Y) - 8 + WorldDy,
       
   206                            0,
       
   207                            hwSign(Gear^.dX),
       
   208                            32,
       
   209                            32);
       
   210                 defaultPos:= false
       
   211                 end;
       
   212             gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180);
       
   213             gtFirePunch: begin
       
   214                 DrawHedgehog(sx, sy,
       
   215                         hwSign(Gear^.dX),
       
   216                         1,
       
   217                         4,
       
   218                         0);
       
   219                 defaultPos:= false
       
   220                 end;
       
   221             gtPickHammer: begin
       
   222                 defaultPos:= false;
       
   223                 dec(sy,20);
       
   224                 end;
       
   225             gtTeleport: defaultPos:= false;
       
   226             gtWhip: begin
       
   227                 DrawRotatedF(sprWhip,
       
   228                         sx,
       
   229                         sy,
       
   230                         1,
       
   231                         hwSign(Gear^.dX),
       
   232                         0);
       
   233                 defaultPos:= false
       
   234                 end;
       
   235             gtKamikaze: begin
       
   236                 if CurAmmoGear^.Pos = 0 then
       
   237                     DrawHedgehog(sx, sy,
       
   238                             hwSign(Gear^.dX),
       
   239                             1,
       
   240                             6,
       
   241                             0)
       
   242                 else
       
   243                     DrawRotatedF(sprKamikaze,
       
   244                             hwRound(Gear^.X) + WorldDx,
       
   245                             hwRound(Gear^.Y) + WorldDy,
       
   246                             CurAmmoGear^.Pos - 1,
       
   247                             hwSign(Gear^.dX),
       
   248                             aangle);
       
   249                 defaultPos:= false
       
   250                 end;
       
   251             gtSeduction: begin
       
   252                 if CurAmmoGear^.Pos >= 6 then
       
   253                     DrawHedgehog(sx, sy,
       
   254                             hwSign(Gear^.dX),
       
   255                             2,
       
   256                             2,
       
   257                             0)
       
   258                 else
       
   259                     begin
       
   260                     DrawRotatedF(sprDress,
       
   261                             hwRound(Gear^.X) + WorldDx,
       
   262                             hwRound(Gear^.Y) + WorldDy,
       
   263                             CurAmmoGear^.Pos,
       
   264                             hwSign(Gear^.dX),
       
   265                             0);
       
   266                     DrawSprite(sprCensored, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 20 + WorldDy, 0)
       
   267                     end;
       
   268                 defaultPos:= false
       
   269                 end;
       
   270         end;
       
   271 
       
   272         case CurAmmoGear^.Kind of
       
   273             gtShotgunShot,
       
   274             gtDEagleShot,
       
   275             gtSniperRifleShot,
       
   276             gtShover: begin
       
   277                 DrawHedgehog(sx, sy,
       
   278                         hwSign(Gear^.dX),
       
   279                         0,
       
   280                         4,
       
   281                         0);
       
   282                 defaultPos:= false;
       
   283                 HatVisible:= true
       
   284             end
       
   285         end
       
   286     end else
       
   287 
       
   288     if ((Gear^.State and gstHHJumping) <> 0) then
       
   289     begin
       
   290     DrawHedgehog(sx, sy,
       
   291         hwSign(Gear^.dX)*m,
       
   292         1,
       
   293         1,
       
   294         0);
       
   295     HatVisible:= true;
       
   296     defaultPos:= false
       
   297     end else
       
   298 
       
   299     if (Gear^.Message and (gm_Left or gm_Right) <> 0) and (not isCursorVisible) then
       
   300         begin
       
   301         DrawHedgehog(sx, sy,
       
   302             hwSign(Gear^.dX),
       
   303             0,
       
   304             HH^.visStepPos div 2,
       
   305             0);
       
   306         defaultPos:= false;
       
   307         HatVisible:= true
       
   308         end
       
   309     else
       
   310 
       
   311     if ((Gear^.State and gstAnimation) <> 0) then
       
   312         begin
       
   313         if (TWave(Gear^.Tag) < Low(TWave)) or (TWave(Gear^.Tag) > High(TWave)) then
       
   314             begin
       
   315             Gear^.State:= Gear^.State and not gstAnimation;
       
   316             end
       
   317         else
       
   318             begin
       
   319             DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite,
       
   320                     sx,
       
   321                     sy,
       
   322                     Gear^.Pos,
       
   323                     hwSign(Gear^.dX),
       
   324                     0.0);
       
   325             defaultPos:= false
       
   326             end
       
   327         end
       
   328     else
       
   329     if ((Gear^.State and gstAttacked) = 0) then
       
   330         begin
       
   331         if HH^.Timer > 0 then
       
   332             begin
       
   333             // There must be a tidier way to do this. Anyone?
       
   334             if aangle <= 90 then aangle:= aangle+360;
       
   335             if Gear^.dX > _0 then aangle:= aangle-((aangle-240)*HH^.Timer/10)
       
   336             else aangle:= aangle+((240-aangle)*HH^.Timer/10);
       
   337             dec(HH^.Timer)
       
   338             end;
       
   339         amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
       
   340         case amt of
       
   341             amBazooka: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
       
   342             amMortar: DrawRotated(sprHandMortar, hx, hy, hwSign(Gear^.dX), aangle);
       
   343             amMolotov: DrawRotated(sprHandMolotov, hx, hy, hwSign(Gear^.dX), aangle);
       
   344             amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
       
   345             amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle);
       
   346             amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
       
   347             amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
       
   348             amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
       
   349             amSineGun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
       
   350             amPortalGun: DrawRotatedF(sprPortalGun, hx, hy, 0, hwSign(Gear^.dX), aangle);
       
   351             amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle);
       
   352             amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
       
   353             amCake: DrawRotated(sprHandCake, hx, hy, hwSign(Gear^.dX), aangle);
       
   354             amGrenade: DrawRotated(sprHandGrenade, hx, hy, hwSign(Gear^.dX), aangle);
       
   355             amWatermelon: DrawRotated(sprHandMelon, hx, hy, hwSign(Gear^.dX), aangle);
       
   356             amSkip: DrawRotated(sprHandSkip, hx, hy, hwSign(Gear^.dX), aangle);
       
   357             amClusterBomb: DrawRotated(sprHandCluster, hx, hy, hwSign(Gear^.dX), aangle);
       
   358             amDynamite: DrawRotated(sprHandDynamite, hx, hy, hwSign(Gear^.dX), aangle);
       
   359             amHellishBomb: DrawRotated(sprHandHellish, hx, hy, hwSign(Gear^.dX), aangle);
       
   360             amMine: DrawRotated(sprHandMine, hx, hy, hwSign(Gear^.dX), aangle);
       
   361             amSeduction: DrawRotated(sprHandSeduction, hx, hy, hwSign(Gear^.dX), aangle);
       
   362             amVampiric: DrawRotated(sprHandVamp, hx, hy, hwSign(Gear^.dX), aangle);
       
   363             amRCPlane: begin
       
   364                 DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0);
       
   365                 defaultPos:= false
       
   366                 end;
       
   367             amGirder: begin
       
   368                 DrawRotated(sprHandConstruction, hx, hy, hwSign(Gear^.dX), aangle);
       
   369                 DrawSpriteClipped(sprGirder,
       
   370                                   sx-256,
       
   371                                   sy-256,
       
   372                                   LongInt(topY)+WorldDy,
       
   373                                   LongInt(rightX)+WorldDx,
       
   374                                   cWaterLine+WorldDy,
       
   375                                   LongInt(leftX)+WorldDx)
       
   376                 end;
       
   377             amBee: DrawRotatedF(sprHandBee, hx, hy, (RealTicks div 125) mod 4, hwSign(Gear^.dX), aangle);
       
   378         end;
       
   379 
       
   380         case amt of
       
   381             amAirAttack,
       
   382             amMineStrike: DrawRotated(sprHandAirAttack, sx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0);
       
   383             amPickHammer: DrawHedgehog(sx, sy,
       
   384                         hwSign(Gear^.dX),
       
   385                         1,
       
   386                         2,
       
   387                         0);
       
   388             amTeleport: DrawRotatedF(sprTeleport, sx, sy, 0, hwSign(Gear^.dX), 0);
       
   389             amKamikaze: DrawHedgehog(sx, sy,
       
   390                         hwSign(Gear^.dX),
       
   391                         1,
       
   392                         5,
       
   393                         0);
       
   394             amWhip: DrawRotatedF(sprWhip,
       
   395                         sx,
       
   396                         sy,
       
   397                         0,
       
   398                         hwSign(Gear^.dX),
       
   399                         0);
       
   400         else
       
   401             DrawHedgehog(sx, sy,
       
   402                 hwSign(Gear^.dX),
       
   403                 0,
       
   404                 4,
       
   405                 0);
       
   406 
       
   407             HatVisible:= true;
       
   408             (* with HH^ do
       
   409                 if (HatTex <> nil)
       
   410                 and (HatVisibility > 0) then
       
   411                     DrawTextureF(HatTex,
       
   412                         HatVisibility,
       
   413                         sx,
       
   414                         hwRound(Gear^.Y) - 8 + WorldDy,
       
   415                         0,
       
   416                         hwSign(Gear^.dX),
       
   417                         32,
       
   418                         32); *)
       
   419         end;
       
   420 
       
   421         case amt of
       
   422             amBaseballBat: DrawRotated(sprHandBaseball,
       
   423                     hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx,
       
   424                     hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle);
       
   425         end;
       
   426 
       
   427         defaultPos:= false
       
   428     end;
       
   429 
       
   430 end else // not gstHHDriven
       
   431     begin
       
   432     if (Gear^.Damage > 0)
       
   433     and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
       
   434         begin
       
   435         DrawHedgehog(sx, sy,
       
   436             hwSign(Gear^.dX),
       
   437             2,
       
   438             1,
       
   439             Gear^.DirAngle);
       
   440         defaultPos:= false
       
   441         end else
       
   442 
       
   443     if ((Gear^.State and gstHHJumping) <> 0) then
       
   444         begin
       
   445         DrawHedgehog(sx, sy,
       
   446             hwSign(Gear^.dX)*m,
       
   447             1,
       
   448             1,
       
   449             0);
       
   450         defaultPos:= false
       
   451         end;
       
   452     end;
       
   453 
       
   454 with HH^ do
       
   455     begin
       
   456     if defaultPos then
       
   457         begin
       
   458         DrawRotatedF(sprHHIdle,
       
   459             sx,
       
   460             sy,
       
   461             (RealTicks div 128 + Gear^.Pos) mod 19,
       
   462             hwSign(Gear^.dX),
       
   463             0);
       
   464         HatVisible:= true;
       
   465         end;
       
   466 
       
   467     if HatVisible then
       
   468         if HatVisibility < 1.0 then
       
   469             HatVisibility:= HatVisibility + 0.2
       
   470         else
       
   471     else
       
   472         if HatVisibility > 0.0 then
       
   473             HatVisibility:= HatVisibility - 0.2;
       
   474 
       
   475     if (HatTex <> nil)
       
   476     and (HatVisibility > 0) then
       
   477         if DefaultPos then
       
   478             DrawTextureF(HatTex,
       
   479                 HatVisibility,
       
   480                 sx,
       
   481                 hwRound(Gear^.Y) - 8 + WorldDy,
       
   482                 (RealTicks div 128 + Gear^.Pos) mod 19,
       
   483                 hwSign(Gear^.dX),
       
   484                 32,
       
   485                 32)
       
   486         else
       
   487             DrawTextureF(HatTex,
       
   488                 HatVisibility,
       
   489                 sx,
       
   490                 hwRound(Gear^.Y) - 8 + WorldDy,
       
   491                 0,
       
   492                 hwSign(Gear^.dX)*m,
       
   493                 32,
       
   494                 32);
       
   495     end;
       
   496 if (Gear^.State and gstHHDriven) <> 0 then
       
   497     begin
       
   498 (*    if (CurAmmoGear = nil) then
       
   499         begin
       
   500         amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
       
   501         case amt of
       
   502             amJetpack: DrawSprite(sprJetpack, sx-32, sy-32, 0);
       
   503             end
       
   504         end; *)
       
   505     if CurAmmoGear <> nil then
       
   506         begin
       
   507         case CurAmmoGear^.Kind of
       
   508             gtJetpack: begin
       
   509                        DrawSprite(sprJetpack, sx-32, sy-32, 0);
       
   510                        if (CurAmmoGear^.MsgParam and gm_Up) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 1);
       
   511                        if (CurAmmoGear^.MsgParam and gm_Left) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 2);
       
   512                        if (CurAmmoGear^.MsgParam and gm_Right) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 3);
       
   513                        if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex);
       
   514                        DrawAltWeapon(Gear, sx, sy)
       
   515                        end;
       
   516             end;
       
   517         end
       
   518     end;
       
   519 
       
   520 with HH^ do
       
   521     begin
       
   522     if ((Gear^.State and not gstWinner) = 0)
       
   523         or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then
       
   524         begin
       
   525         t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy;
       
   526         if (cTagsMask and htTransparent) <> 0 then
       
   527             Tint($80FFFFFF);
       
   528         if ((cTagsMask and htHealth) <> 0) then
       
   529             begin
       
   530             dec(t, HealthTagTex^.h + 2);
       
   531             DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex)
       
   532             end;
       
   533         if (cTagsMask and htName) <> 0 then
       
   534             begin
       
   535             dec(t, NameTagTex^.h + 2);
       
   536             DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex)
       
   537             end;
       
   538         if (cTagsMask and htTeamName) <> 0 then
       
   539             begin
       
   540             dec(t, Team^.NameTagTex^.h + 2);
       
   541             DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex)
       
   542             end;
       
   543         if (cTagsMask and htTransparent) <> 0 then
       
   544             Tint($FFFFFFFF)
       
   545         end;
       
   546     if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
       
   547         begin
       
   548         if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
       
   549             DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy,
       
   550                         GameTicks div 32 mod 16);
       
   551 
       
   552         if (Gear^.State and gstDrowning) = 0 then
       
   553             if (Gear^.State and gstHHThinking) <> 0 then
       
   554                 DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, (RealTicks shr 9) mod 8)
       
   555         end
       
   556     end;
       
   557 
       
   558 if HH^.Effects[hePoisoned] then
       
   559     begin
       
   560     Tint($8040FF00);
       
   561     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 1.5, 0, 0, sx, sy, 0, 1, 22, 22, 360 - (RealTicks shr 37) mod 360);
       
   562     end;
       
   563 
       
   564 if Gear^.Invulnerable then
       
   565     begin
       
   566     Tint($FF, $FF, $FF, max($40, floor($FF * abs(1 - ((RealTicks div 2 + Gear^.uid * 491) mod 1500) / 750))));
       
   567     DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0);
       
   568     end;
       
   569 if cVampiric and
       
   570    (CurrentHedgehog^.Gear <> nil) and
       
   571    (CurrentHedgehog^.Gear = Gear) then
       
   572     begin
       
   573     Tint($FF, $FF, $FF, max($40, floor($FF * abs(1 - (RealTicks mod 1500) / 750))));
       
   574     DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
       
   575     end;
       
   576     Tint($FFFFFFFF)
       
   577 end;
       
   578 
       
   579 procedure DrawGears;
       
   580 var Gear, HHGear: PGear;
       
   581     i: Longword;
       
   582     startX, endX, startY, endY: LongInt;
       
   583 begin
       
   584 Gear:= GearsList;
       
   585 while Gear<>nil do
       
   586     begin
       
   587     case Gear^.Kind of
       
   588        gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
       
   589        gtGasBomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
       
   590     gtMolotov: DrawRotated(sprMolotov, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
       
   591 
       
   592        gtRCPlane: begin
       
   593                   if (Gear^.Tag = -1) then
       
   594                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, -1,  DxDy2Angle(Gear^.dX, Gear^.dY) + 90)
       
   595                   else
       
   596                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX));
       
   597                   if ((TrainingFlags and tfRCPlane) <> 0) and (TrainingTargetGear <> nil) and ((Gear^.State and gstDrowning) = 0) then
       
   598                      DrawRotatedf(sprFinger, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, GameTicks div 32 mod 16, 0, DxDy2Angle(Gear^.X - TrainingTargetGear^.X, TrainingTargetGear^.Y - Gear^.Y));
       
   599                   end;
       
   600        gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, Gear^.DirAngle);
       
   601 // Still need portal types and states
       
   602        gtPortal: DrawRotatedf(sprPortal, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0,0, Gear^.DirAngle);
       
   603 
       
   604        gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
       
   605 
       
   606         gtHedgehog: DrawHH(Gear);
       
   607 
       
   608     gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
       
   609 
       
   610        gtHealthTag: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
       
   611 
       
   612            gtGrave: DrawTextureF(PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex, 1, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks shr 7+Gear^.uid) and 7, 1, 32, 32);
       
   613 
       
   614              gtBee: DrawRotatedF(sprBee, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks shr 5) mod 2, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
       
   615 
       
   616       gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0);
       
   617             gtRope: DrawRope(Gear);
       
   618       gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
       
   619        gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State);
       
   620             gtMine: if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then
       
   621                            DrawRotated(sprMineOff, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle)
       
   622                        else if Gear^.Health <> 0 then DrawRotated(sprMineOn, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle)
       
   623                        else DrawRotated(sprMineDead, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
       
   624             gtCase: case Gear^.Pos of
       
   625                          posCaseAmmo  : begin
       
   626                                         i:= (GameTicks shr 6) mod 64;
       
   627                                         if i > 18 then i:= 0;
       
   628                                         DrawSprite(sprCase, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i);
       
   629                                         end;
       
   630                          posCaseHealth: begin
       
   631                                         i:= ((GameTicks shr 6) + 38) mod 64;
       
   632                                         if i > 13 then i:= 0;
       
   633                                         DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i);
       
   634                                         end;
       
   635                          posCaseUtility: begin
       
   636                                         i:= (GameTicks shr 6) mod 70;
       
   637                                         if i > 23 then i:= 0;
       
   638                                         i:= i mod 12;
       
   639                                         DrawSprite(sprUtility, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i);
       
   640                                         end;
       
   641                          end;
       
   642       gtExplosives: begin
       
   643                     if ((Gear^.State and gstDrowning) <> 0) then
       
   644                         DrawSprite(sprExplosivesRoll, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, 0)
       
   645                     else if Gear^.State and gstAnimation = 0 then
       
   646                         begin
       
   647                         i:= (GameTicks shr 6 + Gear^.uid*3) mod 64;
       
   648                         if i > 18 then i:= 0;
       
   649                         DrawSprite(sprExplosives, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i)
       
   650                         end
       
   651                     else if Gear^.State and gsttmpFlag = 0 then
       
   652                         DrawRotatedF(sprExplosivesRoll, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) +4 + WorldDy, 0, 0, Gear^.DirAngle)
       
   653                     else
       
   654                         DrawRotatedF(sprExplosivesRoll, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) +4 + WorldDy, 1, 0, Gear^.DirAngle);
       
   655                     end;
       
   656         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1);
       
   657      gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
       
   658          gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0);
       
   659            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);
       
   660        gtParachute: begin
       
   661                     DrawSprite(sprParachute, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 48 + WorldDy, 0);
       
   662                     DrawAltWeapon(Gear, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy)
       
   663                     end;
       
   664        gtAirAttack: if Gear^.Tag > 0 then DrawSprite(sprAirplane, hwRound(Gear^.X) - SpritesData[sprAirplane].Width div 2 + WorldDx, hwRound(Gear^.Y) - SpritesData[sprAirplane].Height div 2 + WorldDy, 0)
       
   665                                      else DrawSprite(sprAirplane, hwRound(Gear^.X) - SpritesData[sprAirplane].Width div 2 + WorldDx, hwRound(Gear^.Y) - SpritesData[sprAirplane].Height div 2 + WorldDy, 1);
       
   666          gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
       
   667         gtTeleport: begin
       
   668                     HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
       
   669                     if not PHedgehog(Gear^.Hedgehog)^.Unplaced then DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(Gear^.dX), 0);
       
   670                     DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0);
       
   671                     end;
       
   672         gtSwitcher: DrawSprite(sprSwitch, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 56 + WorldDy, (GameTicks shr 6) mod 12);
       
   673           gtTarget: begin
       
   674                     Tint($FF, $FF, $FF, floor($FF * Gear^.Timer / 1000));
       
   675                     DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0);
       
   676                     Tint($FFFFFFFF);
       
   677                     end;
       
   678           gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
       
   679           gtCake: if Gear^.Pos = 6 then
       
   680                      DrawRotatedf(sprCakeWalk, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90)
       
   681                   else
       
   682                      DrawRotatedf(sprCakeDown, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 5 - Gear^.Pos, hwSign(Gear^.dX), 0);
       
   683        gtSeduction: if Gear^.Pos >= 14 then DrawSprite(sprSeduction, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0);
       
   684       gtWatermelon: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 0, Gear^.DirAngle);
       
   685       gtMelonPiece: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 1, 0, Gear^.DirAngle);
       
   686      gtHellishBomb: DrawRotated(sprHellishBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
       
   687       gtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
       
   688            gtBirdy: begin
       
   689                     if Gear^.State and gstAnimation = gstAnimation then
       
   690                         begin
       
   691                         if Gear^.State and gstTmpFlag = 0 then // Appearing
       
   692                             begin
       
   693                             endX:= hwRound(Gear^.X);
       
   694                             endY:= hwRound(Gear^.Y);
       
   695                             if Gear^.Tag < 0 then
       
   696                                 startX:= max(LAND_WIDTH + 1024, endX + 2048)
       
   697                             else
       
   698                                 startX:= max(-LAND_WIDTH - 1024, endX - 2048);
       
   699                             startY:= endY - 256;
       
   700                             DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + trunc((endX - startX) * (-power(2, -10 * LongInt(Gear^.Timer)/2000) + 1)), startY + WorldDy + trunc((endY - startY) * sqrt(1 - power((LongInt(Gear^.Timer)/2000)-1, 2))), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
       
   701                             end
       
   702                         else // Disappearing
       
   703                             begin
       
   704                             startX:= hwRound(Gear^.X);
       
   705                             startY:= hwRound(Gear^.Y);
       
   706                             if Gear^.Tag > 0 then
       
   707                                 endX:= max(LAND_WIDTH + 1024, startX + 2048)
       
   708                             else
       
   709                                 endX:= max(-LAND_WIDTH - 1024, startX - 2048);
       
   710                             endY:= startY + 256;
       
   711                             DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + trunc((endX - startX) * power(2, 10 * (LongInt(Gear^.Timer)/2000 - 1))) + hwRound(Gear^.dX * Gear^.Timer), startY + WorldDy + trunc((endY - startY) * cos(LongInt(Gear^.Timer)/2000 * (Pi/2)) - (endY - startY)) + hwRound(Gear^.dY * Gear^.Timer), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
       
   712                             end;
       
   713                         end
       
   714                     else
       
   715                         DrawTextureF(SpritesData[sprBirdy].Texture, 1, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
       
   716                     end;
       
   717     gtBigExplosion: begin
       
   718                     Tint($FF, $FF, $FF, floor($FF * (1 - power(Gear^.Timer / 250, 4))));
       
   719                     DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
       
   720                     Tint($FFFFFFFF);
       
   721                     end;
       
   722              gtEgg: DrawRotatedTextureF(SpritesData[sprEgg].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 16, 16, Gear^.DirAngle);
       
   723            gtPiano: begin
       
   724                     if (Gear^.State and gstDrowning) = 0 then
       
   725                         begin
       
   726                         Tint($10FFFFFF);
       
   727                         for i:= 8 downto 1 do
       
   728                             DrawRotatedTextureF(SpritesData[sprPiano].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy - hwRound(Gear^.dY * 4 * i), 0, 1, 128, 128, 0);
       
   729                         Tint($FFFFFFFF)
       
   730                         end;
       
   731                     DrawRotatedTextureF(SpritesData[sprPiano].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 128, 128, 0);
       
   732                     end;
       
   733          end;
       
   734       if Gear^.RenderTimer and (Gear^.Tex <> nil) then DrawCentered(hwRound(Gear^.X) + 8 + WorldDx, hwRound(Gear^.Y) + 8 + WorldDy, Gear^.Tex);
       
   735       Gear:= Gear^.NextGear
       
   736       end;
       
   737 end;