PDA

View Full Version : 5th edition question - create custom critical damage as a global rule...



TheoGeek
October 5th, 2016, 23:24
The more I use FG, the more awesome it is. I just played last night in a quick "test run" with a friend of mine across the state. Worked like a charm.

One funny thing is that he had a party of 4 1st level characters, and he kept rolling crits - he must have gotten like 5 20s in a couple of turns. One character rolled three!

Anyway, it made me think about crit damage, and a house rule I have is that crit damage maxes the "original" damage dice, and then the player rolls the same damage dice again. That way, crits will always do more damage than a standard roll.

Is there a way to make a global rule that is something like : crit damage = Max base damage + roll damage + bonuses that is independent of the type of damage dice and without adding a special damage type to every weapon?

For example, say a weapon does 2d6 base damage with a +4 strength modifier. If that character critted, he'd do 12 (max(2d6)) + 2-12 (2d6) + 4. If we switched to a different weapon that did 1d6, a crit would do 6 + 1-6 + 4, etc.

Thanks again!

Zacchaeus
October 6th, 2016, 00:10
I think you'd need an extension. Or you could make a new damage line for the weapon which added the max damage as a bonus. But you'd then have to fudge the crit roll otherwise FG will double that roll automatically.

LordEntrails
October 6th, 2016, 00:34
I believe Zacchaeus is right, that you will need an extension to do what you want.

If it's something you want to do, start by reading the Developer Guide (https://www.fantasygrounds.com/wiki/index.php/Developer_Guides) entry and then the Extensions (https://www.fantasygrounds.com/wiki/index.php/Extensions)entry in the wiki.

TheoGeek
October 6th, 2016, 05:18
I believe Zacchaeus is right, that you will need an extension to do what you want.

If it's something you want to do, start by reading the Developer Guide (https://www.fantasygrounds.com/wiki/index.php/Developer_Guides) entry and then the Extensions (https://www.fantasygrounds.com/wiki/index.php/Extensions)entry in the wiki.

This is something I'd like to attempt. There's a lot of reading to do! Any hints about where to start? I'm thinking the easiest thing to do would be to intercept the roll and have the non-crit damage dice roll max damage, but I have no idea how to begin to do that or where to look for examples of something similar.

Thanks!

kalmarjan
October 6th, 2016, 05:54
Could this be modelled after the exploding dice rule from the SW ruleset? It's a good place to start, just have to set the first die result at max, and trigger the exploding die, but only once...?

damned
October 6th, 2016, 06:14
You dont need exploding dice - its weapons MAX damage (excluding PC bonuses) + normal damage. Its intercepting the roll that is the challenging bit...


https://www.fg-con.com/wp-content/uploads/2016/09/fgcon9-sig7.jpg (https://www.fg-con.com/events/)
FG Con 9 – Fantasy Grounds Online RPG Convention - October 14-16 2016
Register at www.fg-con.com (https://www.fg-con.com/) for all the latest info.

Trenloe
October 6th, 2016, 14:35
Look at the critical code in the 5e ruleset: scripts\manager_action_damage.lua

JimSocks
October 6th, 2016, 17:26
I like this house rule. I might start using it!

Trenloe
October 6th, 2016, 19:01
The code starting at line 319 in the current 5E v3.1.7 ruleset, scripts\manager_action_damage.lua handles the critical damage dice rolling.

TheoGeek
October 7th, 2016, 08:28
OK, I think I got something...I hamfisted this one - extracted the entire manager_action_damage.lua script, modified the relevant section, and made it into an extension. Not elegant, and there's probably a better way, but it works.

Is it OK to put the relevant code snippet here?

Is there a more elegant way to make this so I don't need to add a modified version of the entire script? (especially since the extension would clobber any update to that file, right?)

The way I hacked this together, the "maxxed die" are not rolled, rather, I added the number of die sides to a modifier that gets added to total damage. Those "die" don't show up as a roll, but as a bonus instead. All other critical die are rolled.

It works, but it ain't elegant. :)

Thanks for the pointers, and I'd like any other input on how to make it "kosher" if you will.

Again, you guys ROCK!

NotRussellCrowe
October 7th, 2016, 11:26
Congrats! I look forward to using this as it is something I've wanted to do myself.

What's the name of your extension? TheoGeek's Improved Critical has a good ring to it I think. :D

Thank you for building this and happy gaming!

Zacchaeus
October 7th, 2016, 13:02
OK, I think I got something...I hamfisted this one - extracted the entire manager_action_damage.lua script, modified the relevant section, and made it into an extension. Not elegant, and there's probably a better way, but it works.

Is it OK to put the relevant code snippet here?

Is there a more elegant way to make this so I don't need to add a modified version of the entire script? (especially since the extension would clobber any update to that file, right?)

The way I hacked this together, the "maxxed die" are not rolled, rather, I added the number of die sides to a modifier that gets added to total damage. Those "die" don't show up as a roll, but as a bonus instead. All other critical die are rolled.

It works, but it ain't elegant. :)

Thanks for the pointers, and I'd like any other input on how to make it "kosher" if you will.

Again, you guys ROCK!

I'm not an expert on such matters but I think what you have done is the only way you can do it. Basically the extension has to replace a segment of code that is in the ruleset and the extension does that by using the code in the extension rather than the one in the ruleset. So you can link your extension to a forum post (not this one - start a new one preferably) telling everyone what it does and how to use it. Have a look at some of the posts in this thread (https://www.fantasygrounds.com/forums/showthread.php?20320-FG-3-0-CoreRPG-Extensions) to get the idea.

kalmarjan
October 7th, 2016, 15:16
I like this so much, I'll probably use it in my campaign. Quick question... Will this code apply to NPC as well?

TheoGeek
October 7th, 2016, 16:25
I like this so much, I'll probably use it in my campaign. Quick question... Will this code apply to NPC as well?

I actually don't know! :) I should probably test it.

I'll post it tonight when I get home from work. Might be late though. You guys can mess around with it, and though I am a programmer by trade, I am a complete NOOB as far as scripting with FG goes, so any issues/requests may take a while to address. :)

The one sort of odd thing is not seeing those "maxxed dice" when you roll, you only see the green crit dice, but you do see the bonus. For example, if a half orc with 20 strength (and no other bonuses) crits with a greatsword, the damage in the chat window shows:

[c1] [c2] [c3] + 17 = total

where c1, c2, and c3 are the three crit rolls (1 from each d6 of the greatsword damage, and 1 from the half orc's savage attack trait) and the 17 is the +5 strength bonus plus 12 from the 2 maxxed d6's of greatsword damage.

where typically, you'd see:

[r1] [r2] [c1] [c2] [c3] + 5 = total

where r1 and r2 are the rolls for standard greatsword damage, c1, c2, c3 are the crit rolls, and the +5 is the strength bonus.

I'd like to change it so that r1 and r2 show up again, but it was easier to do it this way (I think) :)

It also has the effect of treating ALL damage dice the same way for these attacks. For example, if the greatsword also had like a d8 fire damage or something, that would get maxxed and rolled as well:

[c1] [c2] [c3] [f1] + [6+6+6+8] + [str] = total.

I think that's consistent with the rules and it is the general interpretation I have seen dealing with crits in various forums, but there is some doubt as to what is meant by "damage dice".

Moon Wizard
October 7th, 2016, 17:54
You can override a single function within a global script. Just have a separate global script that contains an onInit, and your replacement function.

Something like this:


function onInit()
ActionDamage.onModDamage = onModDamageNew;
end

function onModDamageNew()
<your code>
end


Cheers,
JPG

Nilram the Grey
October 8th, 2016, 14:02
Theogeek,

Do you mind sharing? I've been trying to find time to add confirm criticals with max damage die plus roll damage die again as the resulting damage upon a critical being confirmed (your implementation). I haven't been able to get it done yet. Do you see how to add the confirm critical part as well? I never figured out how to insert the extra attack die roll with the same bonuses as the original die roll.

Working 12-14 hour days seven days a week has blocked my progress entirely now. I've at least managed to hold onto my FG based 5e game once a week, but that is all the fun time I've got right now.

TheoGeek
October 9th, 2016, 16:15
I'll share it as soon as I figure out how to get it to work like Moon Wizard suggested. If I can't get that to work, I'll share what I have.

Moon - I have this in my ModDamageNew.lua file to try it out:



function onInit()
ActionDamage.onModDamage = onModDamageNew;
print("Initializing...");
end

function onModDamageNew(rSource, rTarget, rRoll)
print("I'm here!");
end


The console shows "Initializing...", but when I roll critical damage, it uses the ruleset version and does not print "I'm here!" to the console. I did not see a function called "onModDamage", nor did I see an entry named that in any XML file either, so I tried various combinations of using onModDamage, ModDamage, onModDamageNew, and ModDamageNew and none of them worked.

Is there a hook I'm missing somewhere?

Thanks!

Trenloe
October 9th, 2016, 16:59
Try ActionsManager.registerModHandler("damage", onModDamageNew); instead of ActionDamage.onModDamage = onModDamageNew;

TheoGeek
October 9th, 2016, 17:12
Thanks Trenloe! That worked, but now, I hope, my final dumb question - my function is a copy of the ruleset ModDamage function with a modification to the critical damage code (a SUPER minor change - like two lines). Anyway, when I copy that function out into my onModDamageNew function, there are still calls to functions in the ruleset's manager_action_damage.lus script.

Is there a standard way to handle this or do I just need to make my own version of the entire manager_action_damage.lua script?

Thanks a ton!

Trenloe
October 9th, 2016, 17:29
Anyway, when I copy that function out into my onModDamageNew function, there are still calls to functions in the ruleset's manager_action_damage.lus script.

Is there a standard way to handle this or do I just need to make my own version of the entire manager_action_damage.lua script?
Call the functions in manager_action_damage.lua with ActionDamage.<function name + (arguments)> in your custom script.

TheoGeek
October 10th, 2016, 17:20
All - Thanks for all the help and input!

I have something that I think I am ready to post and let y'all bang around on. If possible, I'd also like someone better at scripting than me to check it out and make sure I didn't inadvertently break something else, the extra code I wrote (beyond the couple lines it took to make the actual damage work) was to make the output in the chat window look right.

Trenloe - I tried making it so that the "standard damage" was maxxed by trying to find a place I could add a REROLL tag, but I couldn't find the right place to put that or know if it can work that way. The idea being, far an attack that does 2d6 damage, have the first 2 dice have a [REROLL 6] modifier, and the second two dice roll normally. Is this possible? If so, then the output in the chat window would naturally make sense, and I wouldn't need to add code to modify the output. I also wouldn't be scared that I broke something by trying to fix the output by removing a clause (my original implementation resulted in the right damage, but the output showed a final (1d12=0) because of the way I handled the max damage).

And kalmarjan - yes, it does affect monster rolls as well. :)

Hopefully, it will be ready tonight!

TheoGeek
October 11th, 2016, 07:39
OK....sorry about all the updates. I found out that [REROLL] doesn't act like I thought. :) I thought [REROLL 6] would keep rerolling until the result was greater than 6. Apparently, it only rerolls once - which makes sense.

So, I'm trying a couple of other things that look like will work better (i.e. less chance of unexpected side effects) :)

Fingers crossed!

Trenloe
October 11th, 2016, 15:20
There's no need to keep re-rolling until you get max damage. Most rulesets will just max the damage to start with and not roll the maxed dice at all. You're best looking at doing this. Remove the relevant dice entries from the dice array (LUA table) and add the max dice roll result as a number to the modifier for the damage roll.

TheoGeek
October 11th, 2016, 15:35
There's no need to keep re-rolling until you get max damage. Most rulesets will just max the damage to start with and not roll the maxed dice at all. You're best looking at doing this. Remove the relevant dice entries from the dice array (LUA table) and add the max dice roll result as a number to the modifier for the damage roll.

Hey Trenloe,

That was my original implementation I got working, but I thought it would be cool to try to get it so that it displayed all of the dice, with the non-critical damage dice maxxed, and the critical dice rolled. I currently have it backwards - it maxxes the crit dice and rolls the weapon damage, but the output is what I wanted. All that is not necessary though, but going through that exercise has helped me understand how the code works and with all your help, I'm starting to see how it all fits together.

I'll "release" the original when I get home and let people mess around with it and see if they want any improvements.

Thanks a ton again!

Trenloe
October 11th, 2016, 16:41
Another option is to not roll the maxed dice, nor put the max result in the modifiers, but code in the maxed dice after the normal damage dice roll with the correct dice type and the .result = max value. The advantage of this is that the result displays these maxed out dice icon and values in the dice roll result. You could also change the maxed out dice result icon to be green (which the 5E ruleset does for rolled critical dice) so that they are distinguishable from the rolled dice results in the final dice result display:

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=15605

TheoGeek
October 11th, 2016, 16:51
Another option is to not roll the maxed dice, nor put the max result in the modifiers, but code in the maxed dice after the normal damage dice roll with the correct dice type and the .result = max value. The advantage of this is that the result displays these maxed out dice icon and values in the dice roll result. You could also change the maxed out dice result icon to be green (which the 5E ruleset does for rolled critical dice) so that they are distinguishable from the rolled dice results in the final dice result display:

That's the way I have it now, but I incorrectly have the dice reversed - it maxes the critical dice, and rolls the normal damage. While I'm sure the players would like this because it drastically increases the minimum damage when multiple critical dice are involved, I'm not so sure the monsters would be too happy (half orc, 18 str, greataxe does 1d12+24+4 instead of 12+4+2d12) :)

TheoGeek
October 11th, 2016, 22:04
Uploaded and posted in a new 5e thread: https://www.fantasygrounds.com/forums/showthread.php?34431-New-Extension-TheoGeek-s-Improved-Critical

Enjoy! And thanks to all who helped!!!