5E Character Create Playlist
Page 1 of 2 12 Last
  1. #1

    Script question (getting info about target)...

    I don't know if this is possible, but I've tried a lot of the APIs to get info about PCs and NPCs, but I can't figure out how to get information about the current actor's target. I'd like to try a couple of things for my "Improved Critical" extension, specifically related to if the target is immune to critical damage.

    Thanks!

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Is this as part of an action (dice roll) or outside of the action process?

    If part of an action process then the targets should be available individually in rTarget as each action is evaluated, and maybe in the LUA table if there is a targeting handler registered with the ActionsManager.

    If you want the targets outside of an action, look at the CoreRPG TargetingManager file \scripts\manager_targeting.lua for some helper functions - like getFullTargets
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    Trenloe is right But, when you're in the second described situation (so when you need getFullTargets) then be aware of that you do not get the target coming from drag&drop, only the ones saved in the CT I had a similar question once, too, and MoonWizard described where to look at for such Drag&Drop targets (just in case when you need it, depends on your situation): https://www.fantasygrounds.com/forums/showthread.php?51417-Getting-targets-of-an-actor

  4. #4
    It's in my extension that executes instead of ActionDamage.onDamageRoll

  5. #5
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Quote Originally Posted by TheoGeek View Post
    It's in my extension that executes instead of ActionDamage.onDamageRoll
    OK, so by default that function only has rSource and the rRoll LUA tables as this function (ran from an event) is designed to only modify the base damage roll independent of targets. The next step in the action process, onDamage, is used to apply the damage to each target.

    What is it you're trying to do? Could you do this before or after this function in the action order?

    EDIT: removed comment about sCreatureNode that wouldn't work.
    Last edited by Trenloe; November 15th, 2019 at 00:18. Reason: Clarified damage event functions
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  6. #6
    The callback registered via registerPostRollHandler is used for modifying a roll made by an action which can affect multiple targets, thus targeting does not make sense in this function.

    You want to use the callback registered via registerResultHandler to make any target specific roll modifications, as the final roll is applied to each target.

    In 5E, a single damage roll can be applied to more than one target.

    Regards,
    JPG

  7. #7
    Yeah, I'm trying to address the issue of the target having adamantine armor (or any other crit immune effect). Currently, this extension maxxes either the damage roll, the critical roll, or both. Adamantine armor ignores critical damage, so it *should* ignore the max damage from a critical hit as well, and just take the original damage roll. Probably.

    Anyway, it can be worked around by selecting the crit dice to be maxxed, but you wouldn't want to keep it maxxing the crit dice all the time because this would be pretty OP'd.

    This is largely a coding exercise for me because an argument can be made that it does ignore the critical damage (but allows the maximum normal damage from the critical hit). I still want to keep this isolated like it is, so if this isn't possible, I'd rather keep it isolated than add functionality that would require me to modify more files.

    Sorry if that was confusing.

    Thanks for the help!
    Last edited by TheoGeek; November 14th, 2019 at 22:52.

  8. #8
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Quote Originally Posted by TheoGeek View Post
    I still want to keep this isolated like it is, so if this isn't possible, I'd rather keep it isolated than add functionality that would require me to modify more files.
    MW is suggesting modifying the registerResultHandler function in the same file - so you'd just be switching code from onDamageRoll to onDamage in the same file.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  9. #9
    Ahh..got it! I'll check that out. Thanks!

  10. #10
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    To expand on what's going on here - when FG kicks off the damage dice roll this is done asynchronously. That is, the dice are rolled and the original FG code that started the process ends, the code doesn't pause execution.

    Then there are two events that kick off ActionDamage code, these are registered at the top of the manager_action_damage.lua file:
    Code:
    	ActionsManager.registerPostRollHandler("damage", onDamageRoll);
    	ActionsManager.registerResultHandler("damage", onDamage);
    The first is, as MW mentions, a generic handler that runs immediately after the roll has finished - hence why it's a PostRollHandler - all this can do is modify the base roll, with reference to the roller (rSource) with no targets being taken into account.

    Then, after the PostRollHandler (the onDamageRoll function in this case) has executed, the next event is raised - to handle the result of the actual roll - the ResultHandler, in this case the onDamage function). This handler is executed for each target, hence the rTarget record is available in the function:
    function onDamage(rSource, rTarget, rRoll)


    So, as Moon Wizard suggests, this is a place to make changes to target specific parameters that modify the result. I'd recommend doing it in the applyDamage function - as this is ran as part of the OOB Messaging in onDamage - basically passing the control from the player side to the GM so that they can make any changes to any PC and NPC records as needed. applyDamage is where resistances, vulnerabilities, etc. are all taken into account so this seems like the best place to do things like this, as part of the getDamageAdjust function that gets called within applyDamage.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

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
  •  
5E Product Walkthrough Playlist

Log in

Log in