PDA

View Full Version : notifyApplyHRFC



bmos
March 7th, 2022, 00:31
Is there any chance we could see this change in the ruleset?

manager_action_attack.lua
line 60

function notifyApplyHRFC(sTable)
local msgOOB = {};
msgOOB.type = OOB_MSGTYPE_APPLYHRFC;

msgOOB.sTable = sTable;

Comm.deliverOOBMessage(msgOOB, "");
end
change to

function notifyApplyHRFC(rAction)
local msgOOB = {};
msgOOB.type = OOB_MSGTYPE_APPLYHRFC;

if rAction.sResult = "fumble" then
msgOOB.sTable = "Fumble";
elseif rAction.sResult = "crit" then
msgOOB.sTable = "Critical Hit;
end

Comm.deliverOOBMessage(msgOOB, "");
end


line 581

-- HANDLE FUMBLE/CRIT HOUSE RULES
local sOptionHRFC = OptionsManager.getOption("HRFC");
if rAction.sResult == "fumble" and ((sOptionHRFC == "both") or (sOptionHRFC == "fumble")) then
notifyApplyHRFC("Fumble");
end
if rAction.sResult == "crit" and ((sOptionHRFC == "both") or (sOptionHRFC == "criticalhit")) then
notifyApplyHRFC("Critical Hit");
end
change to

-- HANDLE FUMBLE/CRIT HOUSE RULES
local sOptionHRFC = OptionsManager.getOption("HRFC");
if rAction.sResult == "fumble" and ((sOptionHRFC == "both") or (sOptionHRFC == "fumble")) then
notifyApplyHRFC(rAction);
end
if rAction.sResult == "crit" and ((sOptionHRFC == "both") or (sOptionHRFC == "criticalhit")) then
notifyApplyHRFC(rAction);
end

by passing rAction to notifyApplyHRFC you would give extension devs a really useful way to expand on critical / fumble effects without having to override a function that has great potential for conflicts.

Moon Wizard
March 7th, 2022, 00:43
I'm not sure how that really helps shield against overwrites. What exactly are you trying to override

Looking at the code, it actually makes more sense to generalize the notifyApplyHRFC to a more general TableManager.rollTableOnGM call (or something like that); but I feel like that might actually be at odds with what you are doing.

JPG

bmos
March 7th, 2022, 00:50
I'm not sure how that really helps shield against overwrites. What exactly are you trying to override

Looking at the code, it actually makes more sense to generalize the notifyApplyHRFC to a more general TableManager.rollTableOnGM call (or something like that); but I feel like that might actually be at odds with what you are doing.

JPGI was hoping to be able to override notifyApplyHRFC to make something happen on crits and fumbles by backing up the function, overriding it, and then calling the original. But the data "Fumble" isn't enough to do what I want (automating Pathfinder 1e fumbles and crits that have different effects based on damage type and attack type). This is what I meant by saying this would give extension devs a way to expand on crits and fumbles without overriding onAttack (which is very long and contains a lots of things that other extension devs might be working with). The easiest way to avoid having to patch extensions to work around each other in my experience is having functions called that we can 'overlay' onto within these big functions like onAttack.

But yes a standardized TableManager.rollTableOnGM call would make more sense from a functional programming approach.

Moon Wizard
March 7th, 2022, 04:57
Ah, I thought that's what you might be after. I think it makes sense to leave that function alone (i.e. notifyApplyHRFC); and maybe add a new function in ActionAttack to allow a hook for handling result behaviors that calls the current function. Let me think on it a bit.

Regards,
JPG

bmos
March 7th, 2022, 12:09
Ah, I thought that's what you might be after. I think it makes sense to leave that function alone (i.e. notifyApplyHRFC); and maybe add a new function in ActionAttack to allow a hook for handling result behaviors that calls the current function. Let me think on it a bit.

Regards,
JPGThat would be even better/more broadly useful to extension developers :)

Moon Wizard
March 10th, 2022, 22:16
I've included some changes in several of the rulesets supporting Critical/Fumble house rule in the Test/beta channel. [i.e. internal function references prefixed with ActionAttack; and post-attack resolution (including this house rule) moved to ActionAttack.onPostAttackResolve(rAction);]

Regards,
JPG

bmos
March 10th, 2022, 22:50
I've included some changes in several of the rulesets supporting Critical/Fumble house rule in the Test/beta channel. [i.e. internal function references prefixed with ActionAttack; and post-attack resolution (including this house rule) moved to ActionAttack.onPostAttackResolve(rAction);]

Regards,
JPGThat's awesome! Thank you!

Kelrugem
March 11th, 2022, 02:54
uuuh, nice, thanks a lot :)

bmos
April 9th, 2022, 18:38
Could we get something like this before the attack is resolved as well?
Many extensions add/modify the contents of rAction before the attack is resolved to add/modify functionality to attack parsing.

Perhaps before "Comm.deliverChatMessage(rMessage);"?

Moon Wizard
April 9th, 2022, 21:35
I'm looking at this; and I can probably do something here. However, it makes more sense to change the signatures so that all similar calls match; which means that the current onPostAttackResolve will be changed and break anything built currently. All sub-functions would have parameters of (rSource, rTarget, rRoll, rMessage).

Regards,
JPG

Moon Wizard
June 11th, 2022, 22:11
https://www.fantasygrounds.com/forums/showthread.php?74059-Beta-Release-2022-07-Ruleset-Updates

Regards,
JPG

bmos
March 21st, 2023, 23:31
Could we get something like this for saves as well?
I know saves are much less standardized than attacks, so perhaps that is not so easy to implement across rulesets.