hedgewars/uGearsRender.pas
branchhedgeroid
changeset 7855 ddcdedd3330b
parent 7829 c1dc7839d7b9
child 7856 70c086d9b03f
equal deleted inserted replaced
6350:41b0a9955c47 7855:ddcdedd3330b
     1 (*
     1 (*
     2  * Hedgewars, a free turn based strategy game
     2  * Hedgewars, a free turn based strategy game
     3  * Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com>
     3  * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
     4  *
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation; version 2 of the License
     7  * the Free Software Foundation; version 2 of the License
     8  *
     8  *
    27 
    27 
    28 var RopePoints: record
    28 var RopePoints: record
    29                 Count: Longword;
    29                 Count: Longword;
    30                 HookAngle: GLfloat;
    30                 HookAngle: GLfloat;
    31                 ar: array[0..MAXROPEPOINTS] of record
    31                 ar: array[0..MAXROPEPOINTS] of record
    32                                   X, Y: hwFloat;
    32                                 X, Y: hwFloat;
    33                                   dLen: hwFloat;
    33                                 dLen: hwFloat;
    34                                   b: boolean;
    34                                 b: boolean;
    35                                   end;
    35                                 end;
    36                 rounded: array[0..MAXROPEPOINTS + 2] of TVertex2f;
    36                 rounded: array[0..MAXROPEPOINTS + 2] of TVertex2f;
    37                 end;
    37                 end;
    38 
    38 
    39 implementation
    39 implementation
    40 uses uRender, uUtils, uVariables, uAmmos, Math;
    40 uses uRender, uUtils, uVariables, uAmmos, Math, uVisualGears;
    41 
    41 
    42 procedure DrawRopeLinesRQ(Gear: PGear);
    42 procedure DrawRopeLinesRQ(Gear: PGear);
    43 begin
    43 begin
    44 with RopePoints do
    44 with RopePoints do
    45     begin
    45     begin
    72     //glDisable(GL_LINE_SMOOTH)
    72     //glDisable(GL_LINE_SMOOTH)
    73     end
    73     end
    74 end;
    74 end;
    75 
    75 
    76 
    76 
    77 procedure DrawRope(Gear: PGear);
    77 function DrawRopeLine(X1, Y1, X2, Y2, roplen: LongInt): LongInt;
    78 var roplen: LongInt;
    78 var  eX, eY, dX, dY: LongInt;
    79     i: Longword;
    79     i, sX, sY, x, y, d: LongInt;
    80 
    80     b: boolean;
    81     procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt);
    81 begin
    82     var  eX, eY, dX, dY: LongInt;
       
    83         i, sX, sY, x, y, d: LongInt;
       
    84         b: boolean;
       
    85     begin
       
    86     if (X1 = X2) and (Y1 = Y2) then
    82     if (X1 = X2) and (Y1 = Y2) then
    87     begin
    83         begin
    88     //OutError('WARNING: zero length rope line!', false);
    84         //OutError('WARNING: zero length rope line!', false);
    89     exit
    85         exit
    90     end;
    86         end;
    91     eX:= 0;
    87     eX:= 0;
    92     eY:= 0;
    88     eY:= 0;
    93     dX:= X2 - X1;
    89     dX:= X2 - X1;
    94     dY:= Y2 - Y1;
    90     dY:= Y2 - Y1;
    95 
    91 
    96     if (dX > 0) then sX:= 1
    92     if (dX > 0) then
       
    93         sX:= 1
    97     else
    94     else
    98     if (dX < 0) then
    95         if (dX < 0) then
    99         begin
    96             begin
   100         sX:= -1;
    97             sX:= -1;
   101         dX:= -dX
    98             dX:= -dX
   102         end else sX:= dX;
    99             end
   103 
   100         else sX:= dX;
   104     if (dY > 0) then sY:= 1
   101 
       
   102     if (dY > 0) then 
       
   103         sY:= 1
   105     else
   104     else
   106     if (dY < 0) then
   105         if (dY < 0) then
   107         begin
   106             begin
   108         sY:= -1;
   107             sY:= -1;
   109         dY:= -dY
   108             dY:= -dY
   110         end else sY:= dY;
   109             end
   111 
   110         else 
   112         if (dX > dY) then d:= dX
   111             sY:= dY;
   113                     else d:= dY;
   112 
   114 
   113     if (dX > dY) then
   115         x:= X1;
   114         d:= dX
   116         y:= Y1;
   115     else
   117 
   116         d:= dY;
   118         for i:= 0 to d do
   117 
   119             begin
   118     x:= X1;
   120             inc(eX, dX);
   119     y:= Y1;
   121             inc(eY, dY);
   120 
   122             b:= false;
   121     for i:= 0 to d do
   123             if (eX > d) then
   122         begin
   124                 begin
   123         inc(eX, dX);
   125                 dec(eX, d);
   124         inc(eY, dY);
   126                 inc(x, sX);
   125         b:= false;
   127                 b:= true
   126         if (eX > d) then
   128                 end;
   127             begin
   129             if (eY > d) then
   128             dec(eX, d);
   130                 begin
   129             inc(x, sX);
   131                 dec(eY, d);
   130             b:= true
   132                 inc(y, sY);
   131             end;
   133                 b:= true
   132         if (eY > d) then
   134                 end;
   133             begin
   135             if b then
   134             dec(eY, d);
   136                 begin
   135             inc(y, sY);
   137                 inc(roplen);
   136             b:= true
   138                 if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0)
   137             end;
   139                 end
   138         if b then
   140         end
   139             begin
       
   140             inc(roplen);
       
   141             if (roplen mod 4) = 0 then
       
   142                 DrawSprite(sprRopeNode, x - 2, y - 2, 0)
       
   143             end
   141     end;
   144     end;
       
   145 DrawRopeLine:= roplen;
       
   146 end;
       
   147 
       
   148 procedure DrawRope(Gear: PGear);
       
   149 var roplen: LongInt;
       
   150     i: Longword;
   142 begin
   151 begin
   143     if (cReducedQuality and rqSimpleRope) <> 0 then
   152     if (cReducedQuality and rqSimpleRope) <> 0 then
   144         DrawRopeLinesRQ(Gear)
   153         DrawRopeLinesRQ(Gear)
   145     else
   154     else
   146         begin
   155         begin
   148         if RopePoints.Count > 0 then
   157         if RopePoints.Count > 0 then
   149             begin
   158             begin
   150             i:= 0;
   159             i:= 0;
   151             while i < Pred(RopePoints.Count) do
   160             while i < Pred(RopePoints.Count) do
   152                     begin
   161                     begin
   153                     DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
   162                     roplen:= DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
   154                                 hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy);
   163                                 hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy, roplen);
   155                     inc(i)
   164                     inc(i)
   156                     end;
   165                     end;
   157             DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
   166             roplen:= DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
   158                         hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy);
   167                         hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, roplen);
   159             DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
   168             roplen:= DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
   160                         hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy);
   169                         hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy, roplen);
   161             end else
   170             end
       
   171         else
   162             if Gear^.Elasticity.QWordValue > 0 then
   172             if Gear^.Elasticity.QWordValue > 0 then
   163             DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
   173             roplen:= DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
   164                         hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy);
   174                         hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy, roplen);
   165         end;
   175         end;
   166 
   176 
   167 
   177 
   168 if RopePoints.Count > 0 then
   178 if RopePoints.Count > 0 then
   169     DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle)
   179     DrawSpriteRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle)
   170     else
   180 else
   171     if Gear^.Elasticity.QWordValue > 0 then
   181     if Gear^.Elasticity.QWordValue > 0 then
   172         DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   182         DrawSpriteRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   173 end;
   183 end;
   174 
   184 
   175 
   185 
   176 procedure DrawAltWeapon(Gear: PGear; sx, sy: LongInt);
   186 procedure DrawAltWeapon(Gear: PGear; sx, sy: LongInt);
   177 begin
   187 begin
   193     defaultPos, HatVisible: boolean;
   203     defaultPos, HatVisible: boolean;
   194     HH: PHedgehog;
   204     HH: PHedgehog;
   195     CurWeapon: PAmmo;
   205     CurWeapon: PAmmo;
   196 begin
   206 begin
   197     HH:= Gear^.Hedgehog;
   207     HH:= Gear^.Hedgehog;
   198     if HH^.Unplaced then exit;
   208     if HH^.Unplaced then
       
   209         exit;
   199     m:= 1;
   210     m:= 1;
   200     if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
   211     if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then
       
   212         m:= -1;
   201     sx:= ox + 1; // this offset is very common
   213     sx:= ox + 1; // this offset is very common
   202     sy:= oy - 3;
   214     sy:= oy - 3;
   203     sign:= hwSign(Gear^.dX);
   215     sign:= hwSign(Gear^.dX);
   204 
   216 
   205     if (Gear^.State and gstHHDeath) <> 0 then
   217     if (Gear^.State and gstHHDeath) <> 0 then
   210         Tint($FF, $FF, $FF, $FF);
   222         Tint($FF, $FF, $FF, $FF);
   211         exit
   223         exit
   212         end
   224         end
   213     else if (Gear^.State and gstHHGone) <> 0 then
   225     else if (Gear^.State and gstHHGone) <> 0 then
   214         begin
   226         begin
   215         DrawRotatedF(sprTeleport, sx, sy, Gear^.Pos, sign, 0);
   227         DrawSpriteRotatedF(sprTeleport, sx, sy, Gear^.Pos, sign, 0);
   216         exit
   228         exit
   217         end;
   229         end;
   218 
   230 
   219     defaultPos:= true;
   231     defaultPos:= true;
   220     HatVisible:= false;
   232     HatVisible:= false;
   221 
   233 
   222 
   234 
   223     if HH^.Effects[hePoisoned] then
   235     if HH^.Effects[hePoisoned] <> 0 then
   224         begin
   236         begin
   225         Tint($00, $FF, $40, $40);
   237         Tint($00, $FF, $40, $40);
   226         DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360);
   238         DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360);
   227         Tint($FF, $FF, $FF, $FF)
   239         Tint($FF, $FF, $FF, $FF)
   228         end;
   240         end;
   229 
   241 
   230     if ((Gear^.State and gstWinner) <> 0) and
   242     if ((Gear^.State and gstWinner) <> 0) and
   231     ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
   243     ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
   258 
   270 
   259     if (Gear^.State and gstHHDriven) <> 0 then
   271     if (Gear^.State and gstHHDriven) <> 0 then
   260         begin
   272         begin
   261         if ((Gear^.State and (gstHHThinking or gstAnimation)) = 0) and
   273         if ((Gear^.State and (gstHHThinking or gstAnimation)) = 0) and
   262 /// If current ammo is active, and current ammo has alt attack and uses a crosshair  (rope, basically, right now, with no crosshair for parachute/saucer
   274 /// If current ammo is active, and current ammo has alt attack and uses a crosshair  (rope, basically, right now, with no crosshair for parachute/saucer
   263            (((CurAmmoGear <> nil) and //((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) and
   275             (((CurAmmoGear <> nil) and //((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) and
   264              ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0)) or
   276              ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0)) or
   265 /// If no current ammo is active, and the selected ammo uses a crosshair
   277 /// If no current ammo is active, and the selected ammo uses a crosshair
   266              ((CurAmmoGear = nil) and ((Ammoz[HH^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0) and ((Gear^.State and gstAttacked) = 0))) then
   278             ((CurAmmoGear = nil) and ((Ammoz[HH^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0) and ((Gear^.State and gstAttacked) = 0))) then
   267             begin
   279             begin
   268     (* These calculations are a little complex for a few reasons:
   280     (* These calculations are a little complex for a few reasons:
   269     1: I need to draw the laser from weapon origin to nearest land
   281     1: I need to draw the laser from weapon origin to nearest land
   270     2: I need to start the beam outside the hedgie for attractiveness.
   282     2: I need to start the beam outside the hedgie for attractiveness.
   271     3: I need to extend the beam beyond land.
   283     3: I need to extend the beam beyond land.
   307                     ty:= round(ly)
   319                     ty:= round(ly)
   308                     end;
   320                     end;
   309                 // reached edge of land. assume infinite beam. Extend it way out past camera
   321                 // reached edge of land. assume infinite beam. Extend it way out past camera
   310                 if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
   322                 if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
   311                     begin
   323                     begin
   312                     tx:= round(lx + ax * (LAND_WIDTH div 4));
   324                     tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2));
   313                     ty:= round(ly + ay * (LAND_WIDTH div 4));
   325                     ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2));
   314                     end;
   326                     end;
   315 
   327 
   316                 //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
   328                 //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
   317                     begin
   329                     begin
   318                     DrawLine(hx, hy, tx, ty, 1.0, $FF, $00, $00, $C0);
   330                     DrawLine(hx, hy, tx, ty, 1.0, $FF, $00, $00, $C0);
   321             // draw crosshair
   333             // draw crosshair
   322             CrosshairX := Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle));
   334             CrosshairX := Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle));
   323             CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
   335             CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
   324  
   336  
   325             
   337             
   326             DrawRotatedTex(HH^.Team^.CrosshairTex,
   338             DrawTextureRotated(HH^.Team^.CrosshairTex,
   327                     12, 12, CrosshairX + WorldDx, CrosshairY + WorldDy, 0,
   339                     12, 12, CrosshairX + WorldDx, CrosshairY + WorldDy, 0,
   328                     sign * (Gear^.Angle * 180.0) / cMaxAngle);
   340                     sign * (Gear^.Angle * 180.0) / cMaxAngle);
   329             end;
   341             end;
   330         hx:= ox + 8 * sign;
   342         hx:= ox + 8 * sign;
   331         hy:= oy - 2;
   343         hy:= oy - 2;
   333         if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind <> gtTardis) then
   345         if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind <> gtTardis) then
   334         begin
   346         begin
   335             case CurAmmoGear^.Kind of
   347             case CurAmmoGear^.Kind of
   336                 gtShotgunShot: begin
   348                 gtShotgunShot: begin
   337                         if (CurAmmoGear^.State and gstAnimation <> 0) then
   349                         if (CurAmmoGear^.State and gstAnimation <> 0) then
   338                             DrawRotated(sprShotgun, hx, hy, sign, aangle)
   350                             DrawSpriteRotated(sprShotgun, hx, hy, sign, aangle)
   339                         else
   351                         else
   340                             DrawRotated(sprHandShotgun, hx, hy, sign, aangle);
   352                             DrawSpriteRotated(sprHandShotgun, hx, hy, sign, aangle);
   341                     end;
   353                     end;
   342                 gtDEagleShot: DrawRotated(sprDEagle, hx, hy, sign, aangle);
   354                 gtDEagleShot: DrawSpriteRotated(sprDEagle, hx, hy, sign, aangle);
   343                 gtSniperRifleShot: begin
   355                 gtSniperRifleShot: begin
   344                         if (CurAmmoGear^.State and gstAnimation <> 0) then
   356                         if (CurAmmoGear^.State and gstAnimation <> 0) then
   345                             DrawRotatedF(sprSniperRifle, hx, hy, 1, sign, aangle)
   357                             DrawSpriteRotatedF(sprSniperRifle, hx, hy, 1, sign, aangle)
   346                         else
   358                         else
   347                             DrawRotatedF(sprSniperRifle, hx, hy, 0, sign, aangle)
   359                             DrawSpriteRotatedF(sprSniperRifle, hx, hy, 0, sign, aangle)
   348                     end;
   360                     end;
   349                 gtBallgun: DrawRotated(sprHandBallgun, hx, hy, sign, aangle);
   361                 gtBallgun: DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle);
   350                 gtRCPlane: begin
   362                 gtRCPlane: begin
   351                     DrawRotated(sprHandPlane, hx, hy, sign, 0);
   363                     DrawSpriteRotated(sprHandPlane, hx, hy, sign, 0);
   352                     defaultPos:= false
   364                     defaultPos:= false
   353                     end;
   365                     end;
   354                 gtRope: begin
   366                 gtRope: begin
   355                     if Gear^.X < CurAmmoGear^.X then
   367                     if Gear^.X < CurAmmoGear^.X then
   356                         begin
   368                         begin
   357                         dAngle:= 0;
   369                         dAngle:= 0;
   358                         hAngle:= 180;
   370                         hAngle:= 180;
   359                         i:= 1
   371                         i:= 1
   360                         end else
   372                         end
       
   373                     else
   361                         begin
   374                         begin
   362                         dAngle:= 180;
   375                         dAngle:= 180;
   363                         hAngle:= 0;
   376                         hAngle:= 0;
   364                         i:= -1
   377                         i:= -1
   365                         end;
   378                         end;
   366                 if ((Gear^.State and gstWinner) = 0) then
   379                     if ((Gear^.State and gstWinner) = 0) then
   367                     begin
   380                         begin
   368                     DrawHedgehog(ox, oy,
   381                         DrawHedgehog(ox, oy,
   369                             i,
   382                                 i,
   370                             1,
   383                                 1,
   371                             0,
   384                                 0,
   372                             DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
   385                                 DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
   373                     with HH^ do
   386                         with HH^ do
   374                         if (HatTex <> nil) then
   387                             if (HatTex <> nil) then
   375                             begin
       
   376                             DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, ox, oy, 0, i, 32, 32,
       
   377                                 i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
       
   378                             if HatTex^.w > 64 then
       
   379                                 begin
   388                                 begin
   380                                 Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
   389                                 DrawTextureRotatedF(HatTex, 1.0, -1.0, -6.0, ox, oy, 0, i, 32, 32,
   381                                 DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, ox, oy, 32, i, 32, 32,
       
   382                                     i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   390                                     i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   383                                 Tint($FF, $FF, $FF, $FF)
   391                                 if HatTex^.w > 64 then
       
   392                                     begin
       
   393                                     Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
       
   394                                     DrawTextureRotatedF(HatTex, 1.0, -1.0, -6.0, ox, oy, 32, i, 32, 32,
       
   395                                         i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
       
   396                                     Tint($FF, $FF, $FF, $FF)
       
   397                                     end
   384                                 end
   398                                 end
   385                             end
       
   386                     end;
   399                     end;
   387                     DrawAltWeapon(Gear, ox, oy);
   400                     DrawAltWeapon(Gear, ox, oy);
   388                     defaultPos:= false
   401                     defaultPos:= false
   389                     end;
   402                     end;
   390                 gtBlowTorch: begin
   403                 gtBlowTorch:
   391                     DrawRotated(sprBlowTorch, hx, hy, sign, aangle);
   404                     begin
       
   405                     DrawSpriteRotated(sprBlowTorch, hx, hy, sign, aangle);
   392                     DrawHedgehog(sx, sy,
   406                     DrawHedgehog(sx, sy,
   393                             sign,
   407                             sign,
   394                             3,
   408                             3,
   395                             HH^.visStepPos div 2,
   409                             HH^.visStepPos div 2,
   396                             0);
   410                             0);
   419                                 Tint($FF, $FF, $FF, $FF)
   433                                 Tint($FF, $FF, $FF, $FF)
   420                                 end
   434                                 end
   421                             end;
   435                             end;
   422                     defaultPos:= false
   436                     defaultPos:= false
   423                     end;
   437                     end;
   424                 gtShover: DrawRotated(sprHandBaseball, hx, hy, sign, aangle + 180);
   438                 gtShover: DrawSpriteRotated(sprHandBaseball, hx, hy, sign, aangle + 180);
   425                 gtFirePunch: begin
   439                 gtFirePunch:
       
   440                     begin
   426                     DrawHedgehog(sx, sy,
   441                     DrawHedgehog(sx, sy,
   427                             sign,
   442                             sign,
   428                             1,
   443                             1,
   429                             4,
   444                             4,
   430                             0);
   445                             0);
   431                     defaultPos:= false
   446                     defaultPos:= false
   432                     end;
   447                     end;
   433                 gtPickHammer: begin
   448                 gtPickHammer:
       
   449                     begin
   434                     defaultPos:= false;
   450                     defaultPos:= false;
   435                     dec(sy,20);
   451                     dec(sy,20);
   436                     end;
   452                     end;
   437                 gtTeleport: defaultPos:= false;
   453                 gtTeleport: defaultPos:= false;
   438                 gtWhip: begin
   454                 gtWhip:
   439                     DrawRotatedF(sprWhip,
   455                     begin
       
   456                     DrawSpriteRotatedF(sprWhip,
   440                             sx,
   457                             sx,
   441                             sy,
   458                             sy,
   442                             1,
   459                             1,
   443                             sign,
   460                             sign,
   444                             0);
   461                             0);
   445                     defaultPos:= false
   462                     defaultPos:= false
   446                     end;
   463                     end;
   447                 gtHammer: begin
   464                 gtHammer:
   448                     DrawRotatedF(sprHammer,
   465                     begin
       
   466                     DrawSpriteRotatedF(sprHammer,
   449                             sx,
   467                             sx,
   450                             sy,
   468                             sy,
   451                             1,
   469                             1,
   452                             sign,
   470                             sign,
   453                             0);
   471                             0);
   454                     defaultPos:= false
   472                     defaultPos:= false
   455                     end;
   473                     end;
   456                 gtResurrector: begin
   474                 gtResurrector:
   457                     DrawRotated(sprHandResurrector, sx, sy, 0, 0);
   475                     begin
       
   476                     DrawSpriteRotated(sprHandResurrector, sx, sy, 0, 0);
   458                     defaultPos:= false
   477                     defaultPos:= false
   459                     end;
   478                     end;
   460                 gtKamikaze: begin
   479                 gtKamikaze:
       
   480                     begin
   461                     if CurAmmoGear^.Pos = 0 then
   481                     if CurAmmoGear^.Pos = 0 then
   462                         DrawHedgehog(sx, sy,
   482                         DrawHedgehog(sx, sy,
   463                                 sign,
   483                                 sign,
   464                                 1,
   484                                 1,
   465                                 6,
   485                                 6,
   466                                 0)
   486                                 0)
   467                     else
   487                     else
   468                         DrawRotatedF(sprKamikaze,
   488                         DrawSpriteRotatedF(sprKamikaze,
   469                                 ox, oy,
   489                                 ox, oy,
   470                                 CurAmmoGear^.Pos - 1,
   490                                 CurAmmoGear^.Pos - 1,
   471                                 sign,
   491                                 sign,
   472                                 aangle);
   492                                 aangle);
   473                     defaultPos:= false
   493                     defaultPos:= false
   474                     end;
   494                     end;
   475                 gtSeduction: begin
   495                 gtSeduction:
       
   496                     begin
   476                     if CurAmmoGear^.Pos >= 6 then
   497                     if CurAmmoGear^.Pos >= 6 then
   477                         DrawHedgehog(sx, sy,
   498                         DrawHedgehog(sx, sy,
   478                                 sign,
   499                                 sign,
   479                                 2,
   500                                 2,
   480                                 2,
   501                                 2,
   481                                 0)
   502                                 0)
   482                     else
   503                     else
   483                         begin
   504                         begin
   484                         DrawRotatedF(sprDress,
   505                         DrawSpriteRotatedF(sprDress,
   485                                 ox, oy,
   506                                 ox, oy,
   486                                 CurAmmoGear^.Pos,
   507                                 CurAmmoGear^.Pos,
   487                                 sign,
   508                                 sign,
   488                                 0);
   509                                 0);
   489                         DrawSprite(sprCensored, ox - 32, oy - 20, 0)
   510                         DrawSprite(sprCensored, ox - 32, oy - 20, 0)
   490                         end;
   511                         end;
   491                     defaultPos:= false
   512                     defaultPos:= false
   492                     end;
   513                     end;
   493                 gtFlamethrower: begin
   514                 gtFlamethrower:
   494                     DrawRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   515                     begin
   495                     if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex)
   516                     DrawSpriteRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   496                     end;
   517                     if CurAmmoGear^.Tex <> nil then
   497                 gtLandGun: begin DrawRotated(sprHandBallgun, hx, hy, sign, aangle);
   518                         DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex)
   498                     if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex)
   519                     end;
       
   520                 gtLandGun:
       
   521                     begin DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle);
       
   522                     if CurAmmoGear^.Tex <> nil then
       
   523                         DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex)
       
   524                     end;
       
   525                 gtIceGun:
       
   526                     begin DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle);
       
   527                     if CurAmmoGear^.Tex <> nil then
       
   528                         DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex)
   499                     end;
   529                     end;
   500             end;
   530             end;
   501 
   531 
   502             case CurAmmoGear^.Kind of
   532             case CurAmmoGear^.Kind of
   503                 gtShotgunShot,
   533                 gtShotgunShot,
   504                 gtDEagleShot,
   534                 gtDEagleShot,
   505                 gtSniperRifleShot,
   535                 gtSniperRifleShot,
   506                 gtShover: begin
   536                 gtShover:
   507                     DrawHedgehog(sx, sy,
   537                     begin
   508                             sign,
   538                     DrawHedgehog(sx, sy, sign, 0, 4, 0);
   509                             0,
       
   510                             4,
       
   511                             0);
       
   512                     defaultPos:= false;
   539                     defaultPos:= false;
   513                     HatVisible:= true
   540                     HatVisible:= true
   514                 end
   541                 end
   515             end
   542             end
   516         end else
   543         end else
   540 
   567 
   541         if ((Gear^.State and gstAnimation) <> 0) then
   568         if ((Gear^.State and gstAnimation) <> 0) then
   542             begin
   569             begin
   543             if (TWave(Gear^.Tag) < Low(TWave)) or (TWave(Gear^.Tag) > High(TWave)) then
   570             if (TWave(Gear^.Tag) < Low(TWave)) or (TWave(Gear^.Tag) > High(TWave)) then
   544                 begin
   571                 begin
   545                 Gear^.State:= Gear^.State and not gstAnimation;
   572                 Gear^.State:= Gear^.State and (not gstAnimation);
   546                 end
   573                 end
   547             else
   574             else
   548                 begin
   575                 begin
   549                 DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite,
   576                 DrawSpriteRotatedF(Wavez[TWave(Gear^.Tag)].Sprite,
   550                         sx,
   577                         sx,
   551                         sy,
   578                         sy,
   552                         Gear^.Pos,
   579                         Gear^.Pos,
   553                         sign,
   580                         sign,
   554                         0.0);
   581                         0.0);
   559         if ((Gear^.State and gstAttacked) = 0) then
   586         if ((Gear^.State and gstAttacked) = 0) then
   560             begin
   587             begin
   561             if HH^.Timer > 0 then
   588             if HH^.Timer > 0 then
   562                 begin
   589                 begin
   563                 // There must be a tidier way to do this. Anyone?
   590                 // There must be a tidier way to do this. Anyone?
   564                 if aangle <= 90 then aangle:= aangle+360;
   591                 if aangle <= 90 then
   565                 if Gear^.dX > _0 then aangle:= aangle-((aangle-240)*HH^.Timer/10)
   592                     aangle:= aangle+360;
   566                 else aangle:= aangle+((240-aangle)*HH^.Timer/10);
   593                 if Gear^.dX > _0 then
       
   594                     aangle:= aangle-((aangle-240)*HH^.Timer/10)
       
   595                 else
       
   596                     aangle:= aangle+((240-aangle)*HH^.Timer/10);
   567                 dec(HH^.Timer)
   597                 dec(HH^.Timer)
   568                 end;
   598                 end;
   569             amt:= CurrentHedgehog^.CurAmmoType;
   599             amt:= CurrentHedgehog^.CurAmmoType;
   570             CurWeapon:= GetAmmoEntry(HH^);
   600             CurWeapon:= GetCurAmmoEntry(HH^);
   571             case amt of
   601             case amt of
   572                 amBazooka: DrawRotated(sprHandBazooka, hx, hy, sign, aangle);
   602                 amBazooka: DrawSpriteRotated(sprHandBazooka, hx, hy, sign, aangle);
   573                 amSnowball: DrawRotated(sprHandSnowball, hx, hy, sign, aangle);
   603                 amSnowball: DrawSpriteRotated(sprHandSnowball, hx, hy, sign, aangle);
   574                 amMortar: DrawRotated(sprHandMortar, hx, hy, sign, aangle);
   604                 amMortar: DrawSpriteRotated(sprHandMortar, hx, hy, sign, aangle);
   575                 amMolotov: DrawRotated(sprHandMolotov, hx, hy, sign, aangle);
   605                 amMolotov: DrawSpriteRotated(sprHandMolotov, hx, hy, sign, aangle);
   576                 amBallgun: DrawRotated(sprHandBallgun, hx, hy, sign, aangle);
   606                 amBallgun: DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle);
   577                 amDrill: DrawRotated(sprHandDrill, hx, hy, sign, aangle);
   607                 amDrill: DrawSpriteRotated(sprHandDrill, hx, hy, sign, aangle);
   578                 amRope: DrawRotated(sprHandRope, hx, hy, sign, aangle);
   608                 amRope: DrawSpriteRotated(sprHandRope, hx, hy, sign, aangle);
   579                 amShotgun: DrawRotated(sprHandShotgun, hx, hy, sign, aangle);
   609                 amShotgun: DrawSpriteRotated(sprHandShotgun, hx, hy, sign, aangle);
   580                 amDEagle: DrawRotated(sprHandDEagle, hx, hy, sign, aangle);
   610                 amDEagle: DrawSpriteRotated(sprHandDEagle, hx, hy, sign, aangle);
   581                 amSineGun: DrawRotatedF(sprHandSinegun, hx, hy, 73 + (sign * LongInt(RealTicks div 73)) mod 8, sign, aangle);
   611                 amSineGun: DrawSpriteRotatedF(sprHandSinegun, hx, hy, 73 + (sign * LongInt(RealTicks div 73)) mod 8, sign, aangle);
   582                 amPortalGun: if (CurWeapon^.Timer and 2) <> 0 then // Add a new Hedgehog value instead of abusing timer?
   612                 
   583                                 DrawRotatedF(sprPortalGun, hx, hy, 0, sign, aangle)
   613                 amPortalGun:
   584                         else
   614                     if (CurWeapon^.Timer and 2) <> 0 then // Add a new Hedgehog value instead of abusing timer?
   585                                 DrawRotatedF(sprPortalGun, hx, hy, 1+CurWeapon^.Pos, sign, aangle);
   615                         DrawSpriteRotatedF(sprPortalGun, hx, hy, 0, sign, aangle)
   586                 amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, sign, aangle);
   616                     else
   587                 amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, sign, aangle);
   617                         DrawSpriteRotatedF(sprPortalGun, hx, hy, 1+CurWeapon^.Pos, sign, aangle);
   588                 amCake: DrawRotated(sprHandCake, hx, hy, sign, aangle);
   618                         
   589                 amGrenade: DrawRotated(sprHandGrenade, hx, hy, sign, aangle);
   619                 amSniperRifle: DrawSpriteRotatedF(sprSniperRifle, hx, hy, 0, sign, aangle);
   590                 amWatermelon: DrawRotated(sprHandMelon, hx, hy, sign, aangle);
   620                 amBlowTorch: DrawSpriteRotated(sprHandBlowTorch, hx, hy, sign, aangle);
   591                 amSkip: DrawRotated(sprHandSkip, hx, hy, sign, aangle);
   621                 amCake: DrawSpriteRotated(sprHandCake, hx, hy, sign, aangle);
   592                 amClusterBomb: DrawRotated(sprHandCluster, hx, hy, sign, aangle);
   622                 amGrenade: DrawSpriteRotated(sprHandGrenade, hx, hy, sign, aangle);
   593                 amDynamite: DrawRotated(sprHandDynamite, hx, hy, sign, aangle);
   623                 amWatermelon: DrawSpriteRotated(sprHandMelon, hx, hy, sign, aangle);
   594                 amHellishBomb: DrawRotated(sprHandHellish, hx, hy, sign, aangle);
   624                 amSkip: DrawSpriteRotated(sprHandSkip, hx, hy, sign, aangle);
   595                 amGasBomb: DrawRotated(sprHandCheese, hx, hy, sign, aangle);
   625                 amClusterBomb: DrawSpriteRotated(sprHandCluster, hx, hy, sign, aangle);
   596                 amMine: DrawRotated(sprHandMine, hx, hy, sign, aangle);
   626                 amDynamite: DrawSpriteRotated(sprHandDynamite, hx, hy, sign, aangle);
   597                 amSMine: DrawRotated(sprHandSMine, hx, hy, sign, aangle);
   627                 amHellishBomb: DrawSpriteRotated(sprHandHellish, hx, hy, sign, aangle);
       
   628                 amGasBomb: DrawSpriteRotated(sprHandCheese, hx, hy, sign, aangle);
       
   629                 amMine: DrawSpriteRotated(sprHandMine, hx, hy, sign, aangle);
       
   630                 amSMine: DrawSpriteRotated(sprHandSMine, hx, hy, sign, aangle);
       
   631                 amKnife: DrawSpriteRotatedF(sprHandKnife, hx, hy, 0, sign, aangle);
   598                 amSeduction: begin
   632                 amSeduction: begin
   599                              DrawRotated(sprHandSeduction, hx, hy, sign, aangle);
   633                              DrawSpriteRotated(sprHandSeduction, hx, hy, sign, aangle);
   600                              DrawCircle(ox, oy, 248, 4, $FF, $00, $00, $AA); 
   634                              DrawCircle(ox, oy, 248, 4, $FF, $00, $00, $AA); 
   601                              //Tint($FF, $0, $0, $AA);
   635                              //Tint($FF, $0, $0, $AA);
   602                              //DrawTexture(ox - 240, oy - 240, SpritesData[sprVampiric].Texture, 10);
   636                              //DrawTexture(ox - 240, oy - 240, SpritesData[sprVampiric].Texture, 10);
   603                              //Tint($FF, $FF, $FF, $FF);
   637                              //Tint($FF, $FF, $FF, $FF);
   604                              end;
   638                              end;
   605                 amVampiric: DrawRotatedF(sprHandVamp, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   639                 amVampiric: DrawSpriteRotatedF(sprHandVamp, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   606                 amRCPlane: begin
   640                 amRCPlane: begin
   607                     DrawRotated(sprHandPlane, hx, hy, sign, 0);
   641                     DrawSpriteRotated(sprHandPlane, hx, hy, sign, 0);
   608                     defaultPos:= false
   642                     defaultPos:= false
   609                     end;
   643                     end;
   610                 amGirder: begin
   644                 amGirder: begin
   611                     DrawRotated(sprHandConstruction, hx, hy, sign, aangle);
   645                     DrawSpriteRotated(sprHandConstruction, hx, hy, sign, aangle);
   612                     DrawSpriteClipped(sprGirder,
   646                     DrawSpriteClipped(sprGirder,
   613                                     ox-256,
   647                                     ox-256,
   614                                     oy-256,
   648                                     oy-256,
   615                                     LongInt(topY)+WorldDy,
   649                                     LongInt(topY)+WorldDy,
   616                                     LongInt(rightX)+WorldDx,
   650                                     LongInt(rightX)+WorldDx,
   617                                     cWaterLine+WorldDy,
   651                                     cWaterLine+WorldDy,
   618                                     LongInt(leftX)+WorldDx)
   652                                     LongInt(leftX)+WorldDx)
   619                     end;
   653                     end;
   620                 amBee: DrawRotatedF(sprHandBee, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   654                 amBee: DrawSpriteRotatedF(sprHandBee, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   621                 amFlamethrower: DrawRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   655                 amFlamethrower: DrawSpriteRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   622                 amLandGun: DrawRotated(sprHandBallgun, hx, hy, sign, aangle);
   656                 amLandGun: DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle);
       
   657                 amIceGun: DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle);
   623                 amResurrector: DrawCircle(ox, oy, 98, 4, $F5, $DB, $35, $AA); // I'd rather not like to hardcode 100 here
   658                 amResurrector: DrawCircle(ox, oy, 98, 4, $F5, $DB, $35, $AA); // I'd rather not like to hardcode 100 here
   624             end;
   659             end;
   625 
   660 
   626             case amt of
   661             case amt of
   627                 amAirAttack,
   662                 amAirAttack,
   628                 amMineStrike,
   663                 amMineStrike,
   629                 amDrillStrike: DrawRotated(sprHandAirAttack, sx, oy, sign, 0);
   664                 amDrillStrike: DrawSpriteRotated(sprHandAirAttack, sx, oy, sign, 0);
   630                 amPickHammer: DrawHedgehog(sx, sy,
   665                 amPickHammer: DrawHedgehog(sx, sy,
   631                             sign,
   666                             sign,
   632                             1,
   667                             1,
   633                             2,
   668                             2,
   634                             0);
   669                             0);
   635                 amTeleport: DrawRotatedF(sprTeleport, sx, sy, 0, sign, 0);
   670                 amTeleport: DrawSpriteRotatedF(sprTeleport, sx, sy, 0, sign, 0);
   636                 amKamikaze: DrawHedgehog(sx, sy,
   671                 amKamikaze: DrawHedgehog(sx, sy,
   637                             sign,
   672                             sign,
   638                             1,
   673                             1,
   639                             5,
   674                             5,
   640                             0);
   675                             0);
   641                 amWhip: DrawRotatedF(sprWhip,
   676                 amWhip: DrawSpriteRotatedF(sprWhip,
   642                             sx,
   677                             sx,
   643                             sy,
   678                             sy,
   644                             0,
   679                             0,
   645                             sign,
   680                             sign,
   646                             0);
   681                             0);
   647                 amHammer: DrawRotatedF(sprHammer,
   682                 amHammer: DrawSpriteRotatedF(sprHammer,
   648                             sx,
   683                             sx,
   649                             sy,
   684                             sy,
   650                             0,
   685                             0,
   651                             sign,
   686                             sign,
   652                             0);
   687                             0);
   670                             32,
   705                             32,
   671                             32); *)
   706                             32); *)
   672             end;
   707             end;
   673 
   708 
   674             case amt of
   709             case amt of
   675                 amBaseballBat: DrawRotated(sprHandBaseball,
   710                 amBaseballBat: DrawSpriteRotated(sprHandBaseball,
   676                         sx - 4 * sign,
   711                         sx - 4 * sign,
   677                         sy + 9, sign, aangle);
   712                         sy + 9, sign, aangle);
   678             end;
   713             end;
   679 
   714 
   680             defaultPos:= false
   715             defaultPos:= false
   706 
   741 
   707     with HH^ do
   742     with HH^ do
   708         begin
   743         begin
   709         if defaultPos then
   744         if defaultPos then
   710             begin
   745             begin
   711             DrawRotatedF(sprHHIdle,
   746             DrawSpriteRotatedF(sprHHIdle,
   712                 sx,
   747                 sx,
   713                 sy,
   748                 sy,
   714                 (RealTicks div 128 + Gear^.Pos) mod 19,
   749                 (RealTicks div 128 + Gear^.Pos) mod 19,
   715                 sign,
   750                 sign,
   716                 0);
   751                 0);
   790             case CurAmmoGear^.Kind of
   825             case CurAmmoGear^.Kind of
   791                 gtJetpack: begin
   826                 gtJetpack: begin
   792                         DrawSprite(sprJetpack, sx-32, sy-32, 0);
   827                         DrawSprite(sprJetpack, sx-32, sy-32, 0);
   793                         if cWaterLine > hwRound(Gear^.Y) + Gear^.Radius then
   828                         if cWaterLine > hwRound(Gear^.Y) + Gear^.Radius then
   794                             begin
   829                             begin
   795                             if (CurAmmoGear^.MsgParam and gmUp) <> 0 then DrawSprite(sprJetpack, sx-32, sy-28, 1);
   830                             if (CurAmmoGear^.MsgParam and gmUp) <> 0 then
   796                             if (CurAmmoGear^.MsgParam and gmLeft) <> 0 then DrawSprite(sprJetpack, sx-28, sy-28, 2);
   831                                 DrawSprite(sprJetpack, sx-32, sy-28, 1);
   797                             if (CurAmmoGear^.MsgParam and gmRight) <> 0 then DrawSprite(sprJetpack, sx-36, sy-28, 3)
   832                             if (CurAmmoGear^.MsgParam and gmLeft) <> 0 then
       
   833                                 DrawSprite(sprJetpack, sx-28, sy-28, 2);
       
   834                             if (CurAmmoGear^.MsgParam and gmRight) <> 0 then
       
   835                                 DrawSprite(sprJetpack, sx-36, sy-28, 3)
   798                             end;
   836                             end;
   799                         if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex);
   837                         if CurAmmoGear^.Tex <> nil then
       
   838                             DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex);
   800                         DrawAltWeapon(Gear, sx, sy)
   839                         DrawAltWeapon(Gear, sx, sy)
   801                         end;
   840                         end;
   802                 end;
   841                 end;
   803             end
   842             end
   804         end;
   843         end;
   805 
   844 
   806     with HH^ do
   845     with HH^ do
   807         begin
   846         begin
   808         if ((Gear^.State and not gstWinner) = 0)
   847         if ((Gear^.State and (not gstWinner)) = 0)
   809             or ((Gear^.State = gstWait) and (Gear^.dY.QWordValue = 0))
   848             or ((Gear^.State = gstWait) and (Gear^.dY.QWordValue = 0))
   810             or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then
   849             or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then
   811             begin
   850             begin
   812             t:= sy - cHHRadius - 9;
   851             t:= sy - cHHRadius - 9;
   813             if (cTagsMask and htTransparent) <> 0 then
   852             if (cTagsMask and htTransparent) <> 0 then
   814                 Tint($FF, $FF, $FF, $80);
   853                 Tint($FF, $FF, $FF, $80);
   815             if ((cTagsMask and htHealth) <> 0) then
   854             if ((cTagsMask and htHealth) <> 0) then
   816                 begin
   855                 begin
   817                 dec(t, HealthTagTex^.h + 2);
   856                 dec(t, HealthTagTex^.h + 2);
   818                 DrawCentered(ox, t, HealthTagTex)
   857                 DrawTextureCentered(ox, t, HealthTagTex)
   819                 end;
   858                 end;
   820             if (cTagsMask and htName) <> 0 then
   859             if (cTagsMask and htName) <> 0 then
   821                 begin
   860                 begin
   822                 dec(t, NameTagTex^.h + 2);
   861                 dec(t, NameTagTex^.h + 2);
   823                 DrawCentered(ox, t, NameTagTex)
   862                 DrawTextureCentered(ox, t, NameTagTex)
   824                 end;
   863                 end;
   825             if (cTagsMask and htTeamName) <> 0 then
   864             if (cTagsMask and htTeamName) <> 0 then
   826                 begin
   865                 begin
   827                 dec(t, Team^.NameTagTex^.h + 2);
   866                 dec(t, Team^.NameTagTex^.h + 2);
   828                 DrawCentered(ox, t, Team^.NameTagTex)
   867                 DrawTextureCentered(ox, t, Team^.NameTagTex)
   829                 end;
   868                 end;
   830             if (cTagsMask and htTransparent) <> 0 then
   869             if (cTagsMask and htTransparent) <> 0 then
   831                 Tint($FF, $FF, $FF, $FF)
   870                 Tint($FF, $FF, $FF, $FF)
   832             end;
   871             end;
   833         if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
   872         if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
   834             begin
   873             begin
   835             if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtResurrector) then
   874             if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtResurrector) then
   836                 DrawCentered(ox, sy - cHHRadius - 7 - HealthTagTex^.h, HealthTagTex);
   875                 DrawTextureCentered(ox, sy - cHHRadius - 7 - HealthTagTex^.h, HealthTagTex);
   837 
   876 
   838             if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
   877             if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
   839                 DrawSprite(sprFinger, ox - 16, oy - 64,
   878                 DrawSprite(sprFinger, ox - 16, oy - 64,
   840                             GameTicks div 32 mod 16);
   879                             GameTicks div 32 mod 16);
   841 
   880 
   843                 if (Gear^.State and gstHHThinking) <> 0 then
   882                 if (Gear^.State and gstHHThinking) <> 0 then
   844                     DrawSprite(sprQuestion, ox - 10, oy - cHHRadius - 34, (RealTicks shr 9) mod 8)
   883                     DrawSprite(sprQuestion, ox - 10, oy - cHHRadius - 34, (RealTicks shr 9) mod 8)
   845             end
   884             end
   846         end;
   885         end;
   847 
   886 
   848     if HH^.Effects[hePoisoned] then
   887     if HH^.Effects[hePoisoned] <> 0 then
   849         begin
   888         begin
   850         Tint($00, $FF, $40, $80);
   889         Tint($00, $FF, $40, $80);
   851         DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 1.5, 0, 0, sx, sy, 0, 1, 22, 22, 360 - (RealTicks shr 37) mod 360);
   890         DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 1.5, 0, 0, sx, sy, 0, 1, 22, 22, 360 - (RealTicks shr 37) mod 360);
   852         end;
   891         end;
   853     if HH^.Effects[heResurrected] then
   892     if HH^.Effects[heResurrected] <> 0 then
   854         begin
   893         begin
   855         Tint($f5, $db, $35, $20);
   894         Tint($f5, $db, $35, $20);
   856         DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
   895         DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
   857         end;
   896         end;
   858 
   897 
   873 
   912 
   874 
   913 
   875 procedure RenderGear(Gear: PGear; x, y: LongInt);
   914 procedure RenderGear(Gear: PGear; x, y: LongInt);
   876 var
   915 var
   877     HHGear: PGear;
   916     HHGear: PGear;
       
   917     vg: PVisualGear;
   878     i: Longword;
   918     i: Longword;
       
   919     aAngle: real;
   879     startX, endX, startY, endY: LongInt;
   920     startX, endX, startY, endY: LongInt;
   880 begin
   921 begin
   881     if Gear^.Target.X <> NoPointX then
   922     if Gear^.Target.X <> NoPointX then
   882         if Gear^.AmmoType = amBee then
   923         if Gear^.AmmoType = amBee then
   883             DrawRotatedF(sprTargetBee, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
   924             DrawSpriteRotatedF(sprTargetBee, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
   884         else
   925 	else if Gear^.AmmoType = amIceGun then
   885             DrawRotatedF(sprTargetP, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360);
   926 	    //DrawSprite(sprSnowDust, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8)
       
   927         //DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1, 0, 0, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8, 1, 22, 22, (RealTicks shr 3) mod 360)
       
   928         DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1/(1+(RealTicks shr 8) mod 5), 0, 0, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8, 1, 22, 22, (RealTicks shr 3) mod 360)
       
   929     else
       
   930         DrawSpriteRotatedF(sprTargetP, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360);
   886 
   931 
   887     case Gear^.Kind of
   932     case Gear^.Kind of
   888           gtGrenade: DrawRotated(sprBomb, x, y, 0, Gear^.DirAngle);
   933           gtGrenade: DrawSpriteRotated(sprBomb, x, y, 0, Gear^.DirAngle);
   889       gtSnowball: DrawRotated(sprSnowball, x, y, 0, Gear^.DirAngle);
   934       gtSnowball: DrawSpriteRotated(sprSnowball, x, y, 0, Gear^.DirAngle);
   890        gtGasBomb: DrawRotated(sprCheese, x, y, 0, Gear^.DirAngle);
   935        gtGasBomb: DrawSpriteRotated(sprCheese, x, y, 0, Gear^.DirAngle);
   891                   
   936                   
   892        gtMolotov: if (Gear^.State and gstDrowning) = 0 then
   937        gtMolotov: if (Gear^.State and gstDrowning) = 0 then
   893                        DrawRotatedF(sprMolotov, x, y, (RealTicks div 125) mod 8, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX))
   938                        DrawSpriteRotatedF(sprMolotov, x, y, (RealTicks div 125) mod 8, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX))
   894                   else DrawSprite(sprMolotov, x, y, 8);
   939                   else DrawSprite(sprMolotov, x, y, 8);
   895 
   940 
   896        gtRCPlane: begin
   941        gtRCPlane: begin
       
   942                   aangle:= Gear^.Angle * 360 / 4096;
       
   943                   if Gear^.Tag < 0 then aangle:= 360-aangle;
   897                   Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF);
   944                   Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF);
   898                   if Gear^.Tag = -1 then
   945                   DrawSpriteRotatedF(sprPlane, x, y, 0, Gear^.Tag, aangle - 90);
   899                       begin
   946                   Tint($FF, $FF, $FF, $FF);
   900                       DrawRotatedF(sprPlane, x, y, 0, -1, DxDy2Angle(Gear^.dX, Gear^.dY) + 90);
   947                   DrawSpriteRotatedF(sprPlane, x, y, 1, Gear^.Tag, aangle - 90)
   901                       Tint($FF, $FF, $FF, $FF);
       
   902                       DrawRotatedF(sprPlane, x, y, 1, -1, DxDy2Angle(Gear^.dX, Gear^.dY) + 90)
       
   903                       end
       
   904                   else
       
   905                       begin
       
   906                       DrawRotatedF(sprPlane, x, y, 0, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
       
   907                       Tint($FF, $FF, $FF, $FF);
       
   908                       DrawRotatedF(sprPlane, x, y, 1, 0, DxDy2Angle(Gear^.dY, Gear^.dX))
       
   909                       end
       
   910                   end;
   948                   end;
   911        gtBall: DrawRotatedf(sprBalls, x, y, Gear^.Tag,0, Gear^.DirAngle);
   949        gtBall: DrawSpriteRotatedF(sprBalls, x, y, Gear^.Tag,0, Gear^.DirAngle);
   912 
   950 
   913        gtPortal: if ((Gear^.Tag and 1) = 0) // still moving?
   951        gtPortal: if ((Gear^.Tag and 1) = 0) // still moving?
   914                  or (Gear^.IntersectGear = nil) or (Gear^.IntersectGear^.IntersectGear <> Gear) // not linked&backlinked?
   952                  or (Gear^.LinkedGear = nil) or (Gear^.LinkedGear^.LinkedGear <> Gear) // not linked&backlinked?
   915                  or ((Gear^.IntersectGear^.Tag and 1) = 0) then // linked portal still moving?
   953                  or ((Gear^.LinkedGear^.Tag and 1) = 0) then // linked portal still moving?
   916                       DrawRotatedf(sprPortal, x, y, Gear^.Tag, hwSign(Gear^.dX), Gear^.DirAngle)
   954                       DrawSpriteRotatedF(sprPortal, x, y, Gear^.Tag, hwSign(Gear^.dX), Gear^.DirAngle)
   917                  else DrawRotatedf(sprPortal, x, y, 4 + Gear^.Tag div 2, hwSign(Gear^.dX), Gear^.DirAngle);
   955                  else DrawSpriteRotatedF(sprPortal, x, y, 4 + Gear^.Tag div 2, hwSign(Gear^.dX), Gear^.DirAngle);
   918 
   956 
   919            gtDrill: if (Gear^.State and gsttmpFlag) <> 0 then
   957            gtDrill: if (Gear^.State and gsttmpFlag) <> 0 then
   920                         DrawRotated(sprAirDrill, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX))
   958                         DrawSpriteRotated(sprAirDrill, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX))
   921                     else
   959                     else
   922                         DrawRotated(sprDrill, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   960                         DrawSpriteRotated(sprDrill, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   923 
   961 
   924         gtHedgehog: DrawHH(Gear, x, y);
   962         gtHedgehog: DrawHH(Gear, x, y);
   925 
   963 
   926            gtShell: DrawRotated(sprBazookaShell, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   964            gtShell: DrawSpriteRotated(sprBazookaShell, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   927 
   965 
   928            gtGrave: begin
   966            gtGrave: begin
   929                     DrawTextureF(Gear^.Hedgehog^.Team^.GraveTex, 1, x, y, (GameTicks shr 7+Gear^.uid) and 7, 1, 32, 32);
   967                     DrawTextureF(Gear^.Hedgehog^.Team^.GraveTex, 1, x, y, (GameTicks shr 7+Gear^.uid) and 7, 1, 32, 32);
   930                     if Gear^.Health > 0 then
   968                     if Gear^.Health > 0 then
   931                         begin
   969                         begin
   934                         //Tint($FF, $FF, $FF, max($40, round($FF * abs(1 - (RealTicks mod 1500) / 750))));
   972                         //Tint($FF, $FF, $FF, max($40, round($FF * abs(1 - (RealTicks mod 1500) / 750))));
   935                         DrawSprite(sprVampiric, x - 24, y - 24, 0);
   973                         DrawSprite(sprVampiric, x - 24, y - 24, 0);
   936                         Tint($FF, $FF, $FF, $FF)
   974                         Tint($FF, $FF, $FF, $FF)
   937                         end
   975                         end
   938                     end;
   976                     end;
   939              gtBee: DrawRotatedF(sprBee, x, y, (GameTicks shr 5) mod 2, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   977              gtBee: DrawSpriteRotatedF(sprBee, x, y, (GameTicks shr 5) mod 2, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   940       gtPickHammer: DrawSprite(sprPHammer, x - 16, y - 50 + LongInt(((GameTicks shr 5) and 1) * 2), 0);
   978       gtPickHammer: DrawSprite(sprPHammer, x - 16, y - 50 + LongInt(((GameTicks shr 5) and 1) * 2), 0);
   941             gtRope: DrawRope(Gear);
   979             gtRope: DrawRope(Gear);
       
   980             
   942             gtMine: if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then
   981             gtMine: if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then
   943                            DrawRotated(sprMineOff, x, y, 0, Gear^.DirAngle)
   982                            DrawSpriteRotated(sprMineOff, x, y, 0, Gear^.DirAngle)
   944                        else if Gear^.Health <> 0 then DrawRotated(sprMineOn, x, y, 0, Gear^.DirAngle)
   983                        else if Gear^.Health <> 0 then
   945                        else DrawRotated(sprMineDead, x, y, 0, Gear^.DirAngle);
   984                            DrawSpriteRotated(sprMineOn, x, y, 0, Gear^.DirAngle)
       
   985                        else DrawSpriteRotated(sprMineDead, x, y, 0, Gear^.DirAngle);
       
   986                        
   946            gtSMine: if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then
   987            gtSMine: if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then
   947                            DrawRotated(sprSMineOff, x, y, 0, Gear^.DirAngle)
   988                            DrawSpriteRotated(sprSMineOff, x, y, 0, Gear^.DirAngle)
   948                        else if Gear^.Health <> 0 then DrawRotated(sprSMineOn, x, y, 0, Gear^.DirAngle)
   989                        else if Gear^.Health <> 0 then
   949                        else DrawRotated(sprMineDead, x, y, 0, Gear^.DirAngle);
   990                            DrawSpriteRotated(sprSMineOn, x, y, 0, Gear^.DirAngle)
   950             gtCase: if ((Gear^.Pos and posCaseAmmo) <> 0) then
   991                        else DrawSpriteRotated(sprMineDead, x, y, 0, Gear^.DirAngle);
   951                         begin
   992            gtKnife: DrawSpriteRotatedF(sprKnife, x, y, 0, hwSign(Gear^.dX), Gear^.DirAngle);
   952                         i:= (GameTicks shr 6) mod 64;
   993                        
   953                         if i > 18 then i:= 0;
   994             gtCase: begin
   954                         DrawSprite(sprCase, x - 24, y - 24, i);
   995                     if Gear^.Timer > 1000 then
       
   996                         begin
       
   997                         if ((Gear^.Pos and posCaseAmmo) <> 0) then
       
   998                             begin
       
   999                             i:= (GameTicks shr 6) mod 64;
       
  1000                             if i > 18 then
       
  1001                                 i:= 0;
       
  1002                             DrawSprite(sprCase, x - 24, y - 24, i);
       
  1003                             end
       
  1004                         else if ((Gear^.Pos and posCaseHealth) <> 0) then
       
  1005                             begin
       
  1006                             i:= ((GameTicks shr 6) + 38) mod 64;
       
  1007                             if i > 13 then
       
  1008                                 i:= 0;
       
  1009                             DrawSprite(sprFAid, x - 24, y - 24, i);
       
  1010                             end
       
  1011                         else if ((Gear^.Pos and posCaseUtility) <> 0) then
       
  1012                             begin
       
  1013                             i:= (GameTicks shr 6) mod 70;
       
  1014                             if i > 23 then
       
  1015                                 i:= 0;
       
  1016                             i:= i mod 12;
       
  1017                             DrawSprite(sprUtility, x - 24, y - 24, i);
       
  1018                             end;
       
  1019                         end;
       
  1020                     if Gear^.Timer < 1833 then
       
  1021                         begin
       
  1022                         DrawTextureRotatedF(SpritesData[sprPortal].texture, min(abs(1.25 - (Gear^.Timer mod 1333) / 400), 1.25), 0, 0,
       
  1023                                             x, LongInt(Gear^.Angle) + WorldDy - 16, 4 + Gear^.Tag, 1, 32, 32, 270);
   955                         end
  1024                         end
   956                     else if ((Gear^.Pos and posCaseHealth) <> 0) then
  1025                     end;
   957                         begin
       
   958                         i:= ((GameTicks shr 6) + 38) mod 64;
       
   959                         if i > 13 then i:= 0;
       
   960                         DrawSprite(sprFAid, x - 24, y - 24, i);
       
   961                         end
       
   962                     else if ((Gear^.Pos and posCaseUtility) <> 0) then
       
   963                         begin
       
   964                         i:= (GameTicks shr 6) mod 70;
       
   965                         if i > 23 then i:= 0;
       
   966                         i:= i mod 12;
       
   967                         DrawSprite(sprUtility, x - 24, y - 24, i);
       
   968                         end;
       
   969       gtExplosives: begin
  1026       gtExplosives: begin
   970                     if ((Gear^.State and gstDrowning) <> 0) then
  1027                     if ((Gear^.State and gstDrowning) <> 0) then
   971                         DrawSprite(sprExplosivesRoll, x - 24, y - 24, 0)
  1028                         DrawSprite(sprExplosivesRoll, x - 24, y - 24, 0)
   972                     else if Gear^.State and gstAnimation = 0 then
  1029                     else if Gear^.State and gstAnimation = 0 then
   973                         begin
  1030                         begin
   974                         i:= (GameTicks shr 6 + Gear^.uid*3) mod 64;
  1031                         i:= (GameTicks shr 6 + Gear^.uid*3) mod 64;
   975                         if i > 18 then i:= 0;
  1032                         if i > 18 then
       
  1033                             i:= 0;
   976                         DrawSprite(sprExplosives, x - 24, y - 24, i)
  1034                         DrawSprite(sprExplosives, x - 24, y - 24, i)
   977                         end
  1035                         end
   978                     else if Gear^.State and gsttmpFlag = 0 then
  1036                     else if Gear^.State and gsttmpFlag = 0 then
   979                         DrawRotatedF(sprExplosivesRoll, x, y + 4, 0, 0, Gear^.DirAngle)
  1037                         DrawSpriteRotatedF(sprExplosivesRoll, x, y + 4, 0, 0, Gear^.DirAngle)
   980                     else
  1038                     else
   981                         DrawRotatedF(sprExplosivesRoll, x, y + 4, 1, 0, Gear^.DirAngle);
  1039                         DrawSpriteRotatedF(sprExplosivesRoll, x, y + 4, 1, 0, Gear^.DirAngle);
   982                     end;
  1040                     end;
   983         gtDynamite: DrawSprite2(sprDynamite, x - 16, y - 25, Gear^.Tag and 1, Gear^.Tag shr 1);
  1041         gtDynamite: DrawSprite(sprDynamite, x - 16, y - 25, Gear^.Tag and 1, Gear^.Tag shr 1);
   984      gtClusterBomb: DrawRotated(sprClusterBomb, x, y, 0, Gear^.DirAngle);
  1042      gtClusterBomb: DrawSpriteRotated(sprClusterBomb, x, y, 0, Gear^.DirAngle);
   985          gtCluster: DrawSprite(sprClusterParticle, x - 8, y - 8, 0);
  1043          gtCluster: DrawSprite(sprClusterParticle, x - 8, y - 8, 0);
   986            gtFlame: if Gear^.Tag and 1 = 0 then
  1044            gtFlame: if Gear^.Tag and 1 = 0 then
   987                          DrawTextureF(SpritesData[sprFlame].Texture, 2 / (Gear^.Tag mod 3 + 2), x, y, (GameTicks shr 7 + LongWord(Gear^.Tag)) mod 8, 1, 16, 16)
  1045                          DrawTextureF(SpritesData[sprFlame].Texture, 2 / (Gear^.Tag mod 3 + 2), x, y, (GameTicks shr 7 + LongWord(Gear^.Tag)) mod 8, 1, 16, 16)
   988                     else DrawTextureF(SpritesData[sprFlame].Texture, 2 / (Gear^.Tag mod 3 + 2), x, y, (GameTicks shr 7 + LongWord(Gear^.Tag)) mod 8, -1, 16, 16);
  1046                     else DrawTextureF(SpritesData[sprFlame].Texture, 2 / (Gear^.Tag mod 3 + 2), x, y, (GameTicks shr 7 + LongWord(Gear^.Tag)) mod 8, -1, 16, 16);
   989        gtParachute: begin
  1047        gtParachute: begin
   990                     DrawSprite(sprParachute, x - 24, y - 48, 0);
  1048                     DrawSprite(sprParachute, x - 24, y - 48, 0);
   991                     DrawAltWeapon(Gear, x + 1, y - 3)
  1049                     DrawAltWeapon(Gear, x + 1, y - 3)
   992                     end;
  1050                     end;
   993        gtAirAttack: begin
  1051        gtAirAttack: begin
   994                     Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF);
  1052                     Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF);
   995                     DrawRotatedF(sprAirplane, x, y, 0, Gear^.Tag, 0);
  1053                     DrawSpriteRotatedF(sprAirplane, x, y, 0, Gear^.Tag, 0);
   996                     Tint($FF, $FF, $FF, $FF);
  1054                     Tint($FF, $FF, $FF, $FF);
   997                     DrawRotatedF(sprAirplane, x, y, 1, Gear^.Tag, 0);
  1055                     DrawSpriteRotatedF(sprAirplane, x, y, 1, Gear^.Tag, 0);
   998                     end;
  1056                     end;
   999          gtAirBomb: DrawRotated(sprAirBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1057          gtAirBomb: DrawSpriteRotated(sprAirBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1000         gtTeleport: begin
  1058         gtTeleport: begin
  1001                     HHGear:= Gear^.Hedgehog^.Gear;
  1059                     HHGear:= Gear^.Hedgehog^.Gear;
  1002                     if not Gear^.Hedgehog^.Unplaced then DrawRotatedF(sprTeleport, x + 1, y - 3, Gear^.Pos, hwSign(Gear^.dX), 0);
  1060                     if not Gear^.Hedgehog^.Unplaced then
  1003                     DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0);
  1061                         DrawSpriteRotatedF(sprTeleport, x + 1, y - 3, Gear^.Pos, hwSign(Gear^.dX), 0);
       
  1062                     DrawSpriteRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0);
  1004                     end;
  1063                     end;
  1005         gtSwitcher: DrawSprite(sprSwitch, x - 16, y - 56, (GameTicks shr 6) mod 12);
  1064         gtSwitcher: DrawSprite(sprSwitch, x - 16, y - 56, (GameTicks shr 6) mod 12);
  1006           gtTarget: begin
  1065           gtTarget: begin
  1007                     Tint($FF, $FF, $FF, round($FF * Gear^.Timer / 1000));
  1066                     Tint($FF, $FF, $FF, round($FF * Gear^.Timer / 1000));
  1008                     DrawSprite(sprTarget, x - 16, y - 16, 0);
  1067                     DrawSprite(sprTarget, x - 16, y - 16, 0);
  1009                     Tint($FF, $FF, $FF, $FF);
  1068                     Tint($FF, $FF, $FF, $FF);
  1010                     end;
  1069                     end;
  1011           gtMortar: DrawRotated(sprMortar, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1070           gtMortar: DrawSpriteRotated(sprMortar, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1012           gtCake: if Gear^.Pos = 6 then
  1071           gtCake: if Gear^.Pos = 6 then
  1013                      DrawRotatedf(sprCakeWalk, x, y, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90)
  1072                      DrawSpriteRotatedF(sprCakeWalk, x, y, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90)
  1014                   else
  1073                   else
  1015                      DrawRotatedf(sprCakeDown, x, y, 5 - Gear^.Pos, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90);
  1074                      DrawSpriteRotatedF(sprCakeDown, x, y, 5 - Gear^.Pos, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90);
  1016        gtSeduction: if Gear^.Pos >= 14 then DrawSprite(sprSeduction, x - 16, y - 16, 0);
  1075        gtSeduction: if Gear^.Pos >= 14 then
  1017       gtWatermelon: DrawRotatedf(sprWatermelon, x, y, 0, 0, Gear^.DirAngle);
  1076            DrawSprite(sprSeduction, x - 16, y - 16, 0);
  1018       gtMelonPiece: DrawRotatedf(sprWatermelon, x, y, 1, 0, Gear^.DirAngle);
  1077            
  1019      gtHellishBomb: DrawRotated(sprHellishBomb, x, y, 0, Gear^.DirAngle);
  1078       gtWatermelon: DrawSpriteRotatedF(sprWatermelon, x, y, 0, 0, Gear^.DirAngle);
       
  1079       gtMelonPiece: DrawSpriteRotatedF(sprWatermelon, x, y, 1, 0, Gear^.DirAngle);
       
  1080      gtHellishBomb: DrawSpriteRotated(sprHellishBomb, x, y, 0, Gear^.DirAngle);
  1020            gtBirdy: begin
  1081            gtBirdy: begin
  1021                     if Gear^.State and gstAnimation = gstAnimation then
  1082                     if Gear^.State and gstAnimation = gstAnimation then
  1022                         begin
  1083                         begin
  1023                         if Gear^.State and gstTmpFlag = 0 then // Appearing
  1084                         if Gear^.State and gstTmpFlag = 0 then // Appearing
  1024                             begin
  1085                             begin
  1025                             endX:= x - WorldDx;
  1086                             endX:= x - WorldDx;
  1026                             endY:= y - WorldDy;
  1087                             endY:= y - WorldDy;
  1027                             if Gear^.Tag < 0 then
  1088                             if Gear^.Tag < 0 then
  1028                                 startX:= max(LAND_WIDTH + 1024, endX + 2048)
  1089                                 startX:= max(max(LAND_WIDTH,4096) + 1024, endX + 2048)
  1029                             else
  1090                             else
  1030                                 startX:= max(-LAND_WIDTH - 1024, endX - 2048);
  1091                                 startX:= max(-max(LAND_WIDTH,4096) - 1024, endX - 2048);
  1031                             startY:= endY - 256;
  1092                             startY:= endY - 256;
  1032                             DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * (-power(2, -10 * LongInt(Gear^.Timer)/2000) + 1))), startY + WorldDy + LongInt(round((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);
  1093                             DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * (-power(2, -10 * LongInt(Gear^.Timer)/2000) + 1))), startY + WorldDy + LongInt(round((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);
  1033                             end
  1094                             end
  1034                         else // Disappearing
  1095                         else // Disappearing
  1035                             begin
  1096                             begin
  1036                             startX:= x - WorldDx;
  1097                             startX:= x - WorldDx;
  1037                             startY:= y - WorldDy;
  1098                             startY:= y - WorldDy;
  1038                             if Gear^.Tag > 0 then
  1099                             if Gear^.Tag > 0 then
  1039                                 endX:= max(LAND_WIDTH + 1024, startX + 2048)
  1100                                 endX:= max(max(LAND_WIDTH,4096) + 1024, startX + 2048)
  1040                             else
  1101                             else
  1041                                 endX:= max(-LAND_WIDTH - 1024, startX - 2048);
  1102                                 endX:= max(-max(LAND_WIDTH,4096) - 1024, startX - 2048);
  1042                             endY:= startY + 256;
  1103                             endY:= startY + 256;
  1043                             DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * power(2, 10 * (LongInt(Gear^.Timer)/2000 - 1)))) + hwRound(Gear^.dX * Gear^.Timer), startY + WorldDy + LongInt(round((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);
  1104                             DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * power(2, 10 * (LongInt(Gear^.Timer)/2000 - 1)))) + hwRound(Gear^.dX * Gear^.Timer), startY + WorldDy + LongInt(round((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);
  1044                             end;
  1105                             end;
  1045                         end
  1106                         end
  1046                     else
  1107                     else
  1049                             DrawTextureF(SpritesData[sprBirdy].Texture, 1, x, y, ((Gear^.Pos shr 6) or (RealTicks shr 7)) mod 2, Gear^.Tag, 75, 75)
  1110                             DrawTextureF(SpritesData[sprBirdy].Texture, 1, x, y, ((Gear^.Pos shr 6) or (RealTicks shr 7)) mod 2, Gear^.Tag, 75, 75)
  1050                         else
  1111                         else
  1051                             DrawTextureF(SpritesData[sprBirdy].Texture, 1, x, y, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
  1112                             DrawTextureF(SpritesData[sprBirdy].Texture, 1, x, y, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
  1052                         end;
  1113                         end;
  1053                     end;
  1114                     end;
  1054              gtEgg: DrawRotatedTextureF(SpritesData[sprEgg].Texture, 1, 0, 0, x, y, 0, 1, 16, 16, Gear^.DirAngle);
  1115              gtEgg: DrawTextureRotatedF(SpritesData[sprEgg].Texture, 1, 0, 0, x, y, 0, 1, 16, 16, Gear^.DirAngle);
  1055            gtPiano: begin
  1116            gtPiano: begin
  1056                     if (Gear^.State and gstDrowning) = 0 then
  1117                     if (Gear^.State and gstDrowning) = 0 then
  1057                         begin
  1118                         begin
  1058                         Tint($FF, $FF, $FF, $10);
  1119                         Tint($FF, $FF, $FF, $10);
  1059                         for i:= 8 downto 1 do
  1120                         for i:= 8 downto 1 do
  1067                         Tint($C0, $C0, $00, Gear^.Timer div 8)
  1128                         Tint($C0, $C0, $00, Gear^.Timer div 8)
  1068                     else if Gear^.Timer > 3980 then
  1129                     else if Gear^.Timer > 3980 then
  1069                         Tint($C0, $C0, $00, (5000 - Gear^.Timer) div 8)
  1130                         Tint($C0, $C0, $00, (5000 - Gear^.Timer) div 8)
  1070                     else
  1131                     else
  1071                         Tint($C0, $C0, $00, $C0);
  1132                         Tint($C0, $C0, $00, $C0);
  1072                     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 3, 0, 0, x, y, 0, 1, 22, 22, (RealTicks shr 36 + Gear^.UID * 100) mod 360);
  1133                     DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 3, 0, 0, x, y, 0, 1, 22, 22, (RealTicks shr 36 + Gear^.UID * 100) mod 360);
  1073                     Tint($FF, $FF, $FF, $FF)
  1134                     Tint($FF, $FF, $FF, $FF)
  1074                     end;
  1135                     end;
  1075      gtResurrector: begin
  1136      gtResurrector: begin
  1076                     DrawRotated(sprCross, x, y, 0, 0);
  1137                     DrawSpriteRotated(sprCross, x, y, 0, 0);
  1077                     Tint($f5, $db, $35, max($00, round($C0 * abs(1 - (GameTicks mod 6000) / 3000))));
  1138                     Tint($f5, $db, $35, max($00, round($C0 * abs(1 - (GameTicks mod 6000) / 3000))));
  1078                     DrawTexture(x - 108, y - 108, SpritesData[sprVampiric].Texture, 4.5);
  1139                     DrawTexture(x - 108, y - 108, SpritesData[sprVampiric].Texture, 4.5);
  1079                     Tint($FF, $FF, $FF, $FF);
  1140                     Tint($FF, $FF, $FF, $FF);
  1080                     end;
  1141                     end;
  1081       gtNapalmBomb: DrawRotated(sprNapalmBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1142       gtNapalmBomb: DrawSpriteRotated(sprNapalmBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1082            gtFlake: if Gear^.State and (gstDrowning or gstTmpFlag) <> 0  then
  1143            gtFlake: if Gear^.State and (gstDrowning or gstTmpFlag) <> 0  then
  1083                         begin
  1144                         begin
  1084                         Tint((cExplosionBorderColor shr RShift) and $FF, 
  1145                         Tint((ExplosionBorderColor shr RShift) and $FF, 
  1085                              (cExplosionBorderColor shr GShift) and $FF, 
  1146                              (ExplosionBorderColor shr GShift) and $FF, 
  1086                              (cExplosionBorderColor shr BShift) and $FF, 
  1147                              (ExplosionBorderColor shr BShift) and $FF, 
  1087                              $FF);
  1148                              $FF);
  1088                         // Needs a nicer white texture to tint
  1149                         // Needs a nicer white texture to tint
  1089                         DrawRotatedTextureF(SpritesData[sprSnowDust].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle);
  1150                         DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle);
  1090                         //DrawRotated(sprSnowDust, x, y, 0, Gear^.DirAngle);
  1151                         //DrawSpriteRotated(sprSnowDust, x, y, 0, Gear^.DirAngle);
  1091                         //DrawTexture(x, y, SpritesData[sprVampiric].Texture, 0.1);
  1152                         //DrawTexture(x, y, SpritesData[sprVampiric].Texture, 0.1);
  1092                         Tint($FF, $FF, $FF, $FF);
  1153                         Tint($FF, $FF, $FF, $FF);
  1093                         end
  1154                         end
  1094                     else //if not isInLag then
  1155                     else //if not isInLag then
  1095                         begin
  1156                         begin
  1096                         if isInLag and (Gear^.FlightTime < 256) then inc(Gear^.FlightTime, 8)
  1157                         if isInLag and (Gear^.FlightTime < 256) then
  1097                         else if not isInLag and (Gear^.FlightTime > 0) then dec(Gear^.FlightTime, 8);
  1158                             inc(Gear^.FlightTime, 8)
  1098                         if Gear^.FlightTime > 0 then Tint($FF, $FF, $FF, $FF-min(255,Gear^.FlightTime));
  1159                         else if not isInLag and (Gear^.FlightTime > 0) then
       
  1160                             dec(Gear^.FlightTime, 8);
       
  1161                         if Gear^.FlightTime > 0 then
       
  1162                             Tint($FF, $FF, $FF, $FF-min(255,Gear^.FlightTime));
  1099                         if vobVelocity = 0 then
  1163                         if vobVelocity = 0 then
  1100                             DrawSprite(sprFlake, x, y, Gear^.Timer)
  1164                             DrawSprite(sprFlake, x, y, Gear^.Timer)
  1101                         else
  1165                         else
  1102                             DrawRotatedF(sprFlake, x, y, Gear^.Timer, 1, Gear^.DirAngle);
  1166                             DrawSpriteRotatedF(sprFlake, x, y, Gear^.Timer, 1, Gear^.DirAngle);
  1103 //DrawSprite(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer)
  1167 //DrawSprite(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer)
  1104 //DrawRotatedF(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer, 1, Gear^.DirAngle);
  1168 //DrawSpriteRotatedF(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer, 1, Gear^.DirAngle);
  1105                         if Gear^.FlightTime > 0 then Tint($FF, $FF, $FF, $FF);
  1169                         if Gear^.FlightTime > 0 then
       
  1170                             Tint($FF, $FF, $FF, $FF);
  1106                         end;
  1171                         end;
  1107        gtStructure: DrawSprite(sprTarget, x - 16, y - 16, 0);
  1172        gtStructure: DrawSprite(sprTarget, x - 16, y - 16, 0);
  1108           gtTardis: if Gear^.Pos <> 4 then
  1173           gtTardis: if Gear^.Pos <> 4 then
  1109                         begin
  1174                         begin
  1110                         if Gear^.Pos = 2 then Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF)
  1175                         if Gear^.Pos = 2 then
  1111                         else Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000)))));
  1176                             Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF)
       
  1177                         else 
       
  1178                             Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000)))));
  1112                         DrawSprite(sprTardis, x-24, y-63,0);
  1179                         DrawSprite(sprTardis, x-24, y-63,0);
  1113                         if Gear^.Pos = 2 then Tint($FF, $FF, $FF, $FF)
  1180                         if Gear^.Pos = 2 then
  1114 			else Tint($FF,$FF,$FF,max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000)))));
  1181                             Tint($FF, $FF, $FF, $FF)
       
  1182                         else
       
  1183                             Tint($FF,$FF,$FF,max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000)))));
  1115                         DrawSprite(sprTardis, x-24, y-63,1);
  1184                         DrawSprite(sprTardis, x-24, y-63,1);
  1116                         if Gear^.Pos <> 2 then Tint($FF, $FF, $FF, $FF)
  1185                         if Gear^.Pos <> 2 then
       
  1186                             Tint($FF, $FF, $FF, $FF)
  1117 (*
  1187 (*
  1118                         Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or max($00, round(Gear^.Power * abs(1 - (RealTicks mod 500) / 250))));
  1188                         Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or max($00, round(Gear^.Power * abs(1 - (RealTicks mod 500) / 250))));
  1119                         DrawTexture(x-6, y-70, SpritesData[sprVampiric].Texture, 0.25);
  1189                         DrawTexture(x-6, y-70, SpritesData[sprVampiric].Texture, 0.25);
  1120                         Tint($FF, $FF, $FF, $FF)
  1190                         Tint($FF, $FF, $FF, $FF)
  1121 *)
  1191 *)
  1122                         end;
  1192                         end;
  1123 
  1193             gtIceGun: begin
  1124 
  1194                       HHGear := Gear^.Hedgehog^.Gear;
       
  1195                       if HHGear <> nil then
       
  1196                           begin
       
  1197                           i:= hwRound(hwSqr(Gear^.X - HHGear^.X) + hwSqr(Gear^.Y - HHGear^.Y));
       
  1198                           if RealTicks mod max(1,50 - (round(sqrt(i)) div 4)) = 0 then // experiment in "intensifying" might not get used
       
  1199                             begin
       
  1200                             vg:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtDust, 1);
       
  1201                             if vg <> nil then
       
  1202                                 begin
       
  1203                                 i:= random(100) + 155;
       
  1204                                 vg^.Tint:= i shl 24 or i shl 16 or $FF shl 8 or Longword(random(200) + 55);
       
  1205                                 vg^.Angle:= random(360);
       
  1206                                 vg^.dx:= 0.001 * random(80);
       
  1207                                 vg^.dy:= 0.001 * random(80)
       
  1208                                 end
       
  1209                             end;
       
  1210                           if RealTicks mod 2 = 0 then
       
  1211                                 begin
       
  1212                                 i:= random(100)+100;
       
  1213                                 if Gear^.Target.X <> NoPointX then
       
  1214                                     DrawLine(Gear^.Target.X, Gear^.Target.Y, hwRound(HHGear^.X), hwRound(HHGear^.Y), 4.0, i, i, $FF, $40)
       
  1215                                 else DrawLine(hwRound(HHGear^.X), hwRound(HHGear^.Y), hwRound(Gear^.X), hwRound(Gear^.Y), 4.0, i, i, $FF, $40);
       
  1216                                 end
       
  1217                           end
       
  1218                       end;
       
  1219             gtGenericFaller: DrawCircle(x, y, 3, 3, $FF, $00, $00, $FF);  // debug
  1125          end;
  1220          end;
  1126       if Gear^.RenderTimer and (Gear^.Tex <> nil) then DrawCentered(x + 8, y + 8, Gear^.Tex);
  1221       if Gear^.RenderTimer and (Gear^.Tex <> nil) then
       
  1222           DrawTextureCentered(x + 8, y + 8, Gear^.Tex);
  1127 end;
  1223 end;
  1128 
  1224 
  1129 end.
  1225 end.