hedgewars/uTeams.pas
branchwebgl
changeset 9127 e350500c4edb
parent 8833 c13ebed437cb
parent 9080 9b42757d7e71
child 9160 fc46e75f6b72
equal deleted inserted replaced
8860:bde641cf53c8 9127:e350500c4edb
     1 (*
     1 (*
     2  * Hedgewars, a free turn based strategy game
     2  * Hedgewars, a free turn based strategy game
     3  * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
     3  * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
     4  *
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation; version 2 of the License
     7  * the Free Software Foundation; version 2 of the License
     8  *
     8  *
   108     end;
   108     end;
   109 GameOver:= true
   109 GameOver:= true
   110 end;
   110 end;
   111 
   111 
   112 procedure SwitchHedgehog;
   112 procedure SwitchHedgehog;
   113 var c, i, j: LongWord;
   113 var c, i, t, j: LongWord;
   114     PrevHH, PrevTeam : LongWord;
   114     PrevHH, PrevTeam : LongWord;
   115 begin
   115 begin
   116 TargetPoint.X:= NoPointX;
   116 TargetPoint.X:= NoPointX;
   117 TryDo(CurrentTeam <> nil, 'nil Team', true);
   117 TryDo(CurrentTeam <> nil, 'nil Team', true);
   118 with CurrentHedgehog^ do
   118 with CurrentHedgehog^ do
   171         inc(c);
   171         inc(c);
   172 
   172 
   173     if c = ClansCount then
   173     if c = ClansCount then
   174         begin
   174         begin
   175         if not PlacingHogs then
   175         if not PlacingHogs then
   176             begin
       
   177             inc(TotalRounds);
   176             inc(TotalRounds);
   178             for i:= 0 to Pred(TeamsCount) do
       
   179                 with TeamsArray[i]^ do
       
   180                     for j:= 0 to Pred(HedgehogsNumber) do
       
   181                         with Hedgehogs[j] do
       
   182                             if Effects[heFrozen] > 255 then
       
   183                                 Effects[heFrozen]:= max(255,Effects[heFrozen]-50000)
       
   184             end;
       
   185         c:= 0
   177         c:= 0
   186         end;
   178         end;
   187 
   179 
   188     with ClansArray[c]^ do
   180     with ClansArray[c]^ do
   189         begin
   181         begin
   194             with CurrentTeam^ do
   186             with CurrentTeam^ do
   195                 begin
   187                 begin
   196                 PrevHH:= CurrHedgehog mod HedgehogsNumber; // prevent infinite loop when CurrHedgehog = 7, but HedgehogsNumber < 8 (team is destroyed before its first turn)
   188                 PrevHH:= CurrHedgehog mod HedgehogsNumber; // prevent infinite loop when CurrHedgehog = 7, but HedgehogsNumber < 8 (team is destroyed before its first turn)
   197                 repeat
   189                 repeat
   198                     CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
   190                     CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
   199                 until ((Hedgehogs[CurrHedgehog].Gear <> nil) and (Hedgehogs[CurrHedgehog].Effects[heFrozen] = 0)) or (CurrHedgehog = PrevHH)
   191                 until ((Hedgehogs[CurrHedgehog].Gear <> nil) and (Hedgehogs[CurrHedgehog].Effects[heFrozen] < 256)) or (CurrHedgehog = PrevHH)
   200                 end
   192                 end
   201         until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam) or ((CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0));
   193         until ((CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] < 50256)) or (PrevTeam = CurrTeam) or ((CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0))
   202         end
   194         end;
   203 until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] = 0);
   195         if (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = nil) or (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] > 255) then
       
   196             begin
       
   197             inc(CurrentTeam^.Clan^.TurnNumber);
       
   198             with CurrentTeam^.Clan^ do
       
   199                 for t:= 0 to Pred(TeamsNumber) do
       
   200                     with Teams[t]^ do
       
   201                         for i:= 0 to Pred(HedgehogsNumber) do
       
   202                             with Hedgehogs[i] do
       
   203                                 if Effects[heFrozen] > 255 then
       
   204                                     Effects[heFrozen]:= max(255,Effects[heFrozen]-50000)
       
   205             end
       
   206 until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] < 256);
   204 
   207 
   205 SwitchCurrentHedgehog(@(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]));
   208 SwitchCurrentHedgehog(@(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]));
   206 {$IFDEF USE_TOUCH_INTERFACE}
   209 {$IFDEF USE_TOUCH_INTERFACE}
   207 if (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
   210 if (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
   208     begin
   211     begin
   245         ResetWeapons
   248         ResetWeapons
   246         end
   249         end
   247     end;
   250     end;
   248 
   251 
   249 inc(CurrentTeam^.Clan^.TurnNumber);
   252 inc(CurrentTeam^.Clan^.TurnNumber);
       
   253 with CurrentTeam^.Clan^ do
       
   254     for t:= 0 to Pred(TeamsNumber) do
       
   255         with Teams[t]^ do
       
   256             for i:= 0 to Pred(HedgehogsNumber) do
       
   257                 with Hedgehogs[i] do
       
   258                     if Effects[heFrozen] > 255 then
       
   259                         Effects[heFrozen]:= max(255,Effects[heFrozen]-50000);
   250 
   260 
   251 CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^);
   261 CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^);
   252 if CurWeapon^.Count = 0 then
   262 if CurWeapon^.Count = 0 then
   253     CurrentHedgehog^.CurAmmoType:= amNothing;
   263     CurrentHedgehog^.CurAmmoType:= amNothing;
   254 
   264