hedgewars/uScript.pas
changeset 6740 4167ebd563d9
parent 6700 e04da46ee43c
child 6741 770689c4625d
equal deleted inserted replaced
6739:97dab041f995 6740:4167ebd563d9
  1773         if StoreCnt-1 < k then AddAmmoStore;
  1773         if StoreCnt-1 < k then AddAmmoStore;
  1774         inc(k)
  1774         inc(k)
  1775         end;
  1775         end;
  1776 if ScriptExists('onAmmoStoreInit') then
  1776 if ScriptExists('onAmmoStoreInit') then
  1777     begin
  1777     begin
       
  1778     // reset ammostore (quite unclean, but works?)
       
  1779     uAmmos.freeModule;
       
  1780     uAmmos.initModule;
  1778     ScriptPrepareAmmoStore;
  1781     ScriptPrepareAmmoStore;
  1779     ScriptCall('onAmmoStoreInit');
  1782     ScriptCall('onAmmoStoreInit');
  1780     ScriptApplyAmmoStore
  1783     ScriptApplyAmmoStore
  1781     end;
  1784     end;
  1782 
  1785 
  1923 end;
  1926 end;
  1924 
  1927 
  1925 procedure ScriptPrepareAmmoStore;
  1928 procedure ScriptPrepareAmmoStore;
  1926 var i: ShortInt;
  1929 var i: ShortInt;
  1927 begin
  1930 begin
  1928 // reset ammostore (quite unclean, but works?)
       
  1929 uAmmos.freeModule;
       
  1930 uAmmos.initModule;
       
  1931 ScriptAmmoLoadout:= '';
  1931 ScriptAmmoLoadout:= '';
  1932 ScriptAmmoDelay:= '';
  1932 ScriptAmmoDelay:= '';
  1933 ScriptAmmoProbability:= '';
  1933 ScriptAmmoProbability:= '';
  1934 ScriptAmmoReinforcement:= '';
  1934 ScriptAmmoReinforcement:= '';
  1935 for i:=1 to ord(High(TAmmoType)) do
  1935 for i:=1 to ord(High(TAmmoType)) do
  1961 SetAmmoReinforcement(ScriptAmmoReinforcement);
  1961 SetAmmoReinforcement(ScriptAmmoReinforcement);
  1962 
  1962 
  1963 if (GameFlags and gfSharedAmmo) <> 0 then
  1963 if (GameFlags and gfSharedAmmo) <> 0 then
  1964     for i:= 0 to Pred(ClansCount) do
  1964     for i:= 0 to Pred(ClansCount) do
  1965         begin
  1965         begin
       
  1966         if ScriptExists('onNewAmmoStore') then
       
  1967             begin
       
  1968             ScriptPrepareAmmoStore;
       
  1969             ScriptCall('onAmmoStoreInit');
       
  1970             end;
  1966         AddAmmoStore;
  1971         AddAmmoStore;
  1967         for j:= 0 to Pred(ClansArray[i]^.TeamsNumber) do
  1972         for j:= 0 to Pred(ClansArray[i]^.TeamsNumber) do
  1968             for k:= 0 to Pred(ClansArray[i]^.Teams[j]^.HedgehogsNumber) do
  1973             for k:= 0 to Pred(ClansArray[i]^.Teams[j]^.HedgehogsNumber) do
  1969                 ClansArray[i]^.Teams[j]^.Hedgehogs[k].AmmoStore:= StoreCnt - 1
  1974                 ClansArray[i]^.Teams[j]^.Hedgehogs[k].AmmoStore:= StoreCnt - 1
  1970         end
  1975         end
  1971 else if (GameFlags and gfPerHogAmmo) <> 0 then
  1976 else if (GameFlags and gfPerHogAmmo) <> 0 then
  1972     for i:= 0 to Pred(TeamsCount) do
  1977     for i:= 0 to Pred(TeamsCount) do
  1973         for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do
  1978         for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do
  1974             begin
  1979             begin
       
  1980             if ScriptExists('onNewAmmoStore') then
       
  1981                 begin
       
  1982                 ScriptPrepareAmmoStore;
       
  1983                 ScriptCall('onAmmoStoreInit');
       
  1984                 end;
  1975             AddAmmoStore;
  1985             AddAmmoStore;
  1976             TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1
  1986             TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1
  1977             end
  1987             end
  1978 else 
  1988 else 
  1979     for i:= 0 to Pred(TeamsCount) do
  1989     for i:= 0 to Pred(TeamsCount) do
  1980         begin
  1990         begin
       
  1991         if ScriptExists('onNewAmmoStore') then
       
  1992             begin
       
  1993             ScriptPrepareAmmoStore;
       
  1994             ScriptCall('onAmmoStoreInit');
       
  1995             end;
  1981         AddAmmoStore;
  1996         AddAmmoStore;
  1982         for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do
  1997         for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do
  1983             TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1
  1998             TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1
  1984         end
  1999         end
  1985 end;
  2000 end;