# HG changeset patch # User Wuzzy # Date 1524323862 -7200 # Node ID 85644a45e988b2e1c51d92b883b0c02c83c267a2 # Parent 450e37b2b4d44ee06103ab42c3b83f2cbd289ed1 New Lua call: Retreat, to force turn into Retreat time diff -r 450e37b2b4d4 -r 85644a45e988 ChangeLog.txt --- a/ChangeLog.txt Thu Apr 19 15:48:00 2018 +0200 +++ b/ChangeLog.txt Sat Apr 21 17:17:42 2018 +0200 @@ -1,5 +1,9 @@ + features * bugfixes +====================== 0.9.25 ====================== +Lua API: + + New call: Retreat(time [, respectGetAwayTimeFactor): Force current turn into retreating mode + ====================== 0.9.24.1 ==================== * Fix crash when portable portal device is fired at reduced graphics quality * Fix possible crash when starting Hedgewars frontend in fullscreen mode diff -r 450e37b2b4d4 -r 85644a45e988 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Thu Apr 19 15:48:00 2018 +0200 +++ b/hedgewars/uScript.pas Sat Apr 21 17:17:42 2018 +0200 @@ -1926,6 +1926,35 @@ lc_endturn:= 0 end; +function lc_retreat(L : Plua_State) : LongInt; Cdecl; +var n, time: LongInt; + respectFactor: Boolean; +const + call = 'Retreat'; + params = 'time [, respectGetAwayTimeFactor]'; +begin + if CheckAndFetchParamCount(L, 1, 2, call, params, n) then + begin + IsGetAwayTime:= true; + AttackBar:= 0; + time:= Trunc(lua_tonumber(L, 1)); + if n = 2 then + respectFactor:= lua_toboolean(L, 2) + else + respectFactor:= True; + if respectFactor then + TurnTimeLeft:= (time * cGetAwayTime) div 100 + else + TurnTimeLeft:= time; + if ((CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil)) then + begin + CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstAttacked; + CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and (not gstAttacking); + end; + end; + lc_retreat:= 0 +end; + function lc_skipturn(L : Plua_State): LongInt; Cdecl; begin L:= L; // avoid compiler hint @@ -3830,6 +3859,7 @@ lua_register(luaState, _P'GetGearType', @lc_getgeartype); lua_register(luaState, _P'EndGame', @lc_endgame); lua_register(luaState, _P'EndTurn', @lc_endturn); +lua_register(luaState, _P'Retreat', @lc_retreat); lua_register(luaState, _P'SkipTurn', @lc_skipturn); lua_register(luaState, _P'GetTeamStats', @lc_getteamstats); lua_register(luaState, _P'SendStat', @lc_sendstat);