hedgewars/uAmmos.pas
changeset 4436 94c948a92759
parent 4403 0dfe26f48ec1
child 4807 180dbfb13903
equal deleted inserted replaced
4366:d19adc635c99 4436:94c948a92759
    18 
    18 
    19 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    20 
    20 
    21 unit uAmmos;
    21 unit uAmmos;
    22 interface
    22 interface
    23 uses uConsts, uTeams;
    23 uses uConsts, uTypes;
    24 
    24 
    25 procedure initModule;
    25 procedure initModule;
    26 procedure freeModule;
    26 procedure freeModule;
    27 
    27 
    28 procedure AddAmmoStore;
    28 procedure AddAmmoStore;
    45 function  GetAmmoEntry(var Hedgehog: THedgehog): PAmmo;
    45 function  GetAmmoEntry(var Hedgehog: THedgehog): PAmmo;
    46 
    46 
    47 var StoreCnt: Longword;
    47 var StoreCnt: Longword;
    48 
    48 
    49 implementation
    49 implementation
    50 uses uMisc, uGears, uWorld, uLocale, uConsole, uMobile;
    50 uses uLocale, uMobile, uVariables, uCommands, uUtils, uCaptions, uDebug;
    51 
    51 
    52 type TAmmoCounts = array[TAmmoType] of Longword;
    52 type TAmmoCounts = array[TAmmoType] of Longword;
    53 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
    53 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
    54     ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring;
    54     ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring;
    55     InitialCounts: array[0..Pred(cMaxHHs)] of TAmmoCounts;
    55     InitialCounts: array[0..Pred(cMaxHHs)] of TAmmoCounts;
   324             begin
   324             begin
   325             s:= trammo[Ammoz[AmmoType].NameId];
   325             s:= trammo[Ammoz[AmmoType].NameId];
   326             if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then
   326             if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then
   327                 s:= s + ' (' + IntToStr(Count) + ')';
   327                 s:= s + ' (' + IntToStr(Count) + ')';
   328             if (Propz and ammoprop_Timerable) <> 0 then
   328             if (Propz and ammoprop_Timerable) <> 0 then
   329                 s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds];
   329                 s:= s + ', ' + IntToStr(Timer div 1000) + ' ' + trammo[sidSeconds];
   330             AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
   330             AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
   331             end;
   331             end;
   332         if (Propz and ammoprop_NeedTarget) <> 0
   332         if (Propz and ammoprop_NeedTarget) <> 0
   333             then begin
   333             then begin
   334             Gear^.State:= Gear^.State or      gstHHChooseTarget;
   334             Gear^.State:= Gear^.State or      gstHHChooseTarget;
   416 
   416 
   417 for a:= Low(TAmmoType) to High(TAmmoType) do
   417 for a:= Low(TAmmoType) to High(TAmmoType) do
   418     if Ammoz[a].SkipTurns >= 10000 then dec(Ammoz[a].SkipTurns,10000)
   418     if Ammoz[a].SkipTurns >= 10000 then dec(Ammoz[a].SkipTurns,10000)
   419 end;
   419 end;
   420 
   420 
       
   421 
       
   422 
       
   423 procedure chAddAmmoStore(var descr: shortstring);
       
   424 begin
       
   425 descr:= ''; // avoid compiler hint
       
   426 AddAmmoStore
       
   427 end;
       
   428 
   421 procedure initModule;
   429 procedure initModule;
   422 begin
   430 begin
       
   431     RegisterVariable('ammloadt', vtCommand, @SetAmmoLoadout, false);
       
   432     RegisterVariable('ammdelay', vtCommand, @SetAmmoDelay, false);
       
   433     RegisterVariable('ammprob',  vtCommand, @SetAmmoProbability, false);
       
   434     RegisterVariable('ammreinf', vtCommand, @SetAmmoReinforcement, false);
       
   435     RegisterVariable('ammstore', vtCommand, @chAddAmmoStore , false);
       
   436 
   423     StoreCnt:= 0;
   437     StoreCnt:= 0;
   424     ammoLoadout:= '';
   438     ammoLoadout:= '';
   425     ammoProbability:= '';
   439     ammoProbability:= '';
   426     ammoDelay:= '';
   440     ammoDelay:= '';
   427     ammoReinforcement:= '';
   441     ammoReinforcement:= '';