hedgewars/uAmmos.pas
changeset 2357 babe1a55e284
parent 2246 4f138785a3ff
child 2360 d4d545da9dbe
equal deleted inserted replaced
2356:b756432fd422 2357:babe1a55e284
    61 var cnt: Longword;
    61 var cnt: Longword;
    62     a: TAmmoType;
    62     a: TAmmoType;
    63     ammos: TAmmoCounts;
    63     ammos: TAmmoCounts;
    64     substr: shortstring; // TEMPORARY
    64     substr: shortstring; // TEMPORARY
    65 begin
    65 begin
    66 TryDo(byte(s[0]) = byte(ord(High(TAmmoType)) + 1), 'Invalid ammo scheme (incompatible frontend)', true);
    66 TryDo(byte(s[0]) = byte(ord(High(TAmmoType))), 'Invalid ammo scheme (incompatible frontend)', true);
    67 
    67 
    68 // FIXME - TEMPORARY hardcoded check on shoppa pending creation of probability editor
    68 // FIXME - TEMPORARY hardcoded check on shoppa pending creation of probability editor
    69 substr:= Copy(s,1,15);
    69 substr:= Copy(s,1,15);
    70 if (substr = '000000990000009') or 
    70 if (substr = '000000990000009') or 
    71    (substr = '000000990000000') then
    71    (substr = '000000990000000') then
    72     shoppa:= true;
    72     shoppa:= true;
    73 for a:= Low(TAmmoType) to High(TAmmoType) do
    73 for a:= Low(TAmmoType) to High(TAmmoType) do
    74     if (ord(a) > 14) and (s[ord(a)+1] <> '0') then shoppa:= false;  // TEMPORARY etc - this just avoids updating every time new wep is added
    74     if (ord(a) > 14) and (s[ord(a)] <> '0') then shoppa:= false;  // TEMPORARY etc - this just avoids updating every time new wep is added
    75 inc(StoreCnt);
    75 inc(StoreCnt);
    76 TryDo(StoreCnt <= cMaxHHs, 'Ammo stores overflow', true);
    76 TryDo(StoreCnt <= cMaxHHs, 'Ammo stores overflow', true);
    77 
    77 
    78 new(StoresList[Pred(StoreCnt)]);
    78 new(StoresList[Pred(StoreCnt)]);
    79 
    79 
    80 for a:= Low(TAmmoType) to High(TAmmoType) do
    80 for a:= Low(TAmmoType) to High(TAmmoType) do
    81     begin
    81     begin
    82     cnt:= byte(s[ord(a) + 1]) - byte('0');
    82     if a <> amNothing then
    83     if cnt = 9 then
       
    84         begin
    83         begin
    85         cnt:= AMMO_INFINITE;
    84         cnt:= byte(s[ord(a)]) - byte('0');
    86         Ammoz[a].Probability:= 0 
    85         if cnt = 9 then
    87         end;
    86             begin
    88     if ((a = amLowGravity) and ((GameFlags and gfLowGravity) <> 0)) or
    87             cnt:= AMMO_INFINITE;
    89        ((a = amInvulnerable) and ((GameFlags and gfInvulnerable) <> 0)) or
    88             Ammoz[a].Probability:= 0 
    90        ((a = amLaserSight) and ((GameFlags and gfLaserSight) <> 0)) or
    89             end;
    91        ((a = amVampiric) and ((GameFlags and gfVampiric) <> 0)) then
    90         if ((a = amLowGravity) and ((GameFlags and gfLowGravity) <> 0)) or
    92         begin
    91            ((a = amInvulnerable) and ((GameFlags and gfInvulnerable) <> 0)) or
    93         cnt:= 0;
    92            ((a = amLaserSight) and ((GameFlags and gfLaserSight) <> 0)) or
    94         Ammoz[a].Probability:= 0 
    93            ((a = amVampiric) and ((GameFlags and gfVampiric) <> 0)) then
       
    94             begin
       
    95             cnt:= 0;
       
    96             Ammoz[a].Probability:= 0 
       
    97             end
       
    98         else if shoppa then      // FIXME - TEMPORARY REMOVE WHEN CRATE PROBABILITY IS ADDED
       
    99             if cnt <> AMMO_INFINITE then
       
   100                 begin
       
   101                 if a = amGirder then
       
   102                     Ammoz[a].Probability:= 0
       
   103                 else
       
   104                     begin
       
   105                     Ammoz[a].Probability:= 100;
       
   106                     Ammoz[a].NumberInCase:= 1;
       
   107                     end
       
   108                 end;
       
   109         ammos[a]:= cnt
    95         end
   110         end
    96     else if shoppa then      // FIXME - TEMPORARY REMOVE WHEN CRATE PROBABILITY IS ADDED
       
    97         if cnt <> AMMO_INFINITE then
       
    98             begin
       
    99             if a = amGirder then
       
   100                 Ammoz[a].Probability:= 0
       
   101             else
       
   102                 begin
       
   103                 Ammoz[a].Probability:= 100;
       
   104                 Ammoz[a].NumberInCase:= 1;
       
   105                 end
       
   106             end;
       
   107     ammos[a]:= cnt
       
   108     end;
   111     end;
   109 
   112 
   110 FillAmmoStore(StoresList[Pred(StoreCnt)], ammos)
   113 FillAmmoStore(StoresList[Pred(StoreCnt)], ammos)
   111 end;
   114 end;
   112 
   115 
   236 
   239 
   237 	ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType);
   240 	ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType);
   238 
   241 
   239 	with Ammo^[CurSlot, CurAmmo] do
   242 	with Ammo^[CurSlot, CurAmmo] do
   240 		begin
   243 		begin
   241 		s:= trammo[Ammoz[AmmoType].NameId];
   244         if AmmoType <> amNothing then
   242 		if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then
   245             begin
   243 			s:= s + ' (' + IntToStr(Count) + ')';
   246 		    s:= trammo[Ammoz[AmmoType].NameId];
   244 		if (Propz and ammoprop_Timerable) <> 0 then
   247 		    if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then
   245 			s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds];
   248 			    s:= s + ' (' + IntToStr(Count) + ')';
   246 		AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
   249 		    if (Propz and ammoprop_Timerable) <> 0 then
       
   250 			    s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds];
       
   251 		    AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
       
   252             end;
   247 		if (Propz and ammoprop_NeedTarget) <> 0
   253 		if (Propz and ammoprop_NeedTarget) <> 0
   248 			then begin
   254 			then begin
   249 			Gear^.State:= Gear^.State or      gstHHChooseTarget;
   255 			Gear^.State:= Gear^.State or      gstHHChooseTarget;
   250 			isCursorVisible:= true
   256 			isCursorVisible:= true
   251 			end else begin
   257 			end else begin