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
4 changes: 3 additions & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,9 @@ This page lists all the individual contributions to the project by their author.
- Maximum amount for power plant enhancer
- Return warhead
- **NaotoYuuki** - Vertical & meteor trajectory projectile prototypes
- **handama** - AI script action to `16005 Jump Back To Previous Script`
- **handama**:
- AI script action to `16005 Jump Back To Previous Script`
- Fix AI team recruitment inconsistency causing underfilled teams
- **TaranDahl (航味麻酱)**:
- Skirmish AI "sell all buildings and set all technos to hunt" behavior dehardcode
- Skirmish AI "gather when MCV deploy" behavior dehardcode
Expand Down
2 changes: 1 addition & 1 deletion YRpp
Submodule YRpp updated 2 files
+3 −0 MissionClass.h
+3 −0 ObjectClass.h
1 change: 1 addition & 0 deletions docs/AI-Scripting-and-Mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This page describes all AI scripting and mapping related additions and changes i
- Teams spawned by trigger action 7,80,107 can use IFV and opentopped logic normally.
- If a pre-placed building has a `NaturalParticleSystem`, it used to always be created when the game starts. This has been removed.
- Superweapons used by AI for script actions `56 Chronoshift to Building`, `57 Chronoshift to a Target Type` and `10104 Chronoshift to Enemy Base` can now be explicitly set via `[General] -> AIChronoSphereSW` & `AIChronoWarpSW` respectively. If `AIChronoSphereSW` is set but `AIChronoWarpSW` is not, game will check former's `SW.PostDependent` for a second superweapon to use. Otherwise if not set, last superweapon listed in `[SuperWeaponTypes]` with `Type=ChronoSphere` or `Type=ChronoWarp` will be used, respectively.
- Fixed AI team recruitment inconsistency causing underfilled teams.

### Increased Overlay Limit

Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ Vanilla fixes:
- Fixed the bug where non-Teleporter miners would not return to work after minerals are depleted and then regenerated (by TaranDahl)
- Miners back to work when ore regenerated (by TaranDahl)
- Fixed the incorrect mission switching in infantry EnterIdleMode (by TaranDahl)
- Fixed AI team recruitment inconsistency causing underfilled teams (by handama)
Phobos fixes:
- Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi)
Expand Down
31 changes: 30 additions & 1 deletion src/Ext/Techno/Body.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Body.h"
#include "Body.h"

#include <JumpjetLocomotionClass.h>

Expand Down Expand Up @@ -884,6 +884,35 @@ void TechnoExt::ClickedApproachObject(FootClass* pThis, ObjectClass* pObject)
event.AddEvent();
}

bool TechnoExt::CanBeRecruitedFix(FootClass* pThis, HouseClass* pHouse)
{
if (!pThis || !pHouse) return false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need check pThis here


const bool inTeam = pThis->Team != nullptr;
const bool available = pThis->IsAlive && pThis->Health > 0 && !pThis->InLimbo;
const bool wrongOwner = pThis->Owner != pHouse;

if (inTeam || !available || wrongOwner)
return false;

const bool canRecruit = pThis->RecruitableA && pThis->RecruitableB;
if (!canRecruit)
return false;

const Mission mission = pThis->GetCurrentMission();

if (!MissionClass::IsRecruitableMission(mission))
return false;

const bool validState =
!(pThis->ShouldEnterAbsorber || pThis->ShouldEnterOccupiable || pThis->ShouldGarrisonStructure) &&
pThis->DrainTarget == nullptr &&
!pThis->BunkerLinkedItem &&
pThis->LocomotorSource == nullptr;

return validState;
}

bool TechnoExt::EjectRandomly(FootClass* pEjectee, const CoordStruct& coords, int distance, bool select)
{
std::vector<CoordStruct> usableCoords;
Expand Down
3 changes: 2 additions & 1 deletion src/Ext/Techno/Body.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#pragma once

#include <Ext/TechnoType/Body.h>
#include <Utilities/Container.h>
Expand Down Expand Up @@ -309,6 +309,7 @@ class TechnoExt
static bool SimpleDeployerAllowedToDeploy(UnitClass* pThis, bool defaultValue, bool alwaysCheckLandTypes);
static void ShowPromoteAnim(TechnoClass* pThis);
static void ClickedApproachObject(FootClass* pThis, ObjectClass* pObject);
static bool CanBeRecruitedFix(FootClass* pThis, HouseClass* pHouse);

static bool EjectRandomly(FootClass* pEjectee, const CoordStruct& coords, int distance, bool select);
static bool EjectSurvivor(FootClass* pSurvivor, CoordStruct coords, bool select);
Expand Down
12 changes: 12 additions & 0 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1971,3 +1971,15 @@ DEFINE_HOOK(0x4D4B43, FootClass_Mission_Capture, 0x6)

return LosesDestination;
}

DEFINE_HOOK(0x4DA230, FootClass_CanBeRecruited, 0x5)
{
enum { SkipGameCode = 0x4DA294 };

GET(FootClass*, pThis, ECX);
GET_STACK(HouseClass*, pHouse, 0x4);

R->AL(TechnoExt::CanBeRecruitedFix(pThis, pHouse));

return SkipGameCode;
}
Loading