PDA

View Full Version : Problems with 5E ActionDamage.onDamage behavior



webdove
April 4th, 2021, 23:07
I am intercepting the call to ActionDamage.onDamage. One call with sword damage works. One call with fireball damage does not display the dice on the right end of the chat entry. Why?
45449

webdove
April 4th, 2021, 23:29
Here are the chat messages.
Sword first
s' onDamage: rMessage:' | {
s'diemodifier' = #7,
s'font' = s'systemfont',
s'dice' =
{ #1 = { s'type' = s'b12', s'result' = #12 }, #2 = { s'type' = s'b12', s'result' = #12 }, #3 = { s'type' = s'b12', s'result' = #7 }, #4 = { s'type' = s'b12', s'result' = #3 }, #5 = { s'type' = s'b12', s'result' = #6 }, #6 = { s'type' = s'b12', s'result' = #12 }, #7 = { s'type' = s'b12', s'result' = #6 }
},
s'type' = s'damage',
s'sender' = s'_GM PC',
s'text' = s'[DAMAGE (M)] Longsword [x1.5] [TYPE: slashing (65=65)]',
s'icon' = s'portrait_gm_token',
s'secret' = bFALSE }

then fireball
s' onDamage: rMessage:' | {
s'diemodifier' = #6, s'font' = s'systemfont',
s'dice' =
{ #1 = { s'type' = s'b9', s'result' = #7 }, #2 = { s'type' = s'b9', s'result' = #6 }, #3 = { s'type' = s'b9', s'result' = #7 }, #4 = { s'type' = s'b9', s'result' = #6 }, #5 = { s'type' = s'b9', s'result' = #9 }, #6 = { s'type' = s'b9', s'result' = #6 }, #7 = { s'type' = s'b9', s'result' = #1 }, #8 = { s'type' = s'b9', s'result' = #1 }
},
s'type' = s'damage',
s'sender' = s'_GM PC',
s'text' = s'[DAMAGE] Fireball (150) = [x1.5] [TYPE: fire (49=49)]',
s'icon' = s'portrait_gm_token',
s'secret' = bFALSE }

The difference in behavior appears to be in one of these two lines from onDamage():
-- Apply damage to the PC or CT entry referenced
local nTotal = ActionsManager.total(rRoll);
notifyApplyDamage(rSource, rTarget, rRoll.bTower, rMessage.text, nTotal);

webdove
April 5th, 2021, 02:20
I suspect I know the answer. Refdoc says: Each die result object is an array with a "type" and a "result" field. The "type" field is a string matching the die type defined in the XML ("d4", "d6", ...). I recommend that in the comm code you substitute the die_general_icon when the number of sides does not match a specific icon. I will try using "bF" for the die type. I don't think it is used in a calculation for the chat message, and "dF" does have a generic 6 sided die icon. That did not work. It would have to be changed in the comm package.

Moon Wizard
April 5th, 2021, 03:51
I'm assuming that "b9" is not a valid die asset type defined in the ruleset; so it will be ignored.

JPG

webdove
April 5th, 2021, 19:49
I'm assuming that "b9" is not a valid die asset type defined in the ruleset; so it will be ignored.

JPG

I had a feeling that you might say that ;).

I wanted to thank you for the delightful experience this past two weeks of learning LUA (I had not coded since the 1990's in Symbolics Lisp and C++) and learning FGU (very cool despite lacking code comments and man pages).

Now that I understand things better I will refactor 5E DMGX. I won't use Celestian's 2E approach of scaling nmod and diesides.

I will intercept the ResultHandler for "damage" (ActionsDamage.onDamage()),
append "[x?]" to rRoll.dDesc,

temporarily wrap ActionsManager.total() to scale its returned value by the DMGX value


run the original ActionsDamage.onDamage().

unwrap ActionsManager.total()
return

This will avoid any issues with non-standard die sizes, avoid comingling the scaled mod with unscaled dice in the chat message and quantize more accurately by only scaling the total.