Skip to content

Commit f61f345

Browse files
authored
[Vanillia Enhancement] Customize airstrike targets (#1633)
- By default whether or not a building can be targeted by airstrikes depends on value of `CanC4`, which also affects other things. This can now be changed independently by setting `AllowAirstrike`. If not set, defaults to value of `CanC4`. - 默认情况下建筑能否作为空袭目标取决于 `CanC4` 的值,这也会影响其他方面。现在可以通过设置 `AllowAirstrike` 来独立更改这一点,如果未设置,默认为 `CanC4` 的值。 - For non building situations, the default value is true. - 对于不是建筑物的目标,其默认值为true。 - Now it is possible to designate air strikes against non building targets. - 现在可以向非建筑目标发起空袭。 - The airstrike aircraft will now aim at the target itself rather than the cell beneath its feet. - 空袭的飞机现在将会瞄准目标本身而不是其脚下的格子。 - Separate the AirstrikeClass pointer between the attacker/aircraft and the target to avoid erroneous overwriting issues. - 分离了攻击者/飞机和目标所用的空袭类对象指针,以免出现错误的指针覆写问题。 - Fixed the bug that buildings will always be tinted as airstrike owner. - 修复当建筑物可以召唤空袭时,它将始终被染色的bug。 - Fixed bug where 'AllowAirstrike=no' cannot completely prevent air strikes from being launched against it. - 修复了 `AllowAirstrike=no` 不能完全阻止对其发动空袭的bug。 In `rulesmd.ini`: ```ini [SOMETECHNO] AllowAirstrike= ; boolean [SOMEWARHEAD] AirstrikeTargets=building ; List of Affected Target Enumeration (none|infantry|units|buildings|all) ```
1 parent e5b66f0 commit f61f345

File tree

17 files changed

+382
-53
lines changed

17 files changed

+382
-53
lines changed

CREDITS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ This page lists all the individual contributions to the project by their author.
379379
- Customize parasite culling targets
380380
- Customize harvester dump amount
381381
- Select box logic
382+
- Customize airstrike targets
383+
- Separate the AirstrikeClass pointer between the attacker/aircraft and the target to avoid erroneous overwriting issues
384+
- Fix the bug that buildings will always be tinted as airstrike owner
385+
- Fix the bug that 'AllowAirstrike=no' cannot completely prevent air strikes from being launched against it
382386
- **Apollo** - Translucent SHP drawing patches
383387
- **ststl**:
384388
- Customizable `ShowTimer` priority of superweapons

Phobos.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<ClCompile Include="src\Blowfish\blowfish.cpp" />
2222
<ClCompile Include="src\Blowfish\Hooks.Blowfish.cpp" />
2323
<ClCompile Include="src\Ext\TechnoType\Hooks.MatrixOp.cpp" />
24+
<ClCompile Include="src\Ext\Techno\Hooks.Airstrike.cpp" />
2425
<ClCompile Include="src\Ext\Unit\Hooks.Harvester.cpp" />
2526
<ClCompile Include="src\Ext\Unit\Hooks.Sinking.cpp" />
2627
<ClCompile Include="src\Misc\Hooks.AlphaImage.cpp" />

docs/Fixed-or-Improved-Logics.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
219219
- Fixed the bug that a unit can overlap with `Teleport` units after it's been damaged by a fallen unit lifted by `IsLocomotor=yes` warheads.
220220
- Fixed an issue that game crashes (EIP:7FB178) when infantry are about to enter an occupiable building that has been removed and is not real dead.
221221
- Fixed an issue that game crashes when spawnee has been removed and is not real dead.
222+
- Separated the AirstrikeClass pointer between the attacker/aircraft and the target to avoid erroneous overwriting issues.
223+
- Fixed the bug that buildings will always be tinted as airstrike owner.
224+
- Fixed the bug that 'AllowAirstrike=no' cannot completely prevent air strikes from being launched against it.
222225

223226
## Fixes / interactions with other extensions
224227

@@ -406,16 +409,6 @@ In `rulesmd.ini`:
406409
AircraftDockingDir(N)= ; Direction type (integers from 0-255)
407410
```
408411

409-
### Airstrike target eligibility
410-
411-
- By default whether or not a building can be targeted by airstrikes depends on value of `CanC4`, which also affects other things. This can now be changed independently by setting `AllowAirstrike`. If not set, defaults to value of `CanC4`.
412-
413-
In `rulesmd.ini`:
414-
```ini
415-
[SOMEBUILDING] ; BuildingType
416-
AllowAirstrike= ; boolean
417-
```
418-
419412
### Allowed / disallowed types for FactoryPlant
420413

421414
- It is now possible to customize which TechnoTypes benefit from bonuses of a `FactoryPlant=true` building by listing them on `FactoryPlant.AllowTypes` and/or `FactoryPlant.DisallowTypes`.
@@ -845,6 +838,22 @@ In `artmd.ini`:
845838
Image= ; name of the file that will be used as image, without extension
846839
```
847840

841+
### Airstrike target eligibility
842+
843+
- By default whether or not a building can be targeted by airstrikes depends on value of `CanC4`, which also affects other things. This can now be changed independently by setting `AllowAirstrike`. If not set, defaults to value of `CanC4`.
844+
- For non building situations, the default value is true.
845+
- Now it is possible to designate air strikes against non building targets.
846+
- The airstrike aircraft will now aim at the target itself rather than the cell beneath its feet.
847+
848+
In `rulesmd.ini`:
849+
```ini
850+
[SOMETECHNO]
851+
AllowAirstrike= ; boolean
852+
853+
[SOMEWARHEAD]
854+
AirstrikeTargets=building ; List of Affected Target Enumeration (none|infantry|units|buildings|all)
855+
```
856+
848857
### Customizable veterancy insignias
849858

850859
- You can now customize veterancy insignia of TechnoTypes.

docs/Whats-New.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ New:
364364
- New `Pips.HideIfNoStrength` and `SelfHealing.EnabledBy` additions for shields (by FS-21)
365365
- [Customize harvester dump amount](Fixed-or-Improved-Logics.md#customize-harvester-dump-amount) (by NetsuNegi)
366366
- Select box logic (by NetsuNegi)
367+
- Customize airstrike targets (by NetsuNegi)
367368
368369
Vanilla fixes:
369370
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
@@ -382,9 +383,12 @@ Vanilla fixes:
382383
- Fixed wrong shadow when a vehicle has hover locomotor and is being lifted by `IsLocomotor=yes` warhead (by NetsuNegi)
383384
- Fixed an issue that game crashes (EIP:7FB178) when infantry are about to enter an occupiable building that has been removed and is not real dead (by CrimRecya)
384385
- Fixed an issue that game crashes when spawnee has been removed and is not real dead (by CrimRecya)
386+
- Separated the AirstrikeClass pointer between the attacker/aircraft and the target to avoid erroneous overwriting issues (by NetsuNegi)
387+
- Fixed the bug that buildings will always be tinted as airstrike owner (by NetsuNegi)
385388
386389
Phobos fixes:
387390
- Fixed an issue that MCV will self-destruct when using trigger 107 to teleport (by CrimRecya)
391+
- Fixed the bug that 'AllowAirstrike=no' cannot completely prevent air strikes from being launched against it (by NetsuNegi)
388392
389393
Fixes / interactions with other extensions:
390394
- Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades (by Ollerus)

src/Ext/BuildingType/Body.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
140140
if (pThis->PowersUpBuilding[0] == NULL && this->PowersUp_Buildings.size() > 0)
141141
strcpy_s(pThis->PowersUpBuilding, this->PowersUp_Buildings[0]->ID);
142142

143-
this->AllowAirstrike.Read(exINI, pSection, "AllowAirstrike");
144143
this->CanC4_AllowZeroDamage.Read(exINI, pSection, "CanC4.AllowZeroDamage");
145144

146145
this->InitialStrength_Cloning.Read(exINI, pSection, "InitialStrength.Cloning");
@@ -263,7 +262,6 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
263262
.Process(this->SuperWeapons)
264263
.Process(this->OccupierMuzzleFlashes)
265264
.Process(this->Powered_KillSpawns)
266-
.Process(this->AllowAirstrike)
267265
.Process(this->CanC4_AllowZeroDamage)
268266
.Process(this->InitialStrength_Cloning)
269267
.Process(this->ExcludeFromMultipleFactoryBonus)

src/Ext/BuildingType/Body.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class BuildingTypeExt
2828

2929
std::vector<Point2D> OccupierMuzzleFlashes;
3030
Valueable<bool> Powered_KillSpawns;
31-
Nullable<bool> AllowAirstrike;
3231
Valueable<bool> CanC4_AllowZeroDamage;
3332
Valueable<bool> Refinery_UseStorage;
3433
Valueable<PartialVector2D<double>> InitialStrength_Cloning;
@@ -93,7 +92,6 @@ class BuildingTypeExt
9392
, PowerPlantEnhancer_Factor { 1.0 }
9493
, OccupierMuzzleFlashes()
9594
, Powered_KillSpawns { false }
96-
, AllowAirstrike {}
9795
, CanC4_AllowZeroDamage { false }
9896
, InitialStrength_Cloning { { 1.0, 0.0 } }
9997
, ExcludeFromMultipleFactoryBonus { false }

src/Ext/BuildingType/Hooks.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -153,30 +153,6 @@ DEFINE_HOOK(0x47EFAE, CellClass_Draw_It_SetPlacementGridTranslucency, 0x6)
153153
return 0;
154154
}
155155

156-
DEFINE_HOOK(0x6F34B7, TechnoClass_WhatWeaponShouldIUse_AllowAirstrike, 0x6)
157-
{
158-
enum { SkipGameCode = 0x6F34BD };
159-
160-
GET(BuildingTypeClass*, pThis, ECX);
161-
162-
const auto pExt = BuildingTypeExt::ExtMap.Find(pThis);
163-
R->EAX(pExt->AllowAirstrike.Get(pThis->CanC4));
164-
165-
return SkipGameCode;
166-
}
167-
168-
DEFINE_HOOK(0x51EAF2, TechnoClass_WhatAction_AllowAirstrike, 0x6)
169-
{
170-
enum { SkipGameCode = 0x51EAF8 };
171-
172-
GET(BuildingTypeClass*, pThis, ESI);
173-
174-
const auto pExt = BuildingTypeExt::ExtMap.Find(pThis);
175-
R->EAX(pExt->AllowAirstrike.Get(pThis->CanC4));
176-
177-
return SkipGameCode;
178-
}
179-
180156
// Rewritten
181157
DEFINE_HOOK(0x465D40, BuildingTypeClass_IsVehicle, 0x6)
182158
{

src/Ext/Techno/Body.Internal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ int TechnoExt::GetTintColor(TechnoClass* pThis, bool invulnerability, bool airst
165165
{
166166
if (invulnerability && pThis->IsIronCurtained())
167167
tintColor |= GeneralUtils::GetColorFromColorAdd(pThis->ForceShielded ? RulesClass::Instance->ForceShieldColor : RulesClass::Instance->IronCurtainColor);
168-
if (airstrike && pThis->Airstrike && pThis->Airstrike->Target == pThis)
168+
if (airstrike && TechnoExt::ExtMap.Find(pThis)->AirstrikeTargetingMe)
169169
tintColor |= GeneralUtils::GetColorFromColorAdd(RulesClass::Instance->LaserTargetColor);
170170
if (berserk && pThis->Berzerk)
171171
tintColor |= GeneralUtils::GetColorFromColorAdd(RulesClass::Instance->BerserkColor);

src/Ext/Techno/Body.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ void TechnoExt::ExtData::Serialize(T& Stm)
587587
.Process(this->IsBeingChronoSphered)
588588
.Process(this->KeepTargetOnMove)
589589
.Process(this->LastSensorsMapCoords)
590+
.Process(this->AirstrikeTargetingMe)
590591
;
591592
}
592593

src/Ext/Techno/Body.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class TechnoExt
6868
bool KeepTargetOnMove;
6969
CellStruct LastSensorsMapCoords;
7070

71+
AirstrikeClass* AirstrikeTargetingMe;
72+
7173
ExtData(TechnoClass* OwnerObject) : Extension<TechnoClass>(OwnerObject)
7274
, TypeExtData { nullptr }
7375
, Shield {}
@@ -110,6 +112,7 @@ class TechnoExt
110112
, IsBeingChronoSphered { false }
111113
, KeepTargetOnMove { false }
112114
, LastSensorsMapCoords { CellStruct::Empty }
115+
, AirstrikeTargetingMe { nullptr }
113116
{ }
114117

115118
void OnEarlyUpdate();

0 commit comments

Comments
 (0)