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 .
×
Create a free account

Automatic "Usage Dice" ammo tracking

1644084836

Edited 1644084888
Overview Black Hack, Darker Dungeons, and several other games abstract inventory management with an "am I running low yet?" item die roll each time you use a consumable. Whenever the dice say "yes" the item die roll gets smaller and therefore the odds of running out get higher. Specific Example: Darker Dungeons (D&D 5e mod) Ammunition Dice Whenever you make an attack using ammunition, roll an Ammo Die with your attack. One a '1' or '2', your Ammo Die goes down one die size until it reaches 0. Once it reaches zero, you are out of ammo. d12 -> d10 -> d8 -> d6 -> d4 -> d1 -> 0 Request: How might this be automated with the attack roll? Currently, the players manually append to the Attack Description "Ammo Die Roll [[1d12]]" and edit whenever it rolls a 1 or 2. My first thought is to use the Ammo script  with  APILogic to handle the conditional logic?
1644264259
timmaugh
Forum Champion
API Scripter
APILogic can definitely help provided you take a couple of steps to prepare, but things might start to bridge into where you might want to use a Muler component, too. And I'm not sure you'll need Ammo script, but let's see. I think you are going to want your Ammo Die Roll to be its own attribute so that it can be easily referenced and the value of it can be easily set without reference to the rest of your attack roll equation. Let's say that you break that portion off into an attribute named AmmoDieRoll - and you store in that attribute ONLY the roll equation (not the double brackets): 1d12 That means that in your attack macro, you can now reference the number of dice by enclosing that attribute call in the double brackets: [[@{selected|AmmoDieRoll}]] The next thing is to have APILogic reference the value of that roll, which will require ZeroFrame, too. Since we need to make sure we always refer to the correct roll, we'll use a define tag from APILogic so that no matter where the roll occurs in the command line, we have the correct handle for it: {&define ([ammocheck][[@{selected|AmmoDieRoll}]].value)} Now we can use ammocheck in our IF block: {&if ammocheck <= 2} ... {&end} Stopping there, we're carving out a space where we will take action if the roll result of ammocheck is a 1 or 2. The action we need to take is that we need to decrement the AmmoDieRoll attribute. If you can do that with the Ammo script, OK, but that script seems more pointed toward decrementing/replenishing an ammo resource based around raw numbers, not a text string. ChatSetAttr can set an attribute to whatever you want, so that might be a better script to use. In fact, you can use CSA inline in another script by enclosing the CSA command line in ! ... !!! So you should be able to put that inside the IF block. Since APIL will run before CSA, you are sure to filter out the command if you don't get a 1 or 2 on your roll. {&if ammocheck <=2}!setattr --charid @{selected|character_id} --AmmoDieRoll|... !!!{&end} Those three dots would need to be the next value in the sequence. Since the metascripts run before CSA, that could be a new APIL IF/ELSEIF block: {&if @{selected|AmmoDieRoll}=1d12}1d10{&elseif @{selected|AmmoDieRoll=1d10}1d8{&elseif ...}...{&end} By the time CSA saw the call, that whole string of IF/ELSEIFs would be replaced with the value that you needed. But you see how that might start to get to be pretty long. That's where a Mule could come in handy. In fact, on a shared Mule Character, everyone's macros could reference the same Mule. Set up an ability named AmmoProgression on a character named MuleBoy, and give access to that character as necessary. The ability/Mule should be setup to be: 1d12=1d10 1d10=1d8 1d8=1d6 1d6=1d4 1d4=1d1 1d1=0 0=0 Then, in the CSA line, put a get statement to retrieve a value based on the current value of the field. --AmmoDieRoll|get.MuleBoy.AmmoProgression.@{selected|AmmoDieRoll}/get And elsewhere in your command line you will need to load up that Mule: {&mule MuleBoy.AmmoProgression} I would suggest some way of knowing that the ammo was at 0 before running the attack, which might mean wrapping the attack macro in a check of whether AmmoDieRoll was 0. Let the command line survive if it is greater than 0, or filter everything out if it equals 0.