Thread: Dice rolling, with dice...
-
February 18th, 2018, 20:53 #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.
-
February 18th, 2018, 20:59 #12
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!
-
February 18th, 2018, 21:55 #13
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.
-
February 18th, 2018, 22:10 #14Private 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!
-
February 18th, 2018, 23:27 #15
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
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.
-
February 18th, 2018, 23:35 #16
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
Thanks, Celestian.
-
February 18th, 2018, 23:37 #17Private 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!
-
February 18th, 2018, 23:40 #18---
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.
-
February 18th, 2018, 23:48 #19
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,583
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
-
February 19th, 2018, 00:07 #20
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