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 .
×

[Help] Wargaming Casualty Script/Macro

Hello, I'm sorry to bother you, but I seem to be a bit incapable of finding a particular type of macro/script! I'm running a small wargaming campaign of my own creation with some friends, and unfortunately at the moment, it requires a large amount of mental math. I was wondering if it was at all possible to construct a macro/script that would allow a player to select an attacking unit, roll 1d? (? representing the men in the regiment) and have those casualties automatically applied to the manpower of a specifically targeted unit on the opposite team? At the moment, I am simply listing the manpower of regiments on Bar 1 - if that helps at all! Any assistance would be grand, I just can't seem to find anything that works, though I admit I am mildly useless when it comes to macros and scripts. Thanks in advance, kind folks.
So, if I understand correctly, you want a macro that will roll 1dx x being whatever you have in bar 1, right?
1655376843

Edited 1655377052
Ziechael
Forum Champion
Sheet Author
API Scripter
As a pro subscriber you have access to the TokenMod API script which would allow you to do something like: ! token - mod - - set bar1_value | -[[1d@{selected|bar1}]] --ids @{target|Target 1|token_id} --report Using the report function you'll get a nice output to show the effect that the script has undertaken, save that macro as a token action and ensure you have the 'active' unit selected when you run it, then simply select the target unit when prompted.
1655376893
Ziechael
Forum Champion
Sheet Author
API Scripter
Please ignore the odd formatting in my prior post, I can't be bothered to wrestle with the text editor today XD Also, that solution is untested but should definitely be in the ball park of what you need.
1655406017

Edited 1655406058
For the most flexibility and the ability to test conditions and perform rolls, I would use a combination of Scriptcards(master script and macro tool), TokenMod (Modifiy Token attributes) and Chatsetattr(Modify character sheet attributes) api scripts.  Use scriptcards to drive the logic, conditionals, gather user input, select targets, etc.and then effect the results by calling TokenMod and Chatsetattr from Scriptcards.  
Julexar said: So, if I understand correctly, you want a macro that will roll 1dx x being whatever you have in bar 1, right? Then have the rolled number removed from the Bar1 of a targetted enemy unit, yeah!
Ziechael said: As a pro subscriber you have access to the TokenMod API script which would allow you to do something like: ! token - mod - - set bar1_value | -[[1d@{selected|bar1}]] --ids @{target|Target 1|token_id} --report Using the report function you'll get a nice output to show the effect that the script has undertaken, save that macro as a token action and ensure you have the 'active' unit selected when you run it, then simply select the target unit when prompted. Would this automatically remove the casualties from the manpower of the selected unit?
1655454027
Ziechael
Forum Champion
Sheet Author
API Scripter
It sure would... I found time to test it and can confirm it works although the report function didn't seem to do anything (and is marked as 'experimental' in the documentation). I'll ask TheAaron to stop by and comment on that bit for you.
Ziechael said: It sure would... I found time to test it and can confirm it works although the report function didn't seem to do anything (and is marked as 'experimental' in the documentation). I'll ask TheAaron to stop by and comment on that bit for you. I believe you need to tell TokenMod what &nbsp;to report. :)&nbsp; <a href="https://app.roll20.net/forum/post/4225825/script-update-tokenmod-an-interface-to-adjusting-properties-of-a-token-from-a-macro-or-the-chat-area/?pageforid=7759266#post-7759266" rel="nofollow">https://app.roll20.net/forum/post/4225825/script-update-tokenmod-an-interface-to-adjusting-properties-of-a-token-from-a-macro-or-the-chat-area/?pageforid=7759266#post-7759266</a> !token-mod --report Who[:Who ...]|Message So it would look something like this: !token-mod --set bar1_value|-[[1d@{selected|bar1}]] --ids @{target|Target 1|token_id} --report all|"{name} takes {bar1_value:change} points of damage."
1655481056
Ziechael
Forum Champion
Sheet Author
API Scripter
Ah sweet, thanks Jarren, I didn't take too much time to look at it while investigating the solution but that makes total sense!