hedgewars/uGears.pas
changeset 12918 6deb29364723
parent 12916 6fede49bc103
child 12920 21827fc9ca98
equal deleted inserted replaced
12917:8cc24173cd71 12918:6deb29364723
    44 procedure DrawGears;
    44 procedure DrawGears;
    45 procedure DrawGearsTimers;
    45 procedure DrawGearsTimers;
    46 procedure FreeGearsList;
    46 procedure FreeGearsList;
    47 procedure AddMiscGears;
    47 procedure AddMiscGears;
    48 procedure AssignHHCoords;
    48 procedure AssignHHCoords;
       
    49 procedure StartSuddenDeath;
    49 function  GearByUID(uid : Longword) : PGear;
    50 function  GearByUID(uid : Longword) : PGear;
    50 function  IsClockRunning() : boolean;
    51 function  IsClockRunning() : boolean;
    51 
    52 
    52 implementation
    53 implementation
    53 uses uStore, uSound, uTeams, uRandom, uIO, uLandGraphics,
    54 uses uStore, uSound, uTeams, uRandom, uIO, uLandGraphics,
   131                 begin
   132                 begin
   132                 inc(tmp, ModifyDamage(Gear^.Hedgehog^.Effects[hePoisoned], Gear));
   133                 inc(tmp, ModifyDamage(Gear^.Hedgehog^.Effects[hePoisoned], Gear));
   133                 if (GameFlags and gfResetHealth) <> 0 then
   134                 if (GameFlags and gfResetHealth) <> 0 then
   134                     dec(Gear^.Hedgehog^.InitialHealth)  // does not need a minimum check since <= 1 basically disables it
   135                     dec(Gear^.Hedgehog^.InitialHealth)  // does not need a minimum check since <= 1 basically disables it
   135                 end;
   136                 end;
       
   137             // Apply SD health decrease as soon as SD starts
   136             if (TotalRounds > cSuddenDTurns - 1) then
   138             if (TotalRounds > cSuddenDTurns - 1) then
   137                 begin
   139                 begin
   138                 inc(tmp, cHealthDecrease);
   140                 inc(tmp, cHealthDecrease);
   139                 if (GameFlags and gfResetHealth) <> 0 then
   141                 if (GameFlags and gfResetHealth) <> 0 then
   140                     dec(Gear^.Hedgehog^.InitialHealth, cHealthDecrease)
   142                     dec(Gear^.Hedgehog^.InitialHealth, cHealthDecrease)
   304         inc(step)
   306         inc(step)
   305         end;
   307         end;
   306     stWater:
   308     stWater:
   307     if (not bBetweenTurns) and (not isInMultiShoot) then
   309     if (not bBetweenTurns) and (not isInMultiShoot) then
   308         begin
   310         begin
       
   311         // Start Sudden Death water rise in the 2nd round of Sudden Death
   309         if TotalRounds = cSuddenDTurns + 1 then
   312         if TotalRounds = cSuddenDTurns + 1 then
   310             bWaterRising:= true;
   313             bWaterRising:= true;
   311         if bWaterRising and (cWaterRise > 0) then
   314         if bWaterRising and (cWaterRise > 0) then
   312             AddGear(0, 0, gtWaterUp, 0, _0, _0, 0)^.Tag:= cWaterRise;
   315             AddGear(0, 0, gtWaterUp, 0, _0, _0, 0)^.Tag:= cWaterRise;
   313         inc(step)
   316         inc(step)
   323     stHealth:
   326     stHealth:
   324         begin
   327         begin
   325         if (cWaterRise <> 0) or (cHealthDecrease <> 0) then
   328         if (cWaterRise <> 0) or (cHealthDecrease <> 0) then
   326              begin
   329              begin
   327             if (TotalRounds = cSuddenDTurns) and (not SuddenDeath) and (not isInMultiShoot) then
   330             if (TotalRounds = cSuddenDTurns) and (not SuddenDeath) and (not isInMultiShoot) then
   328                 begin
   331                 StartSuddenDeath()
   329                 SuddenDeath:= true;
       
   330                 if cHealthDecrease <> 0 then
       
   331                     begin
       
   332                     SuddenDeathDmg:= true;
       
   333 
       
   334                     // flash
       
   335                     ScreenFade:= sfFromWhite;
       
   336                     ScreenFadeValue:= sfMax;
       
   337                     ScreenFadeSpeed:= 1;
       
   338 
       
   339                     ChangeToSDClouds;
       
   340                     ChangeToSDFlakes;
       
   341                     SetSkyColor(SDSkyColor.r * (SDTint.r/255) / 255, SDSkyColor.g * (SDTint.g/255) / 255, SDSkyColor.b * (SDTint.b/255) / 255);
       
   342                     Ammoz[amTardis].SkipTurns:= 9999;
       
   343                     Ammoz[amTardis].Probability:= 0;
       
   344                     end;
       
   345                 AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState);
       
   346                 ScriptCall('onSuddenDeath');
       
   347                 playSound(sndSuddenDeath);
       
   348                 StopMusic;
       
   349                 if SDMusicFN <> '' then PlayMusic
       
   350                 end
       
   351             else if (TotalRounds < cSuddenDTurns) and (not isInMultiShoot) then
   332             else if (TotalRounds < cSuddenDTurns) and (not isInMultiShoot) then
   352                 begin
   333                 begin
   353                 i:= cSuddenDTurns - TotalRounds;
   334                 i:= cSuddenDTurns - TotalRounds;
   354                 s:= ansistring(inttostr(i));
   335                 s:= ansistring(inttostr(i));
   355                 if i = 1 then
   336                 if i = 1 then
  1055         FindPlace(FollowGear, true, 0, LAND_WIDTH);
  1036         FindPlace(FollowGear, true, 0, LAND_WIDTH);
  1056 
  1037 
  1057     SpawnFakeCrateAt := FollowGear;
  1038     SpawnFakeCrateAt := FollowGear;
  1058 end;
  1039 end;
  1059 
  1040 
       
  1041 procedure StartSuddenDeath();
       
  1042 begin
       
  1043     if SuddenDeath then
       
  1044         exit;
       
  1045 
       
  1046     SuddenDeath:= true;
       
  1047     if cHealthDecrease <> 0 then
       
  1048     begin
       
  1049         SuddenDeathDmg:= true;
       
  1050         // flash
       
  1051         ScreenFade:= sfFromWhite;
       
  1052         ScreenFadeValue:= sfMax;
       
  1053         ScreenFadeSpeed:= 1;
       
  1054 
       
  1055         ChangeToSDClouds;
       
  1056         ChangeToSDFlakes;
       
  1057         SetSkyColor(SDSkyColor.r * (SDTint.r/255) / 255, SDSkyColor.g * (SDTint.g/255) / 255, SDSkyColor.b * (SDTint.b/255) / 255);
       
  1058         Ammoz[amTardis].SkipTurns:= 9999;
       
  1059         Ammoz[amTardis].Probability:= 0;
       
  1060     end;
       
  1061     AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState);
       
  1062     ScriptCall('onSuddenDeath');
       
  1063     playSound(sndSuddenDeath);
       
  1064     StopMusic;
       
  1065     if SDMusicFN <> '' then
       
  1066         PlayMusic
       
  1067 end;
  1060 
  1068 
  1061 function GearByUID(uid : Longword) : PGear;
  1069 function GearByUID(uid : Longword) : PGear;
  1062 var gear: PGear;
  1070 var gear: PGear;
  1063 begin
  1071 begin
  1064 GearByUID:= nil;
  1072 GearByUID:= nil;