Hello everyone,
Now
that I have recently learned that it is not possible to use a dice result
within a macro twice (see here: <a href="https://app.roll20.net/forum/post/710901/macro-fo" rel="nofollow">https://app.roll20.net/forum/post/710901/macro-fo</a>... )I decided to switch to the mentor
status to get access to the API.
My
project is quite simple: I trying to write a script to automate the combat in
Dungeonslayers. However, I did not succeed even after 12 hours of try and error
yesterday. I fail at doing the selection of the values of attacker (selected
token) and defender (target token). I have already looked at the other combat
scripts like the great one of Alex L.. But they are written for a complet
different system, have far more functions then I need, and to be honest my
JavaScript skills are (yet) too limited to understand them.
Perhaps
one or the other seems to be able to help me. So far I have heard only good
things about this community and their willingness to help each other. :-)
The
Problem:
The
Dungeonslayers combat system is a little bit special, because the dice result
of the attack role is used for both: the check if the attack is successful and
the damage. The same happens with the dice result of the defender.
When
Character1 attacks Character2 there are five possibilities:
if (a >
AttackAttributeCharacter1 && d > DefenseAttributeCharacter2){damageCharacter2=0};
if
(a > AttackAttributeCharacter1 && d <=
DefenseAttributeCharacter2){damageCharacter2=0};
if
(a <= AttackAttributeCharacter1 && d >
DefenseAttributeCharacter2){damageCharacter2=a};
if
(a <= AttackAttributeCharacter1 && d <=
DefenseAttributeCharacter2 && (a-d)>0){damageCharacter2=a-d};
if
(a <= AttackAttributeCharacter1 && d <=
DefenseAttributeCharacter2 && (a-d)<=0){damageCharacter2=0};
With:
var
AttackAttributeCharacter1 should be selected from the linked charactersheet of
the token who performs the macro. (Name of the attribute = “MAT”)
var
DefenseAttributeCharacter2 should be selected from the linked charactersheet of
the target token. (Name of the attribute = “Defense”)
var a =1d20
Is a=1
then a becomes the value of AttackAttributeCharacter1. Is
a=20 then damageCharacter2=0 and message appears „Fumble on Attack“.
var d =1d20
Is d=1
then d becomes the value of DefenseAttributeCharacter2. Is
d=20 then damageCharacter2=a and message appears „Fumble on Defense“.
At the
end received damage should be shown as a message and be subtracted from the
Bar_1 of the target_token. If value of Bar_1 <= 0 the red X-Marker should
laid on the token.
Also
the Bar_2 from the selected token (Attacker) shoud be reduced by 2. I hope some of you can help me and I would like to thank you in advance! Sven