hedgewars/uGears.pas
changeset 4365 4f2b1a152979
parent 4359 83ef50815535
child 4367 f4a0ec067601
equal deleted inserted replaced
4363:e944cc43f7a4 4365:4f2b1a152979
   556             if (cWaterOpacity < $FF) and (hwRound(Gear^.Y) < cWaterLine + 256) then
   556             if (cWaterOpacity < $FF) and (hwRound(Gear^.Y) < cWaterLine + 256) then
   557                 spawnHealthTagForHH(Gear, t);
   557                 spawnHealthTagForHH(Gear, t);
   558             uStats.HedgehogDamaged(Gear)
   558             uStats.HedgehogDamaged(Gear)
   559             end;
   559             end;
   560 
   560 
   561         team:= PHedgehog(Gear^.Hedgehog)^.Team;
   561         team:= Gear^.Hedgehog^.Team;
   562         if CurrentHedgehog^.Gear = Gear then
   562         if CurrentHedgehog^.Gear = Gear then
   563             FreeActionsList; // to avoid ThinkThread on drawned gear
   563             FreeActionsList; // to avoid ThinkThread on drawned gear
   564 
   564 
   565         PHedgehog(Gear^.Hedgehog)^.Gear:= nil;
   565         Gear^.Hedgehog^.Gear:= nil;
   566         if PHedgehog(Gear^.Hedgehog)^.King then
   566         if Gear^.Hedgehog^.King then
   567             begin
   567             begin
   568             // are there any other kings left? Just doing nil check.  Presumably a mortally wounded king will get reaped soon enough
   568             // are there any other kings left? Just doing nil check.  Presumably a mortally wounded king will get reaped soon enough
   569             k:= false;
   569             k:= false;
   570             for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   570             for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   571                 if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then k:= true;
   571                 if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then k:= true;
   612                 Gear^.Health:= 0
   612                 Gear^.Health:= 0
   613                 end
   613                 end
   614             else
   614             else
   615                 dec(Gear^.Health, dmg);
   615                 dec(Gear^.Health, dmg);
   616 
   616 
   617             if (PHedgehog(Gear^.Hedgehog)^.Team = CurrentTeam) and
   617             if (Gear^.Hedgehog^.Team = CurrentTeam) and
   618                (Gear^.Damage <> Gear^.Karma) and
   618                (Gear^.Damage <> Gear^.Karma) and
   619                 not PHedgehog(Gear^.Hedgehog)^.King and
   619                 not Gear^.Hedgehog^.King and
   620                 not PHedgehog(Gear^.Hedgehog)^.Effects[hePoisoned] and
   620                 not Gear^.Hedgehog^.Effects[hePoisoned] and
   621                 not SuddenDeathDmg then
   621                 not SuddenDeathDmg then
   622                 Gear^.State:= Gear^.State or gstLoser;
   622                 Gear^.State:= Gear^.State or gstLoser;
   623 
   623 
   624             spawnHealthTagForHH(Gear, dmg);
   624             spawnHealthTagForHH(Gear, dmg);
   625 
   625 
   626             RenderHealth(PHedgehog(Gear^.Hedgehog)^);
   626             RenderHealth(Gear^.Hedgehog^);
   627             RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
   627             RecountTeamHealth(Gear^.Hedgehog^.Team);
   628 
   628 
   629             end;
   629             end;
   630         if (not isInMultiShoot) then Gear^.Karma:= 0;
   630         if (not isInMultiShoot) then Gear^.Karma:= 0;
   631         Gear^.Damage:= 0
   631         Gear^.Damage:= 0
   632         end;
   632         end;
   646     while Gear <> nil do
   646     while Gear <> nil do
   647     begin
   647     begin
   648         if Gear^.Kind = gtHedgehog then
   648         if Gear^.Kind = gtHedgehog then
   649             begin
   649             begin
   650             tmp:= 0;
   650             tmp:= 0;
   651             if PHedgehog(Gear^.Hedgehog)^.Effects[hePoisoned] then
   651             if Gear^.Hedgehog^.Effects[hePoisoned] then
   652                 begin
   652                 begin
   653                 inc(tmp, ModifyDamage(5, Gear));
   653                 inc(tmp, ModifyDamage(5, Gear));
   654                 if (GameFlags and gfResetHealth) <> 0 then dec(PHedgehog(Gear^.Hedgehog)^.InitialHealth)  // does not need a minimum check since <= 1 basically disables it
   654                 if (GameFlags and gfResetHealth) <> 0 then dec(Gear^.Hedgehog^.InitialHealth)  // does not need a minimum check since <= 1 basically disables it
   655                 end;
   655                 end;
   656             if (TotalRounds > cSuddenDTurns - 1) then
   656             if (TotalRounds > cSuddenDTurns - 1) then
   657                 begin
   657                 begin
   658                 inc(tmp, cHealthDecrease);
   658                 inc(tmp, cHealthDecrease);
   659                 if (GameFlags and gfResetHealth) <> 0 then dec(PHedgehog(Gear^.Hedgehog)^.InitialHealth, cHealthDecrease)
   659                 if (GameFlags and gfResetHealth) <> 0 then dec(Gear^.Hedgehog^.InitialHealth, cHealthDecrease)
   660                 end;
   660                 end;
   661             if PHedgehog(Gear^.Hedgehog)^.King then
   661             if Gear^.Hedgehog^.King then
   662                 begin
   662                 begin
   663                 flag:= false;
   663                 flag:= false;
   664                 team:= PHedgehog(Gear^.Hedgehog)^.Team;
   664                 team:= Gear^.Hedgehog^.Team;
   665                 for i:= 0 to Pred(team^.HedgehogsNumber) do
   665                 for i:= 0 to Pred(team^.HedgehogsNumber) do
   666                     if (team^.Hedgehogs[i].Gear <> nil) and
   666                     if (team^.Hedgehogs[i].Gear <> nil) and
   667                         (not team^.Hedgehogs[i].King) and
   667                         (not team^.Hedgehogs[i].King) and
   668                         (team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage)
   668                         (team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage)
   669                     then flag:= true;
   669                     then flag:= true;
   670                 if not flag then
   670                 if not flag then
   671                     begin
   671                     begin
   672                     inc(tmp, 5);
   672                     inc(tmp, 5);
   673                     if (GameFlags and gfResetHealth) <> 0 then dec(PHedgehog(Gear^.Hedgehog)^.InitialHealth, 5)
   673                     if (GameFlags and gfResetHealth) <> 0 then dec(Gear^.Hedgehog^.InitialHealth, 5)
   674                     end
   674                     end
   675                 end;
   675                 end;
   676             if tmp > 0 then 
   676             if tmp > 0 then 
   677                 begin
   677                 begin
   678                 inc(Gear^.Damage, min(tmp, max(0,Gear^.Health - 1 - Gear^.Damage)));
   678                 inc(Gear^.Damage, min(tmp, max(0,Gear^.Health - 1 - Gear^.Damage)));
   966     vg: PVisualGear;
   966     vg: PVisualGear;
   967 begin
   967 begin
   968     if (Gear^.Kind = gtHedgehog) and (Damage>=1) then
   968     if (Gear^.Kind = gtHedgehog) and (Damage>=1) then
   969     begin
   969     begin
   970     HHHurt(Gear^.Hedgehog, Source);
   970     HHHurt(Gear^.Hedgehog, Source);
   971     AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color);
   971     AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, Gear^.Hedgehog^.Team^.Clan^.Color);
   972     tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage));
   972     tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage));
   973     if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then
   973     if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then
   974         begin
   974         begin
   975         if cVampiric then
   975         if cVampiric then
   976             begin
   976             begin
  1031     end
  1031     end
  1032 end;
  1032 end;
  1033 
  1033 
  1034 procedure DrawAltWeapon(Gear: PGear; sx, sy: LongInt);
  1034 procedure DrawAltWeapon(Gear: PGear; sx, sy: LongInt);
  1035 begin
  1035 begin
  1036 with PHedgehog(Gear^.Hedgehog)^ do
  1036 with Gear^.Hedgehog^ do
  1037     begin
  1037     begin
  1038     if not (((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) and ((Gear^.State and gstAttacked) = 0)) then
  1038     if not (((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) and ((Gear^.State and gstAttacked) = 0)) then
  1039         exit;
  1039         exit;
  1040     DrawTexture(sx + 16, sy + 16, ropeIconTex);
  1040     DrawTexture(sx + 16, sy + 16, ropeIconTex);
  1041     DrawTextureF(SpritesData[sprAMAmmos].Texture, 0.75, sx + 30, sy + 30, ord(CurAmmoType) - 1, 1, 32, 32);
  1041     DrawTextureF(SpritesData[sprAMAmmos].Texture, 0.75, sx + 30, sy + 30, ord(CurAmmoType) - 1, 1, 32, 32);
  1046 begin
  1046 begin
  1047 with RopePoints do
  1047 with RopePoints do
  1048     begin
  1048     begin
  1049     rounded[Count].X:= hwRound(Gear^.X);
  1049     rounded[Count].X:= hwRound(Gear^.X);
  1050     rounded[Count].Y:= hwRound(Gear^.Y);
  1050     rounded[Count].Y:= hwRound(Gear^.Y);
  1051     rounded[Count + 1].X:= hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X);
  1051     rounded[Count + 1].X:= hwRound(Gear^.Hedgehog^.Gear^.X);
  1052     rounded[Count + 1].Y:= hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y);
  1052     rounded[Count + 1].Y:= hwRound(Gear^.Hedgehog^.Gear^.Y);
  1053     end;
  1053     end;
  1054 
  1054 
  1055 if (RopePoints.Count > 0) or (Gear^.Elasticity.QWordValue > 0) then
  1055 if (RopePoints.Count > 0) or (Gear^.Elasticity.QWordValue > 0) then
  1056     begin
  1056     begin
  1057     glDisable(GL_TEXTURE_2D);
  1057     glDisable(GL_TEXTURE_2D);
  1157                     inc(i)
  1157                     inc(i)
  1158                     end;
  1158                     end;
  1159             DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
  1159             DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
  1160                         hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy);
  1160                         hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy);
  1161             DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
  1161             DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
  1162                         hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy);
  1162                         hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy);
  1163             end else
  1163             end else
  1164             if Gear^.Elasticity.QWordValue > 0 then
  1164             if Gear^.Elasticity.QWordValue > 0 then
  1165             DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
  1165             DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
  1166                         hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy);
  1166                         hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy);
  1167         end;
  1167         end;
  1168 
  1168 
  1169 
  1169 
  1170 if RopePoints.Count > 0 then
  1170 if RopePoints.Count > 0 then
  1171     DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle)
  1171     DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle)
  1306                                     Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
  1306                                     Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
  1307                                 Gear^.Active:= true;
  1307                                 Gear^.Active:= true;
  1308                                 if Gear^.Kind <> gtFlame then FollowGear:= Gear
  1308                                 if Gear^.Kind <> gtFlame then FollowGear:= Gear
  1309                                 end;
  1309                                 end;
  1310                             if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) then
  1310                             if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) then
  1311                                 PHedgehog(Gear^.Hedgehog)^.Effects[hePoisoned] := true;
  1311                                 Gear^.Hedgehog^.Effects[hePoisoned] := true;
  1312                             end;
  1312                             end;
  1313 
  1313 
  1314                         end;
  1314                         end;
  1315                 gtGrave: begin
  1315                 gtGrave: begin
  1316 // Run the calcs only once we know we have a type that will need damage
  1316 // Run the calcs only once we know we have a type that will need damage
  1430                     else
  1430                     else
  1431                         Gear^.State:= Gear^.State or gstWinner;
  1431                         Gear^.State:= Gear^.State or gstWinner;
  1432                     if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then ApplyDamage(Gear, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch
  1432                     if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then ApplyDamage(Gear, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch
  1433 
  1433 
  1434                     DeleteCI(Gear);
  1434                     DeleteCI(Gear);
  1435                     if (Gear^.Kind = gtHedgehog) and PHedgehog(Gear^.Hedgehog)^.King then
  1435                     if (Gear^.Kind = gtHedgehog) and Gear^.Hedgehog^.King then
  1436                         begin
  1436                         begin
  1437                         Gear^.dX:= Ammo^.dX * Power * _0_005;
  1437                         Gear^.dX:= Ammo^.dX * Power * _0_005;
  1438                         Gear^.dY:= Ammo^.dY * Power * _0_005
  1438                         Gear^.dY:= Ammo^.dY * Power * _0_005
  1439                         end
  1439                         end
  1440                     else
  1440                     else
  1844         {$ENDIF}
  1844         {$ENDIF}
  1845         end
  1845         end
  1846     else
  1846     else
  1847     begin
  1847     begin
  1848     OutError('Can''t find place for Gear', false);
  1848     OutError('Can''t find place for Gear', false);
  1849     if Gear^.Kind = gtHedgehog then PHedgehog(Gear^.Hedgehog)^.Effects[heResurrectable] := false;
  1849     if Gear^.Kind = gtHedgehog then Gear^.Hedgehog^.Effects[heResurrectable] := false;
  1850     DeleteGear(Gear);
  1850     DeleteGear(Gear);
  1851     Gear:= nil
  1851     Gear:= nil
  1852     end
  1852     end
  1853 end;
  1853 end;
  1854 
  1854 
  1859    Not without a new damage machine.
  1859    Not without a new damage machine.
  1860    King check should be in here instead of ApplyDamage since Tiy wants them kicked less
  1860    King check should be in here instead of ApplyDamage since Tiy wants them kicked less
  1861 *)
  1861 *)
  1862 i:= _1;
  1862 i:= _1;
  1863 if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then i:= _1_5;
  1863 if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then i:= _1_5;
  1864 if (Gear^.Hedgehog <> nil) and (PHedgehog(Gear^.Hedgehog)^.King) then
  1864 if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King) then
  1865    ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent * _0_5)
  1865    ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent * _0_5)
  1866 else
  1866 else
  1867    ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent)
  1867    ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent)
  1868 end;
  1868 end;
  1869 
  1869