-
-
Notifications
You must be signed in to change notification settings - Fork 116
[Vanilla Enhancement] Vehicle disguise to vehicle #1803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
45d2b78
7e4b478
d15c187
3898511
9c5cd32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -473,28 +473,47 @@ DEFINE_HOOK(0x7295E2, TunnelLocomotionClass_ProcessStateDigging_SubterraneanHeig | |
|
||
DEFINE_HOOK(0x522790, InfantryClass_ClearDisguise_DefaultDisguise, 0x6) | ||
{ | ||
enum { SetDisguise = 0x5227BF }; | ||
|
||
GET(InfantryClass*, pThis, ECX); | ||
auto const pExt = TechnoTypeExt::ExtMap.Find(pThis->Type); | ||
const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->Type); | ||
const auto pDefault = pTypeExt->DefaultDisguise.Get(); | ||
|
||
if (pExt->DefaultDisguise) | ||
if (pDefault && pDefault->WhatAmI() == AbstractType::InfantryType) | ||
{ | ||
pThis->Disguise = pExt->DefaultDisguise; | ||
pThis->Disguise = pDefault; | ||
pThis->DisguisedAsHouse = pThis->Owner; | ||
pThis->Disguised = true; | ||
return 0x5227BF; | ||
return SetDisguise; | ||
} | ||
|
||
pThis->Disguised = false; | ||
|
||
return 0; | ||
} | ||
|
||
DEFINE_HOOK(0x746720, UnitClass_ClearDisguise_DefaultDisguise, 0x5) | ||
{ | ||
enum { SetDisguise = 0x746747 }; | ||
|
||
GET(UnitClass*, pThis, ECX); | ||
const auto pType = pThis->Type; | ||
|
||
if (!pType->PermaDisguise) | ||
return 0; | ||
|
||
const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pType); | ||
const auto pDefault = pTypeExt->DefaultDisguise.Get(); | ||
pThis->Disguise = pDefault && pDefault->WhatAmI() == AbstractType::UnitType ? pDefault : pType; | ||
pThis->DisguisedAsHouse = pThis->Owner; | ||
pThis->Disguised = true; | ||
return SetDisguise; | ||
} | ||
|
||
DEFINE_HOOK(0x74691D, UnitClass_UpdateDisguise_EMP, 0x6) | ||
{ | ||
GET(UnitClass*, pThis, ESI); | ||
// Remove mirage disguise if under emp or being flipped, approximately 15 deg | ||
// Deactivated mirage should still be able to keep disguise | ||
if (pThis->IsUnderEMP() || std::abs(pThis->AngleRotatedForwards) > 0.25 || std::abs(pThis->AngleRotatedSideways) > 0.25) | ||
if (pThis->Deactivated || pThis->IsUnderEMP() || std::abs(pThis->AngleRotatedForwards) > 0.25 || std::abs(pThis->AngleRotatedSideways) > 0.25) | ||
{ | ||
pThis->ClearDisguise(); | ||
R->EAX(pThis->MindControlRingAnim); | ||
|
@@ -504,6 +523,234 @@ DEFINE_HOOK(0x74691D, UnitClass_UpdateDisguise_EMP, 0x6) | |
return 0x746931; | ||
} | ||
|
||
DEFINE_HOOK(0x7466DC, UnitClass_DisguiseAs_DisguiseAsVehicle, 0x6) | ||
{ | ||
enum { SkipGameCode = 0x746712 }; | ||
|
||
GET(UnitClass*, pThis, EDI); | ||
GET(UnitClass*, pTarget, ESI); | ||
const bool targetDisguised = pTarget->IsDisguised(); | ||
|
||
pThis->Disguise = targetDisguised ? pTarget->GetDisguise(true) : pTarget->Type; | ||
pThis->DisguisedAsHouse = targetDisguised ? pTarget->GetDisguiseHouse(true) : pTarget->Owner; | ||
reinterpret_cast<void(__thiscall*)(TechnoClass*, AbstractClass*)>(0x70E280)(pThis, pTarget);//pThis->TechnoClass::DisguiseAs(pTarget); | ||
return SkipGameCode; | ||
} | ||
|
||
DEFINE_HOOK(0x746AFF, UnitClass_Desguise_Update_MoveToClear, 0xA) | ||
{ | ||
enum { DontClearDisguise = 0x746A9C }; | ||
|
||
GET(TechnoClass*, pThis, ESI); | ||
|
||
const auto pDisguise = pThis->Disguise; | ||
return pDisguise && pDisguise->WhatAmI() == UnitTypeClass::AbsID ? DontClearDisguise : 0; | ||
} | ||
|
||
DEFINE_HOOK(0x74659B, UnitClass_RemoveGunner_ClearDisguise, 0x6) | ||
{ | ||
GET(UnitClass*, pThis, EDI); | ||
|
||
if (!pThis->IsDisguised()) | ||
return 0; | ||
|
||
if (const auto pWeapon = pThis->GetWeapon(pThis->CurrentWeaponNumber)->WeaponType) | ||
{ | ||
const auto pWarhead = pWeapon->Warhead; | ||
|
||
if (pWarhead && pWarhead->MakesDisguise) | ||
return 0; | ||
} | ||
|
||
pThis->ClearDisguise(); | ||
return 0; | ||
} | ||
|
||
#pragma region UnitClass DrawSHP | ||
|
||
DEFINE_HOOK(0x73C655, UnitClass_DrawSHP_TechnoType, 0x6) | ||
{ | ||
enum { ApplyDisguiseType = 0x73C65B }; | ||
|
||
GET(UnitClass*, pThis, EBP); | ||
|
||
if (pThis->IsDisguised() && !pThis->IsClearlyVisibleTo(HouseClass::CurrentPlayer)) | ||
{ | ||
const auto pTargetType = pThis->GetDisguise(true); | ||
|
||
if (pTargetType && pTargetType->WhatAmI() == UnitTypeClass::AbsID) | ||
{ | ||
R->ECX(pTargetType); | ||
return ApplyDisguiseType; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
DEFINE_HOOK(0x73C69D, UnitClass_DrawSHP_TechnoType2, 0x6) | ||
{ | ||
enum { ApplyDisguiseType = 0x73C6A3 }; | ||
|
||
GET(UnitClass*, pThis, EBP); | ||
|
||
if (pThis->IsDisguised() && !pThis->IsClearlyVisibleTo(HouseClass::CurrentPlayer)) | ||
{ | ||
const auto pTargetType = pThis->GetDisguise(true); | ||
|
||
if (pTargetType && pTargetType->WhatAmI() == UnitTypeClass::AbsID) | ||
{ | ||
R->ECX(pThis->GetDisguise(true)); | ||
return ApplyDisguiseType; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
DEFINE_HOOK(0x73C702, UnitClass_DrawSHP_TechnoType3, 0x6) | ||
{ | ||
enum { ApplyDisguiseType = 0x73C708 }; | ||
|
||
GET(UnitClass*, pThis, EBP); | ||
|
||
if (pThis->IsDisguised() && !pThis->IsClearlyVisibleTo(HouseClass::CurrentPlayer)) | ||
{ | ||
const auto pTargetType = pThis->GetDisguise(true); | ||
|
||
if (pTargetType && pTargetType->WhatAmI() == UnitTypeClass::AbsID) | ||
{ | ||
R->ECX(pThis->GetDisguise(true)); | ||
return ApplyDisguiseType; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
Comment on lines
+571
to
+629
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These look the same, I think they should be able to be encapsulated into a function |
||
|
||
DEFINE_HOOK(0x73C725, UnitClass_DrawSHP_HasTurret, 0x5) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's 0x6 instead of 0x5. |
||
{ | ||
enum { SkipDrawTurret = 0x73CE0D }; | ||
|
||
GET(UnitClass*, pThis, EBP); | ||
|
||
if (pThis->IsDisguised() && !pThis->IsClearlyVisibleTo(HouseClass::CurrentPlayer)) | ||
{ | ||
const auto pDisguise = pThis->GetDisguise(true); | ||
|
||
if (pDisguise) | ||
{ | ||
const auto pTargetType = TechnoTypeExt::GetTechnoType(pDisguise); | ||
|
||
if (pTargetType && !pTargetType->Turret) | ||
return SkipDrawTurret; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
#pragma endregion | ||
|
||
#pragma region UnitClass DrawVoxel | ||
|
||
DEFINE_HOOK_AGAIN(0x73B765, UnitClass_DrawVoxel_TurretFacing, 0x5) | ||
DEFINE_HOOK_AGAIN(0x73BA78, UnitClass_DrawVoxel_TurretFacing, 0x6) | ||
DEFINE_HOOK_AGAIN(0x73BD8B, UnitClass_DrawVoxel_TurretFacing, 0x5) | ||
DEFINE_HOOK(0x73BDA3, UnitClass_DrawVoxel_TurretFacing, 0x5) | ||
{ | ||
GET(UnitClass*, pThis, EBP); | ||
|
||
if (!pThis->Type->Turret && pThis->IsDisguised() && !pThis->IsClearlyVisibleTo(HouseClass::CurrentPlayer)) | ||
{ | ||
const auto pTargetType = TechnoTypeExt::GetTechnoType(pThis->GetDisguise(true)); | ||
|
||
if (pTargetType && pTargetType->Turret) | ||
{ | ||
GET(DirStruct*, dir, EAX); | ||
*dir = pThis->PrimaryFacing.Current(); | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
DEFINE_HOOK(0x73B8E3, UnitClass_DrawVoxel_HasChargeTurret, 0x5) | ||
{ | ||
GET(UnitClass*, pThis, EBP); | ||
GET(UnitTypeClass*, pType, EBX); | ||
|
||
if (pType != pThis->Type) | ||
{ | ||
if (pType->TurretCount > 0 && !pType->IsGattling) | ||
return 0x73B8EC; | ||
else | ||
return 0x73B92F; | ||
} | ||
else | ||
{ | ||
if (!pType->HasMultipleTurrets() || pType->IsGattling) | ||
return 0x73B92F; | ||
else | ||
return 0x73B8FC; | ||
} | ||
Comment on lines
+683
to
+696
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can make it clearer
|
||
} | ||
|
||
DEFINE_HOOK(0x73BC28, UnitClass_DrawVoxel_HasChargeTurret2, 0x5) | ||
{ | ||
GET(UnitClass*, pThis, EBP); | ||
GET(UnitTypeClass*, pType, EBX); | ||
|
||
if (pType != pThis->Type) | ||
{ | ||
if (pType->TurretCount > 0 && !pType->IsGattling) | ||
{ | ||
if (pThis->CurrentTurretNumber < 0) | ||
R->Stack<int>(0x1C, 0); | ||
|
||
return 0x73BC35; | ||
} | ||
else | ||
{ | ||
return 0x73BD79; | ||
} | ||
} | ||
else | ||
{ | ||
if (!pType->HasMultipleTurrets() || pType->IsGattling) | ||
return 0x73BD79; | ||
else | ||
return 0x73BC49; | ||
} | ||
Comment on lines
+704
to
+724
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, it can also |
||
} | ||
|
||
DEFINE_HOOK(0x73BA63, UnitClass_DrawVoxel_TurretOffset, 0x5) | ||
{ | ||
GET(UnitClass*, pThis, EBP); | ||
GET(UnitTypeClass*, pType, EBX); | ||
|
||
if (pType != pThis->Type) | ||
{ | ||
if (pType->TurretCount > 0 && !pType->IsGattling) | ||
{ | ||
if (pThis->CurrentTurretNumber < 0) | ||
R->Stack<int>(0x1C, 0); | ||
|
||
return 0x73BC35; | ||
} | ||
else | ||
{ | ||
return 0x73BD79; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
DEFINE_JUMP(LJMP, 0x706724, 0x706731); | ||
|
||
#pragma endregion | ||
|
||
#pragma endregion | ||
|
||
#pragma region AttackMindControlledDelay | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEFINE_HOOK(0x7466D8, UnitClass_DisguiseAs_DisguiseAsVehicle, 0xA)
may be better?