mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-30 00:37:58 +03:00
Register CalculateDistance and CalculateHorizontalDistance in GameLogicScript.
This commit is contained in:
parent
582b000fb9
commit
53cd3add4f
1 changed files with 15 additions and 11 deletions
|
@ -143,6 +143,18 @@ static void InventorySeparate(int slot)
|
|||
|
||||
}
|
||||
|
||||
int CalculateDistance(GameScriptPosition const & pos1, GameScriptPosition const & pos2)
|
||||
{
|
||||
auto result = sqrt(SQUARE(pos1.x - pos2.x) + SQUARE(pos1.y - pos2.y) + SQUARE(pos1.z - pos2.z));
|
||||
return static_cast<int>(round(result));
|
||||
}
|
||||
|
||||
int CalculateHorizontalDistance(GameScriptPosition const & pos1, GameScriptPosition const & pos2)
|
||||
{
|
||||
auto result = sqrt(SQUARE(pos1.x - pos2.x) + SQUARE(pos1.z - pos2.z));
|
||||
return static_cast<int>(round(result));
|
||||
}
|
||||
|
||||
// Misc
|
||||
static void PrintString(std::string key, GameScriptPosition pos, GameScriptColor color, int lifetime, int flags)
|
||||
{
|
||||
|
@ -252,6 +264,9 @@ Get a SinkInfo by its name.
|
|||
*/
|
||||
m_lua->set_function("GetSinkByName", &GameScript::GetSinkByName, this);
|
||||
|
||||
m_lua->set_function("CalculateDistance", &CalculateDistance);
|
||||
m_lua->set_function("CalculateHorizontalDistance", &CalculateHorizontalDistance);
|
||||
|
||||
MakeReadOnlyTable("ObjID", kObjIDs);
|
||||
|
||||
auto MakeSpecialTable = [&](std::string const& name)
|
||||
|
@ -603,17 +618,6 @@ void GameScript::ResetVariables()
|
|||
{
|
||||
(*m_lua)["Lara"] = NULL;
|
||||
}
|
||||
|
||||
int CalculateDistance(GameScriptPosition pos1, GameScriptPosition pos2)
|
||||
{
|
||||
return sqrt(SQUARE(pos1.x - pos2.x) + SQUARE(pos1.y - pos2.y) + SQUARE(pos1.z - pos2.z));
|
||||
}
|
||||
|
||||
int CalculateHorizontalDistance(GameScriptPosition pos1, GameScriptPosition pos2)
|
||||
{
|
||||
return sqrt(SQUARE(pos1.x - pos2.x) + SQUARE(pos1.z - pos2.z));
|
||||
}
|
||||
|
||||
sol::object LuaVariables::GetVariable(sol::table tab, std::string key)
|
||||
{
|
||||
if (variables.find(key) == variables.end())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue