hedgewars/uTeams.pas
changeset 70 82d93eeecebe
parent 64 9df467527ae5
child 72 aeb2ac1878dc
equal deleted inserted replaced
69:d8a526934b9f 70:82d93eeecebe
    71 
    71 
    72 var CurrentTeam: PTeam = nil;
    72 var CurrentTeam: PTeam = nil;
    73     TeamsList: PTeam = nil;
    73     TeamsList: PTeam = nil;
    74 
    74 
    75 function AddTeam: PTeam;
    75 function AddTeam: PTeam;
    76 procedure ApplyAmmoChanges(Hedgehog: PHedgehog);
    76 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
    77 procedure SwitchHedgehog;
    77 procedure SwitchHedgehog;
    78 procedure InitTeams;
    78 procedure InitTeams;
    79 procedure OnUsedAmmo(Ammo: PHHAmmo);
    79 procedure OnUsedAmmo(Ammo: PHHAmmo);
    80 function  TeamSize(p: PTeam): Longword;
    80 function  TeamSize(p: PTeam): Longword;
    81 procedure RecountTeamHealth(team: PTeam);
    81 procedure RecountTeamHealth(team: PTeam);
   127      end;
   127      end;
   128 ResetKbd;
   128 ResetKbd;
   129 cWindSpeed:= (GetRandom * 2 - 1) * cMaxWindSpeed;
   129 cWindSpeed:= (GetRandom * 2 - 1) * cMaxWindSpeed;
   130 AddGear(0, 0, gtActionTimer, gtsSmoothWindCh).Tag:= round(72 * cWindSpeed / cMaxWindSpeed);
   130 AddGear(0, 0, gtActionTimer, gtsSmoothWindCh).Tag:= round(72 * cWindSpeed / cMaxWindSpeed);
   131 {$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF}
   131 {$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF}
   132 ApplyAmmoChanges(@CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog]);
   132 ApplyAmmoChanges(CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog]);
   133 TurnTimeLeft:= cHedgehogTurnTime
   133 TurnTimeLeft:= cHedgehogTurnTime
   134 end;
   134 end;
   135 
   135 
   136 procedure SetFirstTurnHedgehog;
   136 procedure SetFirstTurnHedgehog;
   137 var i: integer;
   137 var i: integer;
   217       end;
   217       end;
   218 SetFirstTurnHedgehog;
   218 SetFirstTurnHedgehog;
   219 RecountAllTeamsHealth
   219 RecountAllTeamsHealth
   220 end;
   220 end;
   221 
   221 
   222 procedure ApplyAmmoChanges(Hedgehog: PHedgehog);
   222 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
   223 var s: shortstring;
   223 var s: shortstring;
   224 begin
   224 begin
   225 with Hedgehog^ do
   225 with Hedgehog do
   226      begin
   226      begin
   227      if Ammo[CurSlot, CurAmmo].Count = 0 then
   227      if Ammo[CurSlot, CurAmmo].Count = 0 then
   228         begin
   228         begin
   229         CurAmmo:= 0;
   229         CurAmmo:= 0;
   230         while (CurAmmo <= cMaxSlotAmmoIndex) and (Ammo[CurSlot, CurAmmo].Count = 0) do inc(CurAmmo)
   230         while (CurAmmo <= cMaxSlotAmmoIndex) and (Ammo[CurSlot, CurAmmo].Count = 0) do inc(CurAmmo)
   257 begin
   257 begin
   258     repeat
   258     repeat
   259       b:= false;
   259       b:= false;
   260       ami:= 0;
   260       ami:= 0;
   261       while (not b) and (ami < cMaxSlotAmmoIndex) do
   261       while (not b) and (ami < cMaxSlotAmmoIndex) do
   262           if (Ammo[slot, ami].Count = 0)
   262           if (Ammo[Slot, ami].Count = 0)
   263              and (Ammo[slot, ami + 1].Count > 0) then b:= true
   263              and (Ammo[Slot, ami + 1].Count > 0) then b:= true
   264                                                  else inc(ami);
   264                                                  else inc(ami);
   265       if b then // есть пустое место
   265       if b then // есть пустое место
   266          begin
   266          begin
   267          Ammo[slot, ami]:= Ammo[slot, ami + 1]
   267          Ammo[Slot, ami]:= Ammo[Slot, ami + 1]
   268          end
   268          end
   269     until not b;
   269     until not b;
   270 end;
   270 end;
   271 
   271 
   272 procedure OnUsedAmmo(Ammo: PHHAmmo);
   272 procedure OnUsedAmmo(Ammo: PHHAmmo);