# HG changeset patch # User nemo # Date 1330273292 18000 # Node ID 4167ebd563d97fc4fa8ce0fd81465bc948bf0173 # Parent 97dab041f995388a1cade08028f65ade5d1174fd Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog diff -r 97dab041f995 -r 4167ebd563d9 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Sun Feb 26 12:15:32 2012 +0400 +++ b/hedgewars/uScript.pas Sun Feb 26 11:21:32 2012 -0500 @@ -1775,6 +1775,9 @@ end; if ScriptExists('onAmmoStoreInit') then begin + // reset ammostore (quite unclean, but works?) + uAmmos.freeModule; + uAmmos.initModule; ScriptPrepareAmmoStore; ScriptCall('onAmmoStoreInit'); ScriptApplyAmmoStore @@ -1925,9 +1928,6 @@ procedure ScriptPrepareAmmoStore; var i: ShortInt; begin -// reset ammostore (quite unclean, but works?) -uAmmos.freeModule; -uAmmos.initModule; ScriptAmmoLoadout:= ''; ScriptAmmoDelay:= ''; ScriptAmmoProbability:= ''; @@ -1963,6 +1963,11 @@ if (GameFlags and gfSharedAmmo) <> 0 then for i:= 0 to Pred(ClansCount) do begin + if ScriptExists('onNewAmmoStore') then + begin + ScriptPrepareAmmoStore; + ScriptCall('onAmmoStoreInit'); + end; AddAmmoStore; for j:= 0 to Pred(ClansArray[i]^.TeamsNumber) do for k:= 0 to Pred(ClansArray[i]^.Teams[j]^.HedgehogsNumber) do @@ -1972,12 +1977,22 @@ for i:= 0 to Pred(TeamsCount) do for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do begin + if ScriptExists('onNewAmmoStore') then + begin + ScriptPrepareAmmoStore; + ScriptCall('onAmmoStoreInit'); + end; AddAmmoStore; TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1 end else for i:= 0 to Pred(TeamsCount) do begin + if ScriptExists('onNewAmmoStore') then + begin + ScriptPrepareAmmoStore; + ScriptCall('onAmmoStoreInit'); + end; AddAmmoStore; for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1