Commit graph

41 commits

Author SHA1 Message Date
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
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
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
5929180395 Remove AddLuaId and GetItemById. 2021-08-04 16:21:00 +01:00
hispidence
447ba86d30 Add GameScriptSoundSourceInfo and GameScriptAIObject, and associated functions. 2021-07-24 12:29:25 +01:00
hispidence
f9ae0046c6 Add AddLuaNameSink, RemoveLuaNameSink, and GetSinkByName.
Make a template that all GetXByName member functions work off, to reduce copypasted functions.
For consistency, rename RemoveLuaName and AddLuaName to RemoveLuaNameItem and AddLuaNameItem.
Fix some documentation comments, order function documentation into sections.
2021-07-23 16:02:30 +01:00
hispidence
5257a3c074 Add m_camerasMapName, AddLuaNameCamera, RemoveLuaNameCamera, GetCameraByName, and GetMeshByName. 2021-07-23 02:09:52 +01:00
hispidence
23ec719020 Link up MeshInfo with GameLogicScript, adding a m_meshesMapName and implementing AddLuaNameMesh and RemoveLuaNameMesh.
Add GetMeshByName and make GetItemByName take a constant reference.

Remove no-longer-used headers.
2021-07-21 18:12:17 +01:00
hispidence
53b971c033 Remove 'typedef' from enums and structs. This was required in C, but in C++ all it does is generate thousands of warnings. 2021-07-18 15:22:15 +01:00
hispidence
87ebe31767 Uncomment ExecuteFunction and make it take a const ref.
Make «Add/Remove»LuaName return a bool for future error checking, and pass them via lambdas to GameScriptItemInfo, allowing it to call them whenever an object is added or removed (they would not have access to the m_itemsMapName otherwise).
2021-07-17 22:26:07 +01:00
MontyTRC89
7c1e29e6d0 Added code (to finish) for executing LUA triggers 2021-07-17 05:56:40 +02:00
hispidence
3599cf68d4 Make GameLogicScript use kInventorySlots. Make InvItem a read-only table. This means we do not need to write an enum directly in the Lua source. 2021-07-13 13:21:13 +01:00
hispidence
5dd8ca33a8 Implement GiveInvItem, TakeInvItem, GetInvItemCount and SetInvItemCount (names to be finalized). 2021-07-10 14:05:01 +01:00
hispidence
7a43cd156c Make InventoryAdd and InventoryRemove static. Add them as Lua functions. 2021-07-05 18:18:20 +01:00
hispidence
47f5745304 Register SetAmbientTrack and PlayAudioTrack. Make PlayAudioTrack static, pass its string arg by reference-to-const, and let it use the loop bool passed in instead of the one stored in global state.
Improve some text formatting in the header.
2021-07-04 14:33:57 +01:00
hispidence
b7d2a45a29 Make SetAmbientTrack take a string by const ref. Change functions to access GameScript[Position/Rotation] members directly instead of via getters/setters. 2021-07-03 23:18:10 +01:00
hispidence
948e3519a2 Add m_onStart, m_onEnd, m_onLoad, m_onControlPhase, and m_onSave callbacks. Add InitCallBacks, which assigns the aforementioned member functions and checks that they exist in the script, throwing an exception if not. 2021-07-01 19:31:15 +01:00
hispidence
b4a52de5d0 Register GameScriptRotation and GameScriptPosition in GameScript constructor. Remove GameScriptItem class, which has been merged into GameScriptItemInfo. 2021-07-01 19:29:58 +01:00
MontyTRC89
a507e9e1be Moved GameScriptPosition, GameScriptRotation and GameScriptColor classes in separate files 2021-06-29 05:28:17 +02:00
MontyTRC89
255393b589 Added FROM_DEGREES function; Added quantity param to PickedUpObject(); LUA scripting refactoring WIP; 2021-06-29 05:00:15 +02:00
hispidence
a70bd1f13d GameLogicScript inherits from LuaHandler now. 2021-06-16 14:39:43 +01:00
Raildex
b635f4df13 Fixed std namespace collisions
Refactored ChunkID/ChunkReader/Writer
2020-06-20 23:39:08 +02:00
Raildex
2b4d1ca2e8 resolving namespace std conflicts 2020-06-18 15:54:08 +02:00
asasas9500
b58fc1473e Scripting (#211)
* Create template for variables; Rename properties; Improve console input

* Improve console input again
2020-06-09 09:16:51 +02:00
TokyoSU
b615a98c46 (Broken) Deleted Global Folder
- No more enums.h, constants.h, macro.h, etc...
- moved all structure in types.h to there respective file.
2020-05-30 15:55:23 +02:00
TokyoSU
29f0724693 New project format (#206)
* Starting Reformat the project

- New Import Method, no more "../../" in import,
- New Entity Folder Structure, less compile time

* Refactoring the Project

- added precompiled header with default import like microsoft or directx.
- fix many double import.
- fix math.h confliting math.h from
microsoft.
- fix effects.h confliting Effects.h from DirectX.
- refactored TR4 entity folder and how it's loaded.

* Update Some Code Before Switching to Master

* Finished the NewProjectFormat Template

- need to finish entity in the master later.

* Added Monty NewFileFormat

* Fixed Monty NewFileFormat Include

* Revert "Fixed Monty NewFileFormat Include"

This reverts commit ebf0afca10.

* Trying to fix conflits for NewFileFormat

* Fixed .filters

* Last Commit in NewProjectFormat
2020-05-27 09:21:20 +02:00
Raildex
6fd9ce1473 Added Debug Console Window
Added Script function that handles standalone script commands
2020-05-01 20:42:17 +02:00
MontyTRC89
22ccaa2c5a Merge branch 'master' into scripting 2020-04-30 21:52:16 +02:00
asasas9500
4dc0169461 Improve Lua scripting 2020-04-28 12:24:10 -03:00
MontyTRC89
6b819c2855 Started math refactoring 2020-04-25 16:23:53 +02:00
MontyTRC89
06042a2f57 Decompiled FixedCamera() and CameraBoundsCollide() 2020-04-09 14:19:18 +02:00
MontyTRC89
25418903ad Decompiled EFFECTS.CPP, EFFECT2.CPP, TOMB4FX.CPP 2019-12-22 00:20:10 +01:00
MontyTRC89
37ac9b77fd Merged branches 2019-12-02 09:11:21 +01:00
MontyTRC89
0d342637fb Decompiling Lara 2019-11-21 07:43:34 +01:00
MontyTRC89
548f9c0ad8 Improved readLara(); Added LaraBurn(); Code cleaning in inventory; 2018-10-10 22:29:40 +02:00
MontyTRC89
94b5a6f61a Improved savegame system 2018-10-09 00:02:14 +02:00
MontyTRC89
5c376c0f95 New streams class; Refactored chunk IO; Added chunk writer; Started new savegame system; 2018-10-01 22:22:35 +02:00
MontyTRC89
c7995dae7f Started implementing new file format; Added new functions for scripting; 2018-09-24 21:34:43 +02:00
MontyTRC89
59c02796cb Implemented LUA trigger 2018-09-23 12:01:07 +02:00
MontyTRC89
b7dfc803d2 Refactored script system; Decompiled TestTriggers; Added some functions and variables; Fixed a couple of bugs in control phase; 2018-09-22 23:54:51 +02:00