Commit graph

42 commits

Author SHA1 Message Date
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
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
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
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
052b03ec96 Remove AddLuaId and GetItemById. 2021-08-04 16:21:00 +01:00
hispidence
cf8723c448 Add GameScriptSoundSourceInfo and GameScriptAIObject, and associated functions. 2021-07-24 12:29:25 +01:00
hispidence
97d5d85f7a 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
c13106252f Add m_camerasMapName, AddLuaNameCamera, RemoveLuaNameCamera, GetCameraByName, and GetMeshByName. 2021-07-23 02:09:52 +01:00
hispidence
da5af327e9 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
21a867e821 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
011e1a9bf4 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
f0698a3c80 Added code (to finish) for executing LUA triggers 2021-07-17 05:56:40 +02:00
hispidence
a0ced5c34e 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
a00f3a23fb Implement GiveInvItem, TakeInvItem, GetInvItemCount and SetInvItemCount (names to be finalized). 2021-07-10 14:05:01 +01:00
hispidence
34859c154f Make InventoryAdd and InventoryRemove static. Add them as Lua functions. 2021-07-05 18:18:20 +01:00
hispidence
33dcd85a06 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
9386993bcd 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
997d31af89 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
f22551ab32 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
d25cfb6c92 Moved GameScriptPosition, GameScriptRotation and GameScriptColor classes in separate files 2021-06-29 05:28:17 +02:00
MontyTRC89
f81d8e439f Added FROM_DEGREES function; Added quantity param to PickedUpObject(); LUA scripting refactoring WIP; 2021-06-29 05:00:15 +02:00
Brad Ellis
514a691836 GameLogicScript inherits from LuaHandler now. 2021-06-16 14:39:43 +01:00
Nils Gaitzsch
c860919616 Fixed std namespace collisions
Refactored ChunkID/ChunkReader/Writer
2020-06-20 23:39:08 +02:00
Nils Gaitzsch
232458472b resolving namespace std conflicts 2020-06-18 15:54:08 +02:00
asasas9500
1732048a00
Scripting (#211)
* Create template for variables; Rename properties; Improve console input

* Improve console input again
2020-06-09 09:16:51 +02:00
TokyoSU
ee59d27517 (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
9c1c4517d7
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
Nils Gaitzsch
ca12b10ec3 Added Debug Console Window
Added Script function that handles standalone script commands
2020-05-01 20:42:17 +02:00
MontyTRC
6b16828381
Merge branch 'master' into scripting 2020-04-30 21:52:16 +02:00
asasas9500
960110196e Improve Lua scripting 2020-04-28 12:24:10 -03:00
Montagna Marco
20bd242052 Started math refactoring 2020-04-25 16:23:53 +02:00
Montagna Marco
97c6fe0dd8 Decompiled FixedCamera() and CameraBoundsCollide() 2020-04-09 14:19:18 +02:00
Montagna Marco
d5f6858a01 Decompiled EFFECTS.CPP, EFFECT2.CPP, TOMB4FX.CPP 2019-12-22 00:20:10 +01:00
Montagna Marco
09c2957f4f Merged branches 2019-12-02 09:11:21 +01:00
Montagna Marco
2443494349 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