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