From ce69dc951b88b21389e62d83da4e4fb84a4473f2 Mon Sep 17 00:00:00 2001 From: Starkku Date: Sun, 20 Feb 2022 18:17:23 +0200 Subject: [PATCH] Allow centering attached anims on object center --- README.md | 2 +- docs/Fixed-or-Improved-Logics.md | 14 ++++++++++++-- docs/Whats-New.md | 1 + src/Ext/AnimType/Body.cpp | 2 ++ src/Ext/AnimType/Body.h | 2 ++ src/Ext/AnimType/Hooks.cpp | 18 ++++++++++++++++++ 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9ce2c1433e..cb8aa6d64a 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ Credits - **ChrisLv_CN** - interceptor logic, LaserTrails, laser fixes, general assistance (work relicensed under [following permission](images/ChrisLv-relicense.png)) - **Xkein** - general assistance, YRpp edits - **thomassneddon** - general assistance -- **Starkku** - Warhead shield penetration & breaking, strafing aircraft weapon customization, vehicle DeployFire fixes/improvements, stationary VehicleTypes, Burst logic improvements, TechnoType auto-firing weapons, Secondary weapon fallback customization, weapon target type filtering, AreaFire targeting customization, CreateUnit improvements, Attached animation & jumpjet unit layer customization, IsSimpleDeployer improvements, Shield modification warheads, Warhead decloaking toggle, Warp(In/Out)Weapon, Grinder improvements / additions +- **Starkku** - Warhead shield penetration & breaking, strafing aircraft weapon customization, vehicle DeployFire fixes/improvements, stationary VehicleTypes, Burst logic improvements, TechnoType auto-firing weapons, Secondary weapon fallback customization, weapon target type filtering, AreaFire targeting customization, CreateUnit improvements, Attached animation & jumpjet unit layer customization, IsSimpleDeployer improvements, Shield modification warheads, Warhead decloaking toggle, Warp(In/Out)Weapon, Grinder improvements / additions, Attached animation position customization - **SukaHati (Erzoid)** - Minimum interceptor guard range - **Morton (MortonPL)** - XDrawOffset, Shield passthrough & absorption, building LimboDelivery, fix for Image in art rules, power delta counter - **mevitar** - honorary shield tester *triple* award diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 1bc4c44789..c6d95fd6b6 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -67,8 +67,18 @@ HideIfNoOre.Threshold=0 ; integer, minimal ore growth stage In `artmd.ini`: ```ini -[SOMEANIM] ; AnimationType -Layer.UseObjectLayer= ; boolean +[SOMEANIM] ; AnimationType +Layer.UseObjectLayer= ; boolean +``` + +### Attached animation position customization + +- You can now customize whether or not animations attached to objects are centered at the object's actual center rather than the bottom of their top-leftmost cell (cell #0). + +In `artmd.ini`: +```ini +[SOMEANIM] ; AnimationType +UseCenterCoordsIfAttached=false ; boolean ``` ## Buildings diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 0f00fc1701..3399125190 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -267,6 +267,7 @@ New: - Weapons fired on warping in / out (by Starkku) - `Storage.TiberiumIndex` for customizing resource storage in structures (by FS-21) - Grinder improvements & customizations (by Starkku) +- Attached animation position customization (by Starkku) Vanilla fixes: - Fixed laser drawing code to allow for thicker lasers in house color draw mode (by Kerbiter, ChrisLv_CN) diff --git a/src/Ext/AnimType/Body.cpp b/src/Ext/AnimType/Body.cpp index e5be6a68c8..96a5e0039e 100644 --- a/src/Ext/AnimType/Body.cpp +++ b/src/Ext/AnimType/Body.cpp @@ -32,6 +32,7 @@ void AnimTypeExt::ExtData::LoadFromINIFile(CCINIClass* pINI) this->XDrawOffset.Read(exINI, pID, "XDrawOffset"); this->HideIfNoOre_Threshold.Read(exINI, pID, "HideIfNoOre.Threshold"); this->Layer_UseObjectLayer.Read(exINI, pID, "Layer.UseObjectLayer"); + this->UseCenterCoordsIfAttached.Read(exINI, pID, "UseCenterCoordsIfAttached"); } const void AnimTypeExt::ProcessDestroyAnims(UnitClass* pThis, TechnoClass* pKiller) @@ -108,6 +109,7 @@ void AnimTypeExt::ExtData::Serialize(T& Stm) .Process(this->XDrawOffset) .Process(this->HideIfNoOre_Threshold) .Process(this->Layer_UseObjectLayer) + .Process(this->UseCenterCoordsIfAttached) ; } diff --git a/src/Ext/AnimType/Body.h b/src/Ext/AnimType/Body.h index 70bba9a309..8d46973d9e 100644 --- a/src/Ext/AnimType/Body.h +++ b/src/Ext/AnimType/Body.h @@ -27,6 +27,7 @@ class AnimTypeExt Valueable XDrawOffset; Valueable HideIfNoOre_Threshold; Nullable Layer_UseObjectLayer; + Valueable UseCenterCoordsIfAttached; ExtData(AnimTypeClass* OwnerObject) : Extension(OwnerObject) , Palette { CustomPalette::PaletteMode::Temperate } @@ -41,6 +42,7 @@ class AnimTypeExt , XDrawOffset { 0 } , HideIfNoOre_Threshold { 0 } , Layer_UseObjectLayer {} + , UseCenterCoordsIfAttached { false } { } virtual ~ExtData() = default; diff --git a/src/Ext/AnimType/Hooks.cpp b/src/Ext/AnimType/Hooks.cpp index b212154392..26b85aff17 100644 --- a/src/Ext/AnimType/Hooks.cpp +++ b/src/Ext/AnimType/Hooks.cpp @@ -49,5 +49,23 @@ DEFINE_HOOK(0x424CB0, AnimClass_In_Which_Layer_AttachedObjectLayer, 0x6) return ReturnValue; } + return 0; +} + +DEFINE_HOOK(0x424C49, AnimClass_AttachTo_BuildingCoords, 0x5) +{ + GET(AnimClass*, pThis, ESI); + GET(ObjectClass*, pObject, EDI); + GET(CoordStruct*, pCoords, EAX); + + auto pExt = AnimTypeExt::ExtMap.Find(pThis->Type); + + if (pExt->UseCenterCoordsIfAttached) + { + pCoords = pObject->GetCenterCoord(pCoords); + pCoords->X += 128; + pCoords->Y += 128; + } + return 0; } \ No newline at end of file