Skip to content

Commit 29f4c8a

Browse files
committed
core
code docs update
1 parent 2b234be commit 29f4c8a

8 files changed

Lines changed: 79 additions & 1 deletion

File tree

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ This page lists all the individual contributions to the project by their author.
692692
- Fix an issue where units recruited by a team with `AreTeamMembersRecruitable=false` cannot be recruited even if they have been liberated by that team
693693
- Global default value for `DefaultToGuardArea`
694694
- Weapon range finding in cylinder
695+
- Customize the keep-target-range of attackmove
695696
- **solar-III (凤九歌)**
696697
- Target scanning delay customization (documentation)
697698
- Skip target scanning function calling for unarmed technos (documentation)

docs/Fixed-or-Improved-Logics.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,26 @@ FallingDownDamage= ; integer / percentage
15621562
FallingDownDamage.Water= ; integer / percentage
15631563
```
15641564

1565+
### Customize the keep-target-range of attackmove
1566+
1567+
- In vanilla, the range of keep target in attackmove is determined by the range of weapon, or the range of the secondary weapon with `NeverUse=yes`.
1568+
- Now you can directly specify this distance by setting the following flag to a non-negative value.
1569+
- `AttackMove.KeepTargetRange` is used to directly specify this distance. It takes effect when this flag is not less than 0.
1570+
- `AttackMove.KeepTargetRangeMultiplier` and `AttackMove.KeepTargetRangeAddend` are used to automatically calculate this distance based on the guard range. It takes effect when the multiplier is not less than 0.
1571+
- The final distance is guard range * multiplier + addend.
1572+
1573+
In `rulesmd.ini`:
1574+
```ini
1575+
[General]
1576+
AttackMove.KeepTargetRangeMultiplier=-1.0 ; float
1577+
AttackMove.KeepTargetRangeAddend=0.0 ; float, range in cell
1578+
1579+
[SOMETECHNO] ; TechnoType
1580+
AttackMove.KeepTargetRange=-1.0 ; float, range in cell
1581+
AttackMove.KeepTargetRangeMultiplier= ; float
1582+
AttackMove.KeepTargetRangeAddend= ; float, range in cell
1583+
```
1584+
15651585
### Damaged speed customization
15661586

15671587
- In vanilla, units using drive/ship loco will has hardcoded speed multiplier when damaged. Now you can customize it.

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ New:
535535
- Option to scale `PowerSurplus` setting if enabled to current power drain with `PowerSurplus.ScaleToDrainAmount` (by Starkku)
536536
- Global default value for `DefaultToGuardArea` (by TaranDahl)
537537
- [Weapon range finding in cylinder](New-or-Enhanced-Logics.md#range-finding-in-cylinder) (by TaranDahl)
538+
- Customize the keep-target-range of attackmove (by TaranDahl)
538539
539540
Vanilla fixes:
540541
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/Rules/Body.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
363363
this->AIParadropMission.Read(exINI, GameStrings::General, "AIParadropMission");
364364

365365
this->CylinderRangefinding.Read(exINI, GameStrings::General, "CylinderRangefinding");
366+
367+
this->AttackMove_KeepTargetRangeAddend.Read(exINI, GameStrings::General, "AttackMove.KeepTargetRangeAddend");
368+
this->AttackMove_KeepTargetRangeMultiplier.Read(exINI, GameStrings::General, "AttackMove.KeepTaragetRangeMultiplier");
366369

367370
// Section AITargetTypes
368371
int itemsCount = pINI->GetKeyCount("AITargetTypes");
@@ -663,6 +666,8 @@ void RulesExt::ExtData::Serialize(T& Stm)
663666
.Process(this->AIParadropMission)
664667
.Process(this->DefaultToGuardArea)
665668
.Process(this->CylinderRangefinding)
669+
.Process(this->AttackMove_KeepTargetRangeAddend)
670+
.Process(this->AttackMove_KeepTargetRangeMultiplier)
666671
;
667672
}
668673

src/Ext/Rules/Body.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22

33
#include <RulesClass.h>
44
#include <Utilities/Container.h>
@@ -314,6 +314,9 @@ class RulesExt
314314

315315
Valueable<bool> CylinderRangefinding;
316316

317+
Valueable<Leptons> AttackMove_KeepTargetRangeAddend;
318+
Valueable<double> AttackMove_KeepTargetRangeMultiplier;
319+
317320
ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
318321
, Storage_TiberiumIndex { -1 }
319322
, HarvesterDumpAmount { 0.0f }
@@ -570,6 +573,9 @@ class RulesExt
570573
, DefaultToGuardArea { false }
571574

572575
, CylinderRangefinding { false }
576+
577+
, AttackMove_KeepTargetRangeAddend { Leptons(0) }
578+
, AttackMove_KeepTargetRangeMultiplier { -1.0 }
573579
{ }
574580

575581
virtual ~ExtData() = default;

src/Ext/Techno/Hooks.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,35 @@ DEFINE_HOOK(0x4DF3A6, FootClass_UpdateAttackMove_Follow, 0x6)
11881188
return 0;
11891189
}
11901190

1191+
DEFINE_HOOK(0x6F78D0, TechnoClass_InAttackMoveKeepRange_Start, 0x6)
1192+
{
1193+
enum { RETN = 0x6F7923 };
1194+
1195+
GET(TechnoClass*, pThis, ECX);
1196+
GET_STACK(AbstractClass*, pTarget, 0x4);
1197+
1198+
auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());
1199+
int keepTargetRange = pTypeExt->AttackMove_KeepTargetRange.Get();
1200+
1201+
if (keepTargetRange >= 0)
1202+
{
1203+
R->AL(pThis->DistanceFrom(pTarget) <= keepTargetRange);
1204+
return RETN;
1205+
}
1206+
1207+
double mult = pTypeExt->AttackMove_KeepTargetRangeMultiplier.Get(RulesExt::Global()->AttackMove_KeepTargetRangeMultiplier);
1208+
1209+
if (mult >= 0)
1210+
{
1211+
auto addend = pTypeExt->AttackMove_KeepTargetRangeAddend.Get(RulesExt::Global()->AttackMove_KeepTargetRangeAddend);
1212+
1213+
R->AL(pThis->DistanceFrom(pTarget) <= (int)(pThis->GetGuardRange(0) * mult) + addend);
1214+
return RETN;
1215+
}
1216+
1217+
return 0;
1218+
}
1219+
11911220
#pragma endregion
11921221

11931222
DEFINE_HOOK(0x708FC0, TechnoClass_ResponseMove_Pickup, 0x5)

src/Ext/TechnoType/Body.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,10 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
11501150
this->ParadropMission.Read(exINI, pSection, "ParadropMission");
11511151
this->AIParadropMission.Read(exINI, pSection, "AIParadropMission");
11521152

1153+
this->AttackMove_KeepTargetRange.Read(exINI, pSection, "AttackMove.KeepTargetRange");
1154+
this->AttackMove_KeepTargetRangeAddend.Read(exINI, pSection, "AttackMove.KeepTargetRangeAddend");
1155+
this->AttackMove_KeepTargetRangeMultiplier.Read(exINI, pSection, "AttackMove.KeepTaragetRangeMultiplier");
1156+
11531157
// Ares 0.2
11541158
this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius");
11551159

@@ -1851,6 +1855,10 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
18511855

18521856
.Process(this->ParadropMission)
18531857
.Process(this->AIParadropMission)
1858+
1859+
.Process(this->AttackMove_KeepTargetRange)
1860+
.Process(this->AttackMove_KeepTargetRangeAddend)
1861+
.Process(this->AttackMove_KeepTargetRangeMultiplier)
18541862
;
18551863
}
18561864
void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)

src/Ext/TechnoType/Body.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ class TechnoTypeExt
475475
Nullable<Mission> ParadropMission;
476476
Nullable<Mission> AIParadropMission;
477477

478+
Valueable<Leptons> AttackMove_KeepTargetRange;
479+
Nullable<Leptons> AttackMove_KeepTargetRangeAddend;
480+
Nullable<double> AttackMove_KeepTargetRangeMultiplier;
481+
478482
ExtData(TechnoTypeClass* OwnerObject) : Extension<TechnoTypeClass>(OwnerObject)
479483
, HealthBar_Hide { false }
480484
, HealthBar_HidePips { false }
@@ -903,6 +907,10 @@ class TechnoTypeExt
903907

904908
, ParadropMission {}
905909
, AIParadropMission {}
910+
911+
, AttackMove_KeepTargetRange { Leptons(-256) }
912+
, AttackMove_KeepTargetRangeAddend {}
913+
, AttackMove_KeepTargetRangeMultiplier {}
906914
{ }
907915

908916
virtual ~ExtData() = default;

0 commit comments

Comments
 (0)