From 0854c7d27eb75f7bd17f8694dd06d2af5026641a Mon Sep 17 00:00:00 2001 From: Rampastring Date: Mon, 11 Nov 2024 02:14:01 +0200 Subject: [PATCH 1/3] Add support for rocket inaccuracy --- src/new/locomotion/rocketlocomotion.cpp | 11 ++++++++++- src/new/rockettype/rockettype.cpp | 4 +++- src/new/rockettype/rockettype.h | 5 +++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/new/locomotion/rocketlocomotion.cpp b/src/new/locomotion/rocketlocomotion.cpp index dafe099df..2ef86027c 100644 --- a/src/new/locomotion/rocketlocomotion.cpp +++ b/src/new/locomotion/rocketlocomotion.cpp @@ -508,7 +508,16 @@ IFACEMETHODIMP_(void) RocketLocomotionClass::Move_To(Coordinate to) MissionTimer = timer_delay; CurrentPitch = rocket->PitchInitial * DEG_TO_RAD(90); - DestinationCoord = to; + + // Apply some inaccuracy to the coordinate if the rocket type specifies so. + if (rocket->Inaccuracy <= 0) { + DestinationCoord = to; + } + else { + const int randomx = Random_Pick(-rocket->Inaccuracy, rocket->Inaccuracy); + const int randomy = Random_Pick(-rocket->Inaccuracy, rocket->Inaccuracy); + DestinationCoord = to + Coordinate(randomx, randomy, 0); + } } } diff --git a/src/new/rockettype/rockettype.cpp b/src/new/rockettype/rockettype.cpp index f211226c1..9192128c2 100644 --- a/src/new/rockettype/rockettype.cpp +++ b/src/new/rockettype/rockettype.cpp @@ -68,7 +68,8 @@ RocketTypeClass::RocketTypeClass(const char* name) : CloseEnoughFactor(1.0), Type(nullptr), Warhead(nullptr), - EliteWarhead(nullptr) + EliteWarhead(nullptr), + Inaccuracy(0) { ASSERT_FATAL_PRINT(name != nullptr, "Invalid name for RocketType!"); @@ -397,6 +398,7 @@ bool RocketTypeClass::Read_INI(CCINIClass& ini) EliteWarhead = ini.Get_Warhead(IniName, "EliteWarhead", EliteWarhead); TakeoffAnim = ini.Get_Anim(IniName, "TakeoffAnim", TakeoffAnim); TrailAnim = ini.Get_Anim(IniName, "TrailAnim", TrailAnim); + Inaccuracy = ini.Get_Int(IniName, "Inaccuracy", Inaccuracy); return true; } diff --git a/src/new/rockettype/rockettype.h b/src/new/rockettype/rockettype.h index 783b44dd5..9a668075a 100644 --- a/src/new/rockettype/rockettype.h +++ b/src/new/rockettype/rockettype.h @@ -171,4 +171,9 @@ RocketTypeClass final : IPersistStream */ const AnimTypeClass* TakeoffAnim; const AnimTypeClass* TrailAnim; + + /** + * The maximum number of leptons that this rocket is able to miss its target by. + */ + int Inaccuracy; }; From bcd0028a6712f39456806ed2e3567def6da4f3c4 Mon Sep 17 00:00:00 2001 From: Rampastring Date: Mon, 11 Nov 2024 02:22:29 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Reject=20common=20sense,=20embrace=20java?= =?UTF-8?q?=20=E2=98=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/new/locomotion/rocketlocomotion.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/new/locomotion/rocketlocomotion.cpp b/src/new/locomotion/rocketlocomotion.cpp index 2ef86027c..e73ab8159 100644 --- a/src/new/locomotion/rocketlocomotion.cpp +++ b/src/new/locomotion/rocketlocomotion.cpp @@ -509,7 +509,9 @@ IFACEMETHODIMP_(void) RocketLocomotionClass::Move_To(Coordinate to) MissionTimer = timer_delay; CurrentPitch = rocket->PitchInitial * DEG_TO_RAD(90); - // Apply some inaccuracy to the coordinate if the rocket type specifies so. + /** + * Apply some inaccuracy to the coordinate if the rocket type specifies so. + */ if (rocket->Inaccuracy <= 0) { DestinationCoord = to; } From 113f6f62b69298bc35e7d0e1f184e48dcdd7a543 Mon Sep 17 00:00:00 2001 From: Rampastring Date: Mon, 11 Nov 2024 02:24:52 +0200 Subject: [PATCH 3/3] Update docs --- CREDITS.md | 1 + docs/New-Features-and-Enhancements.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CREDITS.md b/CREDITS.md index 5977d33b1..25f6acdee 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -163,6 +163,7 @@ This page lists all the individual contributions to the project by their author. - Implement the Torpedo logic from Red Alert 1 for BulletTypes. - Add `BuildTimeCost`. - Allow scenarios to have custom score screen bar colors. + - Add `Inaccuracy` to RocketTypes. - **secsome**: - Add support for up to 32767 waypoints to be used in scenarios. - **ZivDero**: diff --git a/docs/New-Features-and-Enhancements.md b/docs/New-Features-and-Enhancements.md index 775861b06..03ffdf519 100644 --- a/docs/New-Features-and-Enhancements.md +++ b/docs/New-Features-and-Enhancements.md @@ -532,6 +532,7 @@ Warhead= ; WarheadType, the warhead that this rocket's explosion EliteWarhead= ; WarheadType, the warhead that this rocket's explosion uses when the spawner is elite. TakeoffAnim= ; AnimType, the takeoff animation used by this rocket. TrailAnim= ; AnimType, the trail animation used by this rocket. +Inaccuracy= ; integer, the maximum number of leptons that this rocket is able to miss its target by. ``` ```{note}