Marco help

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
Adurna
Cave Troll
Posts: 34
Joined: Thu Jul 07, 2016 7:45 am

Marco help

Post by Adurna »

Hi! I'd like to ask you for some help. I'm trying to setup a macro for the attack roll and critical hit roll. Now, while I understand there are lots of premade macros out there, I'd like your help so I can understand what I'm doing wrong and how to fix it.

So far I managed to get the macro to roll for attack, and if I get a 20 show the next roll to see if I can confirm my critical.
Then, if both roll 20, I get the message that the hit is, in fact, a critical hit.
However, I got a little problem.

Code: Select all

Attack Roll
[h:d20roll = d20]
[h:ConfirmCritical = d20]
[:d20roll+2]
[if(d20roll == 20): output = "Critical Threat!" ]
[if(d20roll == 20),code:
{
[ConfirmCritical]
};
{
[if(ConfirmCritical == 20): output = "Critical Hit!"]
}]
My macro says that if the ConfirmCritical roll is 20 it has to display "Critical Hit!", but if the Attack roll isn't 20 but the ConfirmCritical is 20 it tells me I landed a Critical hit, while it doesn't say "Critical Hit" when both are 20...

I tried different ways and tried to search a workaround but I can't find a way to make an if() function with multiple variables. I wanted to get something like

Code: Select all

[if(ConfirmCritical == d20roll == 20): "Critical Hit!]
but it doesn't work...

I've exhausted all the ideas I had to fix it, so now I'm gonna try and see if I can expand the macro with the damage rolls, for now.
Thank you for your time!

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Marco help

Post by wolph42 »

i think you are looking for the AND operator:

Code: Select all

[r,if(ConfirmCritical == 20 && d20roll == 20): "Critical Hit!"] 
that and you make numerous syntax mistakes like missing ", stray : etc. So check your code thoroughly and also read the 'READ THIS' in my sig.

let me elaborate a bit. Nicer would be:

Code: Select all

[r,if(d20roll == 20), CODE:{
  [h:confirmCrit = 1d20]
  [r,if(confirmCrit == 20):"Critical Hit" ; "Critical Threat"]
};{
  <!-- all the other cases -->
}] 

Adurna
Cave Troll
Posts: 34
Joined: Thu Jul 07, 2016 7:45 am

Re: Marco help

Post by Adurna »

Thank you! I can't believe I missed that!

I made some progress (don't mind the syntax, it's probably horrid again), and now I'm trying to setup an input dialog to see whether I've hit or missed. My master doesn't really use tokens with properties, so it needs to be a "manual check". I'd like the input dialog to show me the Attack Roll and then proceed with the macro if I hit yes or stop if I hit no.
I managed to create the input dialog, but I can't have it to parse the [AttackRoll]. I mean, I actually see "[AttackRoll]" in the dialog and not the rolled number. Is there any way to fix it?

thanks again. In the meantime I'll try and see if I can figure out how to tell the macro to stop or continue depending on the input.

Code: Select all

[h:d20roll=1d20]
[h:AttackRoll=d20roll+2]
[h:ConfirmCritical=d20] 

[if(d20roll != 20), code:
{ [h:input("HitCheck|Yes, No|[AttackRoll]Did I hit?| RADIO | orient=h, select=0")]}]




[h,if(d20roll == 20), code:
{
[Critical = "CritThreat!"]
[ShowCrit = ConfirmCritical]
};
{
[Critical = ""]
[ShowCrit = ""]
}]

[h,if(ConfirmCritical == 20 && d20roll == 20), code:
{
[ShowConfirm = "Critical!"]
[DamageRoll = 4d6*2]
};
{
[ShowConfirm = ""]
[DamageRoll = 4d6]
}]



You rolled [AttackRoll] [Critical] [ShowCrit] [ShowConfirm] Dealing [DamageRoll] Damage
edit: I managed the second part with the abort function, even if it's not as fancy as I'd hoped (I have to hit cancel instead of no to get it to abort), but it's working.

Now I'd really need that bit about making the [AttackRoll] show up in the input window...

edit2: nevermind, I found a way. I had to use "+AttackRoll+" to have it show properly. Not sure where that came from since I didn't find it in the tutorials, but searching on the forum worked.

This is the final result:

Code: Select all

[h:d20roll=1d20]
[h:AttackRoll=d20roll+2]
[h:ConfermaCritico=d20] <vari valori da mettere all'inizio>
[h:eval("AttackRoll")]

[if(d20roll != 20), code:
{ [h: abort(input("Hit|Si, No|"+AttackRoll+" L'ho Colpito?| CHECK | "))]}] 


[h,if(d20roll == 20), code:
{
[Critico = "Minaccia Critico!"]
[ShowCrit = ConfermaCritico]
};
{
[Critico = ""]
[ShowCrit = ""]
}]<Minaccia critico>

[h,if(ConfermaCritico == 20 && d20roll == 20), code:
{
[ShowConfirm = "Critico!"]
[DamageRoll = 4d6*2]
};
{
[ShowConfirm = ""]
[DamageRoll = 4d6]
}]<Conferma critico>

Hai tirato [AttackRoll] [Critico] [ShowCrit] [ShowConfirm] Facendo [DamageRoll] Danni
I'm basically set for what I wanted to do, I'll see if I can add an auto fail if I roll 1. And perhaps making a copy of the macro with any circumstance bonuses input.
Still, a little "bug" I have is that I changed the input window to a CHECK, but whether the check is checked or not if I hit "ok" it goes on with the macro. If you could point me in the right direction to fix it I'd appreciate it. Better yet if you could explain me how to have the window create "buttons" to push, like "yes" or "no".

User avatar
metatheurgist
Dragon
Posts: 364
Joined: Mon Oct 26, 2009 5:51 am

Re: Marco help

Post by metatheurgist »

The input function is just to accept input, so there's no options for buttons. The only ones you have are OK and Cancel.

The first string in the input field is the variable that collects the value of the input type. In your case that would be "Hit", so you'd want to check the value of Hit which should be 1 for checked and 0 for unchecked.

Btw, have you read the list of functions?

Adurna
Cave Troll
Posts: 34
Joined: Thu Jul 07, 2016 7:45 am

Re: Marco help

Post by Adurna »

I figured that, but I wanted to see if I could use something else to do it.

I did read the list of function. Not all their pages, mind you, but all those that seemed useful. Tho I can't seem to undestrand certain things just by reading them.

For example, now we've sort of convinced the master to start using properties. I'm trying to create a macro to serve more or less the same function as the one I've been working on before, since I've found a few issues with it that I don't particularly care for.
So looking for a way around I'm trying to use properties.

From what I read the get property function works with current token, but that seems to limit me quite a bit. I mean, I actually need to be the owner of the token in order to use it, right?

Isn't there a way to use it otherwise?

I was thinking of something that, in my opinion, should be relatively easy to pull off, from what I know.
A player macro that rolls the dice, compares the number with the property of the selected token (like the AC of a monster of npc), and then does things whether the number is equal or higher and others if it's lower. Which is quite easy with the if function.


But the problem is:

I'd like this to be a global or campagin macro, but from what I saw if I do this a campaign or global I need to impersonate that token, which won't do.

I'm sure there has to be a way around this. Otherwise the only way I can think of on how you guys make this work is by having the master add each macro on every token, and that seems to be an awful lot of work. Unless I colossally missed something.

I thought I might make it work using a library token macro but either I'm missing something or I was terribly wrong.

This is what I did for my test:

-I created a library token, made sure everything was right as per instructions. Visible, not owned by anyone etc.
-Created a macro for the library token with the get property function. Just a simple [r: getProperty("AC")]
-Created a global macro with the macro function to call another macro. [macro("GP@Lib:Dragon"): "AC"]

And it doesn't work. They do, however, work if I run them from the Selected token panel. But that'd mean adding the macro to each token manually and I'd rather not have the DM do that. Note that right now I'm testing this as gm and that all the macros are non player editable. So it shouldn't be a problem of trusted macro.


As always, I truly appreciate any help you can give me.

User avatar
metatheurgist
Dragon
Posts: 364
Joined: Mon Oct 26, 2009 5:51 am

Re: Marco help

Post by metatheurgist »

getProperty() and setProperty() both have an optional tokenid parameter (this is one of those things in the function documentation). The tokenid parameter can only be used in a trusted token (which is usually a lib token).

You can also switch token context by using switchToken(). This will make the rest of the macro behave as if it were called by the switched token id. switchToken() can only be used in a trusted token.

Usually people write libs with exposed functions that players can call to do things like compare ACs/HPs/etc of different tokens and either apply effects or return results.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Marco help

Post by wolph42 »

in the macro editor there are a couple of checkboxes that are quite relevant to get stuff working (or not).

in your case, you can indeed add the token id, you can also check the 'apply for selected tokens'.

Another thing is that some functions can be quite annoying for GM's if players have access, so they are GM only. These function can only be used if the checkbox 'allow players to edit macro' is turned OFF!
The latter turned on, will result in a 'you don't have permission to...' error messasge

by the way, who's Marco? :P

Post Reply

Return to “Macros”