Skip to content
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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ This page lists all the individual contributions to the project by their author.
- Fast access structure
- Iron Curtain/Custom Tint Support for SHP Turreted Vehicles
- Reactivate unused trigger events 2, 53, and 54
- Attack non-threatening structures extensions
- **NetsuNegi**:
- Forbidding parallel AI queues by type
- Jumpjet crash speed fix when crashing onto building
Expand Down
22 changes: 22 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,18 @@ In `rulesmd.ini`:
AttackMove.IgnoreWeaponCheck=false ; boolean
```

### Attack non-threatening structures

- You can now freely configure whether units can automatically target non-threatening structures.
- `AutoTarget.NoThreatBuildings` affects player-controlled units, `AutoTargetAI.NoThreatBuildings` affects other units.

In `rulesmd.ini`:
```ini
[General]
AutoTarget.NoThreatBuildings=false ; boolean
AutoTargetAI.NoThreatBuildings=true ; boolean
```

### Aircraft spawner customizations

![image](_static/images/spawnrange-01.gif)
Expand Down Expand Up @@ -2575,6 +2587,16 @@ In `rulesmd.ini`:
AreaFire.Target=base ; AreaFire Target Enumeration (base|self|random)
```

### Attack non-threatening structures

- `AttackNoThreatBuildings` permits shooters to attack non-threatening structures. This setting overrides other configurations.

In `rulesmd.ini`:
```ini
[SOMEWEAPON] ; WeaponType
AttackNoThreatBuildings= ; boolean
```

### Burst delay customizations

- `Burst.Delays` allows specifying weapon-specific burst shot delays. Takes precedence over the old `BurstDelayX` logic available on VehicleTypes, functions with Infantry & BuildingType weapons (AircraftTypes are not supported due to their weapon firing system being completely different) and allows every shot of `Burst` to have a separate delay instead of only first four shots.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ New:
- Fast access structure (by FlyStar)
- Toggle off laser trail and shake effects (by Ollerus)
- [Dehardcode the `ZAdjust` of warhead anim](Fixed-or-Improved-Logics.md#dehardcode-the-zadjust-of-warhead-anim) (by TaranDahl)
- Attack non-threatening structures extensions (by FlyStar)

Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
5 changes: 5 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)

this->IvanBombAttachToCenter.Read(exINI, GameStrings::CombatDamage, "IvanBombAttachToCenter");

this->AutoTarget_NoThreatBuildings.Read(exINI, GameStrings::General, "AutoTarget.NoThreatBuildings");
this->AutoTargetAI_NoThreatBuildings.Read(exINI, GameStrings::General, "AutoTargetAI.NoThreatBuildings");

// Section AITargetTypes
int itemsCount = pINI->GetKeyCount("AITargetTypes");
for (int i = 0; i < itemsCount; ++i)
Expand Down Expand Up @@ -600,6 +603,8 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->AdjacentWallDamage)
.Process(this->WarheadAnimZAdjust)
.Process(this->IvanBombAttachToCenter)
.Process(this->AutoTarget_NoThreatBuildings)
.Process(this->AutoTargetAI_NoThreatBuildings)
;
}

Expand Down
6 changes: 6 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ class RulesExt

Valueable<bool> IvanBombAttachToCenter;

Valueable<bool> AutoTarget_NoThreatBuildings;
Valueable<bool> AutoTargetAI_NoThreatBuildings;

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Storage_TiberiumIndex { -1 }
, HarvesterDumpAmount { 0.0f }
Expand Down Expand Up @@ -494,6 +497,9 @@ class RulesExt
, WarheadAnimZAdjust { -15 }

, IvanBombAttachToCenter { false }

, AutoTarget_NoThreatBuildings { false }
, AutoTargetAI_NoThreatBuildings { true }
{ }

virtual ~ExtData() = default;
Expand Down
6 changes: 4 additions & 2 deletions src/Ext/Techno/Hooks.TargetEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ DEFINE_HOOK(0x6F85AB, TechnoClass_CanAutoTargetObject_AggressiveAttackMove, 0x6)

GET(TechnoClass* const, pThis, EDI);

if (!pThis->Owner->IsControlledByHuman())
return CanTarget;
// Now, it is possible to customize which types of national active attacks on non-threatening buildings, so this part has been commented out.
// The new judgment code is in TechnoClass_CanAutoTarget_AttackNoThreatBuildings of Hook.cpp.
// if (!pThis->Owner->IsControlledByHuman())
// return CanTarget;

if (!pThis->MegaMissionIsAttackMove())
return ContinueCheck;
Expand Down
41 changes: 41 additions & 0 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1520,3 +1520,44 @@ DEFINE_HOOK(0x6F9398, TechnoClass_SelectAutoTarget_Scan_FallingDown, 0x9)
}

#pragma endregion

#pragma region AutoTargetExtension

namespace CanAutoTargetTemp
{
TechnoTypeExt::ExtData* TypeExtData = nullptr;
WeaponTypeExt::ExtData* WeaponExt = nullptr;
}

DEFINE_HOOK(0x6F7E30, TechnoClass_CanAutoTarget_SetContent, 0x6)
{
GET(TechnoClass*, pThis, EDI);
GET(WeaponTypeClass*, pWeapon, EBP);

CanAutoTargetTemp::TypeExtData = TechnoExt::ExtMap.Find(pThis)->TypeExtData;
CanAutoTargetTemp::WeaponExt = WeaponTypeExt::ExtMap.TryFind(pWeapon);

return 0;
}

DEFINE_HOOK(0x6F85CF, TechnoClass_CanAutoTarget_AttackNoThreatBuildings, 0xA)
{
enum { CanAttack = 0x6F8604, Continue = 0x6F85D9 };

GET(TechnoClass*, pThis, EDI);
GET(BuildingClass*, pTarget, ESI);

bool canAttack = pThis->Owner->IsControlledByHuman() ? RulesExt::Global()->AutoTarget_NoThreatBuildings : RulesExt::Global()->AutoTargetAI_NoThreatBuildings;

if (const auto pWeaponExt = CanAutoTargetTemp::WeaponExt)
canAttack = pWeaponExt->AttackNoThreatBuildings.Get(canAttack);

if (canAttack)
return CanAttack;

R->EAX(pTarget->GetTurretWeapon());
return Continue;
}

#pragma endregion

2 changes: 2 additions & 0 deletions src/Ext/WeaponType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->DelayedFire_OnlyOnInitialBurst.Read(exINI, pSection, "DelayedFire.OnlyOnInitialBurst");
this->DelayedFire_AnimOffset.Read(exINI, pSection, "DelayedFire.AnimOffset");
this->DelayedFire_AnimOnTurret.Read(exINI, pSection, "DelayedFire.AnimOnTurret");
this->AttackNoThreatBuildings.Read(exINI, pSection, "AttackNoThreatBuildings");

// handle SkipWeaponPicking
if (this->CanTarget != AffectedTarget::All || this->CanTargetHouses != AffectedHouse::All
Expand Down Expand Up @@ -237,6 +238,7 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm)
.Process(this->DelayedFire_OnlyOnInitialBurst)
.Process(this->DelayedFire_AnimOffset)
.Process(this->DelayedFire_AnimOnTurret)
.Process(this->AttackNoThreatBuildings)
;
};

Expand Down
2 changes: 2 additions & 0 deletions src/Ext/WeaponType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class WeaponTypeExt
Valueable<bool> DelayedFire_OnlyOnInitialBurst;
Nullable<CoordStruct> DelayedFire_AnimOffset;
Valueable<bool> DelayedFire_AnimOnTurret;
Nullable<bool> AttackNoThreatBuildings;

bool SkipWeaponPicking;

Expand Down Expand Up @@ -164,6 +165,7 @@ class WeaponTypeExt
, DelayedFire_OnlyOnInitialBurst { false }
, DelayedFire_AnimOffset {}
, DelayedFire_AnimOnTurret { true }
, AttackNoThreatBuildings {}
{ }

int GetBurstDelay(int burstIndex) const;
Expand Down