# HG changeset patch # User Wuzzy # Date 1547679035 -3600 # Node ID 03033213e800df066ae783196f6740a03df2136a # Parent 7c5a9c1b9d4edc5313ee5af69776ef539b80053f Lua: Fix SetAmmoDelay not working properly when called after initialization diff -r 7c5a9c1b9d4e -r 03033213e800 ChangeLog.txt --- a/ChangeLog.txt Wed Jan 16 23:43:23 2019 +0100 +++ b/ChangeLog.txt Wed Jan 16 23:50:35 2019 +0100 @@ -82,6 +82,7 @@ + SpeedShoppa/TargetPractice libraries: Remove custom hog and team info settings + Params explode, poison in the SpawnFake*Crate functions now optional and default to false + New global: InitHealth: Initial hog health value from game scheme (read-only) + * Fix SetAmmoDelay not working properly when called after onGameStart ====================== 0.9.25 ====================== HIGHLIGHTS: diff -r 7c5a9c1b9d4e -r 03033213e800 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Wed Jan 16 23:43:23 2019 +0100 +++ b/hedgewars/uScript.pas Wed Jan 16 23:50:35 2019 +0100 @@ -109,7 +109,7 @@ procedure ScriptPrepareAmmoStore; forward; procedure ScriptApplyAmmoStore; forward; procedure ScriptSetAmmo(ammo : TAmmoType; count, probability, delay, reinforcement: Byte); forward; -procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: Byte); forward; +procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: LongWord); forward; var LuaDebugInfo: lua_Debug; @@ -4097,17 +4097,22 @@ ScriptAmmoReinforcement[ord(ammo)]:= inttostr(reinforcement)[1]; end; -procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: Byte); +procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: LongWord); begin // change loadout string if ammo store has not been initialized yet if (StoreCnt = 0) then -begin + begin if (delay <= 9) then ScriptAmmoDelay[ord(ammo)]:= inttostr(delay)[1]; -end + end // change 'live' delay values else if (CurrentTeam <> nil) then - ammoz[ammo].SkipTurns:= CurrentTeam^.Clan^.TurnNumber + delay; + begin + ammoz[ammo].SkipTurns:= CurrentTeam^.Clan^.TurnNumber + delay; + if ammoz[ammo].SkipTurns > 0 then + dec(ammoz[ammo].SkipTurns); + AmmoMenuInvalidated:= true; + end; end; procedure ScriptApplyAmmoStore;