Lua API: SetCinematicMode(enable)
authorsheepluva
Sat, 23 Jan 2016 08:11:14 +0100
changeset 11525 663ecfb05df6
parent 11524 aab4767d9a50
child 11526 dc36fad455f4
Lua API: SetCinematicMode(enable)
ChangeLog.txt
hedgewars/uScript.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/ChangeLog.txt	Sat Jan 23 07:53:57 2016 +0100
+++ b/ChangeLog.txt	Sat Jan 23 08:11:14 2016 +0100
@@ -12,6 +12,8 @@
  * Fixed screenshots being too bright if taken in quick succession
  * Fixed hog-speech missing a response type (Justyouwait/"You're gonna pay for that") on some platforms (e.g. Linux)
  * Various other fixes
+Lua-API:
+ + New call: SetCinematicMode(enable) -- e.g. for cutscenes etc.
 
 0.9.21 -> 0.9.22
  + New Weapon / Map object: AirMine (floating mine that will follow nearby hedgehogs)
--- a/hedgewars/uScript.pas	Sat Jan 23 07:53:57 2016 +0100
+++ b/hedgewars/uScript.pas	Sat Jan 23 08:11:14 2016 +0100
@@ -440,6 +440,20 @@
     lc_setweapon:= 0;
 end;
 
+// enable/disable cinematic effects
+function lc_setcinematicmode(L : Plua_State) : LongInt; Cdecl;
+var at: LongInt;
+const
+    call = 'SetCinematicMode';
+    params = 'enable';
+begin
+    if (CheckLuaParamCount(L, 1, call, params)) then
+        begin
+        CinematicScript:= lua_toboolean(L, 1);
+        end;
+    lc_setcinematicmode:= 0;
+end;
+
 // no parameter means reset to default (and 0 means unlimited)
 function lc_setmaxbuilddistance(L : Plua_State) : LongInt; Cdecl;
 var np: LongInt;
@@ -3340,6 +3354,7 @@
 lua_register(luaState, _P'SetWaterLine', @lc_setwaterline);
 lua_register(luaState, _P'SetNextWeapon', @lc_setnextweapon);
 lua_register(luaState, _P'SetWeapon', @lc_setweapon);
+lua_register(luaState, _P'SetCinematicMode', @lc_setcinematicmode);
 lua_register(luaState, _P'SetMaxBuildDistance', @lc_setmaxbuilddistance);
 // drawn map functions
 lua_register(luaState, _P'AddPoint', @lc_addPoint);
--- a/hedgewars/uVariables.pas	Sat Jan 23 07:53:57 2016 +0100
+++ b/hedgewars/uVariables.pas	Sat Jan 23 08:11:14 2016 +0100
@@ -215,6 +215,7 @@
     InCinematicMode : boolean;
     CinematicSteps  : LongInt;
     CinematicBarH   : LongInt;
+    CinematicScript : boolean;
 
     UIDisplay       : TUIDisplay;
     LocalMessage    : LongWord;
@@ -2691,6 +2692,7 @@
     InCinematicMode := false;
     CinematicSteps  := 0;
     CinematicBarH   := 0;
+    CinematicScript := false;
 
     // those values still are not perfect
     cLeftScreenBorder:= round(-cMinZoomLevel * cScreenWidth);
--- a/hedgewars/uWorld.pas	Sat Jan 23 07:53:57 2016 +0100
+++ b/hedgewars/uWorld.pas	Sat Jan 23 08:11:14 2016 +0100
@@ -1383,9 +1383,9 @@
 SetScale(cDefaultZoomLevel);
 
 // cinematic effects
-if InCinematicMode
+if CinematicScript or (InCinematicMode
     and ((CurrentHedgehog = nil) or CurrentHedgehog^.Team^.ExtDriven
-    or (CurrentHedgehog^.BotLevel <> 0) or (GameType = gmtDemo)) then
+    or (CurrentHedgehog^.BotLevel <> 0) or (GameType = gmtDemo))) then
     begin
     inc(CinematicSteps, Lag);
     if CinematicSteps > 300 then