From 1431603fe0a62b784a8a9e131e10d774863aee0a Mon Sep 17 00:00:00 2001 From: Starkku Date: Thu, 17 Mar 2022 15:47:05 +0200 Subject: [PATCH] Implement local warhead screen shaking --- README.md | 2 +- docs/Fixed-or-Improved-Logics.md | 10 ++++++++++ docs/Whats-New.md | 1 + src/Ext/Bullet/Hooks.cpp | 19 +++++++++++++++++++ src/Ext/WarheadType/Body.cpp | 6 ++---- src/Ext/WarheadType/Body.h | 2 ++ 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8d959a88e4..26f2acd656 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, Attached animation position customization, Critical hit logic additions, Aircraft & jumpjet speed modifiers fix +- **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, Critical hit logic additions, Aircraft & jumpjet speed modifiers fix, Local warhead screen shaking - **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 2d55ba1c3f..0685d75c51 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -309,4 +309,14 @@ In `rulesmd.ini`: ```ini [SOMEWARHEAD] ; WarheadType DecloakDamagedTargets=true ; boolean +``` + +### Restricting screen shaking to current view + +- You can now specify whether or not the warhead can only shake screen (`ShakeX/Ylo/hi`) if it is detonated while visible on current screen view. + +In `rulesmd.ini`: +```ini +[SOMEWARHEAD] ; WarheadType +ShakeIsLocal=false ; boolean ``` \ No newline at end of file diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 10ac9e8517..008ffcc81c 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -278,6 +278,7 @@ New: - Shared Ammo for transports to passengers (by FS-21) - Additional critical hit logic customizations (by Starkku) - Laser trails for VoxelAnims (by Otamaa) +- Local warhead screen shaking (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/Bullet/Hooks.cpp b/src/Ext/Bullet/Hooks.cpp index 93e585d422..9f575971f6 100644 --- a/src/Ext/Bullet/Hooks.cpp +++ b/src/Ext/Bullet/Hooks.cpp @@ -4,6 +4,7 @@ #include #include +#include // has everything inited except SpawnNextAnim at this point DEFINE_HOOK(0x466556, BulletClass_Init_SetLaserTrail, 0x6) @@ -194,4 +195,22 @@ DEFINE_HOOK(0x46A3D6, BulletClass_Shrapnel_Forced, 0xA) return Shrapnel; return Skip; +} + +DEFINE_HOOK(0x4690D4, BulletClass_Logics_ScreenShake, 0x6) +{ + enum { SkipShaking = 0x469130 }; + + GET(WarheadTypeClass*, pWarhead, EAX); + GET_BASE(CoordStruct*, pCoords, 0x8); + + if (auto const pExt = WarheadTypeExt::ExtMap.Find(pWarhead)) + { + Point2D screenCoords; + + if (pExt->ShakeIsLocal && !TacticalClass::Instance->CoordsToClient(*pCoords, &screenCoords)) + return SkipShaking; + } + + return 0; } \ No newline at end of file diff --git a/src/Ext/WarheadType/Body.cpp b/src/Ext/WarheadType/Body.cpp index bdf4dbabd8..408d5b730a 100644 --- a/src/Ext/WarheadType/Body.cpp +++ b/src/Ext/WarheadType/Body.cpp @@ -82,6 +82,7 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->RemoveMindControl.Read(exINI, pSection, "RemoveMindControl"); this->AnimList_PickRandom.Read(exINI, pSection, "AnimList.PickRandom"); this->DecloakDamagedTargets.Read(exINI, pSection, "DecloakDamagedTargets"); + this->ShakeIsLocal.Read(exINI, pSection, "ShakeIsLocal"); // Crits this->Crit_Chance.Read(exINI, pSection, "Crit.Chance"); @@ -136,16 +137,13 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm) .Process(this->SpySat) .Process(this->BigGap) .Process(this->TransactMoney) - .Process(this->SplashList) .Process(this->SplashList_PickRandom) - .Process(this->RemoveDisguise) .Process(this->RemoveMindControl) - .Process(this->AnimList_PickRandom) - .Process(this->DecloakDamagedTargets) + .Process(this->ShakeIsLocal) .Process(this->Crit_Chance) .Process(this->Crit_ApplyChancePerTarget) diff --git a/src/Ext/WarheadType/Body.h b/src/Ext/WarheadType/Body.h index 0da29f3733..b2244cd3af 100644 --- a/src/Ext/WarheadType/Body.h +++ b/src/Ext/WarheadType/Body.h @@ -24,6 +24,7 @@ class WarheadTypeExt Valueable RemoveMindControl; Valueable AnimList_PickRandom; Valueable DecloakDamagedTargets; + Valueable ShakeIsLocal; Valueable Crit_Chance; Valueable Crit_ApplyChancePerTarget; @@ -87,6 +88,7 @@ class WarheadTypeExt , RemoveMindControl { false } , AnimList_PickRandom { false } , DecloakDamagedTargets { true } + , ShakeIsLocal { false } , Crit_Chance { 0.0 } , Crit_ApplyChancePerTarget { false }