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

Initiatve Macro - adding a finishing touch.

1439357601

Edited 1439357706
With your help I now have a working Initiative macro for my game, which check a selected characers Initiative profile, modifies it by a small +3 to -3 adjustment from a probability table, and then posts the result to the turn tracker. (see below) &{template:default} {{name=Initiative Test}}{{@{selected|token_name}'s Initiative=[[ @{selected|I}+ 1t[Probability] &{tracker} ]] }} e.g. Erica has an I=32 modified by +2, therefore her initiative for this turn is 34. The only thing this doesn't cater for is when Erica is surprised, or caught off-guard.  Under those conditions her initiative will be halved, so either her profile stat of 32 would become 16, or the final outcome would be halved (34 becomes 17).  My idea was to just ask the question, and then modify the result based on the answer. So, ask [Is Erica surprised? (Yes=1 No=0)] then if the answer is 1 multiply the initiative score by 0.5 to reduce the result. I managed to add the question easy enough, but got stumped trying to modify the result of the test conditionally based upon the answer.  I've already checked the Macro help, and Daves video guides but can't find an example of basing a condition on the value of an input.
1439358262

Edited 1439358307
&{template:default} {{name=Initiative Test}}{{@{selected|token_name}'s Initiative=[[ floor(?{Is Erica surprised?|No, 1|Yes, 0.5}*[[ @{selected|I}+ 1t[Probability] &{tracker} ]]) ]] }}
1439358892

Edited 1439359013
Yea ... because a direct 'if/elseif/else' statement is reserved for the API, I believe. That said, it's technically not. First you need a Target Number roll. To function as "If this statement is true" {[[?{bool|0}]]}>1 Then a little computer science math. X * (1 - (0.5 * Y)) With 'X' being the roll you want to modify and 'Y' being the true or false test above. If 'Y' is true (set to 1), the statement is X * (1 - (.5 * 1))  ->  X * (1 - .5) -> X * .5 If 'Y' is false (set to 0), the statement is X * (1 - (.5 * 0)) -> X * (1 - 0) -> X * 1 Edit: The above should work too I believe.
1439365431

Edited 1439365924
Silvyre said: &{template:default} {{name=Initiative Test}}{{@{selected|token_name}'s Initiative=[[ floor(?{Is Erica surprised?|No, 1|Yes, 0.5}*[[ @{selected|I}+ 1t[Probability] &{tracker} ]]) ]] }} Wow! Silvyre that is brilliant. &nbsp;I've just tested and it works even better than I thought it could. &nbsp;I love the little drop down that asks the player to select Yes or No. &nbsp;I've never even seen that feature before. @HarbingerLeo: The Target Number feature is the basis for most tests in WFRPv1 (which is the system I'm using), the only slight challenge I have with that is that whilst the basic function is fine. &nbsp;So, a Gossip Test is d100&lt;Fel (where Fel is the value of the characters attribute for Fellowship. &nbsp;That works and produces a result of 1 Success or 0 Success, which is a bit clunky but once your used to 0 Success = Failed it works. Where it gets a bit more convoluted is that WFRPv1 then has a concept of 'Degrees of Success/Failure', which basically indicates how well, or how badly the character did in attempting to perform the task. I'm using the Liber Fanatica Expanded Skills Rules&nbsp;( <a href="http://www.liberfanatica.net/wfrp_advanced_skills" rel="nofollow">http://www.liberfanatica.net/wfrp_advanced_skills</a>.... )&nbsp;, so ideally for pretty much every test I will need to know not just whether the character succeeded or failed, but by how much and I think that may be a bit more of a challenge. {See below) Degree of Success Perfect Passed by +30 3+ DoS Success Passed by 0-+29 0-2 DoS Failure Failed by -1 to -29 0-2 DoS Botch Failed by -30 to -59 3-5 DoS Fumble Failed by -60+ 6+ DoS So, for a Gossip Test for example: Perfect would get the character 'All the latest news and rumours, plus any specific questions will be answered as accurately as possible.' Success &nbsp;would get 'All the latest news and rumours, plus answers to one specific question.' Failure 'One piece of news, which may be a deliberate lie or completely irrelevant.' Botch 'Character is ignored rudely, threatened, or deceived if NPC is already hostile.' Fumble 'Character is reported to the authorities or enemies for snooping, or is even attacked outright.' The good news is that pretty much all of the standard tests follow exactly the same pattern, the only thing that varies are the skill modifiers (Gossip is modified by (Acting, Bribery, Charm, Comedian, Public Speaking, Seduction, Story Telling and Wit). &nbsp;So, once I've got one macro working I've pretty much cracked it for all of them.
1439367414

Edited 1439367471
Silvyre said: &{template:default} {{name=Initiative Test}}{{@{selected|token_name}'s Initiative=[[ floor(?{Is Erica surprised?|No, 1|Yes, 0.5}*[[ @{selected|I}+ 1t[Probability] &{tracker} ]]) ]] }} Actually, looking at how this macro works begs a couple of other questions the answers to which might open up other possibilities for macros I need to develop. floor(?{Is Erica surprised?|No, 1|Yes, 0.5} I think I read that floor = Round down, but I've not seen the term for round-up is it Ceil or is round down the default. &nbsp;I read somewhere that there is no intrinsic truncate function. The&nbsp; surprised?|No, 1|Yes, 0.5 seems to be assigning numeric values to a given selected option. &nbsp;So, presumably that idea could be extended if necessary. &nbsp;e.g. &nbsp;For a Weapon Skill macro could it be extended to ask the player which weapon they are attacking with, and then modify the chance of success based on that weapons attack modifier, So something like: Which weapon is Erica using?|Fists,-20|Sword or Club,0|Spear, 10|Flail, -10|2-Handed Flail,-20|Lance(if mounted),+10|Net,-10|Whip,-10| That would open up all sorts of possibilities.
1439370004

Edited 1439370706
If I understand? Yea, you can do degrees of success. What you need I think is a offset. Hang on to your pants, this is going to be really simple or jump right to 'OHMygoodlord' levels of complication. I need to check my facts first before I spend hours writing a math idiom you can't actually use. The target's skill is say 50. Making this a opposed roll the player needs to roll at least a 50 (to 79) on to "just" pass it? With higher being better. If you need to use a d100 with a PC skill rating giving them a plus +25 to the roll? Meaning the d100 has to land on at least a 25 or better (to total the minimum roll of 50) to pass the check? Edit: With a roll of at least 55 (totaling 80) for a 'Perfect'?
1439379836

Edited 1439379883
@HarbingerLeo: Almost except that in WFRPv1 you have to roll under the threshold to success. So, for example if your characters Fellowship attribute is 35, then in order to succeed you would need to roll 35 or less. (subject to modifiers etc.) On a base roll with no modifiers a critical fumble would therefore be a score in excess of 95 &nbsp;(35+60). a perfect success would be rolling 5 (35-30) or less. &nbsp;As you can see it's quite hard to achieve either perfection or fumble, and it's usually the modifiers that sway it.
1439398406

Edited 1439398753
So high stats good, low rolls good. So ... I just need to make sure I mapped it right. Floor((d100 - @{attribute}) / -30) Should give you a -X to 0 to X result. With a negative number that many groups of 30 you failed by, zero number being a pass, and anything above a zero being a 'Perfect' success, I think. I'll divide by -30 so two negative numbers cancel each other out. Let me run through this with a Fellowship stat of 35. A roll of 1 to 5, Perfect: Will compute to (-34 to -30) divided by -30. Which should be always be 1 and fraction of 30. Floor() would drop the fraction and just report a 1. A roll of 6 to 35, Pass: Will compute to (-29 to 0) divided by -30. Which should be always be zero to some fraction of 30. Floor() would always report zero as it should always round down. A roll of 36 to 65, Fail: Will compute to (1 to 30) divided by -30. Which should always be some fraction of 30 below zero to -1. Floor() will always see the lower number as -1 and report that. A roll of 66 to 95, Botch: Will compute to (31 to 60) divided by -30. Which should always be -1 and some fraction of 30 to -2. Floor() will always see the lower number as -2 and report that. A roll of 96 to 100, Fumble: Will compute to (61 to 65) divided by -30. Which should always be -2 and some fraction of 30 to -3. Floor() will always see the lower number as -3 and report that.
HarbingerLeo said: So high stats good, low rolls good. So ... I just need to make sure I mapped it right. Floor((d100 - @{attribute}) / -30) Should give you a -X to 0 to X result. With a negative number that many groups of 30 you failed by, zero number being a pass, and anything above a zero being a 'Perfect' success, I think. I'll divide by -30 so two negative numbers cancel each other out. Let me run through this with a Fellowship stat of 35. A roll of 1 to 5, Perfect: Will compute to (-34 to -30) divided by -30. Which should be always be 1 and fraction of 30. Floor() would drop the fraction and just report a 1. A roll of 6 to 35, Pass: Will compute to (-29 to 0) divided by -30. Which should be always be zero to some fraction of 30. Floor() would always report zero as it should always round down. A roll of 36 to 65, Fail: Will compute to (1 to 30) divided by -30. Which should always be some fraction of 30 below zero to -1. Floor() will always see the lower number as -1 and report that. A roll of 66 to 95, Botch: Will compute to (31 to 60) divided by -30. Which should always be -1 and some fraction of 30 to -2. Floor() will always see the lower number as -2 and report that. A roll of 96 to 100, Fumble: Will compute to (61 to 65) divided by -30. Which should always be -2 and some fraction of 30 to -3. Floor() will always see the lower number as -3 and report that. Yes. So an result of: 1 &nbsp;= Perfect Success 0 &nbsp;= Success -1 = Fail -2 = Botched -3 = Fumbled So, I would need to feed the test roll into that (instead of d100) and collect the output as a number between 1 and -3?
1439401094

Edited 1439401619
That's certainty one way to do it. It's the core of it. I'm not done yet though. I'm just testing my assertions before I work out and test something more complicated. Edit: I think the range can go above 1. That's just the limits of this example. I think the full range is 3,2,1,0,-1,-2,-3
Didz said: I think I read that floor = Round down, but I've not seen the term for round-up is it Ceil Correct. Documentation. Didz said: I read somewhere that there is no intrinsic truncate function. True. I added the floor() function because odd sums halved would otherwise end in .5, and I assumed your system would handle this by rounding down. In hindsight, I probably should have remarked on this addition, in case my assumption was incorrect. Didz said: The surprised?|No, 1|Yes, 0.5 seems to be assigning numeric values to a given selected option. Correct. Documentation.
1439404682

Edited 1439405423
Actually, I think I'm at my limit what what I can do without the API to look up specific entries in a table and report what that specific entry says or a way to "add" words together. I can tell you you can "roll" a table to get them to output words like "perfect" and "fumble". I can tell you could add +3 to "Floor((d100 - @{attribute}) / -30)" to make the output range 0,1,2,3,4,5,6. I could tell you how to make a limited 'if/elseif/else' programming statement. I could answer any questions you have about that function call. What I can not tell you is how to convert a numerical output to text so a macro can say the words like 'pass' or 'fail'.
1439409545

Edited 1439409654
Silvyre said: Didz said: The surprised?|No, 1|Yes, 0.5 seems to be assigning numeric values to a given selected option. Correct. Documentation. So, can you do the reverse? Can you convert a numeric value to a text output e.g.&nbsp; 1, Perfect Success 0, Success -1, Fail -2, Botched -3, Fumbled HarbingerLeo said: What I can not tell you is how to convert a numerical output to text so a macro can say the words like 'pass' or 'fail'. Lol! I was thinking along the same lines as you can see above.
Hm... There might be a way to make a progress bar out of that. It's ugly as sin, and I have no way to clean it up. ... Maybe someone else can? Say you rolling table with one entry name '*' or that was a single colored block name 'Pips'. You could line up a series of '*' or colored blocks by using the following: /roll [[floor((d100 - @{attribute}) / -30) +3]]t[Pips] 0pips: Would be a Fumble roll. 1pip: Would be a Botched roll. 2pips: Would be a Fail roll. 3pip: Would be a Success roll. 4pips or more: Would be a Perfect Success roll. It's ugly, it's bulky, but it is a way to convert a number to a graphical representation. Hopefully someone else can find a way to clean it up. Maybe make tweek the +3 to a plus +4 so there's always something displayed and inline to whole thing so you have to mouse over it to see the full bar?
1439422257

Edited 1439422351
Silvyre said: &{template:default} {{name=Initiative Test}}{{@{selected|token_name}'s Initiative=[[ floor(?{Is Erica surprised?|No, 1|Yes, 0.5}*[[ @{selected|I}+ 1t[Probability] &{tracker} ]]) ]] }} Hi Silvyre, I've just noticed that there is an issue with the above macro, and I'm not sure if its a syntax problem or a bug with Roll20. If you look at the above screen shot you can see that when 'Yes' is chosen for 'Surprised?' &nbsp;the macro is correctly reducing the initiation by 50% and posting the result in the game journal on the right. &nbsp;But then for some reason it's posting the full value to the turn tracker, instead of the modified one. I can't think why it would post one thing to one location and something different to the other, but I've tested it several times now and it always does it. &nbsp;It's posting the affect of the probability modifier correctly to both locations. &nbsp;&nbsp;
1439429645

Edited 1439431133
Just a heads up, a lot of these cool macro features and more are posted in the community threads here:&nbsp; <a href="https://app.roll20.net/forum/permalink/2159164/" rel="nofollow">https://app.roll20.net/forum/permalink/2159164/</a> Also, about using drop-down menus for weapons, it has been talked about and is possible, along with spells and class actions and the like. ^^ I've yet to work on it, but I can attempt something along those lines soon. As for the problem, try this instead: &{template:default} {{name=Initiative Test}}{{@{selected|token_name}'s Initiative=[[ floor(?{Is Erica surprised?|No, 1|Yes, 0.5}*[[ @{selected|I}+ 1t[Probability] ]]) ]] &{tracker} }}
Didz said: I can't think why it would post one thing to one location and something different to the other, but I've tested it several times now and it always does it. &nbsp;It's posting the affect of the probability modifier correctly to both locations. &nbsp;&nbsp; Apologies; I forgot to move the location of the tracker roll option when editing the macro. Here is the fixed version: &{template:default} {{name=Initiative Test}}{{@{selected|token_name}'s Initiative=[[ floor(?{Is Erica surprised?|No, 1|Yes, 0.5}*[[ @{selected|I}+ 1t[Probability] ]]) &{tracker} ]] }}
Missed just slightly, oopes. xD Thanks Silvyre. ^^
1439458795

Edited 1439458904
Benson Y. said: Just a heads up, a lot of these cool macro features and more are posted in the community threads here:&nbsp; <a href="https://app.roll20.net/forum/permalink/2159164/" rel="nofollow">https://app.roll20.net/forum/permalink/2159164/</a> Thanks for the heads-up. However, I'm a bit confused now. &nbsp;Are you saying that there are two Roll20 forums, e.g. this one, and the community forum? I tend to just post in the forum because it's the one that comes up when I exit my game and look at the community tab. &nbsp;But the one you linked seems to have different content even though it looks identical in format. &nbsp;
Silvyre said: Didz said: I can't think why it would post one thing to one location and something different to the other, but I've tested it several times now and it always does it. &nbsp;It's posting the affect of the probability modifier correctly to both locations. &nbsp;&nbsp; Apologies; I forgot to move the location of the tracker roll option when editing the macro. Here is the fixed version: &{template:default} {{name=Initiative Test}}{{@{selected|token_name}'s Initiative=[[ floor(?{Is Erica surprised?|No, 1|Yes, 0.5}*[[ @{selected|I}+ 1t[Probability] ]]) &{tracker} ]] }} Thanks! That sorted the tracker out, the only slight problem I've noticed now is that the probability adjustment isn't being reported in the game journal. &nbsp;But it's not a big issue, as its definately being applied, it just looks like Erica's Initiative is fluctuating instead of being modified.&nbsp;
1439459589
Ziechael
Forum Champion
Sheet Author
API Scripter
There are several forums, although they are all on the 'forum' page of the community tab. Consider them sub forums if you will. Specific use like you are using is perfect for this kind of game mechanics application for Roll20 kind of thing. Then there is a forum for API scripts, character sheets, bug reports, looking for groups, the mobile app and one for general on-topic discussion (which is where Benson has linked you to). That one tends to be for things relating directly to Roll20 but that isn't really a question or issue, it is used predominantly for sharing tips, tricks and feature uses, advertising new marketplace content and other such useful information that isn't specific in nature. They are all 'community' forums though, i think replacing that word with 'general' would be more suitable.
Ziechael said: They are all 'community' forums though, i think replacing that word with 'general' would be more suitable. Cool, for a horrible minute there I thought I'd been posting these questions in the wrong place. &nbsp;I got my wrist slapped earlier for talking about suitable sound files for my game, so I'm a bit nervous about posting in the wrong place now.&nbsp;
Changing the subject slightly is there any trick or strategy for getting the brackets right in these macro's. &nbsp;I've been fiddling about with a Gossip macro to see if I can get it to work, and I find the biggest challenge is to work out when to insert brackets, what sort to use and to keep track of how many I need to close and where. &nbsp; I just don't think my brain works like that, it tends to think in images not structured pattern matching (or whatever skill it is). &nbsp;Just wondered if you guys have some clever way of keeping track. &nbsp;I tried sort of breaking everything down on to seperate lines and then compressing it when I thought I'd finished but still didn't get it right.
I'm sure I'm missing some more esoteric uses, but *In General *.... ( ) : Parenthesis segregate math.&nbsp; Math can include rolls. (5+4)*2&nbsp;&nbsp;&nbsp; means 9*2.&nbsp;&nbsp;&nbsp;&nbsp; or &nbsp; (d20 + 4)*2 { } : Curly Brackets are used for roll comparison, some specific functions with Roll Templates, and combining rolls {d20,&nbsp; d20&nbsp; }kh1&nbsp; will roll two d20s, compare them, and keep the highest. [ ] :&nbsp; Single square brackets are used to add descriptions to a roll.&nbsp; They only work with a roll, not with raw math. d20 + 5[Strength]&nbsp;&nbsp; won't change the math any, but when you hover over the result you'll see the "Strength" label next to the number [[ ]] : Double Brackets declare an in-line roll.&nbsp; the results of anything inside will output as a single numeric value [[ d20 + 2]]&nbsp; will show the result in chat as a single number.&nbsp;&nbsp; This is the alternative method of rolling to the /roll command {{&nbsp; }} : Double Curly Brackets are used for Roll Templates &{template:pf_generic} {{ character_name=@{character_name} }} {{ name=Skill Roll }} ..... etc
@Mark G: Thanks! That actually made sense. &nbsp;Sometimes the macro help text is like reading double dutch.