|
3 | 3 | #include <Ext/BulletType/Body.h> |
4 | 4 | #include <Ext/WeaponType/Body.h> |
5 | 5 | #include <Ext/WarheadType/Body.h> |
6 | | -#include <Utilities/EnumFunctions.h> |
7 | | -#include <Utilities/GeneralUtils.h> |
8 | | - |
9 | | -bool TechnoExt::IsAllowedSplitsTarget(TechnoClass* pSource, HouseClass* pOwner, WeaponTypeClass* pWeapon, TechnoClass* pTarget, bool useWeaponTargeting) |
10 | | -{ |
11 | | - auto const pWH = pWeapon->Warhead; |
12 | | - |
13 | | - if (useWeaponTargeting) |
14 | | - { |
15 | | - auto const pType = pTarget->GetTechnoType(); |
16 | | - |
17 | | - if (!pType->LegalTarget || GeneralUtils::GetWarheadVersusArmor(pWH, pTarget, pType) == 0.0) |
18 | | - return false; |
19 | | - |
20 | | - auto const pWeaponExt = WeaponTypeExt::ExtMap.Find(pWeapon); |
21 | | - |
22 | | - if (pWeaponExt->SkipWeaponPicking) |
23 | | - return true; |
24 | | - |
25 | | - if (!EnumFunctions::CanTargetHouse(pWeaponExt->CanTargetHouses, pOwner, pTarget->Owner) |
26 | | - || !EnumFunctions::IsCellEligible(pTarget->GetCell(), pWeaponExt->CanTarget, true, true) |
27 | | - || !EnumFunctions::IsTechnoEligible(pTarget, pWeaponExt->CanTarget) |
28 | | - || !pWeaponExt->IsHealthInThreshold(pTarget) |
29 | | - || !pWeaponExt->IsVeterancyInThreshold(pTarget)) |
30 | | - { |
31 | | - return false; |
32 | | - } |
33 | | - |
34 | | - if (!pWeaponExt->HasRequiredAttachedEffects(pTarget, pSource)) |
35 | | - return false; |
36 | | - } |
37 | | - else |
38 | | - { |
39 | | - if (!WarheadTypeExt::ExtMap.Find(pWH)->CanTargetHouse(pOwner, pTarget)) |
40 | | - return false; |
41 | | - } |
42 | | - |
43 | | - return true; |
44 | | -} |
45 | | - |
46 | | -bool TechnoExt::SplitsProjectileCheck(BulletTypeClass* pProjectile, WeaponTypeClass* pWeapon, TechnoClass* pTarget, bool useWeaponTargeting, TechnoClass* pFirer) |
47 | | -{ |
48 | | - if (!pProjectile || !pTarget) |
49 | | - return false; |
50 | | - |
51 | | - if (!useWeaponTargeting) |
52 | | - return pProjectile->AA || !pTarget->IsInAir(); |
53 | | - |
54 | | - const bool inAir = pTarget->IsInAir(); |
55 | | - |
56 | | - if (inAir) |
57 | | - { |
58 | | - if (!pProjectile->AA) |
59 | | - return false; |
60 | | - } |
61 | | - else |
62 | | - { |
63 | | - auto const pProjectileExt = BulletTypeExt::ExtMap.Find(pProjectile); |
64 | | - |
65 | | - if (pFirer && pFirer->GetTechnoType()->LandTargeting != LandTargetingType::Land_Not_OK |
66 | | - && pProjectile->AA && pProjectileExt->AAOnly) |
67 | | - { |
68 | | - return false; |
69 | | - } |
70 | | - |
71 | | - if (!pProjectile->AG) |
72 | | - return false; |
73 | | - } |
74 | | - |
75 | | - if (pTarget->InWhichLayer() == Layer::Underground && !BulletTypeExt::ExtMap.Find(pProjectile)->AU) |
76 | | - return false; |
77 | | - |
78 | | - return true; |
79 | | -} |
80 | 6 |
|
81 | 7 | // Compares two weapons and returns index of which one is eligible to fire against current target (0 = first, 1 = second), or -1 if neither works. |
82 | 8 | int TechnoExt::PickWeaponIndex(TechnoClass* pThis, TechnoClass* pTargetTechno, AbstractClass* pTarget, int weaponIndexOne, int weaponIndexTwo, bool allowFallback, bool allowAAFallback) |
|
0 commit comments