-
December 9th, 2017, 21:16 #1
Host versus User issue, manager_action_init.lua
I am having an issue that only seems to be a user side problem, NOT a host/DM side.
Currently I have a effect applied when someone rolls initiative for a spell. That is so that if they are hit before their turn there is a notification about spell interruption.
When the DM/Host rolls initiative the value is set properly for nInit in the effect (i.e. the initiative value just rolled).
When the Player/User rolls initiative the value is set to the PREVIOUSLY rolled initiative.
Here is the relevant code.
Code:function onResolve(rSource, rTarget, rRoll) ActionsManager2.decodeAdvantage(rRoll); local rMessage = ActionsManager.createActionMessage(rSource, rRoll); Comm.deliverChatMessage(rMessage); local nTotal = ActionsManager.total(rRoll); notifyApplyInit(rSource, nTotal); -- now we apply effect if this was a spell cast initiative if (rRoll and rRoll.spellPath) then applySpellCastingConcentration(rSource,rRoll); end end function applySpellCastingConcentration(rSource,rRoll) local nTotal = ActionsManager.total(rRoll); local sActorType, nodeActor = ActorManager.getTypeAndNode(rSource); local nodeSpell = DB.findNode(rRoll.spellPath); local nodeChar = nodeActor; if not string.match(nodeActor.getPath(),"^combattracker") then nodeChar = CharManager.getCTNodeByNodeChar(nodeActor); end -- if not in the combat tracker bail if not nodeChar or not nodeSpell then return; end Debug.console("manager_action_init.lua","applySpellCastingConcentration","nodeChar",nodeChar); --local nTotal = rRoll.nT -- build effect fields local sSpellName = DB.getValue(nodeSpell,"name",""); local rEffect = {}; local sEffectString = "(C)"; local sEffectFullName = "Casting " .. sSpellName .. "; " .. sEffectString; rEffect.nDuration = 1; rEffect.sName = sEffectFullName; rEffect.sLabel = sEffectString; rEffect.sUnits = "rnd"; rEffect.nInit = DB.getValue(nodeChar,"initresult",0); rEffect.sSource = nodeChar.getPath(); rEffect.nGMOnly = 0; rEffect.sApply = "action"; Debug.console("manager_action_init.lua","applySpellCastingConcentration","rEffect.nInit",rEffect.nInit); Debug.console("manager_action_init.lua","applySpellCastingConcentration","sEffectFullName",sEffectFullName); Debug.console("manager_action_init.lua","applySpellCastingConcentration","nodeChar.getPath()",nodeChar.getPath()); -- need to do some error checking to make sure we only add it once -- verify existing "effect_source" and "label" isn't the same as this one. local bFound = false; for _,nodeEffect in pairs(DB.getChildren(nodeChar, "effects")) do local sLabel = DB.getValue(nodeEffect,"label",""); local sSource = DB.getValue(nodeEffect,"source_name",""); Debug.console("manager_action_init.lua","applySpellCastingConcentration","sLabel",sLabel); Debug.console("manager_action_init.lua","applySpellCastingConcentration","sSource",sSource); -- if (sSource == nodeSpell.getPath()) then if (sLabel == sEffectFullName and sSource == nodeChar.getPath()) then bFound = true; break; end end -- for item's effects list if bFound then -- effect already exists return; end -- lastly add effect local sUser = User.getUsername(); local sIdentity = User.getCurrentIdentity(sUser); EffectManager.addEffect(sUser, sIdentity, nodeChar, rEffect, true); end
Code:Runtime Notice: Reloading ruleset Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'nodeChar' | databasenode = { combattracker.list.id-00001 } Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'rEffect.nInit' | #12 Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'sEffectFullName' | s'Casting Bless; (C)' Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'nodeChar.getPath()' | s'combattracker.list.id-00001' Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'sLabel' | s'IFT: ARMOR(plate mail,platemail);ATK: 1' Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'sSource' | s'' Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'sLabel' | s'Casting Bless; (C)' Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'sSource' | s'combattracker.list.id-00001' Network Notice: 'Gorig' connected Network Warning: Unable to locate requested file 'Tokens/Elf_Male_Archer2_feather_woodland_bow.png@TP46 Heroic Characters 2 Tokens' Database Notice: Campaign saved.
Code:Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'nodeChar' | databasenode = { combattracker.list.id-00001 } Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'rEffect.nInit' | #12 Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'sEffectFullName' | s'Casting Bless; (C)' Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'nodeChar.getPath()' | s'combattracker.list.id-00001' Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'sLabel' | s'IFT: ARMOR(plate mail,platemail);ATK: 1' Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'sSource' | s'' Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'sLabel' | s'Casting Bless; (C)' Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'sSource' | s'combattracker.list.id-00001'
I'm sure this is an "access" thing but I'm not sure where. I've already given players access to the CT node they "own" so im baffled where else they need it for this to work properly.---
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.
-
December 10th, 2017, 05:15 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,607
No idea, without instrumenting output on every part of the process, from the initial build of the roll through the resolution of the roll.
My guess is that the wrong information is being picked up in the roll, prior to dice being rolled.
Regards,
JPG
-
December 10th, 2017, 05:38 #3
Hum, both use the same code to roll and initiative and the values seem the same from where they are checking (nodeChar). This spot specifically.
rEffect.nInit = DB.getValue(nodeChar,"initresult",0);
And both show the same value for nodeChar in the debug output... it's just that the value of "initresult" is different... that's why im thinking it's a permission issue of some sort?
(DM first)
Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'nodeChar.getPath()' | s'combattracker.list.id-00001'
Runtime Notice: s'manager_action_init.lua' | s'applySpellCastingConcentration' | s'nodeChar.getPath()' | s'combattracker.list.id-00001'
I'll keep poking around to try and locate.---
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.
-
December 12th, 2017, 00:18 #4
So I did some debugging using the most current 5E ruleset to rule out my code here. For this test all I did was add some debug and a check of the initresult.
This function is found in manager_action_init.lua.
Code:function onResolve(rSource, rTarget, rRoll) ActionsManager2.decodeAdvantage(rRoll); local rMessage = ActionsManager.createActionMessage(rSource, rRoll); Comm.deliverChatMessage(rMessage); local nTotal = ActionsManager.total(rRoll); notifyApplyInit(rSource, nTotal); -- MY CODE HERE local sActorType, nodeActor = ActorManager.getTypeAndNode(rSource); local nodeChar = ActorManager.getCTNode(rSource); local nInitresult = DB.getValue(nodeChar,"initresult",0); Debug.console("manager_action_init.lua","onResolve","rSource",rSource); Debug.console("manager_action_init.lua","onResolve","nodeActor",nodeActor); Debug.console("manager_action_init.lua","onResolve","nodeChar",nodeChar); Debug.console("manager_action_init.lua","onResolve","nInitresult",nInitresult); -- END MY STUFF end
DM/Host will see the data for THAT roll. From the Player/User side when they rolled they would see previous roll.
11 was last roll before I /cleared. The last roll is 10 but the Player sees 17 from DB.getValue(nodeChar,"initresult",0);
All I am trying to do is find a hook that will let me see the actual initiative value so I can set that as the nInit on an effect. onResolve should be that hook but it's not working right.---
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.
-
December 12th, 2017, 22:30 #5
So, I was not able to fix this so DB.getValue() worked properly for a User but I was able to get the same number from rRoll (nTotal) so went with that.
It's a work around but I can see this might become a problem for something else down the road.---
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.
-
December 13th, 2017, 22:25 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,607
After thinking about this a bit, I have a theory. The initiative rolls on the client do not set the initiative directly (since all CT entries are owned by the GM), but generates an OOB message to the GM to set the initiative). This means that the initiative field in the CT will not be updated until the GM processes the OOB message, updates the CT initiative value, and sends the updated initiative to the client. If you are trying to pull the initiative for a PC from the initiative roll resolution made from the client PC sheet, then you will need to grab the total of the roll, since the initiative database value won't be set until later.
Regards,
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks