hedgewars/uTeams.pas
changeset 553 5478386d935f
parent 552 2167020d3bc0
child 557 a7d49d5e8257
equal deleted inserted replaced
552:2167020d3bc0 553:5478386d935f
    75     ClansArray: array[0..Pred(cMaxTeams)] of PClan;
    75     ClansArray: array[0..Pred(cMaxTeams)] of PClan;
    76     ClansCount: Longword = 0;
    76     ClansCount: Longword = 0;
    77     CurMinAngle, CurMaxAngle: Longword;
    77     CurMinAngle, CurMaxAngle: Longword;
    78 
    78 
    79 function AddTeam(TeamColor: Longword): PTeam;
    79 function AddTeam(TeamColor: Longword): PTeam;
    80 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
       
    81 procedure SwitchHedgehog;
    80 procedure SwitchHedgehog;
    82 procedure InitTeams;
    81 procedure InitTeams;
    83 function  TeamSize(p: PTeam): Longword;
    82 function  TeamSize(p: PTeam): Longword;
    84 procedure RecountTeamHealth(team: PTeam);
    83 procedure RecountTeamHealth(team: PTeam);
    85 procedure RestoreTeamsFromSave;
    84 procedure RestoreTeamsFromSave;
   145      if Gear <> nil then
   144      if Gear <> nil then
   146         begin
   145         begin
   147         AttacksNum:= 0;
   146         AttacksNum:= 0;
   148         Gear^.Message:= 0;
   147         Gear^.Message:= 0;
   149         Gear^.Z:= cHHZ;
   148         Gear^.Z:= cHHZ;
       
   149         SwitchNotHoldedAmmo(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]);
   150         RemoveGearFromList(Gear);
   150         RemoveGearFromList(Gear);
   151         InsertGearToList(Gear)
   151         InsertGearToList(Gear)
   152         end;
   152         end;
   153 
   153 
   154 c:= CurrentTeam^.Clan^.ClanIndex;
   154 c:= CurrentTeam^.Clan^.ClanIndex;
   266       if th > MaxTeamHealth then MaxTeamHealth:= th;
   266       if th > MaxTeamHealth then MaxTeamHealth:= th;
   267       end;
   267       end;
   268 RecountAllTeamsHealth
   268 RecountAllTeamsHealth
   269 end;
   269 end;
   270 
   270 
   271 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
       
   272 var s: shortstring;
       
   273 begin
       
   274 TargetPoint.X:= NoPointX;
       
   275 
       
   276 with Hedgehog do
       
   277      begin
       
   278      if Ammo^[CurSlot, CurAmmo].Count = 0 then
       
   279         begin
       
   280         CurAmmo:= 0;
       
   281         CurSlot:= 0;
       
   282         while (CurSlot <= cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do inc(CurSlot)
       
   283         end;
       
   284 
       
   285 with Ammo^[CurSlot, CurAmmo] do
       
   286      begin
       
   287      CurMinAngle:= Ammoz[AmmoType].minAngle;
       
   288      if Ammoz[AmmoType].maxAngle <> 0 then CurMaxAngle:= Ammoz[AmmoType].maxAngle
       
   289                                       else CurMaxAngle:= cMaxAngle;
       
   290      with Hedgehog.Gear^ do
       
   291         begin
       
   292         if Angle < CurMinAngle then Angle:= CurMinAngle;
       
   293         if Angle > CurMaxAngle then Angle:= CurMaxAngle;
       
   294         end;
       
   295 
       
   296      s:= trammo[Ammoz[AmmoType].NameId];
       
   297      if Count <> AMMO_INFINITE then
       
   298         s:= s + ' (' + IntToStr(Count) + ')';
       
   299      if (Propz and ammoprop_Timerable) <> 0 then
       
   300         s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds];
       
   301      AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
       
   302      if (Propz and ammoprop_NeedTarget) <> 0
       
   303         then begin
       
   304         Gear^.State:= Gear^.State or      gstHHChooseTarget;
       
   305         isCursorVisible:= true
       
   306         end else begin
       
   307         Gear^.State:= Gear^.State and not gstHHChooseTarget;
       
   308         isCursorVisible:= false
       
   309         end;
       
   310      ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0
       
   311      end
       
   312      end
       
   313 end;
       
   314 
       
   315 function  TeamSize(p: PTeam): Longword;
   271 function  TeamSize(p: PTeam): Longword;
   316 var i, Result: Longword;
   272 var i, Result: Longword;
   317 begin
   273 begin
   318 Result:= 0;
   274 Result:= 0;
   319 for i:= 0 to cMaxHHIndex do
   275 for i:= 0 to cMaxHHIndex do