hedgewars/uAmmos.pas
changeset 2716 b9ca1bfca24f
parent 2715 0e4e0db79e2a
child 2730 f56592281526
equal deleted inserted replaced
2715:0e4e0db79e2a 2716:b9ca1bfca24f
    20 
    20 
    21 unit uAmmos;
    21 unit uAmmos;
    22 interface
    22 interface
    23 uses uConsts, uTeams;
    23 uses uConsts, uTeams;
    24 
    24 
       
    25 procedure init_uAmmos;
    25 procedure free_uAmmos;
    26 procedure free_uAmmos;
       
    27 
    26 procedure AddAmmoStore(s: shortstring);
    28 procedure AddAmmoStore(s: shortstring);
    27 procedure AssignStores;
    29 procedure AssignStores;
    28 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
    30 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
    29 function  HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): boolean;
    31 function  HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): boolean;
    30 procedure PackAmmo(Ammo: PHHAmmo; Slot: LongInt);
    32 procedure PackAmmo(Ammo: PHHAmmo; Slot: LongInt);
    33 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
    35 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
    34 procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog);
    36 procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog);
    35 procedure SetWeapon(weap: TAmmoType);
    37 procedure SetWeapon(weap: TAmmoType);
    36 procedure DisableSomeWeapons;
    38 procedure DisableSomeWeapons;
    37 
    39 
    38 var shoppa: Boolean = false;
    40 var shoppa: boolean;
    39 
    41 
    40 implementation
    42 implementation
    41 uses uMisc, uGears, uWorld, uLocale, uConsole;
    43 uses uMisc, uGears, uWorld, uLocale, uConsole;
       
    44 
    42 type TAmmoCounts = array[TAmmoType] of Longword;
    45 type TAmmoCounts = array[TAmmoType] of Longword;
    43 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
    46 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
    44     StoreCnt: Longword = 0;
    47     StoreCnt: Longword;
    45 
    48 
    46 procedure FillAmmoStore(Ammo: PHHAmmo; var cnts: TAmmoCounts);
    49 procedure FillAmmoStore(Ammo: PHHAmmo; var cnts: TAmmoCounts);
    47 var mi: array[0..cMaxSlotIndex] of byte;
    50 var mi: array[0..cMaxSlotIndex] of byte;
    48     a: TAmmoType;
    51     a: TAmmoType;
    49 begin
    52 begin
   315 
   318 
   316 for t:= Low(TAmmoType) to High(TAmmoType) do
   319 for t:= Low(TAmmoType) to High(TAmmoType) do
   317 	if (Ammoz[t].Ammo.Propz and ammoprop_NotBorder) <> 0 then Ammoz[t].Probability:= 0
   320 	if (Ammoz[t].Ammo.Propz and ammoprop_NotBorder) <> 0 then Ammoz[t].Probability:= 0
   318 end;
   321 end;
   319 
   322 
       
   323 procedure init_uAmmos;
       
   324 begin
       
   325 	shoppa:= false;
       
   326 	StoreCnt:= 0
       
   327 end;
       
   328 
   320 procedure free_uAmmos;
   329 procedure free_uAmmos;
   321 var i: LongWord;
   330 var i: LongWord;
   322 begin
   331 begin
   323 for i:= 0 to Pred(StoreCnt) do Dispose(StoresList[i]);
   332 	for i:= 0 to Pred(StoreCnt) do Dispose(StoresList[i]);
   324 StoreCnt:= 0
   333 	StoreCnt:= 0
   325 end;
   334 end;
   326 
   335 
   327 end.
   336 end.