hedgewars/GearDrawing.inc
changeset 4077 e7d838d063a4
parent 4044 de7170e51cc6
child 4093 70945af0d7e1
equal deleted inserted replaced
4076:7ca17cb94992 4077:e7d838d063a4
     1 procedure DrawHH(Gear: PGear);
     1 procedure DrawHH(Gear: PGear; ox, oy: LongInt);
     2 var i, t: LongInt;
     2 var i, t: LongInt;
     3     amt: TAmmoType;
     3     amt: TAmmoType;
     4     hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
     4     sign, hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
     5     dx, dy, ax, ay, aAngle, dAngle, hAngle, lx, ly: real;  // laser, change
     5     dx, dy, ax, ay, aAngle, dAngle, hAngle, lx, ly: real;  // laser, change
     6     defaultPos, HatVisible: boolean;
     6     defaultPos, HatVisible: boolean;
     7     VertexBuffer: array [0..1] of TVertex2f;
     7     VertexBuffer: array [0..1] of TVertex2f;
     8     HH: PHedgehog;
     8     HH: PHedgehog;
     9     CurWeapon: PAmmo;
     9     CurWeapon: PAmmo;
    10 begin
    10 begin
    11 HH:= PHedgehog(Gear^.Hedgehog);
    11 HH:= PHedgehog(Gear^.Hedgehog);
    12 if HH^.Unplaced then exit;
    12 if HH^.Unplaced then exit;
    13 m:= 1;
    13 m:= 1;
    14 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
    14 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
       
    15 sx:= ox + 1; // this offset is very common
       
    16 sy:= oy - 3;
       
    17 sign:= hwSign(Gear^.dX);
       
    18 
    15 if (Gear^.State and gstHHDeath) <> 0 then
    19 if (Gear^.State and gstHHDeath) <> 0 then
    16     begin
    20     begin
    17     DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos);
    21     DrawSprite(sprHHDeath, ox - 16, oy - 26, Gear^.Pos);
    18     Tint(HH^.Team^.Clan^.Color);
    22     Tint(HH^.Team^.Clan^.Color);
    19     DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos + 8);
    23     DrawSprite(sprHHDeath, ox - 16, oy - 26, Gear^.Pos + 8);
    20     Tint($FF, $FF, $FF, $FF);
    24     Tint($FF, $FF, $FF, $FF);
    21     exit
    25     exit
    22     end
    26     end
    23 else if (Gear^.State and gstHHGone) <> 0 then
    27 else if (Gear^.State and gstHHGone) <> 0 then
    24     begin
    28     begin
    25     DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(Gear^.dX), 0);
    29     DrawRotatedF(sprTeleport, sx, sy, Gear^.Pos, sign, 0);
    26     exit
    30     exit
    27     end;
    31     end;
    28 
    32 
    29 defaultPos:= true;
    33 defaultPos:= true;
    30 HatVisible:= false;
    34 HatVisible:= false;
    31 
    35 
    32 sx:= hwRound(Gear^.X) + 1 + WorldDx;
       
    33 sy:= hwRound(Gear^.Y) - 3 + WorldDy;
       
    34 
    36 
    35 if HH^.Effects[hePoisoned] then
    37 if HH^.Effects[hePoisoned] then
    36     begin
    38     begin
    37     Tint($00, $FF, $40, $40);
    39     Tint($00, $FF, $40, $40);
    38     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360);
    40     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360);
    41 
    43 
    42 if ((Gear^.State and gstWinner) <> 0) and
    44 if ((Gear^.State and gstWinner) <> 0) and
    43    ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
    45    ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
    44     begin
    46     begin
    45     DrawHedgehog(sx, sy,
    47     DrawHedgehog(sx, sy,
    46             hwSign(Gear^.dX),
    48             sign,
    47             2,
    49             2,
    48             0,
    50             0,
    49             0);
    51             0);
    50     defaultPos:= false
    52     defaultPos:= false
    51     end;
    53     end;
    52 if (Gear^.State and gstDrowning) <> 0 then
    54 if (Gear^.State and gstDrowning) <> 0 then
    53     begin
    55     begin
    54     DrawHedgehog(sx, sy,
    56     DrawHedgehog(sx, sy,
    55             hwSign(Gear^.dX),
    57             sign,
    56             1,
    58             1,
    57             7,
    59             7,
    58             0);
    60             0);
    59     defaultPos:= false
    61     defaultPos:= false
    60     end else
    62     end else
    61 if (Gear^.State and gstLoser) <> 0 then
    63 if (Gear^.State and gstLoser) <> 0 then
    62     begin
    64     begin
    63     DrawHedgehog(sx, sy,
    65     DrawHedgehog(sx, sy,
    64             hwSign(Gear^.dX),
    66             sign,
    65             2,
    67             2,
    66             3,
    68             3,
    67             0);
    69             0);
    68     defaultPos:= false
    70     defaultPos:= false
    69     end else
    71     end else
    78    1: I need to draw the laser from weapon origin to nearest land
    80    1: I need to draw the laser from weapon origin to nearest land
    79    2: I need to start the beam outside the hedgie for attractiveness.
    81    2: I need to start the beam outside the hedgie for attractiveness.
    80    3: I need to extend the beam beyond land.
    82    3: I need to extend the beam beyond land.
    81    This routine perhaps should be pushed into uStore or somesuch instead of continuuing the increase in size of this function.
    83    This routine perhaps should be pushed into uStore or somesuch instead of continuuing the increase in size of this function.
    82 *)
    84 *)
    83         dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle);
    85         dx:= sign * m * Sin(Gear^.Angle * pi / cMaxAngle);
    84         dy:= -Cos(Gear^.Angle * pi / cMaxAngle);
    86         dy:= -Cos(Gear^.Angle * pi / cMaxAngle);
    85         if cLaserSighting then
    87         if cLaserSighting then
    86             begin
    88             begin
    87             lx:= GetLaunchX(HH^.CurAmmoType, hwSign(Gear^.dX) * m, Gear^.Angle);
    89             lx:= GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle);
    88             ly:= GetLaunchY(HH^.CurAmmoType, Gear^.Angle);
    90             ly:= GetLaunchY(HH^.CurAmmoType, Gear^.Angle);
    89 
    91 
    90             // ensure we start outside the hedgehog (he's solid after all)
    92             // ensure we start outside the hedgehog (he's solid after all)
    91             while abs(lx * lx + ly * ly) < (Gear^.radius * Gear^.radius) do
    93             while abs(lx * lx + ly * ly) < (Gear^.radius * Gear^.radius) do
    92                 begin
    94                 begin
    93                 lx:= lx + dx;
    95                 lx:= lx + dx;
    94                 ly:= ly + dy
    96                 ly:= ly + dy
    95                 end;
    97                 end;
    96 
    98 
    97             // add hog's position
    99             // add hog's position
    98             lx:= lx + hwRound(Gear^.X);
   100             lx:= lx + ox;
    99             ly:= ly + hwRound(Gear^.Y);
   101             ly:= ly + oy;
   100 
   102 
   101             // decrease number of iterations required
   103             // decrease number of iterations required
   102             ax:= dx * 4;
   104             ax:= dx * 4;
   103             ay:= dy * 4;
   105             ay:= dy * 4;
   104 
   106 
   141                 glEnable(GL_TEXTURE_2D);
   143                 glEnable(GL_TEXTURE_2D);
   142                 glDisable(GL_LINE_SMOOTH);
   144                 glDisable(GL_LINE_SMOOTH);
   143                 end;
   145                 end;
   144             end;
   146             end;
   145         // draw crosshair
   147         // draw crosshair
   146         cx:= Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, hwSign(Gear^.dX) * m, Gear^.Angle));
   148         cx:= Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle));
   147         cy:= Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
   149         cy:= Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
   148         DrawRotatedTex(HH^.Team^.CrosshairTex,
   150         DrawRotatedTex(HH^.Team^.CrosshairTex,
   149                 12, 12, cx + WorldDx, cy + WorldDy, 0,
   151                 12, 12, cx + WorldDx, cy + WorldDy, 0,
   150                 hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle);
   152                 sign * (Gear^.Angle * 180.0) / cMaxAngle);
   151         end;
   153         end;
   152     hx:= hwRound(Gear^.X) + 8 * hwSign(Gear^.dX) + WorldDx;
   154     hx:= ox + 8 * sign;
   153     hy:= hwRound(Gear^.Y) - 2 + WorldDy;
   155     hy:= oy - 2;
   154     aangle:= Gear^.Angle * 180 / cMaxAngle - 90;
   156     aangle:= Gear^.Angle * 180 / cMaxAngle - 90;
   155     if CurAmmoGear <> nil then
   157     if CurAmmoGear <> nil then
   156     begin
   158     begin
   157         case CurAmmoGear^.Kind of
   159         case CurAmmoGear^.Kind of
   158             gtShotgunShot: begin
   160             gtShotgunShot: begin
   159                     if (CurAmmoGear^.State and gstAnimation <> 0) then
   161                     if (CurAmmoGear^.State and gstAnimation <> 0) then
   160                         DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle)
   162                         DrawRotated(sprShotgun, hx, hy, sign, aangle)
   161                     else
   163                     else
   162                         DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   164                         DrawRotated(sprHandShotgun, hx, hy, sign, aangle);
   163                 end;
   165                 end;
   164             gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle);
   166             gtDEagleShot: DrawRotated(sprDEagle, hx, hy, sign, aangle);
   165             gtSniperRifleShot: begin
   167             gtSniperRifleShot: begin
   166                     if (CurAmmoGear^.State and gstAnimation <> 0) then
   168                     if (CurAmmoGear^.State and gstAnimation <> 0) then
   167                         DrawRotatedF(sprSniperRifle, hx, hy, 1, hwSign(Gear^.dX), aangle)
   169                         DrawRotatedF(sprSniperRifle, hx, hy, 1, sign, aangle)
   168                     else
   170                     else
   169                         DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle)
   171                         DrawRotatedF(sprSniperRifle, hx, hy, 0, sign, aangle)
   170                 end;
   172                 end;
   171             gtBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
   173             gtBallgun: DrawRotated(sprHandBallgun, hx, hy, sign, aangle);
   172             gtRCPlane: begin
   174             gtRCPlane: begin
   173                 DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0);
   175                 DrawRotated(sprHandPlane, hx, hy, sign, 0);
   174                 defaultPos:= false
   176                 defaultPos:= false
   175                 end;
   177                 end;
   176             gtRope: begin
   178             gtRope: begin
   177                 if Gear^.X < CurAmmoGear^.X then
   179                 if Gear^.X < CurAmmoGear^.X then
   178                     begin
   180                     begin
   183                     begin
   185                     begin
   184                     dAngle:= 180;
   186                     dAngle:= 180;
   185                     hAngle:= 0;
   187                     hAngle:= 0;
   186                     i:= -1
   188                     i:= -1
   187                     end;
   189                     end;
   188                 sx:= hwRound(Gear^.X) + WorldDx;
       
   189                 sy:= hwRound(Gear^.Y) + WorldDy;
       
   190                if ((Gear^.State and gstWinner) = 0) then
   190                if ((Gear^.State and gstWinner) = 0) then
   191                    begin
   191                    begin
   192                    DrawHedgehog(sx, sy,
   192                    DrawHedgehog(ox, oy,
   193                            i,
   193                            i,
   194                            1,
   194                            1,
   195                            0,
   195                            0,
   196                            DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
   196                            DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
   197                    with HH^ do
   197                    with HH^ do
   198                        if (HatTex <> nil) then
   198                        if (HatTex <> nil) then
   199                            begin
   199                            begin
   200                            DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 0, i, 32, 32,
   200                            DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, ox, oy, 0, i, 32, 32,
   201                                i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   201                                i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   202                            if HatTex^.w > 64 then
   202                            if HatTex^.w > 64 then
   203                                begin
   203                                begin
   204                                Tint(HH^.Team^.Clan^.Color);
   204                                Tint(HH^.Team^.Clan^.Color);
   205                                DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 32, i, 32, 32,
   205                                DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, ox, oy, 32, i, 32, 32,
   206                                    i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   206                                    i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   207                                Tint($FF, $FF, $FF, $FF)
   207                                Tint($FF, $FF, $FF, $FF)
   208                                end
   208                                end
   209                            end
   209                            end
   210                    end;
   210                    end;
   211                 DrawAltWeapon(Gear, sx, sy);
   211                 DrawAltWeapon(Gear, ox, oy);
   212                 defaultPos:= false
   212                 defaultPos:= false
   213                 end;
   213                 end;
   214             gtBlowTorch: begin
   214             gtBlowTorch: begin
   215                 DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
   215                 DrawRotated(sprBlowTorch, hx, hy, sign, aangle);
   216                 DrawHedgehog(sx, sy,
   216                 DrawHedgehog(sx, sy,
   217                         hwSign(Gear^.dX),
   217                         sign,
   218                         3,
   218                         3,
   219                         HH^.visStepPos div 2,
   219                         HH^.visStepPos div 2,
   220                         0);
   220                         0);
   221                 with HH^ do
   221                 with HH^ do
   222                     if (HatTex <> nil) then
   222                     if (HatTex <> nil) then
   223                         begin
   223                         begin
   224                         DrawTextureF(HatTex,
   224                         DrawTextureF(HatTex,
   225                             1,
   225                             1,
   226                             sx,
   226                             sx,
   227                             hwRound(Gear^.Y) - 8 + WorldDy,
   227                             sy - 5,
   228                             0,
   228                             0,
   229                             hwSign(Gear^.dX),
   229                             sign,
   230                             32,
   230                             32,
   231                             32);
   231                             32);
   232                         if HatTex^.w > 64 then
   232                         if HatTex^.w > 64 then
   233                             begin
   233                             begin
   234                             Tint(HH^.Team^.Clan^.Color);
   234                             Tint(HH^.Team^.Clan^.Color);
   235                             DrawTextureF(HatTex,
   235                             DrawTextureF(HatTex,
   236                                 1,
   236                                 1,
   237                                 sx,
   237                                 sx,
   238                                 hwRound(Gear^.Y) - 8 + WorldDy,
   238                                 sy - 5,
   239                                 32,
   239                                 32,
   240                                 hwSign(Gear^.dX),
   240                                 sign,
   241                                 32,
   241                                 32,
   242                                 32);
   242                                 32);
   243                             Tint($FF, $FF, $FF, $FF)
   243                             Tint($FF, $FF, $FF, $FF)
   244                             end
   244                             end
   245                         end;
   245                         end;
   246                 defaultPos:= false
   246                 defaultPos:= false
   247                 end;
   247                 end;
   248             gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180);
   248             gtShover: DrawRotated(sprHandBaseball, hx, hy, sign, aangle + 180);
   249             gtFirePunch: begin
   249             gtFirePunch: begin
   250                 DrawHedgehog(sx, sy,
   250                 DrawHedgehog(sx, sy,
   251                         hwSign(Gear^.dX),
   251                         sign,
   252                         1,
   252                         1,
   253                         4,
   253                         4,
   254                         0);
   254                         0);
   255                 defaultPos:= false
   255                 defaultPos:= false
   256                 end;
   256                 end;
   262             gtWhip: begin
   262             gtWhip: begin
   263                 DrawRotatedF(sprWhip,
   263                 DrawRotatedF(sprWhip,
   264                         sx,
   264                         sx,
   265                         sy,
   265                         sy,
   266                         1,
   266                         1,
   267                         hwSign(Gear^.dX),
   267                         sign,
   268                         0);
   268                         0);
   269                 defaultPos:= false
   269                 defaultPos:= false
   270                 end;
   270                 end;
   271             gtHammer: begin
   271             gtHammer: begin
   272                 DrawRotatedF(sprHammer,
   272                 DrawRotatedF(sprHammer,
   273                         sx,
   273                         sx,
   274                         sy,
   274                         sy,
   275                         1,
   275                         1,
   276                         hwSign(Gear^.dX),
   276                         sign,
   277                         0);
   277                         0);
   278                 defaultPos:= false
   278                 defaultPos:= false
   279                 end;
   279                 end;
   280             gtResurrector: begin
   280             gtResurrector: begin
   281                 DrawRotated(sprHandResurrector, sx, sy, 0, 0); 
   281                 DrawRotated(sprHandResurrector, sx, sy, 0, 0); 
   282                 defaultPos:= false
   282                 defaultPos:= false
   283                 end;
   283                 end;
   284             gtKamikaze: begin
   284             gtKamikaze: begin
   285                 if CurAmmoGear^.Pos = 0 then
   285                 if CurAmmoGear^.Pos = 0 then
   286                     DrawHedgehog(sx, sy,
   286                     DrawHedgehog(sx, sy,
   287                             hwSign(Gear^.dX),
   287                             sign,
   288                             1,
   288                             1,
   289                             6,
   289                             6,
   290                             0)
   290                             0)
   291                 else
   291                 else
   292                     DrawRotatedF(sprKamikaze,
   292                     DrawRotatedF(sprKamikaze,
   293                             hwRound(Gear^.X) + WorldDx,
   293                             ox, oy,
   294                             hwRound(Gear^.Y) + WorldDy,
       
   295                             CurAmmoGear^.Pos - 1,
   294                             CurAmmoGear^.Pos - 1,
   296                             hwSign(Gear^.dX),
   295                             sign,
   297                             aangle);
   296                             aangle);
   298                 defaultPos:= false
   297                 defaultPos:= false
   299                 end;
   298                 end;
   300             gtSeduction: begin
   299             gtSeduction: begin
   301                 if CurAmmoGear^.Pos >= 6 then
   300                 if CurAmmoGear^.Pos >= 6 then
   302                     DrawHedgehog(sx, sy,
   301                     DrawHedgehog(sx, sy,
   303                             hwSign(Gear^.dX),
   302                             sign,
   304                             2,
   303                             2,
   305                             2,
   304                             2,
   306                             0)
   305                             0)
   307                 else
   306                 else
   308                     begin
   307                     begin
   309                     DrawRotatedF(sprDress,
   308                     DrawRotatedF(sprDress,
   310                             hwRound(Gear^.X) + WorldDx,
   309                             ox, oy,
   311                             hwRound(Gear^.Y) + WorldDy,
       
   312                             CurAmmoGear^.Pos,
   310                             CurAmmoGear^.Pos,
   313                             hwSign(Gear^.dX),
   311                             sign,
   314                             0);
   312                             0);
   315                     DrawSprite(sprCensored, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 20 + WorldDy, 0)
   313                     DrawSprite(sprCensored, ox - 32, oy - 20, 0)
   316                     end;
   314                     end;
   317                 defaultPos:= false
   315                 defaultPos:= false
   318                 end;
   316                 end;
   319             gtFlamethrower: begin
   317             gtFlamethrower: begin
   320                 DrawRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, hwSign(Gear^.dX), aangle);
   318                 DrawRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   321                 if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex)
   319                 if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex)
   322                 end;
   320                 end;
   323         end;
   321         end;
   324 
   322 
   325         case CurAmmoGear^.Kind of
   323         case CurAmmoGear^.Kind of
   326             gtShotgunShot,
   324             gtShotgunShot,
   327             gtDEagleShot,
   325             gtDEagleShot,
   328             gtSniperRifleShot,
   326             gtSniperRifleShot,
   329             gtShover: begin
   327             gtShover: begin
   330                 DrawHedgehog(sx, sy,
   328                 DrawHedgehog(sx, sy,
   331                         hwSign(Gear^.dX),
   329                         sign,
   332                         0,
   330                         0,
   333                         4,
   331                         4,
   334                         0);
   332                         0);
   335                 defaultPos:= false;
   333                 defaultPos:= false;
   336                 HatVisible:= true
   334                 HatVisible:= true
   339     end else
   337     end else
   340 
   338 
   341     if ((Gear^.State and gstHHJumping) <> 0) then
   339     if ((Gear^.State and gstHHJumping) <> 0) then
   342     begin
   340     begin
   343     DrawHedgehog(sx, sy,
   341     DrawHedgehog(sx, sy,
   344         hwSign(Gear^.dX)*m,
   342         sign*m,
   345         1,
   343         1,
   346         1,
   344         1,
   347         0);
   345         0);
   348     HatVisible:= true;
   346     HatVisible:= true;
   349     defaultPos:= false
   347     defaultPos:= false
   350     end else
   348     end else
   351 
   349 
   352     if (Gear^.Message and (gmLeft or gmRight) <> 0) and (not isCursorVisible) then
   350     if (Gear^.Message and (gmLeft or gmRight) <> 0) and (not isCursorVisible) then
   353         begin
   351         begin
   354         DrawHedgehog(sx, sy,
   352         DrawHedgehog(sx, sy,
   355             hwSign(Gear^.dX),
   353             sign,
   356             0,
   354             0,
   357             HH^.visStepPos div 2,
   355             HH^.visStepPos div 2,
   358             0);
   356             0);
   359         defaultPos:= false;
   357         defaultPos:= false;
   360         HatVisible:= true
   358         HatVisible:= true
   371             begin
   369             begin
   372             DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite,
   370             DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite,
   373                     sx,
   371                     sx,
   374                     sy,
   372                     sy,
   375                     Gear^.Pos,
   373                     Gear^.Pos,
   376                     hwSign(Gear^.dX),
   374                     sign,
   377                     0.0);
   375                     0.0);
   378             defaultPos:= false
   376             defaultPos:= false
   379             end
   377             end
   380         end
   378         end
   381     else
   379     else
   390             dec(HH^.Timer)
   388             dec(HH^.Timer)
   391             end;
   389             end;
   392         amt:= CurrentHedgehog^.CurAmmoType;
   390         amt:= CurrentHedgehog^.CurAmmoType;
   393         CurWeapon:= GetAmmoEntry(HH^);
   391         CurWeapon:= GetAmmoEntry(HH^);
   394         case amt of
   392         case amt of
   395             amBazooka: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
   393             amBazooka: DrawRotated(sprHandBazooka, hx, hy, sign, aangle);
   396             amMortar: DrawRotated(sprHandMortar, hx, hy, hwSign(Gear^.dX), aangle);
   394             amMortar: DrawRotated(sprHandMortar, hx, hy, sign, aangle);
   397             amMolotov: DrawRotated(sprHandMolotov, hx, hy, hwSign(Gear^.dX), aangle);
   395             amMolotov: DrawRotated(sprHandMolotov, hx, hy, sign, aangle);
   398             amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
   396             amBallgun: DrawRotated(sprHandBallgun, hx, hy, sign, aangle);
   399             amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle);
   397             amDrill: DrawRotated(sprHandDrill, hx, hy, sign, aangle);
   400             amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
   398             amRope: DrawRotated(sprHandRope, hx, hy, sign, aangle);
   401             amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   399             amShotgun: DrawRotated(sprHandShotgun, hx, hy, sign, aangle);
   402             amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
   400             amDEagle: DrawRotated(sprHandDEagle, hx, hy, sign, aangle);
   403             amSineGun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   401             amSineGun: DrawRotated(sprHandShotgun, hx, hy, sign, aangle);
   404             amPortalGun: if (CurWeapon^.Timer and 2) <> 0 then // Add a new Hedgehog value instead of abusing timer?
   402             amPortalGun: if (CurWeapon^.Timer and 2) <> 0 then // Add a new Hedgehog value instead of abusing timer?
   405                             DrawRotatedF(sprPortalGun, hx, hy, 0, hwSign(Gear^.dX), aangle)
   403                             DrawRotatedF(sprPortalGun, hx, hy, 0, sign, aangle)
   406                       else
   404                       else
   407                             DrawRotatedF(sprPortalGun, hx, hy, 1+(CurWeapon^.Timer and 1), hwSign(Gear^.dX), aangle);
   405                             DrawRotatedF(sprPortalGun, hx, hy, 1+(CurWeapon^.Timer and 1), sign, aangle);
   408             amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle);
   406             amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, sign, aangle);
   409             amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
   407             amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, sign, aangle);
   410             amCake: DrawRotated(sprHandCake, hx, hy, hwSign(Gear^.dX), aangle);
   408             amCake: DrawRotated(sprHandCake, hx, hy, sign, aangle);
   411             amGrenade: DrawRotated(sprHandGrenade, hx, hy, hwSign(Gear^.dX), aangle);
   409             amGrenade: DrawRotated(sprHandGrenade, hx, hy, sign, aangle);
   412             amWatermelon: DrawRotated(sprHandMelon, hx, hy, hwSign(Gear^.dX), aangle);
   410             amWatermelon: DrawRotated(sprHandMelon, hx, hy, sign, aangle);
   413             amSkip: DrawRotated(sprHandSkip, hx, hy, hwSign(Gear^.dX), aangle);
   411             amSkip: DrawRotated(sprHandSkip, hx, hy, sign, aangle);
   414             amClusterBomb: DrawRotated(sprHandCluster, hx, hy, hwSign(Gear^.dX), aangle);
   412             amClusterBomb: DrawRotated(sprHandCluster, hx, hy, sign, aangle);
   415             amDynamite: DrawRotated(sprHandDynamite, hx, hy, hwSign(Gear^.dX), aangle);
   413             amDynamite: DrawRotated(sprHandDynamite, hx, hy, sign, aangle);
   416             amHellishBomb: DrawRotated(sprHandHellish, hx, hy, hwSign(Gear^.dX), aangle);
   414             amHellishBomb: DrawRotated(sprHandHellish, hx, hy, sign, aangle);
   417             amGasBomb: DrawRotated(sprHandCheese, hx, hy, hwSign(Gear^.dX), aangle);
   415             amGasBomb: DrawRotated(sprHandCheese, hx, hy, sign, aangle);
   418             amMine: DrawRotated(sprHandMine, hx, hy, hwSign(Gear^.dX), aangle);
   416             amMine: DrawRotated(sprHandMine, hx, hy, sign, aangle);
   419             amSMine: DrawRotated(sprHandSMine, hx, hy, hwSign(Gear^.dX), aangle);
   417             amSMine: DrawRotated(sprHandSMine, hx, hy, sign, aangle);
   420             amSeduction: DrawRotated(sprHandSeduction, hx, hy, hwSign(Gear^.dX), aangle);
   418             amSeduction: DrawRotated(sprHandSeduction, hx, hy, sign, aangle);
   421             amVampiric: DrawRotatedF(sprHandVamp, hx, hy, (RealTicks div 125) mod 4, hwSign(Gear^.dX), aangle);
   419             amVampiric: DrawRotatedF(sprHandVamp, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   422             amRCPlane: begin
   420             amRCPlane: begin
   423                 DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0);
   421                 DrawRotated(sprHandPlane, hx, hy, sign, 0);
   424                 defaultPos:= false
   422                 defaultPos:= false
   425                 end;
   423                 end;
   426             amGirder: begin
   424             amGirder: begin
   427                 DrawRotated(sprHandConstruction, hx, hy, hwSign(Gear^.dX), aangle);
   425                 DrawRotated(sprHandConstruction, hx, hy, sign, aangle);
   428                 DrawSpriteClipped(sprGirder,
   426                 DrawSpriteClipped(sprGirder,
   429                                   sx-256,
   427                                   ox-256,
   430                                   sy-256,
   428                                   oy-256,
   431                                   LongInt(topY)+WorldDy,
   429                                   LongInt(topY)+WorldDy,
   432                                   LongInt(rightX)+WorldDx,
   430                                   LongInt(rightX)+WorldDx,
   433                                   cWaterLine+WorldDy,
   431                                   cWaterLine+WorldDy,
   434                                   LongInt(leftX)+WorldDx)
   432                                   LongInt(leftX)+WorldDx)
   435                 end;
   433                 end;
   436             amBee: DrawRotatedF(sprHandBee, hx, hy, (RealTicks div 125) mod 4, hwSign(Gear^.dX), aangle);
   434             amBee: DrawRotatedF(sprHandBee, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   437             amFlamethrower: DrawRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, hwSign(Gear^.dX), aangle);
   435             amFlamethrower: DrawRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   438             amResurrector: begin
   436             amResurrector: begin
   439                 DrawCircle(hwRound(Gear^.X), hwRound(Gear^.y), 100, 1.5, 0, 0,
   437                 DrawCircle(ox, oy, 100, 1.5, 0, 0,
   440                         $FF, $FF); // I'd rather not like to hardcore 100 here
   438                         $FF, $FF); // I'd rather not like to hardcode 100 here
   441             end;
   439             end;
   442         end;
   440         end;
   443 
   441 
   444         case amt of
   442         case amt of
   445             amAirAttack,
   443             amAirAttack,
   446             amMineStrike: DrawRotated(sprHandAirAttack, sx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0);
   444             amMineStrike: DrawRotated(sprHandAirAttack, sx, oy, sign, 0);
   447             amPickHammer: DrawHedgehog(sx, sy,
   445             amPickHammer: DrawHedgehog(sx, sy,
   448                         hwSign(Gear^.dX),
   446                         sign,
   449                         1,
   447                         1,
   450                         2,
   448                         2,
   451                         0);
   449                         0);
   452             amTeleport: DrawRotatedF(sprTeleport, sx, sy, 0, hwSign(Gear^.dX), 0);
   450             amTeleport: DrawRotatedF(sprTeleport, sx, sy, 0, sign, 0);
   453             amKamikaze: DrawHedgehog(sx, sy,
   451             amKamikaze: DrawHedgehog(sx, sy,
   454                         hwSign(Gear^.dX),
   452                         sign,
   455                         1,
   453                         1,
   456                         5,
   454                         5,
   457                         0);
   455                         0);
   458             amWhip: DrawRotatedF(sprWhip,
   456             amWhip: DrawRotatedF(sprWhip,
   459                         sx,
   457                         sx,
   460                         sy,
   458                         sy,
   461                         0,
   459                         0,
   462                         hwSign(Gear^.dX),
   460                         sign,
   463                         0);
   461                         0);
   464             amHammer: DrawRotatedF(sprHammer,
   462             amHammer: DrawRotatedF(sprHammer,
   465                         sx,
   463                         sx,
   466                         sy,
   464                         sy,
   467                         0,
   465                         0,
   468                         hwSign(Gear^.dX),
   466                         sign,
   469                         0);
   467                         0);
   470         else
   468         else
   471             DrawHedgehog(sx, sy,
   469             DrawHedgehog(sx, sy,
   472                 hwSign(Gear^.dX),
   470                 sign,
   473                 0,
   471                 0,
   474                 4,
   472                 4,
   475                 0);
   473                 0);
   476 
   474 
   477             HatVisible:= true;
   475             HatVisible:= true;
   479                 if (HatTex <> nil)
   477                 if (HatTex <> nil)
   480                 and (HatVisibility > 0) then
   478                 and (HatVisibility > 0) then
   481                     DrawTextureF(HatTex,
   479                     DrawTextureF(HatTex,
   482                         HatVisibility,
   480                         HatVisibility,
   483                         sx,
   481                         sx,
   484                         hwRound(Gear^.Y) - 8 + WorldDy,
   482                         sy - 5,
   485                         0,
   483                         0,
   486                         hwSign(Gear^.dX),
   484                         sign,
   487                         32,
   485                         32,
   488                         32); *)
   486                         32); *)
   489         end;
   487         end;
   490 
   488 
   491         case amt of
   489         case amt of
   492             amBaseballBat: DrawRotated(sprHandBaseball,
   490             amBaseballBat: DrawRotated(sprHandBaseball,
   493                     hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx,
   491                     sx - 4 * sign,
   494                     hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle);
   492                     sy + 9, sign, aangle);
   495         end;
   493         end;
   496 
   494 
   497         defaultPos:= false
   495         defaultPos:= false
   498     end;
   496     end;
   499 
   497 
   501     begin
   499     begin
   502     if (Gear^.Damage > 0)
   500     if (Gear^.Damage > 0)
   503     and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
   501     and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
   504         begin
   502         begin
   505         DrawHedgehog(sx, sy,
   503         DrawHedgehog(sx, sy,
   506             hwSign(Gear^.dX),
   504             sign,
   507             2,
   505             2,
   508             1,
   506             1,
   509             Gear^.DirAngle);
   507             Gear^.DirAngle);
   510         defaultPos:= false
   508         defaultPos:= false
   511         end else
   509         end else
   512 
   510 
   513     if ((Gear^.State and gstHHJumping) <> 0) then
   511     if ((Gear^.State and gstHHJumping) <> 0) then
   514         begin
   512         begin
   515         DrawHedgehog(sx, sy,
   513         DrawHedgehog(sx, sy,
   516             hwSign(Gear^.dX)*m,
   514             sign*m,
   517             1,
   515             1,
   518             1,
   516             1,
   519             0);
   517             0);
   520         defaultPos:= false
   518         defaultPos:= false
   521         end;
   519         end;
   527         begin
   525         begin
   528         DrawRotatedF(sprHHIdle,
   526         DrawRotatedF(sprHHIdle,
   529             sx,
   527             sx,
   530             sy,
   528             sy,
   531             (RealTicks div 128 + Gear^.Pos) mod 19,
   529             (RealTicks div 128 + Gear^.Pos) mod 19,
   532             hwSign(Gear^.dX),
   530             sign,
   533             0);
   531             0);
   534         HatVisible:= true;
   532         HatVisible:= true;
   535         end;
   533         end;
   536 
   534 
   537     if HatVisible then
   535     if HatVisible then
   547         if DefaultPos then
   545         if DefaultPos then
   548             begin
   546             begin
   549             DrawTextureF(HatTex,
   547             DrawTextureF(HatTex,
   550                 HatVisibility,
   548                 HatVisibility,
   551                 sx,
   549                 sx,
   552                 hwRound(Gear^.Y) - 8 + WorldDy,
   550                 sy - 5,
   553                 (RealTicks div 128 + Gear^.Pos) mod 19,
   551                 (RealTicks div 128 + Gear^.Pos) mod 19,
   554                 hwSign(Gear^.dX),
   552                 sign,
   555                 32,
   553                 32,
   556                 32);
   554                 32);
   557             if HatTex^.w > 64 then
   555             if HatTex^.w > 64 then
   558                 begin
   556                 begin
   559                 Tint(HH^.Team^.Clan^.Color);
   557                 Tint(HH^.Team^.Clan^.Color);
   560                 DrawTextureF(HatTex,
   558                 DrawTextureF(HatTex,
   561                     HatVisibility,
   559                     HatVisibility,
   562                     sx,
   560                     sx,
   563                     hwRound(Gear^.Y) - 8 + WorldDy,
   561                     sy - 5,
   564                     (RealTicks div 128 + Gear^.Pos) mod 19 + 32,
   562                     (RealTicks div 128 + Gear^.Pos) mod 19 + 32,
   565                     hwSign(Gear^.dX),
   563                     sign,
   566                     32,
   564                     32,
   567                     32);
   565                     32);
   568                 Tint($FF, $FF, $FF, $FF)
   566                 Tint($FF, $FF, $FF, $FF)
   569                 end
   567                 end
   570             end
   568             end
   571         else
   569         else
   572             begin
   570             begin
   573             DrawTextureF(HatTex,
   571             DrawTextureF(HatTex,
   574                 HatVisibility,
   572                 HatVisibility,
   575                 sx,
   573                 sx,
   576                 hwRound(Gear^.Y) - 8 + WorldDy,
   574                 sy - 5,
   577                 0,
   575                 0,
   578                 hwSign(Gear^.dX)*m,
   576                 sign*m,
   579                 32,
   577                 32,
   580                 32);
   578                 32);
   581             if HatTex^.w > 64 then
   579             if HatTex^.w > 64 then
   582                 begin
   580                 begin
   583                 Tint(HH^.Team^.Clan^.Color);
   581                 Tint(HH^.Team^.Clan^.Color);
   584                 DrawTextureF(HatTex,
   582                 DrawTextureF(HatTex,
   585                     HatVisibility,
   583                     HatVisibility,
   586                     sx,
   584                     sx,
   587                     hwRound(Gear^.Y) - 8 + WorldDy,
   585                     sy - 5,
   588                     32,
   586                     32,
   589                     hwSign(Gear^.dX)*m,
   587                     sign*m,
   590                     32,
   588                     32,
   591                     32);
   589                     32);
   592                 Tint($FF, $FF, $FF, $FF)
   590                 Tint($FF, $FF, $FF, $FF)
   593                 end
   591                 end
   594             end
   592             end
   621     end;
   619     end;
   622 
   620 
   623 with HH^ do
   621 with HH^ do
   624     begin
   622     begin
   625     if ((Gear^.State and not gstWinner) = 0)
   623     if ((Gear^.State and not gstWinner) = 0)
       
   624         or ((Gear^.State = gstWait) and (Gear^.dY.QWordValue = 0))
   626         or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then
   625         or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then
   627         begin
   626         begin
   628         t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy;
   627         t:= sy - cHHRadius - 9;
   629         if (cTagsMask and htTransparent) <> 0 then
   628         if (cTagsMask and htTransparent) <> 0 then
   630             Tint($FF, $FF, $FF, $80);
   629             Tint($FF, $FF, $FF, $80);
   631         if ((cTagsMask and htHealth) <> 0) then
   630         if ((cTagsMask and htHealth) <> 0) then
   632             begin
   631             begin
   633             dec(t, HealthTagTex^.h + 2);
   632             dec(t, HealthTagTex^.h + 2);
   634             DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex)
   633             DrawCentered(ox, t, HealthTagTex)
   635             end;
   634             end;
   636         if (cTagsMask and htName) <> 0 then
   635         if (cTagsMask and htName) <> 0 then
   637             begin
   636             begin
   638             dec(t, NameTagTex^.h + 2);
   637             dec(t, NameTagTex^.h + 2);
   639             DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex)
   638             DrawCentered(ox, t, NameTagTex)
   640             end;
   639             end;
   641         if (cTagsMask and htTeamName) <> 0 then
   640         if (cTagsMask and htTeamName) <> 0 then
   642             begin
   641             begin
   643             dec(t, Team^.NameTagTex^.h + 2);
   642             dec(t, Team^.NameTagTex^.h + 2);
   644             DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex)
   643             DrawCentered(ox, t, Team^.NameTagTex)
   645             end;
   644             end;
   646         if (cTagsMask and htTransparent) <> 0 then
   645         if (cTagsMask and htTransparent) <> 0 then
   647             Tint($FF, $FF, $FF, $FF)
   646             Tint($FF, $FF, $FF, $FF)
   648         end;
   647         end;
   649     if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
   648     if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
   650         begin
   649         begin
   651         if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
   650         if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
   652             DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy,
   651             DrawSprite(sprFinger, ox - 16, oy - 64,
   653                         GameTicks div 32 mod 16);
   652                         GameTicks div 32 mod 16);
   654 
   653 
   655         if (Gear^.State and gstDrowning) = 0 then
   654         if (Gear^.State and gstDrowning) = 0 then
   656             if (Gear^.State and gstHHThinking) <> 0 then
   655             if (Gear^.State and gstHHThinking) <> 0 then
   657                 DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, (RealTicks shr 9) mod 8)
   656                 DrawSprite(sprQuestion, ox - 10, oy - cHHRadius - 34, (RealTicks shr 9) mod 8)
   658         end
   657         end
   659     end;
   658     end;
   660 
   659 
   661 if HH^.Effects[hePoisoned] then
   660 if HH^.Effects[hePoisoned] then
   662     begin
   661     begin
   715                       DrawRotatedf(sprPortal, x, y, Gear^.Tag, hwSign(Gear^.dX), Gear^.DirAngle)
   714                       DrawRotatedf(sprPortal, x, y, Gear^.Tag, hwSign(Gear^.dX), Gear^.DirAngle)
   716                  else DrawRotatedf(sprPortal, x, y, 4 + Gear^.Tag div 2, hwSign(Gear^.dX), Gear^.DirAngle);
   715                  else DrawRotatedf(sprPortal, x, y, 4 + Gear^.Tag div 2, hwSign(Gear^.dX), Gear^.DirAngle);
   717 
   716 
   718        gtDrill: DrawRotated(sprDrill, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   717        gtDrill: DrawRotated(sprDrill, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   719 
   718 
   720         gtHedgehog: DrawHH(Gear);
   719         gtHedgehog: DrawHH(Gear, x, y);
   721 
   720 
   722     gtAmmo_Grenade: DrawRotated(sprGrenade, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   721     gtAmmo_Grenade: DrawRotated(sprGrenade, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   723 
   722 
   724            gtGrave: begin 
   723            gtGrave: begin 
   725                     DrawTextureF(PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex, 1, x, y, (GameTicks shr 7+Gear^.uid) and 7, 1, 32, 32);
   724                     DrawTextureF(PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex, 1, x, y, (GameTicks shr 7+Gear^.uid) and 7, 1, 32, 32);