Commit graph

111 commits

Author SHA1 Message Date
MontyTRC
4f527f9b9b
Merge branch 'master' into displaystrings 2021-09-14 05:11:43 +02:00
Lwmte
37d648cfd0 Revert "Fix regressions"
This reverts commit 7faf1fb02a.
2021-09-11 10:13:04 +03:00
Lwmte
7faf1fb02a Fix regressions 2021-09-11 09:41:29 +03:00
MontyTRC89
865202b33c 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
4186dfe685 Merge branch 'master' into item_data 2021-09-09 11:10:25 +03:00
Lwmte
9af21e3146 Further code organizing 2021-09-08 18:19:06 +03:00
Lwmte
2bee1df81a Move all effect source files to separate directory, rename effect2 to effects 2021-09-08 18:07:48 +03:00
hispidence
dfef61cbe3 Add this comment to remind myself to think about stuff when implementing loading/saving. 2021-08-31 13:25:42 +01:00
hispidence
74629db9d3 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
861720dce0 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
1cde8877e4 Remove PrintString; it has been "replaced" with DisplayString/AddString. 2021-08-29 20:11:29 +01:00
hispidence
9a2d1a0f2d 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
501be9c594 Add ScreenToPercent and PercentToScreen. 2021-08-29 20:03:51 +01:00
hispidence
5e525bb545 Add more reserved script names. 2021-08-29 17:03:51 +01:00
Nils
58eda862e3 Fixed More Include Hell 2021-08-28 13:27:58 +02:00
hispidence
72f925c3bc Change PrintString arg names to better reflect what it does. 2021-08-27 19:08:28 +01:00
hispidence
a61e2fd0b0 Implement ShowString, HideString, and PrintString. 2021-08-27 18:56:35 +01:00
hispidence
68118bc9a3 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
88f056dc41 Set callbacks to nil and collect garbage when unloading level. 2021-08-27 12:46:01 +01:00
hispidence
85d37a3594 Make ExecuteFunction print a better error message with the name of the function. 2021-08-23 22:07:18 +01:00
hispidence
4f6f3b9adf 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
1cccef16b2 Give documentation comments new tag names. Part 2 of making the documentation better. 2021-08-23 19:16:24 +01:00
hispidence
ef9a74d5e0 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
6df0bb5252 Remove some unused includes. 2021-08-17 14:23:47 +01:00
hispidence
e7166b05ba Fix some documentation. 2021-08-12 22:11:50 +01:00
hispidence
62948dddb0 Fix some GameLogic documentation. 2021-08-12 20:14:40 +01:00
hispidence
3b2775203b 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
ece2dd9c38 Actually add documentation. 2021-08-12 19:58:22 +01:00
hispidence
cc5072dc64 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
0d3de8127c Register CalculateDistance and CalculateHorizontalDistance in GameLogicScript. 2021-08-12 19:54:03 +01:00
hispidence
8b7815c8a0 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
801f47704f Fix documentation; Level -> LevelVars. 2021-08-12 02:43:59 +01:00
hispidence
634ab107ad Make "loop" arg to PlayAudioTrack optional; defaulting to false. 2021-08-12 02:39:29 +01:00
hispidence
c29af38f39 Add comments and update documentation for InventoryAdd/InventoryRemove. 2021-08-12 02:38:30 +01:00
hispidence
f4fb3786c9 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
8de08be1de Register GameScriptRotation in GameFlowScript and not GameLogicScript. 2021-08-11 01:26:35 +01:00
hispidence
9ce4157d54 More cleanup. 2021-08-09 00:54:09 +01:00
hispidence
d3742cb87e Change InventoryAdd/Remove/GetCount/SetCount and GameScriptInventoryObject to use ItemEnumPair. 2021-08-09 00:01:40 +01:00
hispidence
5458e7a67e Make the read-only table of kInventorySlots in GameFlowScript instead of GameLogicScript. 2021-08-08 23:53:52 +01:00
hispidence
2dde169769 Don't register Color in GameScript (it's in GameFlow now). 2021-08-07 19:14:11 +01:00
hispidence
9b29de8dda Make MakeReadOnlyTable a member function of LuaHandler so that GameFlow can use it too. 2021-08-07 19:00:45 +01:00
hispidence
aff468f964 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
a34828b5d9 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
8009ed9a3b 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
ead31e63f2 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
052b03ec96 Remove AddLuaId and GetItemById. 2021-08-04 16:21:00 +01:00
hispidence
fde79b4704 Replace std::runtime_exception with TENScriptException. 2021-08-03 15:15:42 +01:00
hispidence
5562667f98 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
9dd4bcf4ca 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
cf8723c448 Add GameScriptSoundSourceInfo and GameScriptAIObject, and associated functions. 2021-07-24 12:29:25 +01:00