Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
May your rolls be merry + bright! 🎄
Create a free account

probably too complicated for roll20

ok so, i gave a weapon to a player that as their health drops it gives and takes some bonuses away,  so with each 10% of health lost the weapon give a +1 to attack to a max of +5 at 50% of the character's max health as well as a -2 to ac for each 10% lost to a max of -10, these two macros I have and have gotten to work now comes the harder one starting at 90% health the weapon gives an additional 1d8 to damage to a max of 5d8 at 50%, I'm struggling to get a macro to work for this mechanic this is what I have been trying to tweek to get to work         [[[[min(5, (floor((@{HP|max} - @{HP}) / (@{HP|max} / 10 / 2))))]] * 1d8]]
1687080702

Edited 1687100486
GiGs
Pro
Sheet Author
API Scripter
That looks like an incredibly powerful weapon. I'd never gie that to a PC. That aside, do these modifiers apply just when attacking with this weapon? If so, it is definitely doable, but if it applies to different actions, you'll need to modify all those actions as well. If just this weapon, you'll need to modify the code for attacks, for damage rolls, and for AC calculation. With that preamble out of the way, I see a few mistakes in your code. First, you want to calculate a fraction of the remaining hit points. So you need to do (HP|max - HP)/HP|max, then multiple by 10 to get increments of 10%, then floor on that. You have done that, kind of, but I don't know where the /2 comes from. You also can't use min(5, something). You need to use {5, something}kl1 (keep lowest), It's a different syntax. Also when using |max, you need to supply a character name. I've used selected , but you can replace that with the character's actual name (that way you don't need to have a token selected to use it). With all that taken into account, you can calculate the increements like so: [[ {5,floor(((@{selected|hp|max} - @{selected|HP})/@{selected|hp|max}) *10)}kl1]] To get the number of d8, dont do  * 1d8 - that will roll the total by a single d8. To get the actual number of d8, stick d8 after the above, like so: [[ {5,floor(((@{selected|hp|max} - @{selected|HP})/@{selected|hp|max}) *10)}kl1]]d8 Note: you can use the first expression above to calulcate the attack modifier,and multiply it by -2 for the AC modifier.
I’d look into ScriptCards API and write something specific to model the functionality.  
1687100515
GiGs
Pro
Sheet Author
API Scripter
Of course, ScriptCards needs the campaign creator to have a Pro subscription, and install the script.
GiGs said: That looks like an incredibly powerful weapon. I'd never gie that to a PC. That aside, do these modifiers apply just when attacking with this weapon? If so, it is definitely doable, but if it applies to different actions, you'll need to modify all those actions as well. If just this weapon, you'll need to modify the code for attacks, for damage rolls, and for AC calculation. With that preamble out of the way, I see a few mistakes in your code. First, you want to calculate a fraction of the remaining hit points. So you need to do (HP|max - HP)/HP|max, then multiple by 10 to get increments of 10%, then floor on that. You have done that, kind of, but I don't know where the /2 comes from. You also can't use min(5, something). You need to use {5, something}kl1 (keep lowest), It's a different syntax. Also when using |max, you need to supply a character name. I've used selected , but you can replace that with the character's actual name (that way you don't need to have a token selected to use it). With all that taken into account, you can calculate the increements like so: [[ {5,floor(((@{selected|hp|max} - @{selected|HP})/@{selected|hp|max}) *10)}kl1]] To get the number of d8, dont do  * 1d8 - that will roll the total by a single d8. To get the actual number of d8, stick d8 after the above, like so: [[ {5,floor(((@{selected|hp|max} - @{selected|HP})/@{selected|hp|max}) *10)}kl1]]d8 Note: you can use the first expression above to calulcate the attack modifier,and multiply it by -2 for the AC modifier. I understand your concern about the weapon being powerful at the start. However, it's designed to incorporate an element of risk and reward. When a player wields this weapon, there is a gamble involved. While it provides bonus damage and a +5 to hit, it also imposes a -10 penalty to the player's AC. This means that the player is more susceptible to attacks and there's a real possibility of reaching half HP with a significant negative impact on their overall defense. Despite the potential drawbacks, the player enjoys this gamble and finds it fun. It adds an exciting dynamic to the gameplay, creating a thrilling experience where they have to carefully consider their actions and weigh the risks. Ultimately, it enhances the player's engagement and enjoyment with the game. Additionally, I wanted to express my gratitude for your assistance. Your code was almost perfect for my needs, and with a slight adjustment, it worked perfectly in my character sheet. Your advice and guidance have been immensely helpful, and I cannot thank you enough for your support. Here's the modified code that I used, incorporating your suggestions: [[[[ {5,floor(((@{HP|max} - @{HP})/@{HP|max}) *10)}kl1]]d8]] Once again, thank you for your invaluable help. GiGs said: Of course, ScriptCards needs the campaign creator to have a Pro subscription, and install the script. yeah, I unfortunately can't afford a pro sub at the moment, but the macro works like a charm.
1687142096
GiGs
Pro
Sheet Author
API Scripter
Gazza said: I understand your concern about the weapon being powerful at the start. However, it's designed to incorporate an element of risk and reward. When a player wields this weapon, there is a gamble involved. While it provides bonus damage and a +5 to hit, it also imposes a -10 penalty to the player's AC. This means that the player is more susceptible to attacks and there's a real possibility of reaching half HP with a significant negative impact on their overall defense. In my experience, GMs tend to massively overestimate the value of AC penalties. Of course the player enjoys the "risk" over "reward" here = they are benefitting massively for a very manageable cost. Change that AC penalty to a damage dice increase (like they get), and their opinnion will rapidly change. Or set the effects to start at 50% and increase as they drop each 10% below, and again, they'll have to manage the benefits gained from the weapon much more carefully. Anyway, this might not be the p;ace for that discussion. I'm glad the macro works out!