diff --git a/TemplePlus/ability_fixes.cpp b/TemplePlus/ability_fixes.cpp index 06aaea25e..8d165a7ea 100644 --- a/TemplePlus/ability_fixes.cpp +++ b/TemplePlus/ability_fixes.cpp @@ -13,17 +13,32 @@ class AbilityConditionFixes : public TempleFix { public: #define ABFIX(fname) static int fname ## (DispatcherCallbackArgs args); - +#define HOOK_ORG(fname) static int (__cdecl* org ##fname)(DispatcherCallbackArgs) = replaceFunction static int PoisonedOnBeginRound(DispatcherCallbackArgs args);; void apply() override { replaceFunction(0x100EA040, PoisonedOnBeginRound); + + // fixes animal companion runoff crash (it didn't null the second part of the obj handle stored in args[1,2] static void (__cdecl*orgCompanionRunoff)(SubDispNode*, objHndl , objHndl ) = replaceFunction(0x100FC3D0, [](SubDispNode* sdn, objHndl owner, objHndl handle){ orgCompanionRunoff(sdn, owner, handle); conds.CondNodeSetArg(sdn->condNode, 2, 0); }); + + // fixes Opportunist getting an AOO for your own attack... + HOOK_ORG(OpportuninstBroadcast)(0x100FADF0, [](DispatcherCallbackArgs args)->int + { + auto numAvail = args.GetCondArg(0); + if (numAvail){ + GET_DISPIO(dispIoTypeSendSignal, DispIoD20Signal); + auto d20a = (D20Actn*)dispIo->data1; + if (d20a->d20APerformer != args.objHndCaller) + return orgOpportuninstBroadcast(args); + } + return 0; + }); } } abilityConditionFixes; diff --git a/TemplePlus/python/python_dispatcher.cpp b/TemplePlus/python/python_dispatcher.cpp index 11c4c9325..87feb48e4 100644 --- a/TemplePlus/python/python_dispatcher.cpp +++ b/TemplePlus/python/python_dispatcher.cpp @@ -83,7 +83,9 @@ PYBIND11_PLUGIN(tp_dispatcher){ Expects(condStr.numHooks < 99); condStr.subDispDefs[condStr.numHooks++] = { (enum_disp_type)dispType, (D20DispatcherKey)ElfHash::Hash(dispKey), PyModHookWrapper, (uint32_t)pycallback.ptr(), (uint32_t)pydataTuple.ptr() }; }, "Add callback hook") - .def("add_to_feat_dict", &CondStructNew::AddToFeatDictionary) + .def("add_to_feat_dict", [](CondStructNew &condStr, int feat_enum, int feat_max, int feat_offset) { + condStr.AddToFeatDictionary((feat_enums)feat_enum, (feat_enums)feat_max, feat_offset); + }, py::arg("feat_enum"), py::arg("feat_list_max") = -1, py::arg("feat_list_offset") = 0) // .def_readwrite("num_args", &CondStructNew::numArgs) // this is probably something we don't want to expose due to how ToEE saves/loads args .def_readwrite("name", &CondStructNew::condName) .def("extend_existing", [](CondStructNew &condStr, std::string condName){ diff --git a/tpdata/templeplus/lib/templeplus/pymod.py b/tpdata/templeplus/lib/templeplus/pymod.py index b8decf6ef..90dcebb71 100644 --- a/tpdata/templeplus/lib/templeplus/pymod.py +++ b/tpdata/templeplus/lib/templeplus/pymod.py @@ -6,4 +6,6 @@ def AddHook(self, eventType, eventKey, callShit, argsTuple ): def ExtendExisting(self, condName): self.extend_existing(condName) def AddItemForceRemoveHandler(self): # in charge of backing up condition args - self.add_item_force_remove_callback() \ No newline at end of file + self.add_item_force_remove_callback() + def MapToFeat(self, feat_enum, feat_list_max = -1, feat_cond_arg2 = 0): + self.add_to_feat_dict(feat_enum, feat_list_max, feat_cond_arg2) \ No newline at end of file diff --git a/tpdata/tpgamefiles.dat b/tpdata/tpgamefiles.dat index 0c17d2024..d5118a240 100644 Binary files a/tpdata/tpgamefiles.dat and b/tpdata/tpgamefiles.dat differ