Skip to content

Commit ff4e4a6

Browse files
committed
Initial commit
- Warheads can now damage the enemy without killing them (minimum health will be 1). - Verified in conventional weapons and radiation types. In `rulesmd.ini`: [SOMEWARHEAD] ; Warhead CanKill=false ; boolean
1 parent b9569c4 commit ff4e4a6

File tree

7 files changed

+63
-0
lines changed

7 files changed

+63
-0
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ This page lists all the individual contributions to the project by their author.
134134
- Customizable FLH when infantry is prone or deployed
135135
- Initial strength for cloned infantry
136136
- Map Events 604 & 605 for checking if a specific Techno enters in a cell
137+
- Warhead that can not kill
137138
- **Starkku**:
138139
- Misc. minor bugfixes & improvements
139140
- AI script actions:

docs/New-or-Enhanced-Logics.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,17 @@ In `rulesmd.ini`:
14751475
RemoveMindControl=false ; boolean
14761476
```
14771477

1478+
### Warhead that can not kill
1479+
1480+
- Warheads can now damage the enemy without killing them (minimum health will be 1).
1481+
- Verified in conventional weapons and radiation types.
1482+
1483+
In `rulesmd.ini`:
1484+
```ini
1485+
[SOMEWARHEAD] ; Warhead
1486+
CanKill=false ; boolean
1487+
```
1488+
14781489
### Chance-based extra damage or Warhead detonation / 'critical hits'
14791490

14801491
- Warheads can now apply additional chance-based damage or Warhead detonation ('critical hits') with the ability to customize chance, damage, affected targets, affected target HP threshold and animations of critical hit.

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ New:
318318
- Custom exit cell for infantry factory (by Starkku)
319319
- Option for vehicles to keep target when issued move command (by Starkku)
320320
- Skip anim delay for burst fire (by TaranDahl)
321+
- Warhead that can not kill (by FS-21)
321322
322323
Vanilla fixes:
323324
- Aircraft will now behave as expected according to it's `MovementZone` and `SpeedType` when moving onto different surfaces. In particular, this fixes erratic behavior when vanilla aircraft is ordered to move onto water surface and instead the movement order changes to a shore nearby (by CrimRecya)

src/Ext/RadSite/Body.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ void RadSiteExt::ExtData::Initialize()
1414
bool RadSiteExt::ExtData::ApplyRadiationDamage(TechnoClass* pTarget, int& damage, int distance)
1515
{
1616
auto const pWarhead = this->Type->GetWarhead();
17+
auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWarhead);
18+
19+
// Check if the WH should affect the techno target or skip it
20+
double versus = MapClass::GetTotalDamage(damage, pWarhead, pTarget->GetTechnoType()->Armor, 0);
21+
int nDamageTotal = damage * versus;
22+
23+
if (pTarget->Health > 0 && !pWHExt->CanKill && nDamageTotal >= pTarget->Health)
24+
{
25+
pTarget->Health = 1;
26+
pTarget->EstimatedHealth = 1;
27+
28+
return false;
29+
}
1730

1831
if (!this->Type->GetWarheadDetonate())
1932
{

src/Ext/Techno/Hooks.ReceiveDamage.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,36 @@ namespace ReceiveDamageTemp
1212
// #issue 88 : shield logic
1313
DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
1414
{
15+
enum { SkipGameCode = 0x701A38 };
16+
1517
GET(TechnoClass*, pThis, ECX);
1618
LEA_STACK(args_ReceiveDamage*, args, 0x4);
1719

1820
const auto pExt = TechnoExt::ExtMap.Find(pThis);
1921

2022
int nDamageLeft = *args->Damage;
23+
double versus = MapClass::GetTotalDamage(nDamageLeft, args->WH, pThis->GetTechnoType()->Armor, 0);
24+
int nDamageTotal = nDamageLeft * versus;
25+
auto const pWHExt = WarheadTypeExt::ExtMap.Find(args->WH);
2126

2227
if (!args->IgnoreDefenses)
2328
{
2429
if (const auto pShieldData = pExt->Shield.get())
2530
{
2631
if (!pShieldData->IsActive())
32+
{
33+
// Check if the warhead can not kill targets
34+
if (pThis->Health > 0 && !pWHExt->CanKill && nDamageTotal >= pThis->Health)
35+
{
36+
*args->Damage = 0;
37+
pThis->Health = 1;
38+
pThis->EstimatedHealth = 1;
39+
40+
return SkipGameCode;
41+
}
42+
2743
return 0;
44+
}
2845

2946
nDamageLeft = pShieldData->ReceiveDamage(args);
3047

@@ -41,6 +58,18 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
4158
}
4259
}
4360

61+
// Update remaining damage and check if the target will die and should be avoided
62+
nDamageTotal = nDamageLeft * versus;
63+
64+
if (pThis->Health > 0 && !pWHExt->CanKill && nDamageTotal >= pThis->Health)
65+
{
66+
*args->Damage = 0;
67+
pThis->Health = 1;
68+
pThis->EstimatedHealth = 1;
69+
70+
return SkipGameCode;
71+
}
72+
4473
return 0;
4574
}
4675

src/Ext/WarheadType/Body.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
266266
this->SuppressReflectDamage.Read(exINI, pSection, "SuppressReflectDamage");
267267
this->SuppressReflectDamage_Types.Read(exINI, pSection, "SuppressReflectDamage.Types");
268268

269+
this->CanKill.Read(exINI, pSection, "CanKill");
270+
269271
// Convert.From & Convert.To
270272
TypeConvertGroup::Parse(this->Convert_Pairs, exINI, pSection, AffectedHouse::All);
271273

@@ -499,6 +501,8 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)
499501
.Process(this->PossibleCellSpreadDetonate)
500502
.Process(this->Reflected)
501503
.Process(this->DamageAreaTarget)
504+
505+
.Process(this->CanKill)
502506
;
503507
}
504508

src/Ext/WarheadType/Body.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ class WarheadTypeExt
167167
bool PossibleCellSpreadDetonate;
168168
TechnoClass* DamageAreaTarget;
169169

170+
Valueable<bool> CanKill;
171+
170172
private:
171173
Valueable<double> Shield_Respawn_Rate_InMinutes;
172174
Valueable<double> Shield_SelfHealing_Rate_InMinutes;
@@ -316,6 +318,8 @@ class WarheadTypeExt
316318
, RemainingAnimCreationInterval { 0 }
317319
, PossibleCellSpreadDetonate { false }
318320
, DamageAreaTarget {}
321+
322+
, CanKill { true }
319323
{ }
320324

321325
void ApplyConvert(HouseClass* pHouse, TechnoClass* pTarget);

0 commit comments

Comments
 (0)