I tried to add a python function to get the turn based status in order to do the same things being done in a section of decompiled code (0x100cd0a0). When I called my function on condition add, memory got corrupted and TOEE later crashed. Any idea what I am doing wrong? m.def("cur_seq_get_turn_based_status", []() { return actSeqSys.curSeqGetTurnBasedStatus(); }); Thanks!
Well you should make sure the current sequence pointer is valid if that func isn't doing that internally.
Definitely agree there should be a validity check if I add the function (should I return null and check the value in python?). The problem is that the function is returning an invalid pointer in add condition when similar code in the Temple DLL does not seem to do that. Do you know why this pointer would be bad when adding a spell condition?
Sure. I am trying to recreate the following functionality from the DLL in python for a spell condition: //----- (100CD0A0) -------------------------------------------------------- int __cdecl TouchAttackOnAdd(Dispatcher_Callback_Args a1) { TurnBasedStatus *v1; // eax@1 int v2; // eax@1 v1 = CurSeqGetTurnBasedStatus(); v1->tbsFlags |= D20CAF_ACTIONFRAME_PROCESSED; v2 = CondNodeGetArg(a1.subDispNode->condNode, 0); d20SendSignal(a1.objHndCaller, Disp_Key_S_TouchAttackAdded, v2, 0); return 0; } I wrote the C++ function I showed you earlier: m.def("cur_seq_get_turn_based_status", []() { return actSeqSys.curSeqGetTurnBasedStatus(); }); I use it in python as follows: def TouchOfFatigueConditionAdd(attachee, args, evt_obj): tbStatus = tpdp.cur_seq_get_turn_based_status() tbStatus.flags = tbStatus.flags | D20CAF_ACTIONFRAME_PROCESSED attachee.d20_send_signal(S_TouchAttackAdded, 1001, 0) return 0 TouchOfFatigue.AddHook(ET_OnConditionAdd, EK_NONE, TouchOfFatigueConditionAdd, ()) The function ends up crashing due to the cur_seq_get_turn_based_status() call.
Sorry to interrupt, Doug, but are you going to add fatigue in general? I would love to see it in the game, my understanding is that the fatigue after a barbarian finishes raging is the only thing the game currently recognises.
When are you adding the ToF condition? It sounds like it's expected that it's part of a particular action (for the section of code you copied at least). Also note that actSeqSys.curSeqGetTurnBasedStatus() can return nullptr, and then python code has no guard against that. What do you see when debugging that? To keep things simple and safe you can just have a setter for curseq tbstatus flag that checks this on the c side.
The condition gets added to the caster of a spell in OnSpellEffect(). The pointer returned actually looks decent at that point but when the python object gets destroyed it takes out TOEE. I also rigged something up to call the function at 100CD0A0 in python directly and it also blows up. Ted: yes adding fatigue is my plan. At least for the touch of fatigue spell right now.
When I changed the code to use get/set turn based flags functions everything worked! Thanks for the help!
@_doug_ Do you also plan to add Waves/Ray of Exhaustion and Waves of Fatigue if they aren't already in?
I am interested in doing those spells and some point. The difficulty would be adding graphics effects and sounds. Anyone interested in helping with sounds and graphics?
I believe there are a number of effects already in the game that were never actually used, if you can find one that seems appropriate you should just be able to assign it to your spell.