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
3 changes: 3 additions & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
<ClCompile Include="src\Ext\Unit\Hooks.Jumpjet.cpp" />
<ClCompile Include="src\Misc\CaptureManager.cpp" />
<ClCompile Include="src\Misc\Hooks.Image.cpp" />
<ClCompile Include="src\Misc\Hooks.Trigger.cpp" />
<ClCompile Include="src\Misc\PhobosToolTip.cpp" />
<ClCompile Include="src\Misc\TextInput.cpp" />
<ClCompile Include="src\Misc\TriggerMPOwner.cpp" />
<ClCompile Include="src\New\Entity\ShieldClass.cpp" />
<ClCompile Include="src\Misc\RetryDialog.cpp" />
<ClCompile Include="src\New\Type\RadTypeClass.cpp" />
Expand Down Expand Up @@ -139,6 +141,7 @@
<ClInclude Include="src\Misc\CaptureManager.h" />
<ClInclude Include="src\Misc\FlyingStrings.h" />
<ClInclude Include="src\Misc\PhobosToolTip.h" />
<ClInclude Include="src\Misc\TriggerMPOwner.h" />
<ClInclude Include="src\New\Entity\ShieldClass.h" />
<ClInclude Include="src\New\Type\RadTypeClass.h" />
<ClInclude Include="src\New\Type\ShieldTypeClass.h" />
Expand Down
4 changes: 4 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ In `rulesmd.ini`:
MinimapColor= ; integer - Red,Green,Blue
```

## Trigger

- In a multiplayer map, set trigger owner as '4475'-'4482' is player@A-player@G, if nonexist, trigger will be desotroyed.

## Vehicles

### IsSimpleDeployer vehicle deploy animation / direction customization
Expand Down
84 changes: 84 additions & 0 deletions src/Misc/Hooks.Trigger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include <HouseClass.h>
#include <TriggerTypeClass.h>
#include <TriggerClass.h>

#include <Helpers/Macro.h>

#include <Misc/TriggerMPOwner.h>

DEFINE_HOOK(0x7272AE, TriggerTypeClass_LoadFromINI_House, 0x8)
{
GET(TriggerTypeClass*, pThis, EBP);
GET(const char*, pID, ESI);

int idx = atoi(pID);

if (HouseClass::PlayerAtA <= idx && idx <= HouseClass::PlayerAtH)
{
TriggerMPOwner::TriggerType_Owner[pThis->GetArrayIndex()] = idx;

R->EDX(HouseTypeClass::Find("special"));

return 0x7272C1;
}

R->EAX(HouseTypeClass::FindIndex(pID));

return 0x7272B5;
}

DEFINE_HOOK(0x72612C, TriggerClass_CTOR_DestoryIfMultiplayerNonexist, 0x8)
{
GET(TriggerClass*, pThis, ESI);

if (pThis->Type == nullptr)
return 0;

int idx = pThis->Type->GetArrayIndex();
const auto& houseIdxMapper = TriggerMPOwner::TriggerType_Owner;

if (houseIdxMapper.count(idx))
{
HouseClass* pHouse = HouseClass::FindByIndex(houseIdxMapper.at(idx));

if (pHouse == nullptr)
pThis->Destroyed = true;
}

return 0;
}


DEFINE_HOOK(0x726538, TriggerClass_RaiseEvent_ReplaceHouse, 0x5)
{
GET(TriggerClass*, pThis, ESI);

int idx = pThis->Type->GetArrayIndex();
const auto& houseIdxMapper = TriggerMPOwner::TriggerType_Owner;

if (houseIdxMapper.count(idx))
{
HouseClass* pHouse = HouseClass::FindByIndex(houseIdxMapper.at(idx));
R->EAX(pHouse == nullptr ? HouseClass::FindSpecial() : pHouse);
}

return 0;
}

DEFINE_HOOK(0x7265F7, TriggerClass_FireActions_ReplaceHouse, 0x6)
{
GET(TriggerClass*, pThis, EDI);

int idx = pThis->Type->GetArrayIndex();
const auto& houseIdxMapper = TriggerMPOwner::TriggerType_Owner;

if (houseIdxMapper.count(idx))
{
HouseClass* pHouse = HouseClass::FindByIndex(houseIdxMapper.at(idx));
R->EAX(pHouse == nullptr ? HouseClass::FindSpecial() : pHouse);

return 0x726602;
}

return 0;
}
19 changes: 19 additions & 0 deletions src/Misc/TriggerMPOwner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "TriggerMPOwner.h"

#include <Utilities/SavegameDef.h>

std::map<int, int> TriggerMPOwner::TriggerType_Owner;

bool TriggerMPOwner::LoadGlobals(PhobosStreamReader& stm)
{
return stm
.Process(TriggerType_Owner)
.Success();
}

bool TriggerMPOwner::SaveGlobals(PhobosStreamWriter& stm)
{
return stm
.Process(TriggerType_Owner)
.Success();
}
15 changes: 15 additions & 0 deletions src/Misc/TriggerMPOwner.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include <map>

#include <Utilities/Savegame.h>

class TriggerMPOwner
{
public:
static std::map<int, int> TriggerType_Owner;

static bool LoadGlobals(PhobosStreamReader& stm);

static bool SaveGlobals(PhobosStreamWriter& stm);
};
5 changes: 4 additions & 1 deletion src/Phobos.Ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <New/Type/RadTypeClass.h>
#include <New/Type/LaserTrailTypeClass.h>

#include <Misc/TriggerMPOwner.h>

#include <utility>

#pragma region Implementation details
Expand Down Expand Up @@ -251,8 +253,9 @@ auto MassActions = MassAction <
// New classes
ShieldTypeClass,
LaserTrailTypeClass,
RadTypeClass
RadTypeClass,
// other classes
TriggerMPOwner
> ();

DEFINE_HOOK(0x7258D0, AnnounceInvalidPointer, 0x6)
Expand Down