Skip to content

Commit 196c4e9

Browse files
committed
Fix issues
- Fix issue causing non-BalloonHover jumpjets not landing correctly - Fix issue causing IsSimpleDeployer jumpjets to not use waypoint mode correctly - Apply some minor optimizations to the drawing hook
1 parent 71d6c3f commit 196c4e9

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

src/Ext/Unit/Hooks.SimpleDeployer.cpp

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void CreateDeployingAnim(UnitClass* pUnit, bool isDeploying)
7878
pAnimType = GeneralUtils::GetItemForDirection<AnimTypeClass*>(pTypeExt->DeployingAnims, pUnit->PrimaryFacing.Current());
7979

8080
auto const pAnim = GameCreate<AnimClass>(pAnimType, pUnit->Location, 0, 1, 0x600, 0,
81-
!isDeploying ? pTypeExt->DeployingAnim_ReverseForUndeploy : false);
81+
!isDeploying && pTypeExt->DeployingAnim_ReverseForUndeploy);
8282

8383
pUnit->DeployAnim = pAnim;
8484
pAnim->SetOwnerObject(pUnit);
@@ -240,29 +240,40 @@ DEFINE_HOOK(0x54C76D, JumpjetLocomotionClass_Descending_DeployDir, 0x7)
240240

241241
// Disable DeployToLand=no forcing landing when idle due to what appears to be
242242
// a code oversight and no need for DeployToLand=no to work in vanilla game.
243-
DEFINE_HOOK(0x54BE3E, JumpjetLocomotionClass_Hovering_DeployToLand, 0x6)
243+
DEFINE_HOOK(0x54BED4, JumpjetLocomotionClass_Hovering_DeployToLand, 0x7)
244244
{
245245
enum { SkipGameCode = 0x54BEE0 };
246246

247+
GET(JumpjetLocomotionClass*, pThis, ESI);
247248
GET(FootClass*, pLinkedTo, ECX);
248249

249-
if (!pLinkedTo->GetTechnoType()->DeployToLand)
250-
return SkipGameCode;
250+
auto const pType = pLinkedTo->GetTechnoType();
251251

252-
return 0;
252+
if (!pType->BalloonHover || pType->DeployToLand)
253+
pThis->State = JumpjetLocomotionClass::State::Descending;
254+
255+
pLinkedTo->TryNextPlanningTokenNode();
256+
return SkipGameCode;
253257
}
254258

255-
// Same as above but at different state.
259+
// Same as above but at a different state.
256260
DEFINE_HOOK(0x54C2DF, JumpjetLocomotionClass_Cruising_DeployToLand, 0xA)
257261
{
258262
enum { SkipGameCode = 0x54C4FD };
259263

264+
GET(JumpjetLocomotionClass*, pThis, ESI);
260265
GET(FootClass*, pLinkedTo, ECX);
261266

262-
if (!pLinkedTo->GetTechnoType()->DeployToLand)
263-
return SkipGameCode;
267+
auto const pType = pLinkedTo->GetTechnoType();
264268

265-
return 0;
269+
if (!pType->BalloonHover || pType->DeployToLand)
270+
{
271+
pThis->CurrentHeight = 0;
272+
pThis->State = JumpjetLocomotionClass::State::Descending;
273+
}
274+
275+
pLinkedTo->TryNextPlanningTokenNode();
276+
return SkipGameCode;
266277
}
267278

268279
// Disable Ares hover locomotor bobbing processing DeployToLand hook.
@@ -376,7 +387,7 @@ DEFINE_HOOK(0x4DA9F3, FootClass_AI_DeployToLand, 0x6)
376387
// Allow keeping unit visible while displaying DeployingAnim.
377388
DEFINE_HOOK(0x73CF46, UnitClass_Draw_It_KeepUnitVisible, 0x6)
378389
{
379-
enum { KeepUnitVisible = 0x73CF62 };
390+
enum { Continue = 0x73CF62, DoNotDraw = 0x73D43F };
380391

381392
GET(UnitClass*, pThis, ESI);
382393

@@ -385,10 +396,12 @@ DEFINE_HOOK(0x73CF46, UnitClass_Draw_It_KeepUnitVisible, 0x6)
385396
const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->Type);
386397

387398
if (pTypeExt->DeployingAnim_KeepUnitVisible || (pThis->Deploying && !pThis->DeployAnim))
388-
return KeepUnitVisible;
399+
return Continue;
400+
401+
return DoNotDraw;
389402
}
390403

391-
return 0;
404+
return Continue;
392405
}
393406

394407
// Disable deploy cursor if Ares type conversion on deploy is available and the new type is not allowed to move to the cell.

0 commit comments

Comments
 (0)