Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ This page lists all the individual contributions to the project by their author.
- Health bar permanently displayed
- Unlimbo Detonate warhead
- Fast access structure
- Iron Curtain/Custom Tint Support for SHP Turreted Vehicles
- **NetsuNegi**:
- Forbidding parallel AI queues by type
- Jumpjet crash speed fix when crashing onto building
Expand Down Expand Up @@ -449,6 +450,7 @@ This page lists all the individual contributions to the project by their author.
- Customize squid grapple animation
- Fix the bug that armor multiplier of new attacheffect will have extra take effect once if restricted warheads
- Fix the bug that techno unit will draw with ironcurtain and airstrike color and intensity who disguised as terrain or overlay
- Iron Curtain/Custom Tint Support for SHP Turreted Vehicles
- **Apollo** - Translucent SHP drawing patches
- **ststl**:
- Customizable `ShowTimer` priority of superweapons
Expand Down
1 change: 1 addition & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ClCompile Include="src\Ext\Infantry\Hooks.Firing.cpp" />
<ClCompile Include="src\Ext\TechnoType\Hooks.MultiWeapon.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.Targeting.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.DrawIt.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.Firing.cpp" />
<ClCompile Include="src\Ext\EBolt\Body.cpp" />
<ClCompile Include="src\Ext\EBolt\Hooks.cpp" />
Expand Down
1 change: 1 addition & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Fixed the bug that techno unit will draw with ironcurtain and airstrike color and intensity who disguised as terrain or overlay.
- Fixed an issue that the AI would enter a combat state when its building receiving damage from friendly units or damage not greater than 0.
- Fixed an issue that the techno with weapon with `AA=yes` and `AG=no` would not auto targeting units that are falling, such as paratroopers.
- Iron Curtain/Custom Tint Support for SHP Turreted Vehicles.

## Fixes / interactions with other extensions

Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ Vanilla fixes:
- Fixed the bug that techno unit will draw with ironcurtain and airstrike color and intensity who disguised as terrain or overlay (by NetsuNegi)
- Fixed an issue that the AI would enter a combat state when its building receiving damage from friendly units or damage not greater than 0 (by TaranDahl)
- Fixed an issue that the techno with weapon with `AA=yes` and `AG=no` would not auto targeting units that are falling, such as paratroopers (by TaranDahl)
- Iron Curtain/Custom Tint Support for SHP Turreted Vehicles (by NetsuNegi, FlyStar)

Phobos fixes:
- Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi)
Expand Down
52 changes: 52 additions & 0 deletions src/Ext/Unit/Hooks.DrawIt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <Helpers/Macro.h>
#include <UnitClass.h>

#include <Ext/TechnoType/Body.h>

DEFINE_HOOK(0x73C7AC, UnitClass_DrawAsSHP_DrawTurret_TintFix, 0x6)
{
enum { SkipDrawCode = 0x73CE00 };

GET(UnitClass*, pThis, EBP);

const auto pThisType = pThis->Type;
const VoxelStruct barrelVoxel = pThisType->BarrelVoxel;

if (barrelVoxel.VXL && barrelVoxel.HVA)
return 0;

GET(UnitTypeClass*, pType, ECX);
GET(SHPStruct*, pShape, EDI);
GET(const int, bodyFrameIdx, EBX);
REF_STACK(Point2D, location, STACK_OFFSET(0x128, 0x4));
REF_STACK(RectangleStruct, bounds, STACK_OFFSET(0x128, 0xC));
GET_STACK(const int, extraLight, STACK_OFFSET(0x128, 0x1C));

const bool tooBigToFitUnderBridge = pType->TooBigToFitUnderBridge
&& reinterpret_cast<bool(__thiscall*)(TechnoClass*)>(0x703B10)(pThis) && !reinterpret_cast<int(__thiscall*)(TechnoClass*)>(0x703E70)(pThis);
const int zAdjust = tooBigToFitUnderBridge ? -16 : 0;
const ZGradient zGradient = tooBigToFitUnderBridge ? ZGradient::Ground : pThis->GetZGradient();

pThis->Draw_A_SHP(pShape, bodyFrameIdx, &location, &bounds, 0, 256, zAdjust, zGradient, 0, extraLight, 0, 0, 0, 0, 0, 0);

const auto secondaryDir = pThis->SecondaryFacing.Current();
const int frameIdx = secondaryDir.GetFacing<32>(4) + pType->WalkFrames * pType->Facings;

const auto primaryDir = pThis->PrimaryFacing.Current();
const double bodyRad = primaryDir.GetRadian<32>();
Matrix3D mtx = Matrix3D::GetIdentity();
mtx.RotateZ(static_cast<float>(bodyRad));

TechnoTypeExt::ApplyTurretOffset(pThisType, &mtx);
const double turretRad = pType->Turret ? secondaryDir.GetRadian<32>() : bodyRad;
mtx.RotateZ(static_cast<float>(turretRad - bodyRad));

const auto res = mtx.GetTranslation();
const auto offset = CoordStruct { static_cast<int>(res.X), static_cast<int>(-res.Y), static_cast<int>(res.Z) };
Point2D drawPoint = location + TacticalClass::Instance->CoordsToScreen(offset);

const bool originalDrawShadow = std::exchange(Game::bDrawShadow, false);
pThis->Draw_A_SHP(pShape, frameIdx, &drawPoint, &bounds, 0, 256, static_cast<DWORD>(-32), zGradient, 0, extraLight, 0, 0, 0, 0, 0, 0);
Game::bDrawShadow = originalDrawShadow;
return SkipDrawCode;
}