Skip to content

Commit

Permalink
Revert 7cda0f8 and project the shadow
Browse files Browse the repository at this point in the history
I know it's ugly, just stay in consistency with others for the moment
  • Loading branch information
chaserli committed Sep 14, 2024
1 parent 9c8d2e8 commit 6f19e74
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
1 change: 0 additions & 1 deletion docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ Vanilla fixes:
- Fixed disguised units not using the correct palette if target has custom palette (by NetsuNegi)
- Building upgrades now consistently use building's `PowerUpN` animation settings corresponding to the upgrade's `PowersUpToLevel` where possible (by Starkku)
- Subterranean units are no longer allowed to perform deploy functions like firing weapons or `IsSimpleDeployer` while burrowed or burrowing, they will instead emerge first like they do for transport unloading (by Starkku)
- Subterranean units no longer draw an incorrectly positioned shadow when burrowing etc. (by Starkku)
- Fixed `Temporal=true` Warheads potentially crashing game if used to attack `Slaved=true` infantry (by Starkku)
Phobos fixes:
Expand Down
5 changes: 0 additions & 5 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,6 @@ DEFINE_HOOK(0x6F9FA9, TechnoClass_AI_PromoteAnim, 0x6)
return aresProcess();
}

// TunnelLocomotionClass_IsToHaveShadow, skip shadow on all but idle.
// TODO: Investigate if it is possible to fix the shadows not tilting on the burrowing etc. states.
DEFINE_JUMP(LJMP, 0x72A070, 0x72A07F);


DEFINE_HOOK(0x51B20E, InfantryClass_AssignTarget_FireOnce, 0x6)
{
enum { SkipGameCode = 0x51B255 };
Expand Down
44 changes: 44 additions & 0 deletions src/Ext/TechnoType/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <JumpjetLocomotionClass.h>
#include <FlyLocomotionClass.h>
#include <RocketLocomotionClass.h>
#include <TunnelLocomotionClass.h>

DEFINE_HOOK(0x6F64A9, TechnoClass_DrawHealthBar_Hide, 0x5)
{
Expand Down Expand Up @@ -312,6 +313,49 @@ struct DummyExtHere // TODO: move it
VoxelStruct NoSpawnAltVXL;
};

Matrix3D* __stdcall TunnelLocomotionClass_ShadowMatrix(ILocomotion* iloco, Matrix3D* ret,VoxelIndexKey* key)
{
__assume(iloco != nullptr);
auto tLoco = static_cast<TunnelLocomotionClass*>(iloco);
*ret = tLoco->LocomotionClass::Shadow_Matrix(key);
if (tLoco->State != TunnelLocomotionClass::State::Idle)
{
double theta = 0.;
switch (tLoco->State)
{
case TunnelLocomotionClass::State::DiggingIn:
if (key)key->Invalidate();
theta = Math::HalfPi;
if (auto total = tLoco->DigTimer.Rate)
theta *= 1.0 - double(tLoco->DigTimer.GetTimeLeft()) / double(total);
break;
case TunnelLocomotionClass::State::DugIn:
theta = Math::HalfPi;
break;
case TunnelLocomotionClass::State::PreDigOut:
theta = -Math::HalfPi;
break;
case TunnelLocomotionClass::State::DiggingOut:
if (key)key->Invalidate();
theta = -Math::HalfPi;
if (auto total = tLoco->DigTimer.Rate)
theta *= double(tLoco->DigTimer.GetTimeLeft()) / double(total);
break;
case TunnelLocomotionClass::State::DugOut:
if (key)key->Invalidate();
theta = Math::HalfPi;
if (auto total = tLoco->DigTimer.Rate)
theta *= double(tLoco->DigTimer.GetTimeLeft()) / double(total);
break;
default:break;
}
ret->ScaleX((float)Math::cos(theta));// I know it's ugly
}
return ret;
}

DEFINE_JUMP(VTABLE, 0x7F5A4C, GET_OFFSET(TunnelLocomotionClass_ShadowMatrix));

DEFINE_HOOK(0x73C47A, UnitClass_DrawAsVXL_Shadow, 0x5)
{
GET(UnitClass*, pThis, EBP);
Expand Down

0 comments on commit 6f19e74

Please sign in to comment.