hedgewars/uGears.pas
changeset 14400 9c7d5f595881
parent 14398 87562a68c41f
child 14402 234bb36d3b8c
equal deleted inserted replaced
14399:352ea82355ae 14400:9c7d5f595881
    60 
    60 
    61 var skipFlag: boolean;
    61 var skipFlag: boolean;
    62 
    62 
    63 var delay: LongWord;
    63 var delay: LongWord;
    64     delay2: LongWord;
    64     delay2: LongWord;
    65     step: (stInit, stDelay, stChDmg, stSweep, stTurnStats, stChWin1,
    65     step: (stInit, stDelay1, stChDmg, stSweep, stTurnStats, stChWin1,
    66     stTurnReact, stAfterDelay, stChWin2, stWater, stChWin3,
    66     stTurnReact, stDelay2, stChWin2, stWater, stChWin3,
    67     stChKing, stHealth, stSpawn, stNTurn);
    67     stChKing, stSuddenDeath, stDelay3, stHealth, stSpawn, stDelay4,
       
    68     stNTurn);
    68     NewTurnTick: LongWord;
    69     NewTurnTick: LongWord;
    69     //SDMusic: shortstring;
    70     //SDMusic: shortstring;
       
    71 
       
    72 const delaySDStart = 1600;
       
    73       delaySDWarning = 1000;
       
    74       delayDamageTag = 500;
       
    75       delayTurnReact = 1500;
       
    76       delayFinal = 100;
    70 
    77 
    71 function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs
    78 function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs
    72 var Gear: PGear;
    79 var Gear: PGear;
    73     dmg: LongInt;
    80     dmg: LongInt;
    74 begin
    81 begin
   118             Gear^.Karma:= 0;
   125             Gear^.Karma:= 0;
   119         Gear^.Damage:= 0
   126         Gear^.Damage:= 0
   120         end;
   127         end;
   121     Gear:= Gear^.NextGear
   128     Gear:= Gear^.NextGear
   122     end;
   129     end;
       
   130 end;
       
   131 
       
   132 function DoDelay: boolean;
       
   133 begin
       
   134 if delay <= 0 then
       
   135     delay:= 1
       
   136 else
       
   137     dec(delay);
       
   138 DoDelay:= delay = 0;
   123 end;
   139 end;
   124 
   140 
   125 function CheckMinionsDie: boolean;
   141 function CheckMinionsDie: boolean;
   126 var Gear: PGear;
   142 var Gear: PGear;
   127 begin
   143 begin
   294         begin
   310         begin
   295         if (not bBetweenTurns) and (not isInMultiShoot) then
   311         if (not bBetweenTurns) and (not isInMultiShoot) then
   296             ScriptCall('onEndTurn');
   312             ScriptCall('onEndTurn');
   297         inc(step)
   313         inc(step)
   298         end;
   314         end;
   299     stDelay:
   315     stDelay1:
   300         begin
   316         if DoDelay() then
   301         if delay = 0 then
   317             inc(step);
   302             delay:= cInactDelay
       
   303         else
       
   304             dec(delay);
       
   305 
       
   306         if delay = 0 then
       
   307             inc(step)
       
   308         end;
       
   309 
       
   310     stChDmg:
   318     stChDmg:
   311     if CheckNoDamage then
   319     if CheckNoDamage then
   312         inc(step)
   320         inc(step)
   313     else
   321     else
   314         step:= stDelay;
   322         begin
       
   323         delay:= delayDamageTag;
       
   324         step:= stDelay1;
       
   325         end;
   315 
   326 
   316     stSweep:
   327     stSweep:
   317     if SweepDirty then
   328     if SweepDirty then
   318         begin
   329         begin
   319         SetAllToActive;
   330         SetAllToActive;
   339         begin
   350         begin
   340         if (not bBetweenTurns) and (not isInMultiShoot) then
   351         if (not bBetweenTurns) and (not isInMultiShoot) then
   341             begin
   352             begin
   342             uStats.TurnReaction;
   353             uStats.TurnReaction;
   343             uStats.TurnStatsReset;
   354             uStats.TurnStatsReset;
       
   355             delay:= delayTurnReact;
   344             inc(step)
   356             inc(step)
   345             end
   357             end
   346         else
   358         else
   347             inc(step, 2);
   359             inc(step, 2);
   348         end;
   360         end;
   349 
   361 
   350     stAfterDelay:
   362     stDelay2:
   351         begin
   363         if DoDelay() then
   352         if delay = 0 then
   364             inc(step);
   353             delay:= cInactDelay
       
   354         else
       
   355             dec(delay);
       
   356 
       
   357         if delay = 0 then
       
   358             inc(step)
       
   359             end;
       
   360     stChWin2:
   365     stChWin2:
   361         begin
   366         begin
   362         CheckForWin();
   367         CheckForWin();
   363         inc(step)
   368         inc(step)
   364         end;
   369         end;
   389         if (not isInMultiShoot) and (CheckMinionsDie) then
   394         if (not isInMultiShoot) and (CheckMinionsDie) then
   390             step:= stChDmg
   395             step:= stChDmg
   391         else
   396         else
   392             inc(step);
   397             inc(step);
   393         end;
   398         end;
   394     stHealth:
   399     stSuddenDeath:
   395         begin
   400         begin
   396         if (cWaterRise <> 0) or (cHealthDecrease <> 0) then
   401         if (cWaterRise <> 0) or (cHealthDecrease <> 0) then
   397             begin
   402             begin
   398             if (TotalRoundsPre = cSuddenDTurns) and (not SuddenDeath) and (not isInMultiShoot) then
   403             if (TotalRoundsPre = cSuddenDTurns) and (not SuddenDeath) and (not isInMultiShoot) then
   399                 StartSuddenDeath()
   404                 begin
       
   405                 StartSuddenDeath();
       
   406                 delay:= delaySDStart;
       
   407                 end
   400             else if (TotalRoundsPre < cSuddenDTurns) and (not isInMultiShoot) then
   408             else if (TotalRoundsPre < cSuddenDTurns) and (not isInMultiShoot) then
   401                 begin
   409                 begin
   402                 i:= cSuddenDTurns - TotalRoundsPre;
   410                 i:= cSuddenDTurns - TotalRoundsPre;
   403                 s:= ansistring(inttostr(i));
   411                 s:= ansistring(inttostr(i));
   404                 if i = 1 then
   412                 if i = 1 then
   405                     AddCaption(trmsg[sidRoundSD], capcolDefault, capgrpGameState)
   413                     begin
       
   414                     AddCaption(trmsg[sidRoundSD], capcolDefault, capgrpGameState);
       
   415                     delay:= delaySDWarning;
       
   416                     end
   406                 else if (i = 2) or ((i > 0) and ((i mod 50 = 0) or ((i <= 25) and (i mod 5 = 0)))) then
   417                 else if (i = 2) or ((i > 0) and ((i mod 50 = 0) or ((i <= 25) and (i mod 5 = 0)))) then
       
   418                     begin
   407                     AddCaption(FormatA(trmsg[sidRoundsSD], s), capcolDefault, capgrpGameState);
   419                     AddCaption(FormatA(trmsg[sidRoundsSD], s), capcolDefault, capgrpGameState);
       
   420                     delay:= delaySDWarning;
       
   421                     end
   408                 end;
   422                 end;
   409             end;
   423             inc(step);
   410             if bBetweenTurns
   424             end
   411             or isInMultiShoot
   425         else
   412             or (TotalRoundsPre = -1) then
   426             inc(step, 2);
   413                 inc(step)
   427         end;
   414             else
   428     stDelay3:
   415                 begin
   429         if DoDelay() then
   416                 bBetweenTurns:= true;
   430             inc(step);
   417                 HealthMachine;
   431     stHealth:
   418                 step:= stChDmg
   432         begin
   419                 end
   433         if bBetweenTurns
   420             end;
   434         or isInMultiShoot
       
   435         or (TotalRoundsPre = -1) then
       
   436             inc(step)
       
   437         else
       
   438             begin
       
   439             bBetweenTurns:= true;
       
   440             HealthMachine;
       
   441             step:= stChDmg
       
   442             end;
       
   443         end;
   421     stSpawn:
   444     stSpawn:
   422         begin
   445         begin
   423         if not isInMultiShoot then
   446         if (not isInMultiShoot) then
       
   447             begin
   424             SpawnBoxOfSmth;
   448             SpawnBoxOfSmth;
   425         inc(step)
   449             delay:= delayFinal;
   426         end;
   450             inc(step);
       
   451             end
       
   452         else
       
   453             inc(step, 2)
       
   454         end;
       
   455     stDelay4:
       
   456         if DoDelay() then
       
   457             inc(step);
   427     stNTurn:
   458     stNTurn:
   428         begin
   459         begin
   429         if isInMultiShoot then
   460         if isInMultiShoot then
   430             isInMultiShoot:= false
   461             isInMultiShoot:= false
   431         else
   462         else
  1365     PrvInactive:= false;
  1396     PrvInactive:= false;
  1366 
  1397 
  1367     //typed const
  1398     //typed const
  1368     delay:= 0;
  1399     delay:= 0;
  1369     delay2:= 0;
  1400     delay2:= 0;
  1370     step:= stDelay;
  1401     step:= stDelay1;
  1371     upd:= 0;
  1402     upd:= 0;
  1372 
  1403 
  1373     //SDMusic:= 'hell.ogg';
  1404     //SDMusic:= 'hell.ogg';
  1374     NewTurnTick:= $FFFFFFFF;
  1405     NewTurnTick:= $FFFFFFFF;
  1375 end;
  1406 end;