STAR TREK 2d20
Page 1 of 2 12 Last

Thread: notifyApplyHRFC

  1. #1

    notifyApplyHRFC

    Is there any chance we could see this change in the ruleset?

    manager_action_attack.lua
    line 60
    Code:
    function notifyApplyHRFC(sTable)
    	local msgOOB = {};
    	msgOOB.type = OOB_MSGTYPE_APPLYHRFC;
    	
    	msgOOB.sTable = sTable;
    
    	Comm.deliverOOBMessage(msgOOB, "");
    end
    change to
    Code:
    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
    Code:
    	-- 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
    Code:
    	-- 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.

  2. #2
    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

  3. #3
    Quote Originally Posted by Moon Wizard View Post
    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
    I 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.
    Last edited by bmos; March 7th, 2022 at 00:52.

  4. #4
    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

  5. #5
    Quote Originally Posted by Moon Wizard View Post
    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
    That would be even better/more broadly useful to extension developers
    Last edited by bmos; March 7th, 2022 at 12:54.

  6. #6
    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

  7. #7
    Quote Originally Posted by Moon Wizard View Post
    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
    That's awesome! Thank you!

  8. #8
    uuuh, nice, thanks a lot

  9. #9
    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);"?
    Last edited by bmos; April 9th, 2022 at 19:55.

  10. #10
    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
    Last edited by Moon Wizard; April 9th, 2022 at 23:31.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in