Skip to content
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

Warhead that can not kill #1518

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ This page lists all the individual contributions to the project by their author.
- Customizable FLH when infantry is prone or deployed
- Initial strength for cloned infantry
- Map Events 604 & 605 for checking if a specific Techno enters in a cell
- Warhead that can not kill
- **Starkku**:
- Misc. minor bugfixes & improvements
- AI script actions:
Expand Down Expand Up @@ -349,6 +350,7 @@ This page lists all the individual contributions to the project by their author.
- Disguised units not using the correct palette if target has custom palette bugfix
- Tunnel/Walk/Mech locomotor being stuck when moving too fast bugfix
- Assign Super Weapon cameo to any sidebar tab
- Fix impassable invisible barrier created by chronosphere on uncrushable unit.
- **Apollo** - Translucent SHP drawing patches
- **ststl**
- Customizable ShowTimer priority of superweapons
Expand Down
2 changes: 1 addition & 1 deletion YRpp
1 change: 1 addition & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Allowed `AuxBuilding` to count building upgrades.
- Fix the bug that parasite will vanish if it missed its target when its previous cell is occupied.
- Prevent the units with locomotors that cause problems from entering the tank bunker.
- Fix an issue where a unit will leave an impassable invisible barrier in its original position when it is teleported by ChronoSphere onto an uncrushable unit and self destruct.

## Fixes / interactions with other extensions

Expand Down
11 changes: 11 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,17 @@ In `rulesmd.ini`:
RemoveMindControl=false ; boolean
```

### Warhead that can not kill

- Warheads can now damage the enemy without killing them (minimum health will be 1).
- Verified in conventional weapons and radiation types.

In `rulesmd.ini`:
```ini
[SOMEWARHEAD] ; Warhead
CanKill=true ; boolean
```

### Chance-based extra damage or Warhead detonation / 'critical hits'

- 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.
Expand Down
2 changes: 2 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,13 @@ New:
- Enhanced Bombard trajectory (by CrimRecya & Ollerus, based on knowledge of NaotoYuuki)
- Toggle waypoint for building (by TaranDahl)
- Bunkerable checks dehardcode (by TaranDahl)
- Warhead that can not kill (by FS-21)

Vanilla fixes:
- 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)
- Fix the bug that parasite will vanish if it missed its target when its previous cell is occupied (by 航味麻酱)
- Prevent the units with locomotors that cause problems from entering the tank bunker (by TaranDahl)
- Fix an issue where a unit will leave an impassable invisible barrier in its original position when it is teleported by ChronoSphere onto an uncrushable unit and self destruct (by NetsuNegi)

Phobos fixes:
- Type conversion on Warheads and Superweapons will no longer recursively convert units if applicable conversion pairs are listed, and only first applicable pair takes effect (by Starkku)
Expand Down
18 changes: 13 additions & 5 deletions src/Ext/RadSite/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ void RadSiteExt::ExtData::Initialize()
bool RadSiteExt::ExtData::ApplyRadiationDamage(TechnoClass* pTarget, int& damage, int distance)
{
auto const pWarhead = this->Type->GetWarhead();
auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWarhead);

// Check if the WH should affect the techno target or skip it
int nDamageTotal = MapClass::GetTotalDamage(damage, pWarhead, pTarget->GetTechnoType()->Armor, 0);

if (pTarget->Health > 0 && !pWHExt->CanKill && nDamageTotal >= pTarget->Health)
{
damage = 0;
pTarget->Health = 1;
pTarget->EstimatedHealth = 1;

return false;
}

if (!this->Type->GetWarheadDetonate())
{
Expand All @@ -23,14 +36,9 @@ bool RadSiteExt::ExtData::ApplyRadiationDamage(TechnoClass* pTarget, int& damage
else
{
if (this->Type->GetWarheadDetonateFull())
{
WarheadTypeExt::DetonateAt(pWarhead, pTarget, this->RadInvoker, damage, this->RadHouse);
}
else
{
auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWarhead);
pWHExt->DamageAreaWithTarget(pTarget->GetCoords(), damage, this->RadInvoker, pWarhead, true, this->RadHouse, pTarget);
}

if (!pTarget->IsAlive)
return false;
Expand Down
26 changes: 26 additions & 0 deletions src/Ext/Techno/Hooks.ReceiveDamage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ namespace ReceiveDamageTemp
// #issue 88 : shield logic
DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
{
enum { SkipGameCode = 0x701A38 };

GET(TechnoClass*, pThis, ECX);
LEA_STACK(args_ReceiveDamage*, args, 0x4);

const auto pRules = RulesExt::Global();
const auto pExt = TechnoExt::ExtMap.Find(pThis);
int nDamageLeft = *args->Damage;
int nDamageTotal = MapClass::GetTotalDamage(nDamageLeft, args->WH, pThis->GetTechnoType()->Armor, 0);
auto const pWHExt = WarheadTypeExt::ExtMap.Find(args->WH);

// Raise Combat Alert
if (pRules->CombatAlert && nDamageLeft > 1)
Expand Down Expand Up @@ -91,7 +95,18 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
if (const auto pShieldData = pExt->Shield.get())
{
if (!pShieldData->IsActive())
{
// Check if the warhead can not kill targets
if (pThis->Health > 0 && !pWHExt->CanKill && nDamageTotal >= pThis->Health)
{
*args->Damage = 0;
pThis->Health = 1;
pThis->EstimatedHealth = 1;
ReceiveDamageTemp::SkipLowDamageCheck = true;
}

return 0;
}

nDamageLeft = pShieldData->ReceiveDamage(args);

Expand All @@ -108,6 +123,17 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
}
}

// Update remaining damage and check if the target will die and should be avoided
nDamageTotal = MapClass::GetTotalDamage(nDamageLeft, args->WH, pThis->GetTechnoType()->Armor, 0);

if (pThis->Health > 0 && !pWHExt->CanKill && nDamageTotal >= pThis->Health)
{
*args->Damage = 0;
pThis->Health = 1;
pThis->EstimatedHealth = 1;
ReceiveDamageTemp::SkipLowDamageCheck = true;
}

return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions src/Ext/WarheadType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

this->CombatAlert_Suppress.Read(exINI, pSection, "CombatAlert.Suppress");

this->CanKill.Read(exINI, pSection, "CanKill");

// Convert.From & Convert.To
TypeConvertGroup::Parse(this->Convert_Pairs, exINI, pSection, AffectedHouse::All);

Expand Down Expand Up @@ -505,6 +507,8 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)
.Process(this->PossibleCellSpreadDetonate)
.Process(this->Reflected)
.Process(this->DamageAreaTarget)

.Process(this->CanKill)
;
}

Expand Down
4 changes: 4 additions & 0 deletions src/Ext/WarheadType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ class WarheadTypeExt
bool PossibleCellSpreadDetonate;
TechnoClass* DamageAreaTarget;

Valueable<bool> CanKill;

private:
Valueable<double> Shield_Respawn_Rate_InMinutes;
Valueable<double> Shield_SelfHealing_Rate_InMinutes;
Expand Down Expand Up @@ -322,6 +324,8 @@ class WarheadTypeExt
, RemainingAnimCreationInterval { 0 }
, PossibleCellSpreadDetonate { false }
, DamageAreaTarget {}

, CanKill { true }
{ }

void ApplyConvert(HouseClass* pHouse, TechnoClass* pTarget);
Expand Down
15 changes: 15 additions & 0 deletions src/Misc/Hooks.BugFixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,21 @@ DEFINE_HOOK(0x743664, UnitClass_ReadFromINI_Follower3, 0x6)

#pragma endregion

#pragma region TeleportLocomotionOccupationFix

DEFINE_HOOK(0x71872C, TeleportLocomotionClass_MakeRoom_OccupationFix, 0x9)
{
enum { SkipMarkOccupation = 0x71878F };

GET(const LocomotionClass* const, pLoco, EBP);

const auto pFoot = pLoco->LinkedTo;

return (pFoot && pFoot->IsAlive && !pFoot->InLimbo && pFoot->Health > 0 && !pFoot->IsSinking) ? 0 : SkipMarkOccupation;
}

#pragma endregion

#pragma region StopEventFix

DEFINE_HOOK(0x4C75DA, EventClass_RespondToEvent_Stop, 0x6)
Expand Down