Skip to content

Commit f772ea3

Browse files
committed
Merge branch 'develop' into DisableStupidTargetScanningOptimization
2 parents 0b61d22 + 0e78aa9 commit f772ea3

File tree

17 files changed

+182
-35
lines changed

17 files changed

+182
-35
lines changed

CREDITS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,8 @@ This page lists all the individual contributions to the project by their author.
688688
- `AllowBerzerkOnAllies`
689689
- Fixed an issue that retaliation will make the unit keep switching among multiple targets with the same amount of threat
690690
- Fix an issue where units recruited by a team with `AreTeamMembersRecruitable=false` cannot be recruited even if they have been liberated by that team
691+
- Global default value for `DefaultToGuardArea`
692+
- Weapon range finding in cylinder
691693
- Allow disable an over-optimization in targeting
692694
- **solar-III (凤九歌)**
693695
- Target scanning delay customization (documentation)

YRpp

docs/Fixed-or-Improved-Logics.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
151151
- Fixed disguised units not using the correct palette if target has custom palette.
152152
- Building upgrades now consistently use building's `PowerUpN` animation settings corresponding to the upgrade's `PowersUpToLevel` where possible.
153153
- Subterranean units are no longer allowed to perform deploy functions like firing weapons or `IsSimpleDeployer` while burrowed or burrowing, they will instead emerge first like they do for transport unloading.
154-
- The otherwise unused setting `[AI] -> PowerSurplus` (defaults to 50) which determines how much surplus power AI players will strive to have can be restored by setting `[AI] -> EnablePowerSurplus` to true.
154+
- The otherwise unused setting `[AI] -> PowerSurplus` (defaults to 50) which determines how much surplus power AI players will strive to have can be restored by setting `[AI] -> EnablePowerSurplus` to true. Additional option `[AI] -> PowerSurplus.ScaleToDrainAmount` if set to value higher than 0 makes it so that power surplus multiplied by current power drain / `PowerSurplus.ScaleToDrainAmount`.
155155
- Planning paths are now shown for all units under player control or when `[GlobalControls] -> DebugPlanningPaths=yes` in singleplayer game modes.
156156
- Fixed `Temporal=true` Warheads potentially crashing game if used to attack `Slaved=true` infantry.
157157
- Fixed some locomotors (Tunnel, Walk, Mech) getting stuck when moving too fast.
@@ -294,6 +294,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
294294
- `ProductionAnim` is now available for `Factory=InfantryType` as well as non-`ConstructionYard=true` `Factory=BuildingType` buildings. `IdleAnim` will cease to play for its duration normally as well.
295295
- Fixed the bug where selected technos would lose their selection if their regular mind control was replaced with permanent mind control or with the control from the Psychic Dominator superweapon.
296296
- Fixed the issue where units recruited by a team with `AreTeamMembersRecruitable=false` cannot be recruited even if they have been liberated by that team.
297+
- Allow the default value of `DefaultToGuardArea` to be defined by `[General] -> DefaultToGuardArea`.
297298

298299
## Fixes / interactions with other extensions
299300

@@ -1425,6 +1426,21 @@ OreGathering.FramesPerDir=15 ; List of integers
14251426
OreGathering.Tiberiums=0 ; List of Tiberium IDs
14261427
```
14271428

1429+
### Customizable paradrop missions
1430+
1431+
- By default paradropped infantry default to `Guard` for human players and `Hunt` for AI players. This has now been changed to be the default for vehicles as well which defaulted to `Guard` for all players and customizable globally and per TechnoType which default to the global settings under `[General]`.
1432+
1433+
In `rulesmd.ini`:
1434+
```ini
1435+
[General]
1436+
ParadropMission=Guard ; MissionType
1437+
AIParadropMission=Hunt ; MissionType
1438+
1439+
[SOMETECHNO] ; TechnoType
1440+
ParadropMission= ; MissionType
1441+
AIParadropMission= ; MissionType
1442+
```
1443+
14281444
### Customizable target evaluation map zone check behaviour
14291445

14301446
- By default, any non-AircraftType units seeking targets via ScriptType team mission (action) `0 Attack Target Type` or any [attack team missions introduced in Phobos](AI-Scripting-and-Mapping.md#attack-actions) check if the potential target is in same map zone as the attacking unit to be able to pick it as a target. This can now be customized to allow objects from any map zone with no constraints (`TargetZoneScanType=any`) or only if they are within weapon range (`TargetZoneScanType=inrange`).

docs/New-or-Enhanced-Logics.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3016,6 +3016,21 @@ OmniFire.TurnToTarget=no ; boolean
30163016

30173017
- In addition to allowing custom radiation types, several enhancements are also available to the default radiation type defined in `[Radiation]`, such as ability to set owner & invoker or deal damage against buildings. See [Custom Radiation Types](#custom-radiation-types) for more details.
30183018

3019+
### Range finding in cylinder
3020+
3021+
- In vanilla, technos in air will ignore the distance in Z axis when checking if the target is in range. Now you can use the following flags to make technos always range finding like that.
3022+
- `[General]->CylinderRangefinding` controls this globally, and can be customized per weapon type.
3023+
- Mind that set the flags to `false` meaning "use default" rather than "disable". Technos in air will always range finding in cylinder like vanilla, despite what you set.
3024+
3025+
In `rulesmd.ini`:
3026+
```ini
3027+
[General] ; WeaponType
3028+
CylinderRangefinding=false ; boolean
3029+
3030+
[SOMEWEAPON] ; WeaponType
3031+
CylinderRangefinding= ; boolean
3032+
```
3033+
30193034
### Strafing aircraft weapon customization
30203035

30213036
![image](_static/images/strafing-01.gif)

docs/Whats-New.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]
1010

1111
### From vanilla
1212

13+
- Vehicles paradropped by AI players now default to `Hunt` mission instead of `Guard`, matching what infantry do. This can be customized by setting `AIParadropMission` on the VehicleType, defaults to `[General]` -> `AIParadropMission`.
1314
- `IsSimpleDeployer` units now obey deploying facing constraint even without deploying animation if `DeployDir` is explicitly set on the unit.
1415
- `Vertical=true` projectiles now default to completely downwards initial trajectory/facing regardless of if their projectile image has `Voxel=true` or not. This behavior can be reverted by setting `VerticalInitialFacing=false` on projectile in `rulesmd.ini`.
1516
- `Vertical=true` projectiles no longer move horizontally if fired by aircraft by default. To re-enable this behaviour set `Vertical.AircraftFix=false` on the projectile.
@@ -530,6 +531,10 @@ New:
530531
- [`AllowBerzerkOnAllies`](Fixed-or-Improved-Logics.md#berzerk-on-allies) (by TaranDahl)
531532
- [Customize whether weapon can be used to targeting ironcurtained technos or not](New-or-Enhanced-Logics.md#customize-whether-weapon-can-target-iron-curtained-technos) (by NetsuNegi)
532533
- Customizable disk drain logic (by NetsuNegi)
534+
- [Customizable paradropped unit missions](Fixed-or-Improved-Logics.md#customizable-paradrop-missions) (by Starkku)
535+
- Option to scale `PowerSurplus` setting if enabled to current power drain with `PowerSurplus.ScaleToDrainAmount` (by Starkku)
536+
- Global default value for `DefaultToGuardArea` (by TaranDahl)
537+
- [Weapon range finding in cylinder](New-or-Enhanced-Logics.md#range-finding-in-cylinder) (by TaranDahl)
533538
534539
Vanilla fixes:
535540
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/House/Body.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,26 @@ void HouseExt::ExtData::SetForceEnemyIndex(int EnemyIndex)
652652
this->ForceEnemyIndex = EnemyIndex;
653653
}
654654

655+
void HouseExt::CalculatePowerSurplus(HouseClass* pThis)
656+
{
657+
auto const pRulesExt = RulesExt::Global();
658+
659+
if (!pRulesExt->EnablePowerSurplus)
660+
return;
661+
662+
int scaleToDrainAmount = pRulesExt->PowerSurplus_ScaleToDrainAmount;
663+
664+
if (scaleToDrainAmount <= 0)
665+
{
666+
pThis->PowerSurplus = RulesClass::Instance->PowerSurplus;
667+
}
668+
else
669+
{
670+
double factor = pThis->PowerDrain / static_cast<double>(scaleToDrainAmount);
671+
pThis->PowerSurplus = static_cast<int>(RulesClass::Instance->PowerSurplus * factor);
672+
}
673+
}
674+
655675
// =============================
656676
// load / save
657677

@@ -759,9 +779,7 @@ DEFINE_HOOK(0x4F6532, HouseClass_CTOR, 0x5)
759779
GET(HouseClass*, pItem, EAX);
760780

761781
HouseExt::ExtMap.TryAllocate(pItem);
762-
763-
if (RulesExt::Global()->EnablePowerSurplus)
764-
pItem->PowerSurplus = RulesClass::Instance->PowerSurplus;
782+
HouseExt::CalculatePowerSurplus(pItem);
765783

766784
return 0;
767785
}

src/Ext/House/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,6 @@ class HouseExt
200200

201201
static CanBuildResult BuildLimitGroupCheck(const HouseClass* pThis, const TechnoTypeClass* pItem, bool buildLimitOnly, bool includeQueued);
202202
static bool ReachedBuildLimit(const HouseClass* pHouse, const TechnoTypeClass* pType, bool ignoreQueued);
203+
204+
static void CalculatePowerSurplus(HouseClass* pThis);
203205
};

src/Ext/House/Hooks.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,34 @@ DEFINE_HOOK(0x502A80, HouseClass_RegisterGain, 0x8)
5757
return 0;
5858
}
5959

60-
DEFINE_HOOK(0x508D8D, HouseClass_UpdatePower_Techno, 0x6)
60+
DEFINE_HOOK(0x508D8D, HouseClass_UpdatePower_AfterBuildings, 0x6)
6161
{
62-
if (!Phobos::Config::UnitPowerDrain)
63-
return 0;
64-
6562
GET(HouseClass*, pThis, ESI);
6663

67-
auto updateDrainForThisType = [pThis](const TechnoTypeClass* pType)
64+
if (Phobos::Config::UnitPowerDrain)
6865
{
69-
const int count = pThis->CountOwnedAndPresent(pType);
70-
if (count == 0)
71-
return;
72-
const auto pExt = TechnoTypeExt::ExtMap.Find(pType);
73-
if (pExt->Power > 0)
74-
pThis->PowerOutput += pExt->Power * count;
75-
else
76-
pThis->PowerDrain -= pExt->Power * count;
77-
};
78-
79-
for (const auto pType : InfantryTypeClass::Array)
80-
updateDrainForThisType(pType);
81-
for (const auto pType : UnitTypeClass::Array)
82-
updateDrainForThisType(pType);
83-
for (const auto pType : AircraftTypeClass::Array)
84-
updateDrainForThisType(pType);
85-
// Don't do this for buildings, they've already been counted.
66+
auto updateDrainForThisType = [pThis](const TechnoTypeClass* pType)
67+
{
68+
const int count = pThis->CountOwnedAndPresent(pType);
69+
if (count == 0)
70+
return;
71+
const auto pExt = TechnoTypeExt::ExtMap.Find(pType);
72+
if (pExt->Power > 0)
73+
pThis->PowerOutput += pExt->Power * count;
74+
else
75+
pThis->PowerDrain -= pExt->Power * count;
76+
};
77+
78+
for (const auto pType : InfantryTypeClass::Array)
79+
updateDrainForThisType(pType);
80+
for (const auto pType : UnitTypeClass::Array)
81+
updateDrainForThisType(pType);
82+
for (const auto pType : AircraftTypeClass::Array)
83+
updateDrainForThisType(pType);
84+
// Don't do this for buildings, they've already been counted.
85+
}
86+
87+
HouseExt::CalculatePowerSurplus(pThis);
8688

8789
return 0;
8890
}

src/Ext/Rules/Body.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ void RulesExt::ExtData::InitializeConstants()
6969
// earliest loader - can't really do much because nothing else is initialized yet, so lookups won't work
7070
void RulesExt::ExtData::LoadFromINIFile(CCINIClass* pINI)
7171
{
72+
INI_EX exINI(pINI);
7273

74+
this->DefaultToGuardArea.Read(exINI, GameStrings::General, "DefaultToGuardArea");
7375
}
7476

7577
void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
@@ -171,6 +173,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
171173
this->ForbidParallelAIQueues_Vehicle.Read(exINI, "GlobalControls", "ForbidParallelAIQueues.Vehicle");
172174

173175
this->EnablePowerSurplus.Read(exINI, GameStrings::AI, "EnablePowerSurplus");
176+
this->PowerSurplus_ScaleToDrainAmount.Read(exINI, GameStrings::AI, "PowerSurplus.ScaleToDrainAmount");
174177

175178
this->AllowDeployControlledMCV.Read(exINI, GameStrings::General, "AllowDeployControlledMCV");
176179

@@ -356,6 +359,11 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
356359
this->AutoTarget_NoThreatBuildings.Read(exINI, GameStrings::General, "AutoTarget.NoThreatBuildings");
357360
this->AutoTargetAI_NoThreatBuildings.Read(exINI, GameStrings::General, "AutoTargetAI.NoThreatBuildings");
358361

362+
this->ParadropMission.Read(exINI, GameStrings::General, "ParadropMission");
363+
this->AIParadropMission.Read(exINI, GameStrings::General, "AIParadropMission");
364+
365+
this->CylinderRangefinding.Read(exINI, GameStrings::General, "CylinderRangefinding");
366+
359367
this->DisableOveroptimizationInTargeting.Read(exINI, GameStrings::General, "DisableOveroptimizationInTargeting");
360368

361369
// Section AITargetTypes
@@ -506,6 +514,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
506514
.Process(this->ForbidParallelAIQueues_Navy)
507515
.Process(this->ForbidParallelAIQueues_Vehicle)
508516
.Process(this->EnablePowerSurplus)
517+
.Process(this->PowerSurplus_ScaleToDrainAmount)
509518
.Process(this->AllowDeployControlledMCV)
510519
.Process(this->TypeSelectUseIFVMode)
511520
.Process(this->IronCurtain_KeptOnDeploy)
@@ -652,6 +661,10 @@ void RulesExt::ExtData::Serialize(T& Stm)
652661
.Process(this->ExtraRange_Prefiring_IncludeBurst)
653662
.Process(this->AutoTarget_NoThreatBuildings)
654663
.Process(this->AutoTargetAI_NoThreatBuildings)
664+
.Process(this->ParadropMission)
665+
.Process(this->AIParadropMission)
666+
.Process(this->DefaultToGuardArea)
667+
.Process(this->CylinderRangefinding)
655668
.Process(this->DisableOveroptimizationInTargeting)
656669
;
657670
}

src/Ext/Rules/Body.h

Lines changed: 18 additions & 2 deletions
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>
@@ -111,6 +111,7 @@ class RulesExt
111111
Valueable<bool> ForbidParallelAIQueues_Vehicle;
112112

113113
Valueable<bool> EnablePowerSurplus;
114+
Valueable<int> PowerSurplus_ScaleToDrainAmount;
114115

115116
Valueable<bool> DisplayIncome;
116117
Valueable<bool> DisplayIncome_AllowAI;
@@ -306,8 +307,15 @@ class RulesExt
306307
Valueable<bool> AutoTarget_NoThreatBuildings;
307308
Valueable<bool> AutoTargetAI_NoThreatBuildings;
308309

309-
Valueable<bool> DisableOveroptimizationInTargeting;
310+
Valueable<Mission> ParadropMission;
311+
Valueable<Mission> AIParadropMission;
312+
313+
Valueable<bool> DefaultToGuardArea;
310314

315+
Valueable<bool> CylinderRangefinding;
316+
317+
Valueable<bool> DisableOveroptimizationInTargeting;
318+
311319
ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
312320
, Storage_TiberiumIndex { -1 }
313321
, HarvesterDumpAmount { 0.0f }
@@ -390,6 +398,7 @@ class RulesExt
390398
, ForbidParallelAIQueues_Vehicle { false }
391399

392400
, EnablePowerSurplus { false }
401+
, PowerSurplus_ScaleToDrainAmount { 0 }
393402

394403
, AllowDeployControlledMCV { false }
395404

@@ -557,6 +566,13 @@ class RulesExt
557566
, AutoTarget_NoThreatBuildings { false }
558567
, AutoTargetAI_NoThreatBuildings { true }
559568

569+
, ParadropMission { Mission::Guard }
570+
, AIParadropMission { Mission::Hunt }
571+
572+
, DefaultToGuardArea { false }
573+
574+
, CylinderRangefinding { false }
575+
560576
, DisableOveroptimizationInTargeting { false }
561577
{ }
562578

0 commit comments

Comments
 (0)