hedgewars/uAmmos.pas
changeset 10015 4feced261c68
parent 9998 736015b847e3
parent 9950 2759212a27de
child 10105 8c5fa1d15bd5
equal deleted inserted replaced
10014:56d2f2d5aad8 10015:4feced261c68
    48 function  GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo;
    48 function  GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo;
    49 
    49 
    50 var StoreCnt: Longword;
    50 var StoreCnt: Longword;
    51 
    51 
    52 implementation
    52 implementation
    53 uses uLocale, uVariables, uCommands, uUtils, uCaptions, uDebug;
    53 uses uVariables, uCommands, uUtils, uCaptions, uDebug;
    54 
    54 
    55 type TAmmoCounts = array[TAmmoType] of Longword;
    55 type TAmmoCounts = array[TAmmoType] of Longword;
    56      TAmmoArray = array[TAmmoType] of TAmmo;
    56      TAmmoArray = array[TAmmoType] of TAmmo;
    57 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
    57 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
    58     ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring;
    58     ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring;
   130         and (a <> amTeleport) and (a <> amSkip)
   130         and (a <> amTeleport) and (a <> amSkip)
   131         and (Ammoz[a].SkipTurns < 10000) then
   131         and (Ammoz[a].SkipTurns < 10000) then
   132             inc(Ammoz[a].SkipTurns,10000);
   132             inc(Ammoz[a].SkipTurns,10000);
   133     if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
   133     if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
   134         ammos[a]:= AMMO_INFINITE
   134         ammos[a]:= AMMO_INFINITE
   135         end 
   135         end
   136         
   136 
   137     else
   137     else
   138         ammos[a]:= AMMO_INFINITE;
   138         ammos[a]:= AMMO_INFINITE;
   139     if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then 
   139     if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
   140         InitialCounts[Pred(StoreCnt)][a]:= cnt
   140         InitialCounts[Pred(StoreCnt)][a]:= cnt
   141     else
   141     else
   142         InitialCounts[Pred(StoreCnt)][a]:= ammos[a];
   142         InitialCounts[Pred(StoreCnt)][a]:= ammos[a];
   143     end;
   143     end;
   144     
   144 
   145     for a:= Low(TAmmoType) to High(TAmmoType) do
   145     for a:= Low(TAmmoType) to High(TAmmoType) do
   146         begin
   146         begin
   147         newAmmos[a]:= Ammoz[a].Ammo;
   147         newAmmos[a]:= Ammoz[a].Ammo;
   148         newAmmos[a].Count:= ammos[a]
   148         newAmmos[a].Count:= ammos[a]
   149         end;
   149         end;
   150         
   150 
   151 FillAmmoStore(StoresList[Pred(StoreCnt)], newAmmos)
   151 FillAmmoStore(StoresList[Pred(StoreCnt)], newAmmos)
   152 end;
   152 end;
   153 
   153 
   154 function GetAmmoByNum(num: Longword): PHHAmmo;
   154 function GetAmmoByNum(num: Longword): PHHAmmo;
   155 begin
   155 begin
   270         if b then // there is a free item in ammo stack
   270         if b then // there is a free item in ammo stack
   271             begin
   271             begin
   272             Ammo^[Slot, ami]:= Ammo^[Slot, ami + 1];
   272             Ammo^[Slot, ami]:= Ammo^[Slot, ami + 1];
   273             Ammo^[Slot, ami + 1].Count:= 0
   273             Ammo^[Slot, ami + 1].Count:= 0
   274             end;
   274             end;
   275     until not b;
   275     until (not b);
   276 AmmoMenuInvalidated:= true;
   276 AmmoMenuInvalidated:= true;
   277 end;
   277 end;
   278 
   278 
   279 procedure OnUsedAmmo(var Hedgehog: THedgehog);
   279 procedure OnUsedAmmo(var Hedgehog: THedgehog);
   280 var CurWeapon: PAmmo;
   280 var CurWeapon: PAmmo;
   309     begin
   309     begin
   310         with Hedgehog.Ammo^[Slot, ami] do
   310         with Hedgehog.Ammo^[Slot, ami] do
   311             if (AmmoType = Ammo) then
   311             if (AmmoType = Ammo) then
   312                 if Hedgehog.Team^.Clan^.TurnNumber > Ammoz[AmmoType].SkipTurns then
   312                 if Hedgehog.Team^.Clan^.TurnNumber > Ammoz[AmmoType].SkipTurns then
   313                     exit(Count)
   313                     exit(Count)
   314                 else 
   314                 else
   315                     exit(0);
   315                     exit(0);
   316         inc(ami)
   316         inc(ami)
   317     end;
   317     end;
   318 end;
   318 end;
   319 
   319 
   480         for i:= 0 to cMaxHHIndex do
   480         for i:= 0 to cMaxHHIndex do
   481             Hedgehogs[i].CurAmmoType:= amNothing;
   481             Hedgehogs[i].CurAmmoType:= amNothing;
   482 
   482 
   483 for a:= Low(TAmmoType) to High(TAmmoType) do
   483 for a:= Low(TAmmoType) to High(TAmmoType) do
   484     newAmmos[a]:= Ammoz[a].Ammo;
   484     newAmmos[a]:= Ammoz[a].Ammo;
   485     
   485 
   486 for i:= 0 to Pred(StoreCnt) do
   486 for i:= 0 to Pred(StoreCnt) do
   487     begin
   487     begin
   488     for a:= Low(TAmmoType) to High(TAmmoType) do
   488     for a:= Low(TAmmoType) to High(TAmmoType) do
   489         newAmmos[a].Count:= InitialCounts[i][a];
   489         newAmmos[a].Count:= InitialCounts[i][a];
   490     FillAmmoStore(StoresList[i], newAmmos);
   490     FillAmmoStore(StoresList[i], newAmmos);
   497 
   497 
   498 
   498 
   499 
   499 
   500 procedure chAddAmmoStore(var descr: shortstring);
   500 procedure chAddAmmoStore(var descr: shortstring);
   501 begin
   501 begin
   502 descr:= ''; // avoid compiler hint
   502     descr:= ''; // avoid compiler hint
   503 AddAmmoStore
   503     AddAmmoStore
   504 end;
   504 end;
   505 
   505 
   506 procedure initModule;
   506 procedure initModule;
   507 var i: Longword;
   507 var i: Longword;
   508 begin
   508 begin