@@ -21,14 +21,10 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
21
21
22
22
const auto pRules = RulesExt::Global ();
23
23
const auto pExt = TechnoExt::ExtMap.Find (pThis);
24
- const auto pTypeExt = pExt->TypeExtData ;
25
- const auto pType = pTypeExt->OwnerObject ();
26
24
const auto pWHExt = WarheadTypeExt::ExtMap.Find (args->WH );
27
25
28
26
const auto pSourceHouse = args->SourceHouse ;
29
27
const auto pTargetHouse = pThis->Owner ;
30
- const bool unkillable = !pWHExt->CanKill || pExt->AE .Unkillable ;
31
- int nDamageLeft = *args->Damage ;
32
28
33
29
// Calculate Damage Multiplier
34
30
if (!args->IgnoreDefenses && *args->Damage )
@@ -62,7 +58,11 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
62
58
63
59
if (pHouseExt->CombatAlertTimer .HasTimeLeft () || pWHExt->CombatAlert_Suppress .Get (!pWHExt->Malicious || pWHExt->Nonprovocative ))
64
60
return ;
65
- else if (!pTypeExt->CombatAlert .Get (pRules->CombatAlert_Default .Get (!pType->Insignificant && !pType->Spawned )) || !pThis->IsInPlayfield )
61
+
62
+ const auto pTypeExt = pExt->TypeExtData ;
63
+ const auto pType = pTypeExt->OwnerObject ();
64
+
65
+ if (!pTypeExt->CombatAlert .Get (pRules->CombatAlert_Default .Get (!pType->Insignificant && !pType->Spawned )) || !pThis->IsInPlayfield )
66
66
return ;
67
67
68
68
const auto pBuilding = abstract_cast<BuildingClass*>(pThis);
@@ -104,42 +104,30 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
104
104
// Shield Receive Damage
105
105
if (!args->IgnoreDefenses )
106
106
{
107
+ int nDamageLeft = *args->Damage ;
108
+
107
109
if (const auto pShieldData = pExt->Shield .get ())
108
110
{
109
- if (! pShieldData->IsActive ())
111
+ if (pShieldData->IsActive ())
110
112
{
111
- int nDamageTotal = MapClass::GetTotalDamage (nDamageLeft, args-> WH , pThis-> GetTechnoType ()-> Armor , 0 );
113
+ nDamageLeft = pShieldData-> ReceiveDamage (args );
112
114
113
- // Check if the warhead can not kill targets
114
- if (pThis->Health > 0 && unkillable && nDamageTotal >= pThis->Health )
115
+ if (nDamageLeft >= 0 )
115
116
{
116
- *args->Damage = 0 ;
117
- pThis->Health = 1 ;
118
- pThis->EstimatedHealth = 1 ;
119
- ReceiveDamageTemp::SkipLowDamageCheck = true ;
120
- }
121
-
122
- return 0 ;
123
- }
117
+ *args->Damage = nDamageLeft;
124
118
125
- nDamageLeft = pShieldData->ReceiveDamage (args);
126
-
127
- if (nDamageLeft >= 0 )
128
- {
129
- *args->Damage = nDamageLeft;
119
+ if (auto pTag = pThis->AttachedTag )
120
+ pTag->RaiseEvent ((TriggerEvent)PhobosTriggerEvent::ShieldBroken, pThis, CellStruct::Empty);
121
+ }
130
122
131
- if (auto pTag = pThis-> AttachedTag )
132
- pTag-> RaiseEvent ((TriggerEvent)PhobosTriggerEvent::ShieldBroken, pThis, CellStruct::Empty) ;
123
+ if (nDamageLeft == 0 )
124
+ ReceiveDamageTemp::SkipLowDamageCheck = true ;
133
125
}
134
-
135
- if (nDamageLeft == 0 )
136
- ReceiveDamageTemp::SkipLowDamageCheck = true ;
137
126
}
138
127
139
- // Update remaining damage and check if the target will die and should be avoided
140
- int nDamageTotal = MapClass::GetTotalDamage (nDamageLeft, args->WH , pThis->GetTechnoType ()->Armor , 0 );
141
-
142
- if (pThis->Health > 0 && unkillable && nDamageTotal >= pThis->Health )
128
+ if (pThis->Health > 0 && (!pWHExt->CanKill || pExt->AE .Unkillable ) // Check if the warhead can not kill targets
129
+ // Update remaining damage and check if the target will die and should be avoided
130
+ && MapClass::GetTotalDamage (nDamageLeft, args->WH , pThis->GetTechnoType ()->Armor , 0 ) >= pThis->Health )
143
131
{
144
132
*args->Damage = 0 ;
145
133
pThis->Health = 1 ;
0 commit comments