From 7376c2bccf75f12a26c9f0a926de7f2d52824785 Mon Sep 17 00:00:00 2001 From: FS-21 Date: Wed, 12 Jan 2022 17:41:44 +0100 Subject: [PATCH 1/2] Added PassengerDeletion.Anim Added PassengerDeletion.Anim tag. Added 1 optional animation when the passenger is erased. --- docs/New-or-Enhanced-Logics.md | 3 ++- src/Ext/Techno/Body.cpp | 10 ++++++++++ src/Ext/Techno/Body.h | 1 + src/Ext/TechnoType/Body.cpp | 2 ++ src/Ext/TechnoType/Body.h | 2 ++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index c086ce6539..6b554e3353 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -268,11 +268,12 @@ DefaultDisguise=E2 ; InfantryType In `rulesmd.ini`: ```ini [SOMETECHNO] ; TechnoType -PassengerDeletion.Rate= ; integer, game frames +PassengerDeletion.Rate=0 ; integer, game frames PassengerDeletion.Rate.SizeMultiply=yes ; boolean, whether to multiply frames amount by size PassengerDeletion.Soylent=no ; boolean PassengerDeletion.SoylentFriendlies=no ; boolean PassengerDeletion.ReportSound= ; sound +PassengerDeletion.Anim= ; animation ``` ### Customizable OpenTopped Properties diff --git a/src/Ext/Techno/Body.cpp b/src/Ext/Techno/Body.cpp index cc36605a38..341d851d70 100644 --- a/src/Ext/Techno/Body.cpp +++ b/src/Ext/Techno/Body.cpp @@ -358,6 +358,16 @@ void TechnoExt::EatPassengers(TechnoClass* pThis) { VocClass::PlayAt(pData->PassengerDeletion_ReportSound, pThis->GetCoords(), nullptr); + const auto pAnimType = pData->PassengerDeletion_Anim.Get(nullptr); + if (pAnimType) + { + if (auto const pAnim = GameCreate(pAnimType, pThis->Location)) + { + pAnim->SetOwnerObject(pThis); + pAnim->Owner = pThis->Owner; + } + } + // Check if there is money refund if (pData->PassengerDeletion_Soylent) { diff --git a/src/Ext/Techno/Body.h b/src/Ext/Techno/Body.h index b6832f49f7..66b3d688cb 100644 --- a/src/Ext/Techno/Body.h +++ b/src/Ext/Techno/Body.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include #include diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 0554f807b0..ae9168f2ee 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -122,6 +122,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->PassengerDeletion_ReportSound.Read(exINI, pSection, "PassengerDeletion.ReportSound"); this->PassengerDeletion_Rate_SizeMultiply.Read(exINI, pSection, "PassengerDeletion.Rate.SizeMultiply"); this->PassengerDeletion_Rate.Read(exINI, pSection, "PassengerDeletion.Rate"); + this->PassengerDeletion_Anim.Read(exINI, pSection, "PassengerDeletion.Anim"); this->DefaultDisguise.Read(exINI, pSection, "DefaultDisguise"); @@ -265,6 +266,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->PassengerDeletion_Rate) .Process(this->PassengerDeletion_ReportSound) .Process(this->PassengerDeletion_Rate_SizeMultiply) + .Process(this->PassengerDeletion_Anim) .Process(this->OpenTopped_RangeBonus) .Process(this->OpenTopped_DamageMultiplier) .Process(this->OpenTopped_WarpDistance) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index dce4cb64b4..6900bda51b 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -46,6 +46,7 @@ class TechnoTypeExt Valueable PassengerDeletion_Rate; NullableIdx PassengerDeletion_ReportSound; Valueable PassengerDeletion_Rate_SizeMultiply; + Nullable PassengerDeletion_Anim; Valueable ShieldType; @@ -149,6 +150,7 @@ class TechnoTypeExt , PassengerDeletion_Rate { 0 } , PassengerDeletion_ReportSound {} , PassengerDeletion_Rate_SizeMultiply { true } + , PassengerDeletion_Anim {} , DefaultDisguise {} , OpenTopped_RangeBonus {} , OpenTopped_DamageMultiplier {} From 9d0e3bddd3c6d3f96a47f972ff0c2f105a64c923 Mon Sep 17 00:00:00 2001 From: FS-21 Date: Fri, 14 Jan 2022 16:43:20 +0100 Subject: [PATCH 2/2] Applied suggested changes apply isset() comparison for nullptr values amd documentation fix --- docs/New-or-Enhanced-Logics.md | 2 +- src/Ext/Techno/Body.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 6b554e3353..1f2b9466f5 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -268,7 +268,7 @@ DefaultDisguise=E2 ; InfantryType In `rulesmd.ini`: ```ini [SOMETECHNO] ; TechnoType -PassengerDeletion.Rate=0 ; integer, game frames +PassengerDeletion.Rate=0 ; integer, game frames PassengerDeletion.Rate.SizeMultiply=yes ; boolean, whether to multiply frames amount by size PassengerDeletion.Soylent=no ; boolean PassengerDeletion.SoylentFriendlies=no ; boolean diff --git a/src/Ext/Techno/Body.cpp b/src/Ext/Techno/Body.cpp index 341d851d70..8bb88868da 100644 --- a/src/Ext/Techno/Body.cpp +++ b/src/Ext/Techno/Body.cpp @@ -358,9 +358,9 @@ void TechnoExt::EatPassengers(TechnoClass* pThis) { VocClass::PlayAt(pData->PassengerDeletion_ReportSound, pThis->GetCoords(), nullptr); - const auto pAnimType = pData->PassengerDeletion_Anim.Get(nullptr); - if (pAnimType) + if (pData->PassengerDeletion_Anim.isset()) { + const auto pAnimType = pData->PassengerDeletion_Anim.Get(); if (auto const pAnim = GameCreate(pAnimType, pThis->Location)) { pAnim->SetOwnerObject(pThis);