Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
823fa47
New actions 127 to 133
FS-21 Mar 31, 2022
ce08dae
I forgot including in this branch some code
FS-21 Mar 31, 2022
fc6c92e
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Mar 31, 2022
f3a42cb
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Apr 10, 2022
ef6f0fb
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Apr 17, 2022
f178aab
Point to latest YRpp
FS-21 Apr 17, 2022
0fa5476
Update GH Actions workflows
Metadorius May 11, 2022
8d300a5
Merge remote-tracking branch 'origin/develop' into feature/ai-trigger…
FS-21 May 11, 2022
5299dff
Fix name due to YRpp change
FS-21 May 11, 2022
f0d6055
Merge remote-tracking branch 'origin/develop' into feature/ai-trigger…
FS-21 May 11, 2022
9b31e87
Merge remote-tracking branch 'origin/develop' into feature/ai-trigger…
FS-21 May 11, 2022
a63b2d9
Merge remote-tracking branch 'origin/develop' into feature/ai-trigger…
FS-21 May 11, 2022
a7ac2a0
Merge remote-tracking branch 'origin/develop' into feature/ai-trigger…
FS-21 May 12, 2022
36b6c78
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Jul 4, 2022
2500eb9
Point to latest YRpp
FS-21 Oct 17, 2022
9a77959
Merge remote-tracking branch 'origin/develop' into feature/ai-trigger…
FS-21 Oct 17, 2022
e9c7793
Point changelog to v0.3.1 and not v0.3
FS-21 Oct 17, 2022
41825d9
Actions renumeration
FS-21 Oct 17, 2022
531e771
Added lost documentation from older merges
FS-21 Oct 17, 2022
aaa7f0b
small change in docs
FS-21 Oct 17, 2022
3a6a696
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Feb 13, 2023
61c50d9
Compilation fixes
FS-21 Feb 13, 2023
c7d39d1
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 May 27, 2023
ec077b7
.
FS-21 May 27, 2023
21aaaad
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Jul 22, 2023
0ba374a
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Sep 23, 2023
3f639b5
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Mar 10, 2024
35b3a83
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Mar 12, 2024
aea534c
Moved code into the new file
FS-21 Apr 30, 2024
fd71803
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Apr 30, 2024
474a070
Rewrote HouseExt::GetHouseIndex(...) with the requested changes.
FS-21 Jul 15, 2024
7718627
Fix small mistake
FS-21 Jul 15, 2024
5c8a756
Moved scriptType Action
FS-21 Jul 15, 2024
f3234a6
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Jul 15, 2024
4e92269
Small changes
FS-21 Aug 29, 2024
692519e
Merge remote-tracking branch 'origin/develop' into feature/ai-trigger…
FS-21 Aug 29, 2024
34a5a0c
FA2 documentation
FS-21 Aug 29, 2024
c66f451
fix mistake
FS-21 Aug 29, 2024
1d5e9df
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Aug 30, 2024
b57a5ac
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Oct 27, 2024
e067201
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Oct 28, 2024
f329756
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Feb 18, 2025
247deae
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 May 21, 2025
d048d45
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 May 24, 2025
2364427
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 May 29, 2025
34f74c7
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 May 30, 2025
8c51345
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Jun 8, 2025
744707d
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Aug 7, 2025
7c49fff
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Sep 2, 2025
49c959d
Merge branch 'develop' into feature/ai-trigger-manipulation-actions
FS-21 Aug 24, 2026
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
3 changes: 1 addition & 2 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,9 @@ This page lists all the individual contributions to the project by their author.
- Power plant damage factor
- **FS-21**:
- Dump Object Info enhancements
- `Powered.KillSpawns`
- `Spawner.LimitRange`
- Majority of ScriptType actions
- ScriptType Action 14004: Force Global `OnlyTargetHouseEnemy` value in Teams
- Script actions for managing AI Triggers
- MC deployer fixes
- Help with docs
- Automatic Passenger Deletion logic
Expand Down
1 change: 1 addition & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
<ClCompile Include="src\Ext\Scenario\Hooks.Waypoints.cpp" />
<!-- src\Ext\Script -->
<ClCompile Include="src\Ext\Script\Body.cpp" />
<ClCompile Include="src\Ext\Script\Body.ManageAITriggers.cpp" />
<ClCompile Include="src\Ext\Script\Hooks.cpp" />
<ClCompile Include="src\Ext\Script\Mission.Attack.cpp" />
<ClCompile Include="src\Ext\Script\Mission.Move.cpp" />
Expand Down
81 changes: 81 additions & 0 deletions docs/AI-Scripting-and-Mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,87 @@ In `aimd.ini`:
x=16005,0
```

### `16006` Set House Index For Managing AI Triggers

- Set the house index for enabling and disabling triggers. The indexes aren't the ones used in [Countries], these are internal in-game House indexes.

In `aimd.ini`:
```ini
[SOMESCRIPTTYPE] ; ScriptType
x=16006,n ; integer
```

- The possible argument values are:

| *Argument* | *Description* |
| :--------: | :-------------------------------------------: |
| 4475-4482 | Multiplayer start location indexes |
| 8997 | Special case that returns the house index of the Team object |
| >= 0 | House index. Neutral houses can be used |
| -1 | Random non-neutral House |
| -2 | Find the first Neutral house available |
| -3 | Random Human Player alive |

### `16007` Enable Or Disable All AI Triggers

- All AI triggers will be enabled or disabled.
You must set the affected side with action `16012` and house with action `16006`.

In `aimd.ini`:
```ini
[SOMESCRIPTTYPE] ; ScriptType
x=16007,n ; integer, 1 == enable, 0 == disable
```

### `16008` Enable AI Triggers From List

- When executed this action enable all AI trigger types from the selected list in `AITriggersList`. The second parameter is a 0-based index from the new section `AITriggersList` explained below.

In `aimd.ini`:
```ini
[SOMESCRIPTTYPE] ; ScriptType
x=16008,n
```

The second parameter is a 0-based index for the `AITriggersList` section that specifies the list of possible `AITriggerTypes` that can be evaluated. The new `AITriggersList` section must be declared in `rulesmd.ini` for making this script work:

In `rulesmd.ini`:
```ini
[AITriggersList] ; List of AITriggerTypes lists
0=SOMEAITRIGGERTYPE,SOMEOTHERAITRIGGERTYPE,SAMPLETRIGGERTYPE
1=ANOTHERTRIGGERTYPE,YETANOTHERTRIGGERTYPE
; ...
```

### `16009` Disable AI Triggers From List

- Works silimar to the Action `16008`. When executed this action disable all AI trigger types from the selected list in `AITriggersList`. The second parameter is a 0-based index from the new section `AITriggersList`.

### `16010` Disable AI Triggers If Contains Any Objects From the List

- Works silimar to the Action `16011`. When executed this action all AI Trigger Types that contains any unit of the selected list in `AITargetTypes` will be disabled. The second parameter is a 0-based index from the new section `AITargetTypes`.

### `16011` Enable AI Triggers If Contains Any Objects From the List

- When executed this action all AI trigger types that contains any unit of the selected list in `AITargetTypes` will be enabled. The second parameter is a 0-based index from the new section `AITargetTypes`.

In `aimd.ini`:
```ini
[SOMESCRIPTTYPE] ; ScriptType
x=16011,n
```

### `16012` Set Side Index For Managing AI Triggers

- Set the side index for enabling and disabling triggers.
0 means any side.

In `aimd.ini`:
```ini
[SOMESCRIPTTYPE] ; ScriptType
x=16012,n ; integer, where 0 > n, default -1
```

### `18000-18999` Variable Manipulation

#### `18000-18023` Edit Variable
Expand Down
15 changes: 15 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,13 @@ HideShakeEffects=false ; boolean
10103=Load Onto Transports,0,0,1,[LONG DESC]
10104=Chronoshift to Enemy Base,20,0,1,[LONG DESC]
14004=Force Global OnlyTargetHouseEnemy value in Teams,20,0,1,[LONG DESC]
16006=Set House Index For Managing AI Triggers,20,0,1,[LONG DESC]
16007=Enable Or Disable All AI Triggers,21,0,1,[LONG DESC]
16008=Enable AI Triggers From List,28,0,1,[LONG DESC]
16009=Disable AI Triggers From List,28,0,1,[LONG DESC]
16010=Disable AI Triggers If Contains Any Objects From the List,29,0,1,[LONG DESC]
16011=Enable AI Triggers If Contains Any Objects From the List,29,0,1,[LONG DESC]
16012=Set Side Index For Managing AI Triggers,20,0,1,[LONG DESC]
18000=Local variable set,22,0,1,[LONG DESC]
18001=Local variable add,22,0,1,[LONG DESC]
18002=Local variable minus,22,0,1,[LONG DESC]
Expand Down Expand Up @@ -408,6 +415,12 @@ HideShakeEffects=false ; boolean
25=Local variables,-4
26=Global variables,-5
27=Global variables,-6
28=AI Scripts List, -7
29=AI Target Type,-8

[ScriptParamTypes]
7=AIScriptsList,1,1,0
8=AITargetTypes,1,1,0
```
````

Expand All @@ -421,6 +434,7 @@ HideShakeEffects=false ; boolean
#### New:
- [Customized transport plane for teams](AI-Scripting-and-Mapping.md#customized-transport-plane-for-teams) (by FlyStar)
- [Modify ammo on impact](New-or-Enhanced-Logics.md#modify-ammo-on-impact) (by FS-21)
- [Script actions for managing AI Triggers](AI-Scripting-and-Mapping.md#script-actions-for-managing-ai-triggers) (by FS-21)

#### Vanilla fixes:
- Fixed the bug where a building with `Factory=BuildingType` owned by the AI did not play `ProductionAnim` when placing a produced building (by Noble_Fish)
Expand Down Expand Up @@ -951,6 +965,7 @@ HideShakeEffects=false ; boolean
- Building airstrike target eligibility customization (by Starkku)
- IvanBomb detonation & image display optionally centered on buildings (by Starkku)
- Forcing specific weapon against cloaked or disguised targets (by Starkku)
- Script action for enabling & disabling AI Triggers (by FS-21)
- Customizable ROF random delay (by Starkku)
- Animation with `Tiled=yes` now supports `CustomPalette` (by ststl)
- Toggleable `DieSound` when grinding (by Trsdy)
Expand Down
67 changes: 67 additions & 0 deletions src/Ext/House/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,73 @@ float HouseExt::GetRestrictedFactoryPlantMult(TechnoTypeClass* pTechnoType) cons
return 1.0f - ((1.0f - mult) * pTechnoTypeExt->FactoryPlant_Multiplier);
}

int HouseExt::GetHouseIndex(int param, TeamClass* pTeam, TActionClass* pTAction)
{
if ((pTeam && pTAction) || (param == 8997 && !pTeam && !pTAction))
return -1;

int houseIdx = -1;
std::vector<int> housesListIdx;

// Check special cases
if (param < 0)
{
if (param < -3)
return -1;

for (auto pHouse : HouseClass::Array)
{
if (param == -2 && pHouse->IsNeutral())
{
houseIdx = pHouse->ArrayIndex;
break;
}
else if (!pHouse->Defeated && !pHouse->IsObserver())
{
if ((param == -1 && !pHouse->Type->MultiplayPassive) // Random non-neutral player
|| (param == -3 && !pHouse->IsObserver())) // Random human player
{
housesListIdx.push_back(pHouse->ArrayIndex);
}

if (housesListIdx.size() > 0)
houseIdx = housesListIdx.at(ScenarioClass::Instance->Random.RandomRanged(0, housesListIdx.size() - 1));
else
return -1;
}
}

return houseIdx;
}

// Check a specific house of the map
if (param >= HouseClass::PlayerAtA && param <= HouseClass::PlayerAtH)
{
// Is a multiplayer house index (Player@A - Player@H) ?
houseIdx = param - HouseClass::PlayerAtA;
}
else if (param == 8997)
{
// Is the owner of the trigger ?
houseIdx = pTeam ? pTeam->Owner->ArrayIndex : pTAction->TeamType->Owner->ArrayIndex;
}
else if (param > 8997 || HouseClass::Array.Count <= param)
{
// Is a invalid index value
if (pTAction)
Debug::Log(__FUNCTION__": Invalid house index '%d'. This action could be skipped.\n", (int)pTAction->ActionKind, param);

return -1;
}

HouseClass* pHouse = HouseClass::Array.GetItem(houseIdx);

if (!pHouse->Defeated && !pHouse->IsObserver())
return houseIdx;

return -1;
}

void HouseExt::SetForceOnlyTargetHouseEnemy(HouseClass* pThis, int mode)
{
const auto pHouseExt = HouseExt::Fetch(pThis);
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/House/Body.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <HouseClass.h>
#include <TActionClass.h>

#include <Ext/HouseType/Body.h>

Expand Down Expand Up @@ -171,6 +172,7 @@ class HouseExt final : public AbstractExt, public Detach::Listener<BuildingClass
static int ActiveHarvesterCount(HouseClass* pThis);
static int TotalHarvesterCount(HouseClass* pThis);
static HouseClass* GetHouseKind(OwnerHouseKind kind, bool allowRandom, HouseClass* pDefault, HouseClass* pInvoker = nullptr, HouseClass* pVictim = nullptr);
static int GetHouseIndex(int param, TeamClass* pTeam, TActionClass* pTAction);
static CellClass* GetEnemyBaseGatherCell(HouseClass* pTargetHouse, HouseClass* pCurrentHouse, CoordStruct defaultCurrentCoords, SpeedType speedTypeZone, int extraDistance = 0);
static void GetAIChronoshiftSupers(HouseClass* pThis, SuperClass*& pSuperCSphere, SuperClass*& pSuperCWarp);

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

this->AIScriptsLists.emplace_back(std::move(objectsList));
}

// Section AITriggersList
int triggerItemsCount = pINI->GetKeyCount("AITriggersList");
for (int i = 0; i < triggerItemsCount; ++i)
{
std::vector<AITriggerTypeClass*> objectsList;

char* context = nullptr;
pINI->ReadString("AITriggersList", pINI->GetKeyName("AITriggersList", i), "", Phobos::readBuffer);

for (char *cur = strtok_s(Phobos::readBuffer, Phobos::readDelims, &context); cur; cur = strtok_s(nullptr, Phobos::readDelims, &context))
{
AITriggerTypeClass* pNewTrigger = GameCreate<AITriggerTypeClass>(cur); // Note: Don't use ::FindOrAllocate(cur) here...
objectsList.emplace_back(pNewTrigger);
}

this->AITriggersLists.emplace_back(std::move(objectsList));
}
}

// this should load everything that TypeData is not dependant on
Expand Down Expand Up @@ -695,6 +713,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
Stm
.Process(this->AITargetTypesLists)
.Process(this->AIScriptsLists)
.Process(this->AITriggersLists)
.Process(this->Storage_TiberiumIndex)
.Process(this->HarvesterDumpAmount)
.Process(this->InfantryGainSelfHealCap)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <AITriggerTypeClass.h>
#include <Utilities/Container.h>
#include <Utilities/TemplateDef.h>

Expand All @@ -24,6 +25,7 @@ class RulesExt
public:
std::vector<std::vector<TechnoTypeClass*>> AITargetTypesLists;
std::vector<std::vector<ScriptTypeClass*>> AIScriptsLists;
std::vector<std::vector<AITriggerTypeClass*>> AITriggersLists;

Valueable<int> Storage_TiberiumIndex;
Valueable<float> HarvesterDumpAmount;
Expand Down
Loading
Loading