Thread: Warhammer Fantasy RPG 4 ed
-
December 7th, 2020, 11:25 #71
See in that video here:
https://youtu.be/RiBkE32tgv8?list=PL...lcerBvW3&t=260
ChangeCode:<totalchar name="ts" source="abilities.ts"> <anchored to="as" position="insidetopleft" offset="0,28" width="18" /> <tooltip text="Strength Skill" /> <target>ts</target> <statname>Strength Skill</statname> <stat>ts</stat> <script> function onInit() local nodeWin =window.getDatabaseNode(); CharacterUpdate.updateS(nodeWin); end </script> </totalchar>
Code:<totalchar name="ts" source="abilities.ts"> <anchored to="as" position="insidetopleft" offset="0,28" width="18" /> <tooltip text="Strength Skill" /> <target>ts</target> <statname>Strength Skill</statname> <stat>ts</stat> <script> function onInit() local nodeWin =window.getDatabaseNode(); Debug.chat("nodeWin1: ", nodeWin); CharacterUpdate.updateS(nodeWin); end </script> </totalchar>
Code:function updateS(nodeWin) local nIS = nodeWin.getChild("is").getValue(); local nAS = nodeWin.getChild("as").getValue(); local nTS = (nIS+nAS); Debug.console("nTS: ", nTS); nodeWin.getChild("abilities.ts").setValue(nTS); end
Code:function updateS(nodeWin) Debug.chat("nodeWin2: ", nodeWin); local nIS = nodeWin.getChild("is").getValue(); local nAS = nodeWin.getChild("as").getValue(); local nTS = (nIS+nAS); Debug.console("nTS: ", nTS); nodeWin.getChild("abilities.ts").setValue(nTS); end
and see if it outputs
then in
-
December 7th, 2020, 12:51 #72
- Join Date
- Mar 2018
- Location
- Norway
- Posts
- 104
Yep, that did something:
Code:s'nodeWin1:' | databasenode = { charsheet.id-00002 } s'nodeWin2: ' | databasenode = { charsheet.id-00002 }
-
December 7th, 2020, 13:28 #73
But the error persists?
What is Line 106 in this file?
scripts/wh4_damagedr.lua
actually post the whole script/function containing that line and mark which line is 106
-
December 7th, 2020, 14:40 #74
- Join Date
- Mar 2018
- Location
- Norway
- Posts
- 104
Here it is.
I've marked the line with "Line 106" and made it bold.
Code:-- -- Please see the license.html file included with this distribution for -- attribution and copyright information. -- function onInit() -- Register the new action we're creating. We'll allow use of the modifier stack for this action type. --GameSystem.actions["abilities"] = { bUseModStack = true }; ActionsManager.registerModHandler("attack", modRoll); -- Register the result handler - called after the dice have stopped rolling ActionsManager.registerResultHandler("attack", onRoll); -- Used for testing - register a chat window slash handler to start the action Comm.registerSlashHandler("test", processRoll); end --function processRoll(draginfo, rActor, sAbilitiesStat, bSecretRoll) -- -- Start the action! -- performRoll(draginfo, rActor, bSecretRoll); --end function getRoll(rActor, sAbilitiesStat, bSecretRoll, nodeWin) -- Initialise a blank rRoll record local rRoll = {}; -- Add the 4 minimum parameters needed: -- the action type. rRoll.sType = "attack"; -- the dice to roll. rRoll.aDice = { "d100"}; -- A modifier to apply to the roll. rRoll.nMod = 0; -- The description to show in the chat window rRoll.sAbilities = sAbilitiesStat; rRoll.bSecret = bSecretRoll; --rRoll.nStrength = nodeWin.getChild("abilities.ts").getValue(); rRoll.nTarget = DB.getValue(ActorManager.getCreatureNode(rActor), "abilities." .. sAbilitiesStat, 0); local sAbilitiesEffect = DataCommon.skills_ltos[sAbilitiesStat]; if sAbilitiesEffect then rRoll.sDesc = sAbilitiesEffect; --Debug.console("sAbilitiesEffect:" , sAbilitiesEffect) end return rRoll; end --function getStrength(nodeWin) -- local nS = nodeWin.getChild("abilities.nSTR").getValue(); -- local value = math.floor(nS/10); -- -- return value; --end function onRoll(rSource, rTarget, rRoll) -- Create the base message based off the source and the final rRoll record (includes dice results). local rMessage = ActionsManager.createActionMessage(rSource, rRoll); local nTotal = ActionsManager.total(rRoll); rMessage.text = rMessage.text .. "Attack: " .. "[".. rRoll.nTarget .."]" .. "\n".. "Result: " .. rollOutcome(nTotal, rRoll.nTarget) .. "\n" .. rollDamage(nTotal, rRoll.nTarget) .. rollHitlocation(nTotal, rRoll.nTarget).."\n"..rollCritical(nTotal, rRoll.nTarget); -- Display the message in chat. Comm.deliverChatMessage(rMessage); Debug.console("rRoll:" , rRoll) end function modRoll(rSource, rTarget, rRoll) local aAddDesc = {}; local aAddDice = {}; local nAddMod = 0; if rSource then local nBonusStat, nBonusEffects = ActorManager2.getAbilitiesEffectsBonus(rSource, sAbilities); if nBonusEffects > 0 then bEffects = true; nAddMod = nAddMod + nBonusStat; end end end function rollOutcome(rollValue, successValue) local desc = ""; local value = 0; local lSuccessValue = tonumber(successValue); local lRollValue = rollValue; if lRollValue <= lSuccessValue then value = math.floor(lSuccessValue/10)-math.floor(lRollValue/10); desc = string.format("HIT!" .." [SL %d]", value); else value = math.floor(lRollValue/10)-math.floor(lSuccessValue/10) desc = string.format("MISS!" .. " [SL -%d]", value); end return desc; end function rollDamage(rollValue,successValue, nodeWin) local desc = ""; local value = 0; local lSuccessValue = tonumber(successValue); Line 106 local nStrength = nodeWin.getChild("abilities.ts").getValue(); Debug.console("nStrength:" , nStrength) --local nS = 5; --local nS = nodeWin.getChild("abilities.ts").getValue(); local lRollValue = rollValue; if lRollValue <= lSuccessValue then value = math.floor(lSuccessValue/10)-math.floor(lRollValue/10)+nStrength; desc = string.format("Dmg: %d", value) else desc = ""; end return desc; end function rollHitlocation(rollValue,successValue) local desc = ""; local value = 0; local lSuccessValue = tonumber(successValue); local lRollValue = rollValue; if lRollValue <= lSuccessValue then local nX = math.floor(lRollValue/10); local nY = (lRollValue-(nX*10))*10; value = (nX+nY) if value >0 and value < 10 then desc = string.format(" Head", value) elseif value >=10 and value <25 then desc = string.format(" Left Arm", value) elseif value >=25 and value <45 then desc = string.format(" Right Arm", value) elseif value >=45 and value <80 then desc = string.format(" Body", value) elseif value >=80 and value <90 then desc = string.format(" Left Leg", value) elseif value >=90 then desc = string.format(" Right Leg", value) end else desc = ""; end return desc; end function rollCritical(rollValue,successValue) local desc = ""; local value = 0; local lSuccessValue = tonumber(successValue); local lRollValue = rollValue; if lRollValue <= lSuccessValue then local nX = (math.floor(lRollValue/10))*10; local nY = math.floor(lRollValue/10); value = (lRollValue-nX) if value == nY then desc = string.format("CRITICAL!!!",value) else desc = ""; end end return desc; end -- Start the action process function performRoll(draginfo, rActor, sAbilitiesStat, bSecretRoll) local rRoll = getRoll(rActor, sAbilitiesStat, bSecretRoll); ActionsManager.performAction(draginfo, rActor, rRoll); -- Debug.console("rActor:", rActor) end
-
December 7th, 2020, 16:40 #75
-
December 7th, 2020, 21:49 #76
Put the Debug.chat("nodeWin3: ", nodeWin); before line 106
If it doesnt report the same as the others then whatever is calling/passing to rollDamage isnt passing nodeWin.
-
December 8th, 2020, 18:37 #77
- Join Date
- Mar 2018
- Location
- Norway
- Posts
- 104
Yeah, there is something wrong there.
Code:s'nodeWin3: ' | nil
This is the order of things in this roll.
First the template:
Code:<template name="weapondmg"> <simplenumber> <frame mergerule="replace" name="bwframe" offset="3,3,3,4" /> <script file="common/scripts/attackroll.lua" /> </simplenumber> </template>
Code:function action(draginfo) local rActor = ActorManager.getActor("pc", window.getDatabaseNode()); AttackRoll.performRoll(draginfo, rActor, stat[1]); return true; --Debug.console("rActor:" , rActor); end function onDragStart(button, x, y, draginfo) return action(draginfo); end function onDoubleClick(x,y) return action(); end
Code:function onInit() -- Register the new action we're creating. We'll allow use of the modifier stack for this action type. --GameSystem.actions["abilities"] = { bUseModStack = true }; ActionsManager.registerModHandler("attack", modRoll); -- Register the result handler - called after the dice have stopped rolling ActionsManager.registerResultHandler("attack", onRoll); -- Used for testing - register a chat window slash handler to start the action Comm.registerSlashHandler("test", processRoll); end --function processRoll(draginfo, rActor, sAbilitiesStat, bSecretRoll) -- -- Start the action! -- performRoll(draginfo, rActor, bSecretRoll); --end function getRoll(rActor, sAbilitiesStat, bSecretRoll, nodeWin) -- Initialise a blank rRoll record local rRoll = {}; -- Add the 4 minimum parameters needed: -- the action type. rRoll.sType = "attack"; -- the dice to roll. rRoll.aDice = { "d100"}; -- A modifier to apply to the roll. rRoll.nMod = 0; -- The description to show in the chat window rRoll.sAbilities = sAbilitiesStat; rRoll.bSecret = bSecretRoll; --rRoll.nStrength = nodeWin.getChild("abilities.ts").getValue(); rRoll.nTarget = DB.getValue(ActorManager.getCreatureNode(rActor), "abilities." .. sAbilitiesStat, 0); local sAbilitiesEffect = DataCommon.skills_ltos[sAbilitiesStat]; if sAbilitiesEffect then rRoll.sDesc = sAbilitiesEffect; --Debug.console("sAbilitiesEffect:" , sAbilitiesEffect) end return rRoll; end --function getStrength(nodeWin) -- local nS = nodeWin.getChild("abilities.nSTR").getValue(); -- local value = math.floor(nS/10); -- -- return value; --end function onRoll(rSource, rTarget, rRoll) -- Create the base message based off the source and the final rRoll record (includes dice results). local rMessage = ActionsManager.createActionMessage(rSource, rRoll); local nTotal = ActionsManager.total(rRoll); rMessage.text = rMessage.text .. "Attack: " .. "[".. rRoll.nTarget .."]" .. "\n".. "Result: " .. rollOutcome(nTotal, rRoll.nTarget) .. "\n" .. rollDamage(nTotal, rRoll.nTarget) .. rollHitlocation(nTotal, rRoll.nTarget).."\n"..rollCritical(nTotal, rRoll.nTarget); -- Display the message in chat. Comm.deliverChatMessage(rMessage); Debug.console("rRoll:" , rRoll) end function modRoll(rSource, rTarget, rRoll) local aAddDesc = {}; local aAddDice = {}; local nAddMod = 0; if rSource then local nBonusStat, nBonusEffects = ActorManager2.getAbilitiesEffectsBonus(rSource, sAbilities); if nBonusEffects > 0 then bEffects = true; nAddMod = nAddMod + nBonusStat; end end end function rollOutcome(rollValue, successValue) local desc = ""; local value = 0; local lSuccessValue = tonumber(successValue); local lRollValue = rollValue; if lRollValue <= lSuccessValue then value = math.floor(lSuccessValue/10)-math.floor(lRollValue/10); desc = string.format("HIT!" .." [SL %d]", value); else value = math.floor(lRollValue/10)-math.floor(lSuccessValue/10) desc = string.format("MISS!" .. " [SL -%d]", value); end return desc; end function rollDamage(rollValue,successValue, nodeWin) local desc = ""; local value = 0; local lSuccessValue = tonumber(successValue); Debug.chat("nodeWin3: " , nodeWin) local nStrength = nodeWin.getChild("abilities.ts").getValue(); --Debug.chat("nStrength: ". nStrength) --Debug.console("nStrength:" , nStrength) --local nS = 5; --local nS = nodeWin.getChild("abilities.ts").getValue(); local lRollValue = rollValue; if lRollValue <= lSuccessValue then value = math.floor(lSuccessValue/10)-math.floor(lRollValue/10)+nStrength; desc = string.format("Dmg: %d", value) else desc = ""; end return desc; end function rollHitlocation(rollValue,successValue) local desc = ""; local value = 0; local lSuccessValue = tonumber(successValue); local lRollValue = rollValue; if lRollValue <= lSuccessValue then local nX = math.floor(lRollValue/10); local nY = (lRollValue-(nX*10))*10; value = (nX+nY) if value >0 and value < 10 then desc = string.format(" Head", value) elseif value >=10 and value <25 then desc = string.format(" Left Arm", value) elseif value >=25 and value <45 then desc = string.format(" Right Arm", value) elseif value >=45 and value <80 then desc = string.format(" Body", value) elseif value >=80 and value <90 then desc = string.format(" Left Leg", value) elseif value >=90 then desc = string.format(" Right Leg", value) end else desc = ""; end return desc; end function rollCritical(rollValue,successValue) local desc = ""; local value = 0; local lSuccessValue = tonumber(successValue); local lRollValue = rollValue; if lRollValue <= lSuccessValue then local nX = (math.floor(lRollValue/10))*10; local nY = math.floor(lRollValue/10); value = (lRollValue-nX) if value == nY then desc = string.format("CRITICAL!!!",value) else desc = ""; end end return desc; end -- Start the action process function performRoll(draginfo, rActor, sAbilitiesStat, bSecretRoll) local rRoll = getRoll(rActor, sAbilitiesStat, bSecretRoll); ActionsManager.performAction(draginfo, rActor, rRoll); -- Debug.console("rActor:", rActor) end
Code:<totalchar name="ts" source="abilities.ts"> <anchored to="as" position="insidetopleft" offset="0,28" width="18" /> <tooltip text="Strength Skill" /> <target>ts</target> <statname>Strength Skill</statname> <stat>ts</stat> <script> function onInit() local nodeWin =window.getDatabaseNode(); CharacterUpdate.updateS(nodeWin); end </script> </totalchar>
I just can't seem to find the way to add this one little variable. It may be I have to find a completely different way to do this.
-
December 11th, 2020, 19:03 #78
- Join Date
- Mar 2018
- Location
- Norway
- Posts
- 104
Thanks for all the help. It made me think how things worked, and I finally figured out a way to fix the roll.
So now we have an attack roll which:
- Calculates HIT/Miss
- Number of SL
- Total dmg with str and SL
- Hit location
- CRITICAL hit message
Even though I found a way to do it, it's not nearly as refined as other rolls I've seen. But brute force has it charm (I hope).
I need to change a lot of things to make it functional in a way I would like, but I am putting out a rough version here.
At least you can have one place to put in the equipped weapon and roll for attack (no CT functions)
You manually have to put in the total WS, and dmg of the weapon, but doubleclicking the left square will roll an attack with the str modifier.
Example.png
Warhammer_4.ext
-
January 28th, 2021, 18:55 #79
- Join Date
- Nov 2019
- Location
- Germany
- Posts
- 141
Hi ShakyLuigi
Thank you for this great Warhammer extension. Apperently I have a few little problems. The first affects the attack rolls. The rolls with a weapon always fail. The first field I use WS score and the second Field for the Damage score. The attack shows [0] and the # of SL is always negative. Am I missing something?
The other issue I have is with the advanced skills. When I try to roll a skill test, a script execution error shows up and tells me something about a nil value...
I use the latest version of MoreCore and the lastest update of FGU.
Thanx in advance for help
-
January 28th, 2021, 20:08 #80
- Join Date
- Mar 2018
- Location
- Norway
- Posts
- 104
Hi Tom.
Thank you for the feedback!
I am aware that the current version has a few (many) errors and bugs, and is in need of an update. It didn't really work as I thought it would.
Currently I am playtesting the extenstion with my friends, and have heavily changed the attack rolls (among other things).
I am trying to test as many things, and try to get rid of as many of the game-breaking functions as I can before updating.
Hopefully it won't take to much time, and I hope the version that is out now can hold you over until I come with a proper update.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks