diff --git a/CREDITS.md b/CREDITS.md index 651ce1651b..21b7a5191a 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -227,6 +227,7 @@ This page lists all the individual contributions to the project by their author. - Unlimited skirmish colors - Show designator & inhibitor range - Dump variables to file on scenario end / hotkey + - "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 diff --git a/docs/AI-Scripting-and-Mapping.md b/docs/AI-Scripting-and-Mapping.md index 5034673e40..a60889629f 100644 --- a/docs/AI-Scripting-and-Mapping.md +++ b/docs/AI-Scripting-and-Mapping.md @@ -593,3 +593,19 @@ 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. + +```{note} +These events, as opposed to [events 81 & 82 from Ares](https://ares-developers.github.io/Ares-docs/new/triggerevents.html#house-owns-techno-type-81-82), take house as a parameter instead of using the trigger owner. +``` + +In `mycampaign.map`: +```ini +[Events] +... +ID=EventCount,...,[EVENTID],2,[HouseIndex],[TechnoType],... +... +``` diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 59baaf0edd..c5a7244769 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -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 @@ -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 @@ -339,6 +342,7 @@ New: - Allow using `Secondary` weapon against walls if `Primary` cannot target them (by Starkku) - Reloading ammo in transports (by Starkku) - Dump variables to file on scenario end / hotkey (by Morton) +- "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) diff --git a/src/Ext/TEvent/Body.cpp b/src/Ext/TEvent/Body.cpp index a6d4e1ce18..913d4e6b74 100644 --- a/src/Ext/TEvent/Body.cpp +++ b/src/Ext/TEvent/Body.cpp @@ -7,6 +7,7 @@ #include #include #include +#include //Static init TEventExt::ExtContainer TEventExt::ExtMap; @@ -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; @@ -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 diff --git a/src/Ext/TEvent/Body.h b/src/Ext/TEvent/Body.h index 8b20723e89..86b694bf6b 100644 --- a/src/Ext/TEvent/Body.h +++ b/src/Ext/TEvent/Body.h @@ -49,6 +49,8 @@ enum PhobosTriggerEvent GlobalVariableAndIsTrueGlobalVariable = 535, ShieldBroken = 600, + HouseOwnsTechnoType = 601, + HouseDoesntOwnTechnoType = 602, _DummyMaximum, }; @@ -86,6 +88,9 @@ class TEventExt template static bool VariableCheckBinary(TEventClass* pThis); + static bool HouseOwnsTechnoTypeTEvent(TEventClass* pThis); + static bool HouseDoesntOwnTechnoTypeTEvent(TEventClass* pThis); + class ExtContainer final : public Container { public: