77 SpeechType: Longword = 1; |
77 SpeechType: Longword = 1; |
78 SpeechText: shortstring; |
78 SpeechText: shortstring; |
79 |
79 |
80 implementation |
80 implementation |
81 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, |
81 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, |
82 uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, |
82 uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, |
83 {$IFDEF GLES11} |
83 {$IFDEF GLES11} |
84 gles11, |
84 gles11, |
85 {$ELSE} |
85 {$ELSE} |
86 GL, |
86 GL, |
87 {$ENDIF} |
87 {$ENDIF} |
434 t:= max(Gear^.Damage, Gear^.Health); |
434 t:= max(Gear^.Damage, Gear^.Health); |
435 Gear^.Damage:= t; |
435 Gear^.Damage:= t; |
436 AddGear(hwRound(Gear^.X), min(hwRound(Gear^.Y),cWaterLine+cVisibleWater+32), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
436 AddGear(hwRound(Gear^.X), min(hwRound(Gear^.Y),cWaterLine+cVisibleWater+32), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
437 uStats.HedgehogDamaged(Gear) |
437 uStats.HedgehogDamaged(Gear) |
438 end; |
438 end; |
439 |
439 |
440 team:= PHedgehog(Gear^.Hedgehog)^.Team; |
440 team:= PHedgehog(Gear^.Hedgehog)^.Team; |
441 if CurrentHedgehog^.Gear = Gear then |
441 if CurrentHedgehog^.Gear = Gear then |
442 FreeActionsList; // to avoid ThinkThread on drawned gear |
442 FreeActionsList; // to avoid ThinkThread on drawned gear |
443 |
443 |
444 PHedgehog(Gear^.Hedgehog)^.Gear:= nil; |
444 PHedgehog(Gear^.Hedgehog)^.Gear:= nil; |
445 inc(KilledHHs); |
445 inc(KilledHHs); |
446 RecountTeamHealth(team) |
446 RecountTeamHealth(team) |
447 end; |
447 end; |
448 {$IFDEF DEBUGFILE} |
448 {$IFDEF DEBUGFILE} |
718 AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
718 AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
719 RenderHealth(CurrentHedgehog^); |
719 RenderHealth(CurrentHedgehog^); |
720 RecountTeamHealth(CurrentHedgehog^.Team); |
720 RecountTeamHealth(CurrentHedgehog^.Team); |
721 end |
721 end |
722 end; |
722 end; |
723 if ((GameFlags and gfKarma) <> 0) and |
723 if ((GameFlags and gfKarma) <> 0) and |
724 ((GameFlags and gfInvulnerable) = 0) and |
724 ((GameFlags and gfInvulnerable) = 0) and |
725 not CurrentHedgehog^.Gear^.Invulnerable then |
725 not CurrentHedgehog^.Gear^.Invulnerable then |
726 begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid |
726 begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid |
727 inc(CurrentHedgehog^.Gear^.Karma, tmpDmg); |
727 inc(CurrentHedgehog^.Gear^.Karma, tmpDmg); |
728 AddGear(hwRound(CurrentHedgehog^.Gear^.X), |
728 AddGear(hwRound(CurrentHedgehog^.Gear^.X), |
729 hwRound(CurrentHedgehog^.Gear^.Y), |
729 hwRound(CurrentHedgehog^.Gear^.Y), |
730 gtHealthTag, tmpDmg, _0, _0, 0)^.Hedgehog:= CurrentHedgehog; |
730 gtHealthTag, tmpDmg, _0, _0, 0)^.Hedgehog:= CurrentHedgehog; |
731 end; |
731 end; |
732 end; |
732 end; |
733 end; |
733 end; |
734 inc(Gear^.Damage, Damage); |
734 inc(Gear^.Damage, Damage); |
808 defaultPos:= false |
808 defaultPos:= false |
809 end else |
809 end else |
810 |
810 |
811 if (Gear^.State and gstHHDriven) <> 0 then |
811 if (Gear^.State and gstHHDriven) <> 0 then |
812 begin |
812 begin |
813 if ((Gear^.State and gstHHThinking) = 0) and |
813 if ((Gear^.State and gstHHThinking) = 0) and |
814 ShowCrosshair and |
814 ShowCrosshair and |
815 ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then |
815 ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then |
816 begin |
816 begin |
817 (* These calculations are a little complex for a few reasons: |
817 (* These calculations are a little complex for a few reasons: |
818 1: I need to draw the laser from weapon origin to nearest land |
818 1: I need to draw the laser from weapon origin to nearest land |
819 2: I need to start the beam outside the hedgie for attractiveness. |
819 2: I need to start the beam outside the hedgie for attractiveness. |
820 3: I need to extend the beam beyond land. |
820 3: I need to extend the beam beyond land. |
821 This routine perhaps should be pushed into uStore or somesuch instead of continuuing the increase in size of this function. |
821 This routine perhaps should be pushed into uStore or somesuch instead of continuuing the increase in size of this function. |
822 *) |
822 *) |
823 dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle); |
823 dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle); |
824 dy:= - Cos(Gear^.Angle * pi / cMaxAngle); |
824 dy:= - Cos(Gear^.Angle * pi / cMaxAngle); |
825 if cLaserSighting then |
825 if cLaserSighting then |
849 if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then |
849 if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then |
850 begin |
850 begin |
851 tx:= round(lx + ax * (LAND_WIDTH div 4)); |
851 tx:= round(lx + ax * (LAND_WIDTH div 4)); |
852 ty:= round(ly + ay * (LAND_WIDTH div 4)); |
852 ty:= round(ly + ay * (LAND_WIDTH div 4)); |
853 end; |
853 end; |
854 |
854 |
855 //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then |
855 //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then |
856 begin |
856 begin |
857 glDisable(GL_TEXTURE_2D); |
857 glDisable(GL_TEXTURE_2D); |
858 glEnable(GL_LINE_SMOOTH); |
858 glEnable(GL_LINE_SMOOTH); |
859 |
859 |
860 glLineWidth(1.0); |
860 glLineWidth(1.0); |
861 |
861 |
862 glColor4ub($FF, $00, $00, $C0); |
862 glColor4ub($FF, $00, $00, $C0); |
863 VertexBuffer[0].X:= hx + WorldDx; |
863 VertexBuffer[0].X:= hx + WorldDx; |
864 VertexBuffer[0].Y:= hy + WorldDy; |
864 VertexBuffer[0].Y:= hy + WorldDy; |
865 VertexBuffer[1].X:= tx + WorldDx; |
865 VertexBuffer[1].X:= tx + WorldDx; |
866 VertexBuffer[1].Y:= ty + WorldDy; |
866 VertexBuffer[1].Y:= ty + WorldDy; |
867 |
867 |
868 glEnableClientState(GL_VERTEX_ARRAY); |
868 glEnableClientState(GL_VERTEX_ARRAY); |
869 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
869 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
870 glDrawArrays(GL_LINES, 0, Length(VertexBuffer)); |
870 glDrawArrays(GL_LINES, 0, Length(VertexBuffer)); |
871 glColor4f(1, 1, 1, 1); |
871 glColor4f(1, 1, 1, 1); |
872 glEnable(GL_TEXTURE_2D); |
872 glEnable(GL_TEXTURE_2D); |
1275 //glEnable(GL_LINE_SMOOTH); |
1275 //glEnable(GL_LINE_SMOOTH); |
1276 |
1276 |
1277 glPushMatrix; |
1277 glPushMatrix; |
1278 |
1278 |
1279 glTranslatef(WorldDx, WorldDy, 0); |
1279 glTranslatef(WorldDx, WorldDy, 0); |
1280 |
1280 |
1281 glLineWidth(4.0); |
1281 glLineWidth(4.0); |
1282 |
1282 |
1283 glColor3ub($B0, $B0, $B0); |
1283 glColor3ub($B0, $B0, $B0); |
1284 |
1284 |
1285 glEnableClientState(GL_VERTEX_ARRAY); |
1285 glEnableClientState(GL_VERTEX_ARRAY); |
1286 glVertexPointer(2, GL_INT, 0, @RopePoints.rounded[0]); |
1286 glVertexPointer(2, GL_INT, 0, @RopePoints.rounded[0]); |
1287 glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2); |
1287 glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2); |
1288 glColor4f(1, 1, 1, 1); |
1288 glColor4f(1, 1, 1, 1); |
1289 |
1289 |
1290 glPopMatrix; |
1290 glPopMatrix; |
1291 |
1291 |
1292 glEnable(GL_TEXTURE_2D); |
1292 glEnable(GL_TEXTURE_2D); |
1293 //glDisable(GL_LINE_SMOOTH) |
1293 //glDisable(GL_LINE_SMOOTH) |
1294 end |
1294 end |
1295 end; |
1295 end; |
1296 |
1296 |
1404 |
1404 |
1405 gtRCPlane: if (Gear^.Tag = -1) then |
1405 gtRCPlane: if (Gear^.Tag = -1) then |
1406 DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, -1, DxDy2Angle(Gear^.dX, Gear^.dY) + 90) |
1406 DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, -1, DxDy2Angle(Gear^.dX, Gear^.dY) + 90) |
1407 else |
1407 else |
1408 DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX)); |
1408 DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX)); |
1409 |
1409 |
1410 gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1410 gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1411 |
1411 |
1412 gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1412 gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1413 |
1413 |
1414 gtHedgehog: DrawHH(Gear); |
1414 gtHedgehog: DrawHH(Gear); |
1415 |
1415 |
1416 gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1416 gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1417 |
1417 |
1418 gtHealthTag: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex); |
1418 gtHealthTag: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex); |
1419 |
1419 |
1420 gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex); |
1420 gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex); |
1421 |
1421 |
1422 gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4); |
1422 gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4); |
1423 |
1423 |
1424 gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0); |
1424 gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0); |
1425 gtRope: DrawRope(Gear); |
1425 gtRope: DrawRope(Gear); |
1426 gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
1426 gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
1427 gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State); |
1427 gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State); |
1428 gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420) |
1428 gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420) |
1666 if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX)) |
1666 if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX)) |
1667 or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
1667 or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
1668 if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX)) |
1668 if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX)) |
1669 or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
1669 or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
1670 end; |
1670 end; |
1671 |
1671 |
1672 FollowGear:= t^.ar[i] |
1672 FollowGear:= t^.ar[i] |
1673 end; |
1673 end; |
1674 end |
1674 end |
1675 end; |
1675 end; |
1676 SetAllToActive |
1676 SetAllToActive |
1911 repeat |
1911 repeat |
1912 inc(x, Delta); |
1912 inc(x, Delta); |
1913 cnt:= 0; |
1913 cnt:= 0; |
1914 if topY > 1024 then |
1914 if topY > 1024 then |
1915 y:= 1024-Gear^.Radius * 2 |
1915 y:= 1024-Gear^.Radius * 2 |
1916 else |
1916 else |
1917 y:= topY-Gear^.Radius * 2; |
1917 y:= topY-Gear^.Radius * 2; |
1918 while y < LAND_HEIGHT do |
1918 while y < LAND_HEIGHT do |
1919 begin |
1919 begin |
1920 repeat |
1920 repeat |
1921 inc(y, 2); |
1921 inc(y, 2); |
1922 until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0); |
1922 until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0); |
1923 |
1923 |
1924 sy:= y; |
1924 sy:= y; |
1925 |
1925 |
1926 repeat |
1926 repeat |
1927 inc(y); |
1927 inc(y); |
1928 until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0); |
1928 until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0); |
1929 |
1929 |
1930 if (y - sy > Gear^.Radius * 2) |
1930 if (y - sy > Gear^.Radius * 2) |
1931 and (y < LAND_HEIGHT) |
1931 and (y < LAND_HEIGHT) |
1932 and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then |
1932 and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then |
1933 begin |
1933 begin |
1934 ar[cnt].X:= x; |
1934 ar[cnt].X:= x; |
1935 if withFall then ar[cnt].Y:= sy + Gear^.Radius |
1935 if withFall then ar[cnt].Y:= sy + Gear^.Radius |
1936 else ar[cnt].Y:= y - Gear^.Radius; |
1936 else ar[cnt].Y:= y - Gear^.Radius; |
1937 inc(cnt) |
1937 inc(cnt) |
1938 end; |
1938 end; |
1939 |
1939 |
1940 inc(y, 45) |
1940 inc(y, 45) |
1941 end; |
1941 end; |
1942 |
1942 |
1943 if cnt > 0 then |
1943 if cnt > 0 then |
1944 with ar[GetRandom(cnt)] do |
1944 with ar[GetRandom(cnt)] do |
1945 begin |
1945 begin |
1946 ar2[cnt2].x:= x; |
1946 ar2[cnt2].x:= x; |
1947 ar2[cnt2].y:= y; |
1947 ar2[cnt2].y:= y; |
1948 inc(cnt2) |
1948 inc(cnt2) |
1949 end |
1949 end |
1950 until (x + Delta > Right); |
1950 until (x + Delta > Right); |
1951 |
1951 |
1952 dec(Delta, 60) |
1952 dec(Delta, 60) |
1953 until (cnt2 > 0) or (Delta < 70); |
1953 until (cnt2 > 0) or (Delta < 70); |
1954 |
1954 |
1955 if cnt2 > 0 then |
1955 if cnt2 > 0 then |
1956 with ar2[GetRandom(cnt2)] do |
1956 with ar2[GetRandom(cnt2)] do |