PDA

View Full Version : Source and <op> tag



Larhalt
September 23rd, 2015, 20:42
Hello,
I have a problem with the result of an operation.

In this image I need that the -16 and -15 show only "16" and "15", without the minus
11096

This is what I have in the code

<sheetbonus name="meleeattackbonus" source="attackbonus.melee">
<anchored>
<to>thac0</to>
<position>below</position>
<offset>0,28</offset>
<size>
<height>20</height>
</size>
</anchored>
<source>
<name>thac0</name>
<op>-</op>
</source>
<source>
<name>hitprobability</name>
<op>-</op>
</source>
<source>
<name>miscattackbonus.melee</name>
<op>-</op>
</source>
<script>
function onSourceUpdate()
setValue(calculateSources());
end
</script>
</sheetbonus>
<stringcontrol>
<anchored>
<to>meleeattackbonus</to>
<position>above</position>
<offset>0,1</offset>
</anchored>
<font>sheetlabelsmall</font>
<center />
<static>Totale</static>
</stringcontrol>

Moon Wizard
September 23rd, 2015, 20:52
Can you just change all the operators to "+" instead of "-"?

If you need the result inverted later, you can always invert the value after getting from the field.

Regards,
JPG

Larhalt
September 23rd, 2015, 20:57
Thank you moon, but I want to show only the result of operation. If I use the "+", I can't subtract the thac0 modifiers from the thac0 base.
In the D&D 2E, the thac0 is negative, the lowest it is, the better it is.

leozelig
September 24th, 2015, 01:39
So, are the "to hit" modifiers penalties? What should the THAC0 be in this example? 21 and 20?

Try removing <op>-</op> from thac0 only, so it just says:

<source>
<name>thac0</name>
</source>

If that doesn't work, change the <op> to + for thac0 only (leave the other ones -), and see if that works.

Larhalt
September 24th, 2015, 09:35
In the "Totale" field must be this operation: Thac0 - Stat - Misc = Totale

This is without <op> tag in thac0 source
11102

And ths is with the "+" op
11103

leozelig
September 24th, 2015, 19:53
I guess looking at this again, I am confused about why "thac0" is a source for the melee attack bonus calculation. To me, the formula should be "Total = Stat + Misc", where "Total" is the melee attack bonus that is applied to your attack roll.

Since "Total" is displaying the +/- sign, I suspect this is in fact the case. You would then remove "thac0" entirely from the equation. Maybe looking at how "meleeattackbonus" is used elsewhere in the code would shed some light on this.

Were you fixing a bug, or just dissecting the code?

Larhalt
September 24th, 2015, 22:50
The thac0 field in the charsheet is manually modified and it change when the PC gain a level. We need to modify it, but also modified by the bonus from Strenght and Dexterity. So we need a base value (thac0) and the modifiers.

I'm just modifying the code :)

leozelig
September 25th, 2015, 01:28
If Total is supposed to be a thac0 with modifiers applied, then the second screenshot looks correct. You just have to remove the <displaysign /> code for that number. The -2 modifier would raise your thac0 from 18 to 20.