Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -226,6 +226,7 @@ This page lists all the individual contributions to the project by their author.
- TechnoType conversion warhead & superweapon
- Unlimited skirmish colors
- Show designator & inhibitor range
- "House owns TechnoType" and "House doesn't own TechnoType" trigger events
- Help with docs
- **ChrisLv_CN** (work relicensed under [following permission](https://github.com/Phobos-developers/Phobos/blob/develop/images/ChrisLv-relicense.png)):
- General assistance
Expand Down
12 changes: 12 additions & 0 deletions docs/AI-Scripting-and-Mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,15 @@ ID=EventCount,...,600,2,0,0,...
...
```

### `601-602` House owns/doesn't own Techno Type
- 601: Springs when specified house owns at least 1 instance of set TechnoType.
- 602: Springs when specified house doesn't own a single instance of set TechnoType.
- Multiplayer houses (indices 4475 through 4482) are supported.

In `mycampaign.map`:
```ini
[Events]
...
ID=EventCount,...,[EVENTID],2,[HouseIndex],[TechnoType],...
...
```
4 changes: 4 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]
59=Operate var is global,10
60=Operate var index,0
65=Campaign AI Repairable,0
68=House,1,2

[EventsRA2]
500=Local variable is greater than,48,6,0,0,[LONG DESC],0,1,500,1
Expand Down Expand Up @@ -116,6 +117,8 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]
534=Global variable is less than or equals to global variable,48,35,0,0,[LONG DESC],0,1,510,1
535=Global variable and global variable is true,48,35,0,0,[LONG DESC],0,1,511,1
600=Shield of the attached object is broken,0,0,0,0,[LONG DESC],0,1,600,1
601=House owns Techno Type,68,46,0,0,[LONG DESC],0,1,601,1
602=House doesn't own Techno Type,68,46,0,0,[LONG DESC],0,1,602,1

[ActionsRA2]
125=Build at...,-10,47,0,65,0,0,1,0,0,[LONG DESC],0,1,125
Expand Down Expand Up @@ -338,6 +341,7 @@ New:
- Owner-only sound on unit creation (by Fryone)
- Allow using `Secondary` weapon against walls if `Primary` cannot target them (by Starkku)
- Reloading ammo in transports (by Starkku)
- "House owns TechnoType" and "House doesn't own TechnoType" trigger events

Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
23 changes: 23 additions & 0 deletions src/Ext/TEvent/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <InfantryClass.h>
#include <UnitClass.h>
#include <AircraftClass.h>
#include <HouseClass.h>

//Static init
TEventExt::ExtContainer TEventExt::ExtMap;
Expand Down Expand Up @@ -118,6 +119,10 @@ bool TEventExt::Execute(TEventClass* pThis, int iEvent, HouseClass* pHouse, Obje

case PhobosTriggerEvent::ShieldBroken:
return ShieldClass::ShieldIsBrokenTEvent(pObject);
case PhobosTriggerEvent::HouseOwnsTechnoType:
return TEventExt::HouseOwnsTechnoTypeTEvent(pThis);
case PhobosTriggerEvent::HouseDoesntOwnTechnoType:
return TEventExt::HouseDoesntOwnTechnoTypeTEvent(pThis);

default:
bHandled = false;
Expand Down Expand Up @@ -158,6 +163,24 @@ bool TEventExt::VariableCheckBinary(TEventClass* pThis)
return false;
}

bool TEventExt::HouseOwnsTechnoTypeTEvent(TEventClass* pThis)
{
auto pType = TechnoTypeClass::Find(pThis->String);
if (!pType)
return false;

auto pHouse = HouseClass::FindByIndex(pThis->Value);
if (!pHouse)
return false;

return pHouse->CountOwnedAndPresent(pType) > 0;
}

bool TEventExt::HouseDoesntOwnTechnoTypeTEvent(TEventClass* pThis)
{
return !TEventExt::HouseOwnsTechnoTypeTEvent(pThis);
}

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

Expand Down
5 changes: 5 additions & 0 deletions src/Ext/TEvent/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ enum PhobosTriggerEvent
GlobalVariableAndIsTrueGlobalVariable = 535,

ShieldBroken = 600,
HouseOwnsTechnoType = 601,
HouseDoesntOwnTechnoType = 602,

_DummyMaximum,
};
Expand Down Expand Up @@ -86,6 +88,9 @@ class TEventExt
template<bool IsSrcGlobal, bool IsGlobal, typename _Pr>
static bool VariableCheckBinary(TEventClass* pThis);

static bool HouseOwnsTechnoTypeTEvent(TEventClass* pThis);
static bool HouseDoesntOwnTechnoTypeTEvent(TEventClass* pThis);

class ExtContainer final : public Container<TEventExt>
{
public:
Expand Down