diff --git a/CREDITS.md b/CREDITS.md index 625a910865..b8d4562121 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -436,6 +436,7 @@ This page lists all the individual contributions to the project by their author. - Fix the bug that `IsLocomotor=yes` warhead rendering hover units unselectable and undamageable on elevated bridge - Fix the bug that Locomotor warhead won't stop working when firer (except for vehicle) stop firing - Fix the bug that hover vehicle will sink if destroyed on bridge + - Spawns particle when spawns tiberium by terrain - **Apollo** - Translucent SHP drawing patches - **ststl**: - Customizable `ShowTimer` priority of superweapons diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 0b32fc9a08..845d68d863 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -1518,6 +1518,7 @@ SpawnsTiberium.Type=0 ; tiberium/ore type index SpawnsTiberium.Range=1 ; integer, radius in cells SpawnsTiberium.GrowthStage=3 ; integer - single or comma-sep. range SpawnsTiberium.CellsPerAnim=1 ; integer - single or comma-sep. range +SpawnsTiberium.Particle= ; particle ``` ### Damaged frames and crumbling animation diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 81b6324d09..d0ff427863 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -426,6 +426,7 @@ New: - [Additional attached animation position customizations](Fixed-or-Improved-Logics.md#attached-animation-position-customization) (by Starkku) - Use `SkipCrushSlowdown=true` to avoid the bug related to `Accelerates=true` and `MovementZone=CrushAll` (by TaranDahl) - Units can customize the attack voice that plays when using more weapons (by FlyStar) +- Spawns particle when spawns tiberium by terrain (by NetsuNegi) Vanilla fixes: - Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya) diff --git a/src/Ext/Techno/Hooks.WeaponEffects.cpp b/src/Ext/Techno/Hooks.WeaponEffects.cpp index cbd091f65e..69464707ba 100644 --- a/src/Ext/Techno/Hooks.WeaponEffects.cpp +++ b/src/Ext/Techno/Hooks.WeaponEffects.cpp @@ -214,10 +214,11 @@ DEFINE_HOOK(0x62B8BC, ParticleClass_CTOR_CoordAdjust, 0x6) enum { SkipCoordAdjust = 0x62B8CB }; GET(ParticleClass*, pThis, ESI); + const auto pParticleSys = pThis->ParticleSystem; - if (pThis->ParticleSystem) + if (pParticleSys && pParticleSys->Type) { - const auto behavesLike = pThis->ParticleSystem->Type->BehavesLike; + const auto behavesLike = pParticleSys->Type->BehavesLike; if (behavesLike == BehavesLike::Railgun || behavesLike == BehavesLike::Fire) return SkipCoordAdjust; diff --git a/src/Ext/TerrainType/Body.cpp b/src/Ext/TerrainType/Body.cpp index ceee2db165..eab3506f8f 100644 --- a/src/Ext/TerrainType/Body.cpp +++ b/src/Ext/TerrainType/Body.cpp @@ -50,6 +50,7 @@ void TerrainTypeExt::ExtData::Serialize(T& Stm) .Process(this->SpawnsTiberium_Range) .Process(this->SpawnsTiberium_GrowthStage) .Process(this->SpawnsTiberium_CellsPerAnim) + .Process(this->SpawnsTiberium_Particle) .Process(this->DestroyAnim) .Process(this->DestroySound) .Process(this->MinimapColor) @@ -73,6 +74,7 @@ void TerrainTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->SpawnsTiberium_Range.Read(exINI, pSection, "SpawnsTiberium.Range"); this->SpawnsTiberium_GrowthStage.Read(exINI, pSection, "SpawnsTiberium.GrowthStage"); this->SpawnsTiberium_CellsPerAnim.Read(exINI, pSection, "SpawnsTiberium.CellsPerAnim"); + this->SpawnsTiberium_Particle.Read(exINI, pSection, "SpawnsTiberium.Particle"); this->DestroyAnim.Read(exINI, pSection, "DestroyAnim"); this->DestroySound.Read(exINI, pSection, "DestroySound"); diff --git a/src/Ext/TerrainType/Body.h b/src/Ext/TerrainType/Body.h index 95a13afccb..f472492fe1 100644 --- a/src/Ext/TerrainType/Body.h +++ b/src/Ext/TerrainType/Body.h @@ -21,6 +21,7 @@ class TerrainTypeExt Valueable SpawnsTiberium_Range; Valueable> SpawnsTiberium_GrowthStage; Valueable> SpawnsTiberium_CellsPerAnim; + ValueableIdx SpawnsTiberium_Particle; Valueable DestroyAnim; ValueableIdx DestroySound; Nullable MinimapColor; @@ -39,6 +40,7 @@ class TerrainTypeExt , SpawnsTiberium_Range { 1 } , SpawnsTiberium_GrowthStage { { 3, 0 } } , SpawnsTiberium_CellsPerAnim { { 1, 0 } } + , SpawnsTiberium_Particle { -1 } , DestroyAnim {} , DestroySound {} , MinimapColor {} diff --git a/src/Ext/TerrainType/Hooks.cpp b/src/Ext/TerrainType/Hooks.cpp index 21ca293bba..ce5f6306c7 100644 --- a/src/Ext/TerrainType/Hooks.cpp +++ b/src/Ext/TerrainType/Hooks.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,14 @@ DEFINE_HOOK(0x71C84D, TerrainClass_AI_Animated, 0x6) for (int i = 0; i < cellCount; i++) pCell->SpreadTiberium(true); + const int particleIdx = pTypeExt->SpawnsTiberium_Particle; + + if (particleIdx >= 0) + { + const auto particleSys = reinterpret_cast(0xA8ED78); + reinterpret_cast(0x62E430)(particleSys, ParticleTypeClass::Array[particleIdx], pThis->Location); + } + // Unset context for CellClass hooks. TerrainTypeTemp::pCurrentType = nullptr; TerrainTypeTemp::pCurrentExt = nullptr; diff --git a/src/Utilities/TemplateDef.h b/src/Utilities/TemplateDef.h index a533f4e65f..7fe1c7216c 100644 --- a/src/Utilities/TemplateDef.h +++ b/src/Utilities/TemplateDef.h @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include