hedgewars/uGears.pas
changeset 3396 e5b3e5f2818e
parent 3390 1d4926d10a9e
child 3399 885304636abf
equal deleted inserted replaced
3395:095273ad0e08 3396:e5b3e5f2818e
    79     
    79     
    80 procedure initModule;
    80 procedure initModule;
    81 procedure freeModule;
    81 procedure freeModule;
    82 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    82 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    83 procedure ProcessGears;
    83 procedure ProcessGears;
    84 procedure ResetUtilities;
    84 procedure EndTurnCleanup;
    85 procedure ApplyDamage(Gear: PGear; Damage: Longword);
    85 procedure ApplyDamage(Gear: PGear; Damage: Longword);
    86 procedure SetAllToActive;
    86 procedure SetAllToActive;
    87 procedure SetAllHHToActive;
    87 procedure SetAllHHToActive;
    88 procedure DrawGears;
    88 procedure DrawGears;
    89 procedure FreeGearsList;
    89 procedure FreeGearsList;
   734                 begin
   734                 begin
   735                 cHealthDecrease:= 5;
   735                 cHealthDecrease:= 5;
   736                 AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState);
   736                 AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState);
   737                 playSound(sndSuddenDeath)
   737                 playSound(sndSuddenDeath)
   738                 end
   738                 end
   739             else if (TotalRounds < cSuddenDTurns - 1) then
   739             else if (TotalRounds < cSuddenDTurns - 1) and not isInMultiShoot then
   740                 begin
   740                 begin
   741                 i:= cSuddenDTurns - TotalRounds - 1;
   741                 i:= cSuddenDTurns - TotalRounds - 1;
   742                 s:= inttostr(i);
   742                 s:= inttostr(i);
   743                 if i = 1 then
   743                 if i = 1 then
   744                     AddCaption(trmsg[sidRoundSD], cWhiteColor, capgrpGameState)
   744                     AddCaption(trmsg[sidRoundSD], cWhiteColor, capgrpGameState)
   769                 with CurrentHedgehog^ do
   769                 with CurrentHedgehog^ do
   770                     if (Gear <> nil) 
   770                     if (Gear <> nil) 
   771                         and ((Gear^.State and gstAttacked) = 0)
   771                         and ((Gear^.State and gstAttacked) = 0)
   772                         and (MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^);
   772                         and (MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^);
   773                 
   773                 
   774                 ResetUtilities;
   774                 EndTurnCleanup;
   775 
   775 
   776                 FreeActionsList; // could send -left, -right and similar commands, so should be called before /nextturn
   776                 FreeActionsList; // could send -left, -right and similar commands, so should be called before /nextturn
   777 
   777 
   778                 ParseCommand('/nextturn', true);
   778                 ParseCommand('/nextturn', true);
   779                 SwitchHedgehog;
   779                 SwitchHedgehog;
   814     end;
   814     end;
   815 
   815 
   816 inc(GameTicks)
   816 inc(GameTicks)
   817 end;
   817 end;
   818 
   818 
   819 //Purpose, to reset all transient attributes toggled by a utility.
   819 //Purpose, to reset all transient attributes toggled by a utility and clean up various gears and effects at end of turn
   820 //If any of these are set as permanent toggles in the frontend, that needs to be checked and skipped here.
   820 //If any of these are set as permanent toggles in the frontend, that needs to be checked and skipped here.
   821 procedure ResetUtilities;
   821 procedure EndTurnCleanup;
   822 var  i: LongInt;
   822 var  i: LongInt;
       
   823     tmpGear, iterator: PGear;
   823 begin
   824 begin
   824     SpeechText:= ''; // in case it has not been consumed
   825     SpeechText:= ''; // in case it has not been consumed
   825 
   826 
   826     if (GameFlags and gfLowGravity) = 0 then
   827     if (GameFlags and gfLowGravity) = 0 then
   827         cGravity:= cMaxWindSpeed * 2;
   828         cGravity:= cMaxWindSpeed * 2;
   851 
   852 
   852                   if (Gear <> nil) then
   853                   if (Gear <> nil) then
   853                      if (GameFlags and gfInvulnerable) = 0 then
   854                      if (GameFlags and gfInvulnerable) = 0 then
   854                         Gear^.Invulnerable:= false;
   855                         Gear^.Invulnerable:= false;
   855                   end;
   856                   end;
       
   857     iterator:= GearsList;
       
   858     tmpGear:= nil;
       
   859     while iterator <> nil do
       
   860         begin
       
   861         if (iterator^.Kind = gtPortal) then 
       
   862             begin
       
   863             tmpGear:= iterator;
       
   864             if iterator^.NextGear <> nil then iterator:= iterator^.NextGear;
       
   865             DeleteGear(tmpGear)
       
   866             end
       
   867         else iterator:= iterator^.NextGear;
       
   868         end;
   856 end;
   869 end;
   857 
   870 
   858 procedure ApplyDamage(Gear: PGear; Damage: Longword);
   871 procedure ApplyDamage(Gear: PGear; Damage: Longword);
   859 var s: shortstring;
   872 var s: shortstring;
   860     vampDmg, tmpDmg, i: Longword;
   873     vampDmg, tmpDmg, i: Longword;