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 @@ -737,6 +737,7 @@ This page lists all the individual contributions to the project by their author.
- Miners back to work when ore regenerated
- Allow disable an over-optimization in targeting
- Extra threat
- Allow the unit to stop immediately if the target enters the range during ApproachTarget
- **solar-III (凤九歌)**
- Target scanning delay customization (documentation)
- Skip target scanning function calling for unarmed technos (documentation)
Expand Down
11 changes: 11 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,17 @@ In `rulesmd.ini`:
RadarInvisibleToHouse= ; Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all), default to enemy if RadarInvisible=true, none otherwise
```

### Stop immediately if the target enters the range during ApproachTarget

- In vanilla, the ApproachTarget will simply exit and do nothing if the target is in range. This will cause your units to approach the target unnecessarily.
- Now you can change this behavior by the following flag.

In `rulesmd.ini`:
```ini
[General]
ApproachTarget.StopWhenInRange=false ; boolean
```

### Subterranean unit travel height and speed

- It is now possible to control the height at which units with subterranean (Tunnel) `Locomotor` travel, globally or per TechnoType.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ New:
- [Allow customize jumpjet properties on warhead](Fixed-or-Improved-Logics.md#customizing-locomotor-warhead) (by NetsuNegi)
- Customize effects range of power plant enhancer (by NetsuNegi)
- Allow each side to customize the color when the proportion of working miners is higher than `HarvesterCounter.ConditionYellow` (by Noble_Fish)
- [Allow the unit to stop immediately if the target enters the range during ApproachTarget](Fixed-or-Improved-Logics.md#stop-immediately-if-the-target-enters-the-range-during-approachtarget) (by TaranDahl)

Comment thread
TaranDahl marked this conversation as resolved.
Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
7 changes: 4 additions & 3 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Body.h"
#include "Body.h"

#include <Ext/TechnoType/Body.h>
#include <New/Type/RadTypeClass.h>
Expand Down Expand Up @@ -321,7 +321,6 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->AllowBerzerkOnAllies.Read(exINI, GameStrings::CombatDamage, "AllowBerzerkOnAllies");

this->AttackMove_IgnoreWeaponCheck.Read(exINI, GameStrings::General, "AttackMove.IgnoreWeaponCheck");
this->AttackMove_StopWhenTargetAcquired.Read(exINI, GameStrings::General, "AttackMove.StopWhenTargetAcquired");

this->Parasite_GrappleAnim.Read(exINI, GameStrings::AudioVisual, "Parasite.GrappleAnim");

Expand Down Expand Up @@ -375,6 +374,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->PenetratesTransport_Level.Read(exINI, GameStrings::CombatDamage, "PenetratesTransport.Level");

this->UnitsUnsellable.Read(exINI, GameStrings::General, "UnitsUnsellable");

this->ApproachTarget_StopWhenInRange.Read(exINI, GameStrings::General, "ApproachTarget.StopWhenInRange");

this->DisableOveroptimizationInTargeting.Read(exINI, GameStrings::General, "DisableOveroptimizationInTargeting");

Expand Down Expand Up @@ -666,7 +667,6 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->TintColorForceShield)
.Process(this->TintColorBerserk)
.Process(this->AttackMove_IgnoreWeaponCheck)
.Process(this->AttackMove_StopWhenTargetAcquired)
.Process(this->Parasite_GrappleAnim)
.Process(this->InfantryAutoDeploy)
.Process(this->AdjacentWallDamage)
Expand Down Expand Up @@ -699,6 +699,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->ExtraThreatCoefficient_InRangeDistance)
.Process(this->ExtraThreatCoefficient_Facing)
.Process(this->ExtraThreatCoefficient_DistanceToLastTarget)
.Process(this->ApproachTarget_StopWhenInRange)
;
}

Expand Down
8 changes: 5 additions & 3 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#pragma once

#include <RulesClass.h>
#include <Utilities/Container.h>
Expand Down Expand Up @@ -278,7 +278,6 @@ class RulesExt
Valueable<bool> AllowBerzerkOnAllies;

Valueable<bool> AttackMove_IgnoreWeaponCheck;
Nullable<bool> AttackMove_StopWhenTargetAcquired;

NullableIdx<AnimTypeClass> Parasite_GrappleAnim;

Expand Down Expand Up @@ -334,6 +333,8 @@ class RulesExt
Valueable<double> ExtraThreatCoefficient_Facing;
Valueable<double> ExtraThreatCoefficient_DistanceToLastTarget;

Valueable<bool> ApproachTarget_StopWhenInRange;

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Storage_TiberiumIndex { -1 }
, HarvesterDumpAmount { 0.0f }
Expand Down Expand Up @@ -560,7 +561,6 @@ class RulesExt
, TintColorBerserk { 0 }

, AttackMove_IgnoreWeaponCheck { false }
, AttackMove_StopWhenTargetAcquired { }

, Parasite_GrappleAnim {}
, InfantryAutoDeploy { false }
Expand Down Expand Up @@ -609,6 +609,8 @@ class RulesExt
, ExtraThreatCoefficient_InRangeDistance { 0.0 }
, ExtraThreatCoefficient_Facing { 0.0 }
, ExtraThreatCoefficient_DistanceToLastTarget { 0.0 }

, ApproachTarget_StopWhenInRange { false }
{ }

virtual ~ExtData() = default;
Expand Down
26 changes: 26 additions & 0 deletions src/Ext/Techno/Hooks.Firing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,3 +1158,29 @@ DEFINE_HOOK(0x6F755A, TechnoClass_IsCloseEnough_CylinderRangefinding, 0x7)
R->EAX(pCoord->X);
return (cylinder || pThis->WhatAmI() == AbstractType::Aircraft) ? 0x6F75B2 : 0x6F7568;
}

DEFINE_HOOK(0x4D5A34, FootClass_ApproachTarget_StopWhenInRange, 0x6)
{
GET_STACK(bool, closeEnough, STACK_OFFSET(0x158, -0x146));

if (RulesExt::Global()->ApproachTarget_StopWhenInRange && closeEnough)
{
GET(FootClass*, pThis, EBX);
if (auto const pJumpjetLoco = locomotion_cast<JumpjetLocomotionClass*>(pThis->Locomotor))
{
auto const crd = pThis->GetCoords();
pJumpjetLoco->DestinationCoords.X = crd.X;
pJumpjetLoco->DestinationCoords.Y = crd.Y;
pJumpjetLoco->CurrentSpeed = 0;
pJumpjetLoco->MaxSpeed = 0;
pJumpjetLoco->State = JumpjetLocomotionClass::State::Hovering;
pThis->AbortMotion();
}
else
{
pThis->SetDestination(nullptr, true);
}
}

return 0;
}
49 changes: 0 additions & 49 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,55 +1122,6 @@ DEFINE_HOOK(0x519FEC, InfantryClass_UpdatePosition_EngineerRepair, 0xA)

#pragma region AttackMove

DEFINE_HOOK(0x4DF410, FootClass_UpdateAttackMove_TargetAcquired, 0x6)
{
GET(FootClass* const, pThis, ESI);

auto const pTypeExt = TechnoExt::ExtMap.Find(pThis)->TypeExtData;

if (pThis->IsCloseEnoughToAttack(pThis->Target)
&& pTypeExt->AttackMove_StopWhenTargetAcquired.Get(RulesExt::Global()->AttackMove_StopWhenTargetAcquired.Get(!pTypeExt->OwnerObject()->OpportunityFire)))
{
if (auto const pJumpjetLoco = locomotion_cast<JumpjetLocomotionClass*>(pThis->Locomotor))
{
auto const crd = pThis->GetCoords();
pJumpjetLoco->DestinationCoords.X = crd.X;
pJumpjetLoco->DestinationCoords.Y = crd.Y;
pJumpjetLoco->CurrentSpeed = 0;
pJumpjetLoco->MaxSpeed = 0;
pJumpjetLoco->State = JumpjetLocomotionClass::State::Hovering;
pThis->AbortMotion();
}
else
{
pThis->StopMoving();
pThis->AbortMotion();
}
}

if (pTypeExt->AttackMove_PursuitTarget)
pThis->SetDestination(pThis->Target, true);

return 0;
}

DEFINE_HOOK(0x4DF4DB, TechnoClass_RefreshMegaMission_CheckMissionFix, 0xA)
{
enum { ClearMegaMission = 0x4DF4F9, ContinueMegaMission = 0x4DF4CF };

GET(FootClass* const, pThis, ESI);

auto const pTypeExt = TechnoExt::ExtMap.Find(pThis)->TypeExtData;
auto const mission = pThis->GetCurrentMission();
const bool stopWhenTargetAcquired = pTypeExt->AttackMove_StopWhenTargetAcquired.Get(RulesExt::Global()->AttackMove_StopWhenTargetAcquired.Get(!pTypeExt->OwnerObject()->OpportunityFire));
bool clearMegaMission = mission != Mission::Guard;

if (stopWhenTargetAcquired && clearMegaMission)
clearMegaMission = !(mission == Mission::Move && pThis->MegaDestination && pThis->DistanceFrom(pThis->MegaDestination) > 256);

return clearMegaMission ? ClearMegaMission : ContinueMegaMission;
}

DEFINE_HOOK(0x711E90, TechnoTypeClass_CanAttackMove_IgnoreWeapon, 0x6)
{
enum { SkipGameCode = 0x711E9A };
Expand Down
4 changes: 0 additions & 4 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,6 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->AttackMove_Follow.Read(exINI, pSection, "AttackMove.Follow");
this->AttackMove_Follow_IncludeAir.Read(exINI, pSection, "AttackMove.Follow.IncludeAir");
this->AttackMove_Follow_IfMindControlIsFull.Read(exINI, pSection, "AttackMove.Follow.IfMindControlIsFull");
this->AttackMove_StopWhenTargetAcquired.Read(exINI, pSection, "AttackMove.StopWhenTargetAcquired");
this->AttackMove_PursuitTarget.Read(exINI, pSection, "AttackMove.PursuitTarget");

this->Ammo_AutoConvertMinimumAmount.Read(exINI, pSection, "Ammo.AutoConvertMinimumAmount");
this->Ammo_AutoConvertMaximumAmount.Read(exINI, pSection, "Ammo.AutoConvertMaximumAmount");
Expand Down Expand Up @@ -1870,8 +1868,6 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->AttackMove_Follow)
.Process(this->AttackMove_Follow_IncludeAir)
.Process(this->AttackMove_Follow_IfMindControlIsFull)
.Process(this->AttackMove_StopWhenTargetAcquired)
.Process(this->AttackMove_PursuitTarget)

.Process(this->MultiWeapon)
.Process(this->MultiWeapon_IsSecondary)
Expand Down
4 changes: 0 additions & 4 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,6 @@ class TechnoTypeExt
Valueable<bool> AttackMove_Follow;
Valueable<bool> AttackMove_Follow_IncludeAir;
Valueable<bool> AttackMove_Follow_IfMindControlIsFull;
Nullable<bool> AttackMove_StopWhenTargetAcquired;
Valueable<bool> AttackMove_PursuitTarget;

Valueable<bool> MultiWeapon;
ValueableVector<bool> MultiWeapon_IsSecondary;
Expand Down Expand Up @@ -905,8 +903,6 @@ class TechnoTypeExt
, AttackMove_Follow { false }
, AttackMove_Follow_IncludeAir { false }
, AttackMove_Follow_IfMindControlIsFull { false }
, AttackMove_StopWhenTargetAcquired { }
, AttackMove_PursuitTarget { false }

, MultiWeapon { false }
, MultiWeapon_IsSecondary {}
Expand Down
1 change: 1 addition & 0 deletions src/Utilities/TemplateDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include <ParticleTypeClass.h>
#include <CRT.h>
#include <LocomotionClass.h>
#include <JumpjetLocomotionClass.h>
#include <Locomotion/TestLocomotionClass.h>

namespace detail
Expand Down
Loading