Skip to content

Commit 1c13ccf

Browse files
authored
TriggerEvent 75/77 fixes、GetFlags extension (#1686)
Fixed an issue where a portion of Ares's **trigger event 75/77** was determined unsuccessfully. Extends TEventClass_GetFlags for classification. --------- 修复了Ares的**触发条件75/77**有一部分判定不成功的问题。 扩展TEventClass_GetFlags以进行分类。
1 parent 0698da6 commit 1c13ccf

File tree

8 files changed

+70
-7
lines changed

8 files changed

+70
-7
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ This page lists all the individual contributions to the project by their author.
362362
- Fix the issue where computer players did not search for new enemies after defeating them or forming alliances with them
363363
- Customize the damage taken when falling from a bridge
364364
- `600 The shield of the attached object is broken` bug fix for the triggered event
365+
- Fixed an issue where a portion of Ares's trigger event 75/77 was determined unsuccessfully
365366
- **NetsuNegi**:
366367
- Forbidding parallel AI queues by type
367368
- Jumpjet crash speed fix when crashing onto building

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
244244
- Fixed Ares' InitialPayload not being created for vehicles spawned by trigger actions.
245245
- Allowed Ares' `SW.AuxBuildings` and `SW.NegBuildings` to count building upgrades.
246246
- Taking over Ares' AlphaImage respawn logic to make it not recreate in every frame for buildings, static techno and techno without turret, in order to reduce lags from it.
247+
- Fixed an issue where a portion of Ares's trigger event 75/77 was determined unsuccessfully.
247248

248249
## Aircraft
249250

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ Phobos fixes:
410410
Fixes / interactions with other extensions:
411411
- Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades (by Ollerus)
412412
- Taking over Ares' AlphaImage respawn logic to reduce lags from it (by NetsuNegi)
413+
- Fixed an issue where a portion of Ares's trigger event 75/77 was determined unsuccessfully (by FlyStar)
413414
414415
```
415416

src/Ext/SWType/FireSuperWeapon.cpp

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,58 @@
1717

1818
void SWTypeExt::FireSuperWeaponExt(SuperClass* pSW, const CellStruct& cell)
1919
{
20-
auto const pTypeExt = SWTypeExt::ExtMap.Find(pSW->Type);
20+
const auto pHouse = pSW->Owner;
21+
const auto pType = pSW->Type;
22+
auto const pTypeExt = SWTypeExt::ExtMap.Find(pType);
2123

2224
if (pTypeExt->LimboDelivery_Types.size() > 0)
23-
pTypeExt->ApplyLimboDelivery(pSW->Owner);
25+
pTypeExt->ApplyLimboDelivery(pHouse);
2426

2527
if (pTypeExt->LimboKill_IDs.size() > 0)
26-
pTypeExt->ApplyLimboKill(pSW->Owner);
28+
pTypeExt->ApplyLimboKill(pHouse);
2729

2830
if (pTypeExt->Detonate_Warhead || pTypeExt->Detonate_Weapon)
29-
pTypeExt->ApplyDetonation(pSW->Owner, cell);
31+
pTypeExt->ApplyDetonation(pHouse, cell);
3032

3133
if (pTypeExt->SW_Next.size() > 0)
3234
pTypeExt->ApplySWNext(pSW, cell);
3335

3436
if (pTypeExt->Convert_Pairs.size() > 0)
3537
pTypeExt->ApplyTypeConversion(pSW);
3638

37-
if (static_cast<int>(pSW->Type->Type) == 28 && !pTypeExt->EMPulse_TargetSelf) // Ares' Type=EMPulse SW
39+
if (static_cast<int>(pType->Type) == 28 && !pTypeExt->EMPulse_TargetSelf) // Ares' Type=EMPulse SW
3840
pTypeExt->HandleEMPulseLaunch(pSW, cell);
3941

40-
auto& sw_ext = HouseExt::ExtMap.Find(pSW->Owner)->SuperExts[pSW->Type->ArrayIndex];
42+
auto& sw_ext = HouseExt::ExtMap.Find(pHouse)->SuperExts[pType->ArrayIndex];
4143
sw_ext.ShotCount++;
44+
45+
const auto pTags = &pHouse->RelatedTags;
46+
if (pTags->Count > 0)
47+
{
48+
int index = 0;
49+
int TagCount = pTags->Count;
50+
51+
while (true)
52+
{
53+
if (TagCount <= 0 || index >= TagCount)
54+
break;
55+
56+
const auto pTag = pTags->GetItem(index);
57+
58+
// don't be confused as to why (TechnoClass*)(pSW) is there, it's something very much needed..
59+
if (pTag->RaiseEvent(static_cast<TriggerEvent>(77), nullptr, CellStruct::Empty, false, (TechnoClass*)(pSW))
60+
|| pTag->RaiseEvent(static_cast<TriggerEvent>(75), nullptr, CellStruct::Empty, false, (TechnoClass*)(pSW)))
61+
{
62+
if (TagCount != pTags->Count)
63+
{
64+
TagCount = pTags->Count;
65+
continue;
66+
}
67+
}
68+
69+
++index;
70+
}
71+
}
4272
}
4373

4474
// ====================================================

src/Ext/TEvent/Body.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ void TEventExt::ExtData::SaveToStream(PhobosStreamWriter& Stm)
3333
this->Serialize(Stm);
3434
}
3535

36+
// by Fly-Star
37+
int TEventExt::GetFlags(int iEvent)
38+
{
39+
// 0x0 : If it has to have an AttachedObject in order to use it, then let it return 0.
40+
// 0x4 : In MapClass, ZoneEntryBy uses it. borrowed from 0x684D61.
41+
// 0x8 : In HouseClass, It will be added to the RelatedTags of the specified house. Ares' TriggerEvent 75/77 uses it. borrowed from 0x684E34.
42+
// 0x10 : In LogicClass. borrowed from 0x684DCA.
43+
switch (static_cast<PhobosTriggerEvent>(iEvent))
44+
{
45+
case PhobosTriggerEvent::ShieldBroken:
46+
return 0;
47+
//case
48+
// return 0x4;
49+
//case
50+
// return 0x8;
51+
default:
52+
return 0x10;
53+
}
54+
}
55+
3656
std::optional<bool> TEventExt::Execute(TEventClass* pThis, int iEvent, HouseClass* pHouse,
3757
ObjectClass* pObject, CDTimerClass* pTimer, bool* isPersitant, TechnoClass* pSource)
3858
{

src/Ext/TEvent/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ class TEventExt
8383
void Serialize(T& Stm);
8484
};
8585

86+
static int GetFlags(int iEvent);
87+
8688
static std::optional<bool> Execute(TEventClass* pThis, int iEvent, HouseClass* pHouse,
8789
ObjectClass* pObject, CDTimerClass* pTimer, bool* isPersitant, TechnoClass* pSource);
8890

src/Ext/TEvent/Hooks.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ DEFINE_HOOK(0x7271F9, TEventClass_GetFlags, 0x5)
3636

3737
int nEvent = static_cast<int>(pThis->EventKind);
3838
if (nEvent >= PhobosTriggerEvent::LocalVariableGreaterThan && nEvent < PhobosTriggerEvent::_DummyMaximum)
39-
eAttach |= 0x10; // LOGIC
39+
{
40+
eAttach |= TEventExt::GetFlags(nEvent);
41+
}
4042

4143
R->EAX(eAttach);
4244

src/Misc/Hooks.Ares.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ void Apply_Ares3_0_Patches()
4646

4747
// Replace the TemporalClass::Detach call by LetGo in convert function:
4848
Patch::Apply_CALL(AresHelper::AresBaseAddress + 0x436DA, &LetGo);
49+
50+
// SuperClass_Launch_SkipRelatedTags
51+
Patch::Apply_LJMP(AresHelper::AresBaseAddress + 0x3207C, AresHelper::AresBaseAddress + 0x320DF);
4952
}
5053

5154
void Apply_Ares3_0p1_Patches()
@@ -71,4 +74,7 @@ void Apply_Ares3_0p1_Patches()
7174

7275
// Replace the TemporalClass::Detach call by LetGo in convert function:
7376
Patch::Apply_CALL(AresHelper::AresBaseAddress + 0x441BA, &LetGo);
77+
78+
// SuperClass_Launch_SkipRelatedTags
79+
Patch::Apply_LJMP(AresHelper::AresBaseAddress + 0x32A5C, AresHelper::AresBaseAddress + 0x32ABF);
7480
}

0 commit comments

Comments
 (0)