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

[Customized] Aggressive attack move mission #1473

Open
wants to merge 2 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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ This page lists all the individual contributions to the project by their author.
- Fix `LimboKill` not working reliably
- Allow using waypoints, area guard and attack move with aircraft
- Fix `Stop` command not working so well in some cases
- Aggressive attack move mission
- **Ollerus**
- Build limit group enhancement
- Customizable rocker amplitude
Expand Down
10 changes: 10 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,16 @@ Convert.HumanToComputer = ; TechnoType
Convert.ComputerToHuman = ; TechnoType
```

### Aggressive attack move mission

- `AttackMove.Aggressive` allows your technos to attack the enemy's unarmed buildings more aggressively when in attack move mission (Ctrl+Shift). If a higher threat enemy techno is found in the range during this process, it will attack this enemy techno instead first.

In `rulesmd.ini`:
```ini
[General]
AttackMove.Aggressive=false ; boolean
```

## Terrain

### Destroy animation & sound
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ New:
- Allow infantry to use land sequences in water (by Starkku)
- `<Player @ X>` can now be used as owner for pre-placed objects on skirmish and multiplayer maps (by Starkku)
- Allow customizing charge turret delays per burst on a weapon (by Starkku)
- Aggressive attack move mission (by CrimRecya)
- Unit `Speed` setting now accepts floating point values (by Starkku)

Vanilla fixes:
Expand Down
3 changes: 3 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)

this->UseFixedVoxelLighting.Read(exINI, GameStrings::AudioVisual, "UseFixedVoxelLighting");

this->AttackMove_Aggressive.Read(exINI, GameStrings::General, "AttackMove.Aggressive");

this->GatherWhenMCVDeploy.Read(exINI, GameStrings::General, "GatherWhenMCVDeploy");
this->AIFireSale.Read(exINI, GameStrings::General, "AIFireSale");
this->AIFireSaleDelay.Read(exINI, GameStrings::General, "AIFireSaleDelay");
Expand Down Expand Up @@ -384,6 +386,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->VoxelLightSource)
// .Process(this->VoxelShadowLightSource)
.Process(this->UseFixedVoxelLighting)
.Process(this->AttackMove_Aggressive)
.Process(this->GatherWhenMCVDeploy)
.Process(this->AIFireSale)
.Process(this->AIFireSaleDelay)
Expand Down
3 changes: 3 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class RulesExt
// Nullable<Vector3D<float>> VoxelShadowLightSource;
Valueable<bool> UseFixedVoxelLighting;

Valueable<bool> AttackMove_Aggressive;

Valueable<bool> GatherWhenMCVDeploy;
Valueable<bool> AIFireSale;
Valueable<int> AIFireSaleDelay;
Expand Down Expand Up @@ -280,6 +282,7 @@ class RulesExt
, VoxelLightSource { }
// , VoxelShadowLightSource { }
, UseFixedVoxelLighting { false }
, AttackMove_Aggressive { false }
, GatherWhenMCVDeploy { true }
, AIFireSale { true }
, AIFireSaleDelay { 0 }
Expand Down
69 changes: 69 additions & 0 deletions src/Ext/Techno/Hooks.TargetEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,75 @@ DEFINE_JUMP(CALL6, 0x6F8DD2, GET_OFFSET(TechnoClass_EvaluateCellGetWeaponRangeWr

#pragma endregion

#pragma region AggressiveAttackMove

static inline bool CheckAttackMoveCanResetTarget(FootClass* pThis)
{
const auto pTarget = pThis->Target;

if (!pTarget || pTarget == pThis->MegaTarget)
return false;

const auto pTargetTechno = abstract_cast<TechnoClass*>(pTarget);

if (!pTargetTechno || pTargetTechno->IsArmed())
return false;

if (pThis->TargetingTimer.InProgress())
return false;

const auto pPrimary = pThis->GetWeapon(0);

if (!pPrimary)
return false;

const auto pPrimaryWeapon = pPrimary->WeaponType;

if (!pPrimaryWeapon)
return false;

const auto pNewTarget = abstract_cast<TechnoClass*>(pThis->GreatestThreat(ThreatType::Range, &pThis->Location, false));

if (!pNewTarget || pNewTarget->GetTechnoType() == pTargetTechno->GetTechnoType())
return false;

const auto pSecondary = pThis->GetWeapon(1);

if (!pSecondary)
return true;

const auto pSecondaryWeapon = pSecondary->WeaponType;

if (!pSecondaryWeapon || !pSecondaryWeapon->NeverUse)
return true;

return pSecondaryWeapon->Range <= pPrimaryWeapon->Range;
}

DEFINE_HOOK(0x4DF3A0, FootClass_UpdateAttackMove_SelectNewTarget, 0x6)
{
GET(FootClass* const, pThis, ECX);

if (RulesExt::Global()->AttackMove_Aggressive && CheckAttackMoveCanResetTarget(pThis))
{
pThis->Target = nullptr;
pThis->HaveAttackMoveTarget = false;
}

return 0;
}

DEFINE_HOOK(0x6F85AB, TechnoClass_CanAutoTargetObject_AggressiveAttackMove, 0x6)
{
enum { ContinueCheck = 0x6F85BA, CanTarget = 0x6F8604 };

GET(TechnoClass* const, pThis, EDI);

return (!pThis->Owner->IsControlledByHuman() || (RulesExt::Global()->AttackMove_Aggressive && pThis->MegaMissionIsAttackMove())) ? CanTarget : ContinueCheck;
}

#pragma endregion

#pragma region HealingWeapons

#pragma region TechnoClass_EvaluateObject
Expand Down
Loading