FG Spreadshirt Swag
Page 2 of 3 First 123 Last
  1. #11
    Okay, so figured out what I was missing.

    manager_gamesystem.lua, specifically "actions" and "targetactions" needed to have the "turnundead" type added.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  2. #12
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,416
    See the bottom of post #1 from "Note:" onwards: https://www.fantasygrounds.com/forum...(dice-rolling)
    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. #13
    Quote Originally Posted by Trenloe View Post
    See the bottom of post #1 from "Note:" onwards: https://www.fantasygrounds.com/forum...(dice-rolling)
    Yes, I completely skimmed over that. I glanced at the CoreRPG version and it didn't ring any bells, when I looked over the 5E version I immediately realized what I needed to do.

    The problem is now it seems to be that each rTarget is pushed into the "registerResultHandler" function (onRoll() in this case) one at a time. I need them en masse so I can sort by HD, flip through lowest HDs and manage turns. I looked over the sTargeting = "all" for gamesystem setting but didn't seem to change anything. Going to dig through the CoreRPG code for the sTargeting handling and see if I am missing something.

    Grabbing the <targets> from rSource works for the "en masse" but I'm having permission issues when trying to apply damage and/or effects from the PC side when I do that. I know how to fix it (or kludge around it) by temporarily giving the User permission to the node but there has got to be a better way.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  4. #14
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,416
    Quote Originally Posted by celestian View Post
    ...but I'm having permission issues when trying to apply damage and/or effects from the PC side when I do that. I know how to fix it (or kludge around it) by temporarily giving the User permission to the node but there has got to be a better way.
    The main rulesets always hand this part of the process off to the GM instance using OOB messaging. Look at the 5E handleApplyDamage OOB messaging in manager_action_damage.lua, which is initiated through the notifyApplyDamage function.
    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!

  5. #15
    Quote Originally Posted by Trenloe View Post
    The main rulesets always hand this part of the process off to the GM instance using OOB messaging. Look at the 5E handleApplyDamage OOB messaging in manager_action_damage.lua, which is initiated through the notifyApplyDamage function.
    That was exactly what I needed! Thanks.

    It's a bit convoluted but it works. Here is what I ended up with if anyone cares.

    Problem, need to apply damage or effects to nodes. CAn't do that as a player so you have to send the commands to "OOBManager" who DOES have access.

    • Notify(): the part where you tell OOBManager to take it
    • Handle(): The part where OOB takes the options and sends to apply() (at this point you have all the access you need to nodes)
    • Apply(): Perform actual action to the node you wanted (you could probably merge apply() into handle() if you wanted).



    Here are the registers.

    Code:
    OOB_MSGTYPE_APPLYOBLITERATE = "applyobliterate";
    OOB_MSGTYPE_APPLYTURN = "applyturn";
    
    function onInit()
      OOBManager.registerOOBMsgHandler(OOB_MSGTYPE_APPLYOBLITERATE, handleApplyObliteration);
    	OOBManager.registerOOBMsgHandler(OOB_MSGTYPE_APPLYTURN, handleApplyTurned);
      
      ActionsManager.registerModHandler("turnundead", modRoll);
      ActionsManager.registerResultHandler("turnundead", onRoll);
    end
    And the register code.

    Code:
    -- handle turning a creature
    function handleTurn(rSource, nodeTurn,rMessage,bDestroy)
    Debug.console("manager_action_turnundead.lua","handleTurn","nodeTurn",nodeTurn);
      local rTarget = ActorManager.getActor("ct",nodeTurn);
      
      local sName = DB.getValue(nodeTurn,"name","NO-NAME");
      if (bDestroy) then
        notifyApplyObliteration(rSource,rTarget);
        rMessage.text = rMessage.text .."\r\nObliterated " .. sName .. "!";
      else
        notifyApplyTurn(rSource,rTarget);
        rMessage.text = rMessage.text .."\r\nTurned " .. sName .. "!";
      end
    end
    
    function notifyApplyObliteration(rSource, rTarget)
    	local msgOOB = {};
    	msgOOB.type = OOB_MSGTYPE_APPLYOBLITERATE;
    	
    	msgOOB.sSourceNode = ActorManager.getCTNodeName(rSource);
    	msgOOB.sTargetNode = ActorManager.getCTNodeName(rTarget);
    	
    	Comm.deliverOOBMessage(msgOOB, "");
    end
    function handleApplyObliteration(msgOOB)
    	local rSource = ActorManager.getActor(msgOOB.sSourceType, msgOOB.sSourceNode);
    	local rTarget = ActorManager.getActor(msgOOB.sTargetType, msgOOB.sTargetNode);
    	if rTarget then
    		rTarget.nOrder = msgOOB.nTargetOrder;
    	end
    	
    	local nTotal = tonumber(msgOOB.nTotal) or 0;
    	applyObliteration(rSource, rTarget);
    end
    function applyObliteration(rSource, rTarget)
        -- obliterate undead
        local nodeTurn = ActorManager.getCTNode(rTarget);
        local nHPMax = DB.getValue(nodeTurn,"hptotal",0);
        DB.setValue(nodeTurn,"wounds","number",nHPMax+1);
    end
    
    function notifyApplyTurn(rSource, rTarget)
    	local msgOOB = {};
    	msgOOB.type = OOB_MSGTYPE_APPLYTURN;
    	
    	msgOOB.sSourceNode = ActorManager.getCTNodeName(rSource);
    	msgOOB.sTargetNode = ActorManager.getCTNodeName(rTarget);
    	
    	Comm.deliverOOBMessage(msgOOB, "");
    end
    function handleApplyTurned(msgOOB)
    	local rSource = ActorManager.getActor(msgOOB.sSourceType, msgOOB.sSourceNode);
    	local rTarget = ActorManager.getActor(msgOOB.sTargetType, msgOOB.sTargetNode);
    	if rTarget then
    		rTarget.nOrder = msgOOB.nTargetOrder;
    	end
    	
    	local nTotal = tonumber(msgOOB.nTotal) or 0;
    	applyTurnedState(rSource, rTarget);
    end
    function applyTurnedState(rSource, rTarget)
      -- turn undead
      if not EffectManager5E.hasEffect(rTarget, "Turned") then
        EffectManager.addEffect("", "", ActorManager.getCTNode(rTarget), { sName = "Turned", nDuration = 0 }, true);
      end
    end
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  6. #16

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Thanks, Celestian.

  7. #17
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,416
    Quote Originally Posted by celestian View Post
    It's a bit convoluted but it works.
    Yeah, when I'm developing and I realise I need to offload some stuff to an OOB process I sigh and lookup how it's done to remind myself...
    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!

  8. #18
    Quote Originally Posted by Trenloe View Post
    Yeah, when I'm developing and I realise I need to offload some stuff to an OOB process I sigh and lookup how it's done to remind myself...
    Definately going to bookmark this thread for when I need it down the road again
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  9. #19
    Well done. I had bookmarked this thread to come back and respond when I was at my computer, but you and Trenloe figured it out.

    Cheers,
    JPG

  10. #20
    Quote Originally Posted by Moon Wizard View Post
    Well done. I had bookmarked this thread to come back and respond when I was at my computer, but you and Trenloe figured it out.
    The only bit I'm still trying to figure out is rTarget. Right now if I use rTarget it sends one at a time to onRoll. Is that how it's going to work for turnactions/actions? Is there no way to send an array/table/something ?

    The way I get around this right now is get the <targets> for the rSource and everything does work... I just think folks might be confused that the drag/drop the dice on the target not working.

    The way turn undead works in AD&D I really need the entire list of npcs, sorted by HD (low to high). The player rolls a dice, I sort through a table and see if that roll turns X HD then turn/destroy it (or add bonus dice if it's a easy one)... all of which is about impossible to do if I only get them one at a time in onRoll().

    Here is the "turn undead" table if it helps



    If it's not possible then I'm good cause it's working but if there is a way to get a "list" of targetd nodes through rTarget style to make it more normalized I'll do that.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

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 Character Create Playlist

Log in

Log in