@@ -51,8 +51,12 @@ DEFINE_HOOK(0x6F33CD, TechnoClass_WhatWeaponShouldIUse_ForceFire, 0x6)
51
51
auto const pWeaponSecondary = pThis->GetWeapon (1 )->WeaponType ;
52
52
auto const pPrimaryExt = WeaponTypeExt::ExtMap.Find (pWeaponPrimary);
53
53
54
- if (pWeaponSecondary && !pPrimaryExt->SkipWeaponPicking && (!EnumFunctions::IsCellEligible (pCell, pPrimaryExt->CanTarget , true , true )
55
- || !pPrimaryExt->IsHealthRatioEligible (pThis) || (pPrimaryExt->AttachEffect_CheckOnFirer && !pPrimaryExt->HasRequiredAttachedEffects (pThis, pThis))))
54
+ if (pWeaponSecondary
55
+ && !pPrimaryExt->SkipWeaponPicking
56
+ && (!EnumFunctions::IsCellEligible (pCell, pPrimaryExt->CanTarget , true , true )
57
+ || !pPrimaryExt->IsHealthRatioEligible (pThis)
58
+ || (pPrimaryExt->AttachEffect_CheckOnFirer
59
+ && !pPrimaryExt->HasRequiredAttachedEffects (pThis, pThis))))
56
60
{
57
61
R->EAX (1 );
58
62
return ReturnWeaponIndex;
@@ -257,52 +261,48 @@ DEFINE_HOOK(0x6FC339, TechnoClass_CanFire, 0x6)
257
261
}
258
262
259
263
// AAOnly doesn't need to be checked if LandTargeting=1.
260
- if (pThis->GetTechnoType ()->LandTargeting != LandTargetingType::Land_Not_OK && pWeapon->Projectile ->AA && pTarget && !pTarget->IsInAir ())
264
+ if (pThis->GetTechnoType ()->LandTargeting != LandTargetingType::Land_Not_OK && pWeapon->Projectile ->AA
265
+ && pTarget && !pTarget->IsInAir () && BulletTypeExt::ExtMap.Find (pWeapon->Projectile )->AAOnly )
261
266
{
262
- const auto pBulletTypeExt = BulletTypeExt::ExtMap.Find (pWeapon->Projectile );
263
-
264
- if (pBulletTypeExt->AAOnly )
265
- return CannotFire;
267
+ return CannotFire;
266
268
}
267
269
268
270
const auto pTechno = abstract_cast<TechnoClass*>(pTarget);
269
271
CellClass* pTargetCell = nullptr ;
270
272
271
273
if (pTarget)
272
274
{
273
- if (const auto pCell = abstract_cast<CellClass*>(pTarget))
274
- {
275
- pTargetCell = pCell;
276
- }
277
- else if (const auto pObject = abstract_cast<ObjectClass*>(pTarget))
275
+ if (const auto pObject = abstract_cast<ObjectClass*, true >(pTarget))
278
276
{
279
277
// Ignore target cell for technos that are in air.
280
278
if ((pTechno && !pTechno->IsInAir ()) || pObject != pTechno)
281
279
pTargetCell = pObject->GetCell ();
282
280
}
281
+ else if (const auto pCell = abstract_cast<CellClass*, true >(pTarget))
282
+ {
283
+ pTargetCell = pCell;
284
+ }
283
285
}
284
286
285
287
const auto pWeaponExt = WeaponTypeExt::ExtMap.Find (pWeapon);
286
288
287
- if (!pWeaponExt->SkipWeaponPicking && pTargetCell)
289
+ if (!pWeaponExt->SkipWeaponPicking && pTargetCell
290
+ && !EnumFunctions::IsCellEligible (pTargetCell, pWeaponExt->CanTarget , true , true ))
288
291
{
289
- if (!EnumFunctions::IsCellEligible (pTargetCell, pWeaponExt->CanTarget , true , true ))
290
- return CannotFire;
292
+ return CannotFire;
291
293
}
292
294
293
295
if (pTechno)
294
296
{
295
297
if (!pWeaponExt->SkipWeaponPicking )
296
298
{
297
- if (!EnumFunctions::IsTechnoEligible (pTechno, pWeaponExt->CanTarget ) ||
298
- !EnumFunctions::CanTargetHouse (pWeaponExt->CanTargetHouses , pThis->Owner , pTechno->Owner ) ||
299
- !pWeaponExt->IsHealthRatioEligible (pTechno))
299
+ if (!EnumFunctions::IsTechnoEligible (pTechno, pWeaponExt->CanTarget )
300
+ || !EnumFunctions::CanTargetHouse (pWeaponExt->CanTargetHouses , pThis->Owner , pTechno->Owner )
301
+ || !pWeaponExt->IsHealthRatioEligible (pTechno)
302
+ || !pWeaponExt->HasRequiredAttachedEffects (pTechno, pThis))
300
303
{
301
304
return CannotFire;
302
305
}
303
-
304
- if (!pWeaponExt->HasRequiredAttachedEffects (pTechno, pThis))
305
- return CannotFire;
306
306
}
307
307
308
308
if (pWH->Airstrike )
@@ -369,8 +369,8 @@ DEFINE_HOOK(0x6FC689, TechnoClass_CanFire_LandNavalTarget, 0x6)
369
369
{
370
370
const auto landType = pCell->LandType ;
371
371
372
- if (pType->NavalTargeting == NavalTargetingType::Naval_None &&
373
- (landType == LandType::Water || landType == LandType::Beach))
372
+ if (pType->NavalTargeting == NavalTargetingType::Naval_None
373
+ && (landType == LandType::Water || landType == LandType::Beach))
374
374
{
375
375
return DisallowFiring;
376
376
}
@@ -379,13 +379,13 @@ DEFINE_HOOK(0x6FC689, TechnoClass_CanFire_LandNavalTarget, 0x6)
379
379
{
380
380
const auto landType = pTerrain->GetCell ()->LandType ;
381
381
382
- if (pType->LandTargeting == LandTargetingType::Land_Not_OK &&
383
- landType != LandType::Water && landType != LandType::Beach)
382
+ if (pType->LandTargeting == LandTargetingType::Land_Not_OK
383
+ && landType != LandType::Water && landType != LandType::Beach)
384
384
{
385
385
return DisallowFiring;
386
386
}
387
- else if (pType->NavalTargeting == NavalTargetingType::Naval_None &&
388
- (landType == LandType::Water || landType == LandType::Beach))
387
+ else if (pType->NavalTargeting == NavalTargetingType::Naval_None
388
+ && (landType == LandType::Water || landType == LandType::Beach))
389
389
{
390
390
return DisallowFiring;
391
391
}
0 commit comments