hedgewars/uAmmos.pas
changeset 1966 31e449e1d9dd
parent 1964 dc9ea05c9d2f
child 2017 7845c77c8d31
equal deleted inserted replaced
1965:340bfd438ca5 1966:31e449e1d9dd
    31 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
    31 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
    32 procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog);
    32 procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog);
    33 procedure SetWeapon(weap: TAmmoType);
    33 procedure SetWeapon(weap: TAmmoType);
    34 procedure DisableSomeWeapons;
    34 procedure DisableSomeWeapons;
    35 
    35 
       
    36 var shoppa: Boolean = false;
       
    37 
    36 implementation
    38 implementation
    37 uses uMisc, uGears, uWorld, uLocale, uConsole;
    39 uses uMisc, uGears, uWorld, uLocale, uConsole;
    38 type TAmmoCounts = array[TAmmoType] of Longword;
    40 type TAmmoCounts = array[TAmmoType] of Longword;
    39 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
    41 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
    40     StoreCnt: Longword = 0;
    42     StoreCnt: Longword = 0;
    60     a: TAmmoType;
    62     a: TAmmoType;
    61     ammos: TAmmoCounts;
    63     ammos: TAmmoCounts;
    62 begin
    64 begin
    63 TryDo(byte(s[0]) = byte(ord(High(TAmmoType)) + 1), 'Invalid ammo scheme (incompatible frontend)', true);
    65 TryDo(byte(s[0]) = byte(ord(High(TAmmoType)) + 1), 'Invalid ammo scheme (incompatible frontend)', true);
    64 
    66 
       
    67 // TEMPORARY hardcoded check on shoppa pending creation of probability editor
       
    68 if (s = '000000990000009000000000000000000000') or (s = '000000990000000000000000000000000000') then
       
    69     shoppa:= true;
    65 inc(StoreCnt);
    70 inc(StoreCnt);
    66 TryDo(StoreCnt <= cMaxHHs, 'Ammo stores overflow', true);
    71 TryDo(StoreCnt <= cMaxHHs, 'Ammo stores overflow', true);
    67 
    72 
    68 new(StoresList[Pred(StoreCnt)]);
    73 new(StoresList[Pred(StoreCnt)]);
    69 
    74 
    79        ((a = amInvulnerable) and ((GameFlags and gfInvulnerable) <> 0)) or
    84        ((a = amInvulnerable) and ((GameFlags and gfInvulnerable) <> 0)) or
    80        ((a = amLaserSight) and ((GameFlags and gfLaserSight) <> 0)) then
    85        ((a = amLaserSight) and ((GameFlags and gfLaserSight) <> 0)) then
    81         begin
    86         begin
    82         cnt:= 0;
    87         cnt:= 0;
    83         Ammoz[a].Probability:= 0 
    88         Ammoz[a].Probability:= 0 
    84         end;
    89         end
       
    90     else if shoppa then      // TEMPORARY REMOVE WHEN CRATE PROBABILITY IS ADDED
       
    91         if not cnt = AMMO_INFINITE then
       
    92             Ammoz[a].Probability:= 100;
    85     ammos[a]:= cnt
    93     ammos[a]:= cnt
    86     end;
    94     end;
    87 
    95 
    88 FillAmmoStore(StoresList[Pred(StoreCnt)], ammos)
    96 FillAmmoStore(StoresList[Pred(StoreCnt)], ammos)
    89 end;
    97 end;