mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-30 08:47:58 +03:00
Merge branch 'NewLuaScripting' of https://github.com/MontyTRC89/TR5Main into NewLuaScripting
# Conflicts: # TR5Main/Scripting/GameLogicScript.cpp
This commit is contained in:
commit
aaee0e833a
5 changed files with 101 additions and 0 deletions
|
@ -810,6 +810,11 @@ GAME_STATUS DoLevel(int index, std::string ambient, bool loadFromSavegame)
|
|||
InitialiseCamera();
|
||||
SOUND_Stop();
|
||||
|
||||
// Run the level script
|
||||
GameScriptLevel* level = g_GameFlow->Levels[index];
|
||||
std::string err;
|
||||
g_GameScript->ExecuteScript(level->ScriptFileName, err);
|
||||
|
||||
// Restore the game?
|
||||
if (loadFromSavegame)
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <Game/tomb4fx.h>
|
||||
#include <Game/effect2.h>
|
||||
#include <Game/pickup.h>
|
||||
#include "GameScriptItemInfo.h"
|
||||
|
||||
extern GameFlow* g_GameFlow;
|
||||
GameScript* g_GameScript;
|
||||
|
@ -18,6 +19,7 @@ bool WarningsAsErrors = false;
|
|||
|
||||
GameScript::GameScript(sol::state* lua) : LuaHandler{ lua }
|
||||
{
|
||||
GameScriptItemInfo::Register(m_lua);
|
||||
m_lua->new_enum<GAME_OBJECT_ID>("Object", {
|
||||
{"LARA", ID_LARA}
|
||||
});
|
||||
|
|
61
TR5Main/Scripting/GameScriptItemInfo.cpp
Normal file
61
TR5Main/Scripting/GameScriptItemInfo.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
#include "framework.h"
|
||||
#include "GameScriptItemInfo.h"
|
||||
#include "items.h"
|
||||
#include "objectslist.h"
|
||||
#include "level.h"
|
||||
|
||||
void GameScriptItemInfo::Register(sol::state * state)
|
||||
{
|
||||
state->new_usertype<GameScriptItemInfo>("ItemInfo",
|
||||
"new", sol::factories(&GameScriptItemInfo::Create));
|
||||
}
|
||||
|
||||
std::unique_ptr<GameScriptItemInfo> GameScriptItemInfo::Create(
|
||||
short hp,
|
||||
short currentAnim,
|
||||
short requiredAnimState,
|
||||
sol::as_table_t<std::array<int, 3>> pos,
|
||||
sol::as_table_t<std::array<short, 3>> rot,
|
||||
sol::as_table_t<std::array<short, 8>> itemFlags,
|
||||
short ocb,
|
||||
byte aiBits,
|
||||
short status,
|
||||
bool active,
|
||||
bool hitStatus)
|
||||
{
|
||||
short num = CreateItem();
|
||||
ITEM_INFO * item = &g_Level.Items[num];
|
||||
|
||||
auto p = pos.value();
|
||||
auto r = rot.value();
|
||||
item->pos = PHD_3DPOS(
|
||||
p[0],
|
||||
p[1],
|
||||
p[2],
|
||||
r[0],
|
||||
r[1],
|
||||
r[2]
|
||||
);
|
||||
|
||||
//make it a big medipack by default for now
|
||||
item->objectNumber = ID_BIGMEDI_ITEM;
|
||||
InitialiseItem(num);
|
||||
|
||||
item->hitPoints = hp;
|
||||
item->currentAnimState = currentAnim;
|
||||
item->requiredAnimState = requiredAnimState;
|
||||
memcpy(item->itemFlags, itemFlags.value().data(), sizeof(item->itemFlags));
|
||||
item->triggerFlags = ocb;
|
||||
item->aiBits = aiBits;
|
||||
item->status = status;
|
||||
item->active = active;
|
||||
item->hitStatus = hitStatus;
|
||||
|
||||
return std::make_unique<GameScriptItemInfo>(num);
|
||||
}
|
||||
|
||||
GameScriptItemInfo::GameScriptItemInfo(short num) : m_num{ num } {};
|
||||
|
||||
GameScriptItemInfo::~GameScriptItemInfo() {
|
||||
KillItem(m_num);
|
||||
}
|
31
TR5Main/Scripting/GameScriptItemInfo.h
Normal file
31
TR5Main/Scripting/GameScriptItemInfo.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
namespace sol {
|
||||
class state;
|
||||
template <typename T> class as_table_t;
|
||||
}
|
||||
|
||||
|
||||
class GameScriptItemInfo
|
||||
{
|
||||
private:
|
||||
short m_num;
|
||||
public:
|
||||
GameScriptItemInfo(short num);
|
||||
~GameScriptItemInfo();
|
||||
GameScriptItemInfo& operator=(GameScriptItemInfo const& other) = delete;
|
||||
GameScriptItemInfo(GameScriptItemInfo const& other) = delete;
|
||||
static void Register(sol::state *);
|
||||
static std::unique_ptr<GameScriptItemInfo> Create(
|
||||
short hp,
|
||||
short currentAnim,
|
||||
short requiredAnimState,
|
||||
sol::as_table_t<std::array<int, 3>> pos,
|
||||
sol::as_table_t<std::array<short, 3>> rot,
|
||||
sol::as_table_t<std::array<short, 8>> itemFlags,
|
||||
short ocb,
|
||||
byte aiBits,
|
||||
short status,
|
||||
bool active,
|
||||
bool hitStatus);
|
||||
};
|
|
@ -164,6 +164,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
|
|||
<ClInclude Include="Game\prng.h" />
|
||||
<ClInclude Include="Game\puzzles_keys.h" />
|
||||
<ClInclude Include="Game\room.h" />
|
||||
<ClInclude Include="Scripting\GameScriptItemInfo.h" />
|
||||
<ClInclude Include="Game\smoke.h" />
|
||||
<ClInclude Include="Game\spark.h" />
|
||||
<ClInclude Include="Objects\Generic\generic_objects.h" />
|
||||
|
@ -478,6 +479,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
|
|||
<ClCompile Include="Game\particle\SimpleParticle.cpp" />
|
||||
<ClCompile Include="Game\prng.cpp" />
|
||||
<ClCompile Include="Game\puzzles_keys.cpp" />
|
||||
<ClCompile Include="Scripting\GameScriptItemInfo.cpp" />
|
||||
<ClCompile Include="Game\trmath.cpp" />
|
||||
<ClCompile Include="Game\smoke.cpp" />
|
||||
<ClCompile Include="Game\spark.cpp" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue