From bbfef06d88e89716abb81e6d0903baf40f861eb0 Mon Sep 17 00:00:00 2001 From: Gareth YR Date: Tue, 15 Mar 2022 02:25:20 -0300 Subject: [PATCH 1/3] Added ACDropShip property HoverHeightModifier --- CHANGELOG.md | 3 +++ Entities/ACDropShip.cpp | 10 ++++++++-- Entities/ACDropShip.h | 14 ++++++++++++++ Lua/LuaBindingsEntities.cpp | 1 + 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb963a26c..7261f4e52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased]
Added + +- New INI and Lua (R/W) `ACDropShip` property `HoverHeightModifier`. This allows for modification of the height at which an `ACDropShip` will hover when unloading cargo, or staying at a location. +
Changed diff --git a/Entities/ACDropShip.cpp b/Entities/ACDropShip.cpp index fe8255180..aa423f469 100644 --- a/Entities/ACDropShip.cpp +++ b/Entities/ACDropShip.cpp @@ -44,6 +44,7 @@ void ACDropShip::Clear() m_LateralControlSpeed = 6.0f; m_AutoStabilize = 1; m_MaxEngineAngle = 20.0f; + m_HoverHeightModifier = 0; } @@ -98,6 +99,8 @@ int ACDropShip::Create(const ACDropShip &reference) { m_MaxEngineAngle = reference.m_MaxEngineAngle; + m_HoverHeightModifier = reference.m_HoverHeightModifier; + return 0; } @@ -129,8 +132,10 @@ int ACDropShip::ReadProperty(const std::string_view &propName, Reader &reader) { reader >> m_AutoStabilize; } else if (propName == "MaxEngineAngle") { reader >> m_MaxEngineAngle; - } else if (propName == "LateralControlSpeed") { - reader >> m_LateralControlSpeed; + } else if (propName == "LateralControlSpeed") { + reader >> m_LateralControlSpeed; + } else if (propName == "HoverHeightModifier") { + reader >> m_HoverHeightModifier; } else { return ACraft::ReadProperty(propName, reader); } @@ -169,6 +174,7 @@ int ACDropShip::Save(Writer &writer) const writer << m_MaxEngineAngle; writer.NewProperty("LateralControlSpeed"); writer << m_LateralControlSpeed; + writer.NewPropertyWithValue("HoverHeightModifier", m_HoverHeightModifier); return 0; } diff --git a/Entities/ACDropShip.h b/Entities/ACDropShip.h index e99fcf6dd..29aab8f41 100644 --- a/Entities/ACDropShip.h +++ b/Entities/ACDropShip.h @@ -296,6 +296,18 @@ ClassInfoGetters; float GetLateralControl() const { return m_LateralControl; } + /// + /// Gets the modifier for height at which this ACDropship should hover above terrain. + /// + /// The modifier for height at which this ACDropship should hover above terrain. + float GetHoverHeightModifier() const { return m_HoverHeightModifier; } + + /// + /// Sets the modifier for height at which this ACDropship should hover above terrain. + /// + /// The new modifier for height at which this ACDropship should hover above terrain. + void SetHoverHeightModifier(float newHoverHeightModifier) { m_HoverHeightModifier = newHoverHeightModifier; } + ////////////////////////////////////////////////////////////////////////////////////////// // Protected member variable and method declarations @@ -333,6 +345,8 @@ ClassInfoGetters; // Maximum engine rotation in degrees float m_MaxEngineAngle; + float m_HoverHeightModifier; + ////////////////////////////////////////////////////////////////////////////////////////// // Private member variable and method declarations diff --git a/Lua/LuaBindingsEntities.cpp b/Lua/LuaBindingsEntities.cpp index ae08e70b2..7970c6c08 100644 --- a/Lua/LuaBindingsEntities.cpp +++ b/Lua/LuaBindingsEntities.cpp @@ -40,6 +40,7 @@ namespace RTE { .property("MaxEngineAngle", &ACDropShip::GetMaxEngineAngle, &ACDropShip::SetMaxEngineAngle) .property("LateralControlSpeed", &ACDropShip::GetLateralControlSpeed, &ACDropShip::SetLateralControlSpeed) .property("LateralControl", &ACDropShip::GetLateralControl) + .property("HoverHeightModifier", &ACDropShip::GetHoverHeightModifier, &ACDropShip::SetHoverHeightModifier) .def("DetectObstacle", &ACDropShip::DetectObstacle) .def("GetAltitude", &ACDropShip::GetAltitude); From 131f9bcda2efa29531aad0dc35348d47ad701803 Mon Sep 17 00:00:00 2001 From: Gareth YR Date: Sun, 17 Apr 2022 14:13:06 -0300 Subject: [PATCH 2/3] Added missing comment on hover height modifier Used hover height modifier in cpp dropship AI --- Entities/ACDropShip.cpp | 2 +- Entities/ACDropShip.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Entities/ACDropShip.cpp b/Entities/ACDropShip.cpp index aa423f469..e9919b1f9 100644 --- a/Entities/ACDropShip.cpp +++ b/Entities/ACDropShip.cpp @@ -319,7 +319,7 @@ void ACDropShip::UpdateAI() float angle = m_Rotation.GetRadAngle(); // This is the altitude at which the craft will hover and unload its cargo - float hoverAltitude = m_CharHeight * 2; + float hoverAltitude = m_CharHeight * 2 + GetHoverHeightModifier(); // The gutter range threshold for how much above and below the hovering altitude is ok to stay in float hoverRange = m_CharHeight / 4; // Get the altitude reading, within 25 pixels precision diff --git a/Entities/ACDropShip.h b/Entities/ACDropShip.h index 29aab8f41..439459e18 100644 --- a/Entities/ACDropShip.h +++ b/Entities/ACDropShip.h @@ -345,7 +345,7 @@ ClassInfoGetters; // Maximum engine rotation in degrees float m_MaxEngineAngle; - float m_HoverHeightModifier; + float m_HoverHeightModifier; //!< The modifier for the height at which this ACDropShip should hover above terrain when releasing its cargo. Used in cpp and Lua AI. ////////////////////////////////////////////////////////////////////////////////////////// // Private member variable and method declarations From 87cfacd0ac9fc6f602cf951b2f86146ddf192131 Mon Sep 17 00:00:00 2001 From: Gareth YR Date: Wed, 11 May 2022 13:42:50 -0300 Subject: [PATCH 3/3] Change to use property instead of getter for hover height --- Entities/ACDropShip.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Entities/ACDropShip.cpp b/Entities/ACDropShip.cpp index e9919b1f9..a44eaa6ed 100644 --- a/Entities/ACDropShip.cpp +++ b/Entities/ACDropShip.cpp @@ -319,7 +319,7 @@ void ACDropShip::UpdateAI() float angle = m_Rotation.GetRadAngle(); // This is the altitude at which the craft will hover and unload its cargo - float hoverAltitude = m_CharHeight * 2 + GetHoverHeightModifier(); + float hoverAltitude = m_CharHeight * 2 + m_HoverHeightModifier; // The gutter range threshold for how much above and below the hovering altitude is ok to stay in float hoverRange = m_CharHeight / 4; // Get the altitude reading, within 25 pixels precision