Skip to content
Draft
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 @@ -153,6 +153,7 @@ This page lists all the individual contributions to the project by their author.
- Event 606: AttachEffect is attaching to a Techno
- Linked superweapons
- Unit & infantry auto-conversion on ammo change
- Force the check of events in sequential order
- **Starkku**:
- Misc. minor bugfixes & improvements
- AI script actions:
Expand Down
2 changes: 2 additions & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ClCompile Include="src\Ext\Infantry\Hooks.Firing.cpp" />
<ClCompile Include="src\Ext\TechnoType\Hooks.MultiWeapon.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.Targeting.cpp" />
<ClCompile Include="src\Ext\Trigger\Body.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.DrawIt.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.Firing.cpp" />
<ClCompile Include="src\Ext\EBolt\Body.cpp" />
Expand Down Expand Up @@ -218,6 +219,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Ext\EBolt\Body.h" />
<ClInclude Include="src\Ext\Trigger\Body.h" />
<ClInclude Include="src\New\Entity\Ares\RadarJammerClass.h" />
<ClInclude Include="src\New\Type\Affiliated\CreateUnitTypeClass.h" />
<ClInclude Include="src\Blowfish\blowfish.h" />
Expand Down
15 changes: 15 additions & 0 deletions docs/AI-Scripting-and-Mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -881,3 +881,18 @@ In `mycampaign.map`:
ID=EventCount,...,606,2,0,[AttachEffectType],...
...
```

### `1000` Force the check of events in sequential order

- By default, the game evaluates all map triggers in parallel. Adding this map event forces short-circuit evaluation as soon as any subsequent event returns `false`.
- This only affects evaluation from this control event (inclusive) to the last event in the list.
- All events placed before this control event still work in a non-short-circuiting manner.
- Sequential events will not begin evaluation until all preceding events have successfully completed.

In `mycampaign.map`:
```ini
[Events]
...
ID=EventCount,...,1000,0,0,0,...
...
```
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ New:
- [Customize if cloning need power](Fixed-or-Improved-Logics.md#customize-if-cloning-need-power) (by NetsuNegi)
- [Added Target Filtering Options to AttachEffect System](New-or-Enhanced-Logics.md#attached-effects) (by Flactine)
- [Customize type selection for IFV](Fixed-or-Improved-Logics.md#customize-type-selection-for-ifv) (by NetsuNegi)
- Force the check of events in sequential order (by FS-21)
- CellSpread in cylinder shape (by TaranDahl)
- CellSpread damage check if victim is in air or on floor (by TaranDahl)

Expand Down
2 changes: 2 additions & 0 deletions src/Ext/TEvent/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ enum PhobosTriggerEvent
CellHasAnyTechnoTypeFromList = 605,
AttachedIsUnderAttachedEffect = 606,

ForceSequentialEvents = 1000,

_DummyMaximum,
};

Expand Down
101 changes: 101 additions & 0 deletions src/Ext/Trigger/Body.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#include "Body.h"

#include <BuildingClass.h>
#include <InfantryClass.h>
#include <HouseClass.h>

#include <Ext/Scenario/Body.h>
#include <Ext/Techno/Body.h>

//Static init
TriggerExt::ExtContainer TriggerExt::ExtMap;

// =============================
// load / save

template <typename T>
void TriggerExt::ExtData::Serialize(T& Stm)
{
Stm
.Process(this->SortedEventsList)
.Process(this->SequentialTimers)
.Process(this->SequentialTimersOriginalValue)
.Process(this->ParallelTimers)
.Process(this->ParallelTimersOriginalValue)
.Process(this->SequentialSwitchModeIndex)
;
}

void TriggerExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)
{
Extension<TriggerClass>::LoadFromStream(Stm);
this->Serialize(Stm);
}

void TriggerExt::ExtData::SaveToStream(PhobosStreamWriter& Stm)
{
Extension<TriggerClass>::SaveToStream(Stm);
this->Serialize(Stm);
}

DEFINE_HOOK(0x7260C8, TriggerClass_CTOR, 0x8)
{
GET(TriggerClass*, pItem, ESI);

TriggerExt::ExtMap.Allocate(pItem);

return 0;
}

DEFINE_HOOK(0x72617D, TriggerClass_DTOR, 0xF)
{
GET(TriggerClass*, pItem, ESI);

TriggerExt::ExtMap.Remove(pItem);

return 0;
}

DEFINE_HOOK(0x726860, TriggerClass_Load_Prefix, 0x5)
{
GET_STACK(TriggerClass*, pItem, 0x4);
GET_STACK(IStream*, pStm, 0x8);

TriggerExt::ExtMap.PrepareStream(pItem, pStm);

return 0;
}

DEFINE_HOOK(0x7268CB, TriggerClass_Load_Suffix, 0x4)
{
TriggerExt::ExtMap.LoadStatic();

return 0;
}

DEFINE_HOOK(0x7268D0, TriggerClass_Save_Prefix, 0x8)
{
GET_STACK(TriggerClass*, pItem, 0x4);
GET_STACK(IStream*, pStm, 0x8);

TriggerExt::ExtMap.PrepareStream(pItem, pStm);

return 0;
}

DEFINE_HOOK(0x7268EA, TriggerClass_Save_Suffix, 0x5)
{
TriggerExt::ExtMap.SaveStatic();

return 0;
}

// =============================
// container

TriggerExt::ExtContainer::ExtContainer() : Container("TriggerClass") { }

TriggerExt::ExtContainer::~ExtContainer() = default;

// =============================
// container hooks
58 changes: 58 additions & 0 deletions src/Ext/Trigger/Body.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#pragma once
#include <TriggerClass.h>
#include <timer.h>

#include <map>

#include <Helpers/Macro.h>
#include <Utilities/Container.h>
#include <Utilities/Constructs.h>
#include <Utilities/Template.h>

class TriggerExt
{
public:
using base_type = TriggerClass;

static constexpr DWORD Canary = 0x73171331;

class ExtData final : public Extension<TriggerClass>
{
public:
std::vector<TEventClass*> SortedEventsList;
PhobosMap<int, CDTimerClass> SequentialTimers;
std::map<int, int> SequentialTimersOriginalValue;
PhobosMap<int, CDTimerClass> ParallelTimers;
std::map<int, int> ParallelTimersOriginalValue;
int SequentialSwitchModeIndex = -1;

ExtData(TriggerClass* OwnerObject) : Extension<TriggerClass>(OwnerObject)
, SortedEventsList {}
, SequentialTimers {}
, SequentialTimersOriginalValue {}
, ParallelTimers {}
, ParallelTimersOriginalValue {}
, SequentialSwitchModeIndex { -1 }
{ }

virtual ~ExtData() = default;

virtual void InvalidatePointer(void* ptr, bool bRemoved) override { }

virtual void LoadFromStream(PhobosStreamReader& Stm) override;
virtual void SaveToStream(PhobosStreamWriter& Stm) override;

private:
template <typename T>
void Serialize(T& Stm);
};

class ExtContainer final : public Container<TriggerExt>
{
public:
ExtContainer();
~ExtContainer();
};

static ExtContainer ExtMap;
};
Loading