Commit graph

111 commits

Author SHA1 Message Date
MontyTRC89
88de21198a Merge branch 'master' into displaystrings 2021-09-14 05:11:43 +02:00
Lwmte
744325bea2 Revert "Fix regressions"
This reverts commit c1fc33ab52.
2021-09-11 10:13:04 +03:00
Lwmte
c1fc33ab52 Fix regressions 2021-09-11 09:41:29 +03:00
MontyTRC89
8db7df3868 Merge branch 'doors_refactoring'
# Conflicts:
#	TR5Main/Game/door.cpp
#	TR5Main/Game/door.h
#	TR5Main/Game/memory/malloc.cpp
#	TR5Main/Objects/Generic/Switches/cog_switch.cpp
#	TR5Main/Objects/Generic/Switches/crowbar_switch.cpp
#	TR5Main/Objects/Generic/Switches/generic_switch.h
#	TR5Main/Objects/Generic/Switches/turn_switch.cpp
#	TR5Main/Objects/TR4/Object/tr4_obelisk.cpp
#	TR5Main/Renderer/Renderer11Draw.cpp
#	TR5Main/Specific/level.cpp
#	TR5Main/TombEngine.vcxproj
#	TR5Main/TombEngine.vcxproj.filters
2021-09-11 05:38:26 +02:00
Lwmte
48a9a1d52a Merge branch 'master' into item_data 2021-09-09 11:10:25 +03:00
Lwmte
ba6c260b92 Further code organizing 2021-09-08 18:19:06 +03:00
Lwmte
f293735d11 Move all effect source files to separate directory, rename effect2 to effects 2021-09-08 18:07:48 +03:00
hispidence
88c31503ca Add this comment to remind myself to think about stuff when implementing loading/saving. 2021-08-31 13:25:42 +01:00
hispidence
70cc036605 Make SetLevelFunc and GetLevelFunc only store the function in m_levelFuncs.
Store the function in m_levelFuncs instead of the table itself.
2021-08-30 18:21:42 +01:00
hispidence
fa5a6fd443 Add DisplayString "flags" and "translated" support, as well as some things I forgot to commit earlier. 2021-08-29 20:25:54 +01:00
hispidence
9a1831bc8f Remove PrintString; it has been "replaced" with DisplayString/AddString. 2021-08-29 20:11:29 +01:00
hispidence
8c1e290683 Rename AddDisplayString to SetDisplayString. Make it call insert_or_assign instead of just insert.
Add GetDisplayString and assorted types/static functions.
2021-08-29 20:09:59 +01:00
hispidence
3d1f2abd0b Add ScreenToPercent and PercentToScreen. 2021-08-29 20:03:51 +01:00
hispidence
d946f4c118 Add more reserved script names. 2021-08-29 17:03:51 +01:00
Raildex
2621fa8f0d Fixed More Include Hell 2021-08-28 13:27:58 +02:00
hispidence
434b1f146e Change PrintString arg names to better reflect what it does. 2021-08-27 19:08:28 +01:00
hispidence
e63153cc88 Implement ShowString, HideString, and PrintString. 2021-08-27 18:56:35 +01:00
hispidence
5a5ca519dc Replace Get*ByName with GetByName, AddLuaName* with AddName, and RemoveLuaName* with RemoveName. Replace m_*MapName with m_nameMap. Use a std::variant for the types that m_nameMap elements could be. Modify SetNameCallbacks params to be variadic. These do make it look more complex, but also make it more generic, and mean that specific parameters do not need to be repeated (which will make it easier if/when we change said parameters). 2021-08-27 18:21:37 +01:00
hispidence
578724a9c6 Set callbacks to nil and collect garbage when unloading level. 2021-08-27 12:46:01 +01:00
hispidence
770a791c0d Make ExecuteFunction print a better error message with the name of the function. 2021-08-23 22:07:18 +01:00
hispidence
cb1ad16b2d Remove more vestiges of old trigger system. Replace TO_LUA_SCRIPT with the enum that used to be there - TO_BODYBAG - so that the following enums still have their same values. 2021-08-23 22:05:58 +01:00
hispidence
bc9e863307 Give documentation comments new tag names. Part 2 of making the documentation better. 2021-08-23 19:16:24 +01:00
hispidence
9bf5c361e2 Clean up GameLogicScript.
Add some new member functions, ResetLevelTables and GetLevelFunc. The former is called in FreeLevelScripts, which is now called in control.cpp.

Remove AddTrigger, as the LevelFuncs table takes care of triggers.
2021-08-23 02:02:47 +01:00
hispidence
07a756a369 Remove some unused includes. 2021-08-17 14:23:47 +01:00
hispidence
93117c56a3 Fix some documentation. 2021-08-12 22:11:50 +01:00
hispidence
adcee07c68 Fix some GameLogic documentation. 2021-08-12 20:14:40 +01:00
hispidence
c8de277d44 Remove GetLara as the Lara object is easier to use.
Add documentation for the Lara object.
2021-08-12 20:14:02 +01:00
hispidence
cd16268e19 Actually add documentation. 2021-08-12 19:58:22 +01:00
hispidence
3efa8f16b7 Take CalculateDistance and CalculateHorizontalDistance out of header file as they can be static now.
Add documentation for said functions.
2021-08-12 19:57:17 +01:00
hispidence
53cd3add4f Register CalculateDistance and CalculateHorizontalDistance in GameLogicScript. 2021-08-12 19:54:03 +01:00
hispidence
582b000fb9 Make OnControlPhase take a float, representing the delta time.
This is not ACTUALLY the amount of time that has passed, since things in the gameplay loop appear to assume they are being called thirty times per second, even if more or less time has passed. Thus to keep the scripts in sync with the the rest of the engine, we force a 1/30 second delta time.
2021-08-12 18:20:14 +01:00
hispidence
adf1361d99 Fix documentation; Level -> LevelVars. 2021-08-12 02:43:59 +01:00
hispidence
ea1649b7b1 Make "loop" arg to PlayAudioTrack optional; defaulting to false. 2021-08-12 02:39:29 +01:00
hispidence
b708a6068d Add comments and update documentation for InventoryAdd/InventoryRemove. 2021-08-12 02:38:30 +01:00
hispidence
c1b46afd62 Rename Lua tables Game and Level to GameVars and LevelVars to disambiguate the latter from the Level class. 2021-08-12 00:39:52 +01:00
hispidence
156342ca14 Register GameScriptRotation in GameFlowScript and not GameLogicScript. 2021-08-11 01:26:35 +01:00
hispidence
7300193b47 More cleanup. 2021-08-09 00:54:09 +01:00
hispidence
61d9e00e63 Change InventoryAdd/Remove/GetCount/SetCount and GameScriptInventoryObject to use ItemEnumPair. 2021-08-09 00:01:40 +01:00
hispidence
05054a05fe Make the read-only table of kInventorySlots in GameFlowScript instead of GameLogicScript. 2021-08-08 23:53:52 +01:00
hispidence
4a2e61fcbc Don't register Color in GameScript (it's in GameFlow now). 2021-08-07 19:14:11 +01:00
hispidence
2d4c091b64 Make MakeReadOnlyTable a member function of LuaHandler so that GameFlow can use it too. 2021-08-07 19:00:45 +01:00
hispidence
7bc9e7b935 Replace a TENLog call with ScriptWarn, so that it won't get logged in ERROR_MODE::SILENT. 2021-08-06 16:48:03 +01:00
hispidence
dc40060a63 Make m_levelFuncs an unordered_set, as these seem to be the proper structure to use when the key IS the value.
Make all GameScript maps unordered_maps, as these are supposed to be more suitable for cases where we don't need the data to be sorted.

Add default member initialisers to GameScript.
2021-08-06 16:47:24 +01:00
hispidence
354b21d4f4 Add m_levelFuncs and SetLevelFunc. These correspond to the table "LevelFuncs", which will hold trigger functions and the OnStart (etc) callbacks. Putting them into a table will make it much easier to discard them when the player goes from one level to another (through loading a save or finishing the current level).
Rework Level and Game tables as they weren't entirely working before. These correspond to m_locals and m_globals, which hold the level-specific and game-spanning data that will go into save files.

Make GetVariable and SetVariable take sol::table args. Sol seems to require this in order to use them as metamethods of a table (it doesn't require them for usertypes, but it seems more logical from the API point of view for Level and Game to be tables).

Add documentation for the above tables.

Move several functions out of the GameScript class in order to simplify its interface, and make them static functions that only live in GameLogicScript.cpp.

Remove g_GameScript from GameLogicScript.cpp as it's not used there; let winmain.cpp deal with it instead.
2021-08-05 21:36:18 +01:00
hispidence
1d1653f995 Replace WarningsAsErrors usage with ScriptAssert usage.
For recoverable errors, add some recovery behaviour and logging so a level designer can see in the log what was done as a result of the error.

Warn about default behaviour if no callbacks are added.
2021-08-04 16:51:28 +01:00
hispidence
5929180395 Remove AddLuaId and GetItemById. 2021-08-04 16:21:00 +01:00
hispidence
a637701d63 Replace std::runtime_exception with TENScriptException. 2021-08-03 15:15:42 +01:00
hispidence
e6c076eb41 Move GameScriptLevel, GameScriptAudioTrack, GameScriptInventoryObject, GameScriptSkyLayer, GameScriptSettings and GameScriptMirror into their own files. This could be changed later as this does create many small .h and .cpp files, but for now this cleans things up and makes it easier to check things class by class.
Treat functions as global that would previously be accessed through the GameFlow table. This does pollute the global environment in Lua a bit, but keeps it consistent with the functions in GameLogicScript, which are all accessed as globals.

Add some default member initialisers.

Remove WriteDefaults. Rename Intro to IntroImagePath and make it a std::string.

Add some documentation for the functions of GameFlowScript.

Fix some comments.
2021-07-28 18:44:24 +01:00
hispidence
783d344185 Add SOUND_SOURCE_INFO and AI_OBJECT names when loading in the level data. Implement remaining functions on the GameLogicScript side. 2021-07-24 12:45:33 +01:00
hispidence
447ba86d30 Add GameScriptSoundSourceInfo and GameScriptAIObject, and associated functions. 2021-07-24 12:29:25 +01:00