Skip to content

Commit 8f27ae5

Browse files
authored
[Customized] Reverse engineer warhead (#1813)
- Warheads can now uses the reverse-engineering logic *(Ares feature)* , the technology of the victim will be reversed. In `rulesmd.ini`: ```ini [SOMEWARHEAD] ; WarheadType ReverseEngineer=false ; boolean ``` ```{warning} This feature requires Ares 3.0 or higher to function! ```
1 parent f23649b commit 8f27ae5

File tree

8 files changed

+47
-4
lines changed

8 files changed

+47
-4
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ This page lists all the individual contributions to the project by their author.
532532
- Burst without delay
533533
- Fix an issue that if the garrison unload occupants when there is no open space around it would result in the disappearance of the occupants
534534
- Fix an issue where Ares' `Convert.Deploy` triggers repeatedly when the unit is turning or moving
535+
- Reverse engineer warhead
535536
- **Ollerus**:
536537
- Build limit group enhancement
537538
- Customizable rocker amplitude

docs/New-or-Enhanced-Logics.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,6 +2398,20 @@ In `rulesmd.ini`:
23982398
Reveal=0 ; integer - cell radius, negative values mean reveal the entire map
23992399
```
24002400

2401+
### Reverse engineer warhead
2402+
2403+
- Warheads can now uses the reverse-engineering logic *(Ares feature)* , the technology of the victim will be reversed.
2404+
2405+
In `rulesmd.ini`:
2406+
```ini
2407+
[SOMEWARHEAD] ; WarheadType
2408+
ReverseEngineer=false ; boolean
2409+
```
2410+
2411+
```{warning}
2412+
This feature requires Ares 3.0 or higher to function!
2413+
```
2414+
24012415
### Sell or undeploy building on impact
24022416

24032417
- Warheads with `BuildingSell` can now sell buildings with build up image. It has a higher priority than `BuildingUndeploy`.

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ New:
429429
- Customize squid grapple animation (by NetsuNegi)
430430
- [Auto deploy for GI-like infantry](Fixed-or-Improved-Logics.md#auto-deploy-for-gi-like-infantry) (by TaranDahl)
431431
- When the vehicle loses its target, you can customize whether to align the turret direction with the vehicle body (by FlyStar)
432+
- Reverse engineer warhead (by CrimRecya)
432433
433434
Vanilla fixes:
434435
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/WarheadType/Body.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
301301
if (this->AffectsAbovePercent > this->AffectsBelowPercent)
302302
Debug::Log("[Developer warning][%s] AffectsAbovePercent is bigger than AffectsBelowPercent, the warhead will never activate!\n", pSection);
303303

304+
this->ReverseEngineer.Read(exINI, pSection, "ReverseEngineer");
305+
304306
// Convert.From & Convert.To
305307
TypeConvertGroup::Parse(this->Convert_Pairs, exINI, pSection, AffectedHouse::All);
306308

@@ -356,6 +358,7 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
356358
|| this->AttachEffects.RemoveGroups.size() > 0
357359
|| this->BuildingSell
358360
|| this->BuildingUndeploy
361+
|| this->ReverseEngineer
359362
);
360363

361364
char tempBuffer[32];
@@ -565,6 +568,10 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)
565568

566569
.Process(this->AirstrikeTargets)
567570

571+
.Process(this->CanKill)
572+
573+
.Process(this->ReverseEngineer)
574+
568575
// Ares tags
569576
.Process(this->AffectsEnemies)
570577
.Process(this->AffectsOwner)
@@ -576,8 +583,6 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)
576583
.Process(this->PossibleCellSpreadDetonate)
577584
.Process(this->Reflected)
578585
.Process(this->DamageAreaTarget)
579-
580-
.Process(this->CanKill)
581586
;
582587
}
583588

src/Ext/WarheadType/Body.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ class WarheadTypeExt
187187
Valueable<double> AffectsAbovePercent;
188188
Valueable<bool> AffectsNeutral;
189189

190+
Valueable<bool> ReverseEngineer;
191+
192+
Valueable<bool> CanKill;
193+
190194
// Ares tags
191195
// http://ares-developers.github.io/Ares-docs/new/warheads/general.html
192196
Valueable<bool> AffectsEnemies;
@@ -206,8 +210,6 @@ class WarheadTypeExt
206210
bool HealthCheck;
207211
TechnoClass* DamageAreaTarget;
208212

209-
Valueable<bool> CanKill;
210-
211213
private:
212214
Valueable<double> Shield_Respawn_Rate_InMinutes;
213215
Valueable<double> Shield_SelfHealing_Rate_InMinutes;
@@ -398,6 +400,8 @@ class WarheadTypeExt
398400
, KillWeapon_OnFirer_AffectsHouses { AffectedHouse::All }
399401
, KillWeapon_Affects { AffectedTarget::All }
400402
, KillWeapon_OnFirer_Affects { AffectedTarget::All }
403+
404+
, ReverseEngineer { false }
401405
{ }
402406

403407
void ApplyConvert(HouseClass* pHouse, TechnoClass* pTarget);
@@ -433,6 +437,7 @@ class WarheadTypeExt
433437
void ApplyShieldModifiers(TechnoClass* pTarget);
434438
void ApplyAttachEffects(TechnoClass* pTarget, HouseClass* pInvokerHouse, TechnoClass* pInvoker);
435439
void ApplyBuildingUndeploy(TechnoClass* pTarget);
440+
void ApplyReverseEngineer(HouseClass* pHouse, TechnoClass* pTarget);
436441
double GetCritChance(TechnoClass* pFirer) const;
437442
};
438443

src/Ext/WarheadType/Detonate.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <Misc/FlyingStrings.h>
1717
#include <Utilities/Helpers.Alex.h>
1818
#include <Utilities/EnumFunctions.h>
19+
#include <Utilities/AresFunctions.h>
1920

2021
#pragma region CreateGap Calls
2122

@@ -215,6 +216,9 @@ void WarheadTypeExt::ExtData::DetonateOnOneUnit(HouseClass* pHouse, TechnoClass*
215216
if (this->BuildingSell || this->BuildingUndeploy)
216217
this->ApplyBuildingUndeploy(pTarget);
217218

219+
if (this->ReverseEngineer)
220+
this->ApplyReverseEngineer(pHouse, pTarget);
221+
218222
#ifdef LOCO_TEST_WARHEADS
219223
if (this->InflictLocomotor)
220224
this->ApplyLocomotorInfliction(pTarget);
@@ -225,6 +229,12 @@ void WarheadTypeExt::ExtData::DetonateOnOneUnit(HouseClass* pHouse, TechnoClass*
225229

226230
}
227231

232+
void WarheadTypeExt::ExtData::ApplyReverseEngineer(HouseClass* pHouse, TechnoClass* pTarget)
233+
{
234+
if (pHouse && !pHouse->Type->MultiplayPassive && AresFunctions::ReverseEngineer)
235+
AresFunctions::ReverseEngineer(reinterpret_cast<void*>(pHouse->unknown_16084), pTarget->GetTechnoType());
236+
}
237+
228238
void WarheadTypeExt::ExtData::ApplyBuildingUndeploy(TechnoClass* pTarget)
229239
{
230240
const auto pBuilding = abstract_cast<BuildingClass*, true>(pTarget);

src/Utilities/AresAddressInit.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
decltype(AresFunctions::ConvertTypeTo) AresFunctions::ConvertTypeTo = nullptr;
88
decltype(AresFunctions::CreateAresEBolt) AresFunctions::CreateAresEBolt = nullptr;
99
decltype(AresFunctions::SpawnSurvivors) AresFunctions::SpawnSurvivors = nullptr;
10+
decltype(AresFunctions::ReverseEngineer) AresFunctions::ReverseEngineer = nullptr;
1011
decltype(AresFunctions::IsTargetConstraintsEligible) AresFunctions::IsTargetConstraintsEligible = nullptr;
1112
std::function<AresSWTypeExtData* (SuperWeaponTypeClass*)> AresFunctions::SWTypeExtMap_Find;
1213
PhobosMap<ObjectClass*, AlphaShapeClass*>* AresFunctions::AlphaExtMap = nullptr;
@@ -33,6 +34,8 @@ void AresFunctions::InitAres3_0()
3334
NOTE_ARES_FUN(SpawnSurvivors, 0x464C0);
3435
}
3536

37+
NOTE_ARES_FUN(ReverseEngineer, 0x022360);
38+
3639
NOTE_ARES_FUN(IsTargetConstraintsEligible, 0x032110);
3740

3841
NOTE_ARES_FUN(_SWTypeExtMapFind, 0x57C70);
@@ -62,6 +65,8 @@ void AresFunctions::InitAres3_0p1()
6265
NOTE_ARES_FUN(SpawnSurvivors, 0x47030);
6366
}
6467

68+
NOTE_ARES_FUN(ReverseEngineer, 0x022DE0);
69+
6570
NOTE_ARES_FUN(IsTargetConstraintsEligible, 0x032AF0);
6671

6772
NOTE_ARES_FUN(_SWTypeExtMapFind, 0x58900);

src/Utilities/AresFunctions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class AresFunctions
3232

3333
static void(__stdcall* SpawnSurvivors)(FootClass* pThis, TechnoClass* pKiller, bool Select, bool IgnoreDefenses);
3434

35+
static bool(__thiscall* ReverseEngineer)(void* pAresHouseExt, TechnoTypeClass* pType);
36+
3537
static bool(__thiscall* IsTargetConstraintsEligible)(void*, HouseClass*, bool);
3638

3739
static std::function<AresSWTypeExtData* (SuperWeaponTypeClass*)> SWTypeExtMap_Find;

0 commit comments

Comments
 (0)