Step by step simple universal macros - Forum Pros needed

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
User avatar
Doc_Waldo
Giant
Posts: 108
Joined: Wed Sep 08, 2010 11:41 pm
Location: Boise, ID

Step by step simple universal macros - Forum Pros needed

Post by Doc_Waldo »

I wanted to create a post where I and others who are not real experienced and are learning macro's could post help for simple macro examples. The Wiki is fine, but sometimes there are special cases, and something that would take me 3 hours trying to figure out, can be produced by the "Pros" (which there are many in this forum) is a few minutes. I would hope to just put a keyword on a separate line and then followed by what is wanted.

Many of us play with people who use different frameworks, but would love to create our own attack macro's, but don't want to deal with making the DM change the properties. So yes, some of the macro's could be created more efficiently other ways I am sure, but if we can get some help that keeps the macro's really self contained it would be wonderful. Here is my first one.

--REQUEST: Critical Attack and Damage--
I want to create a macro that will produce text that says "CRITICAL", when a 20 is rolled and then the critical damage is rolled. Something that is a little different in this one also is that it is for Twin Strike, 2 separate attacks, but rolled at the same time. Here is what I as variables. (Keep in mind that I am writing this how I think of it, via something like excel, hopefully someone can convert to the proper format)

Code: Select all

[h:AttackRoll1=1d20]
[h:AttackRoll2=1d20]
[h:AttackBonus=12]
[h:DamageBonus=12]
[h:MHWDamage=1d12]
[h:OHWDamage=1d20]
[h:HQDamage=1d6]
[h:MHWCritical=2d6]
[h:OHWCritical=1d10]
[h:CritialHit1=IF(AttackRoll1=20, 1, 0)]
[h:CriticalHit2=IF(AttackRoll2=20, 1, 0)]
[h:MHWCriticalDamage=IF(CriticalHit1=1,MHWCritical+MAX(MHWDamage)-MHWDamage,0)]
[h:OHWCriticalDamage=IF(CriticalHit2=1,OHWCritical+MAX(OHWDamage)-OHWDamage,0)]
[h:MHWTotalDamage=MHWDamage+DamageBonus+HQDamage+MHWCriticalDamage]
[h:OHWTotalDamage=OHWDamage+DamageBonus+HQDamage+OHWCriticalDamage]
[h:TotalDamage=MHWTotalDamage+OHWTotalDamage-HQDamage]
[h:Attack1Total=AttackRoll1+AttackBonus]
[h:Attack2Total=AttackRoll2+AttackBonus]
[h:CriticalHitText=IF(OR(CriticalHit1=1,CriticalHit2=1), "**CRITICAL HIT**", "")]
[h:CriticalDamageText1=(IF(CriticalHit1=1,"Critical damage of [r:MHWCritical] included.","")]
[h:CriticalDamageText2=(IF(CriticalHit2=1,"Critical damage of [r:OHWCritical] included.","")]
[h:PowerName="Twin Strike"]
[h:MHW="Blood Fury War Axe"]
[h:OHW="Dwarven War Axe"]
[h:HQ="Hunters Quarry"]
[h:AttackVerseText="(Strength vs AC)"]
Chat Display Code:

Code: Select all

Ugarth slashes at his enemies with his [r:PowerName] and rolls:
[r:MHW]: [r:AttackTotal1] [r:VerseText] [r:CriticalHitText]
[r:OHW]: [r:AttackTotal2] [r:VerseText] [r:CriticalHitText]
Damage breakdown for [r:PowerName], including [r:HQ]:
[r:MHW]: [r:DamageTotal1] [r:DamageText] [r:CriticalHitText1]
[r:OHW]: [r:DamageTotal2] [r:DamageText] [r:CriticalHitText2]
Both Hit: [r.TotalDamage] [r:DamageText]

Code: Select all

Chat Display as seen (hopefully)
Ugarth slashes at his enemies with his Twin Strike and rolls:
Bloody Fury War Axe: 22 (Strength vs AC)
Dwarven War Axe: 32 (Strength vs AC) **CRITICAL HIT**
Damage breakdown for Twin Strike, including Hunters Quarry:
Bloody Fury War Axe: 20 damage
Dwarven War Axe: 35 damage, including CRITICAL damage of 10
Both Hit: 50 damage
Please don't worry about whether the numbers are adding up, etc. I can get that (the both hit of 50 is different then just adding the two attacks together because you only get one hunters quarry, in this case, it would have been 5 (20+35-5=50)), again don't worry about the numbers of if I used slightly different "filler" text. Hopefully the concept comes across pretty clear at what I am going at.

I am sure this is not rocket science, but I would like to utilize the format above because I can easily just edit each power with variables above. I also can then use html with the variables inside, so I don't have to go into the html once I get everything looking pretty.

Thanks for you help and any suggestions. I have several others, but I will post each one separate.
Last edited by Doc_Waldo on Fri Nov 19, 2010 5:36 pm, edited 2 times in total.
--DOC

User avatar
Doc_Waldo
Giant
Posts: 108
Joined: Wed Sep 08, 2010 11:41 pm
Location: Boise, ID

Re: Step by step simple universal macros - Help from the pro

Post by Doc_Waldo »

REQUEST: Simple Input Box

Variables:

Code: Select all

[h:AttackRoll=1d20]
[h:aWeaponEnhancement=Enter_Weapon_Enhancement_Bonus_for_Attack]
[h:aFeatBonus=Enter_Attack_Bonus_for_Feat]
[h:TotalAttackRoll=AttackRoll+aWeaponEnhancement+aFeatBonus]
[h:DamageRoll=1d10]
[h:dWeaponEnhancement=Enter_Weapon_Enhancement_Bonus_for_Damage]
[h:dFeatBonus=Enter_Damage_Bonus_for_Feat]
[h:TotalDamage=DamageRoll+dWeaponEnhancement+dFeatBonus]
To Chat:

Code: Select all

Ugarth rolls an attack of [r:TotalAttackRoll] and hopefully hits!
If he does, Ugarth does [r:TotalDamage] of damage.
Hope:
Instead of have the separate dialog boxes come on each attack, I am hoping to have one input box come up where I can put everything in at one time, with nice descriptions next the fields. Also, I would like to have one checkbox for say "combat advantage" (see one example, should get me going enough that I can create several if I need to, but for this purpose, I just what to see one, i.e. combat advantage.

Also, as a separate step, so it doesn't muddy the water of the first request, I would also like to see how or if it is possible to have it so when you enter the numbers the first time, each subsequent attack or use of the macro the same numbers pop up, the fields have "memories" of the last entry. Again, if I could see this in a separate step I would greatly appreciate it.

Again thanks.
Last edited by Doc_Waldo on Fri Nov 19, 2010 5:22 pm, edited 1 time in total.
--DOC

User avatar
Doc_Waldo
Giant
Posts: 108
Joined: Wed Sep 08, 2010 11:41 pm
Location: Boise, ID

Re: Step by step simple universal macros - Help from the pro

Post by Doc_Waldo »

REQUEST: Simple targeting of enemies.

Variables for Basic Attack:

Code: Select all

[h:AttackRoll=1d20]
[h:AttackBonus=10]
[Total Attack=AttackRoll+AttackBonus]
[h:DamageRoll=1d10]
[h:DamageBonus=10]
[Total Damage=DamageRoll+DamageBonus]
Want:
To be able to use the macro above, with a target function, so the macro becomes "smart" and I can have text for "hits" and "misses". In my simple mind, it is just an "IF" statement after selecting the target, but I am at a lose of how to do this one example. Also, make the assumption the DM will let me have "trusted" macros, although when helping create this macro, maybe some detail of what is involved. I can use the word "trusted" macros, and I know that in targeting you need to have "trusted" macros, but I don't know why, nor how.

Want Summary:
1- Select target
2- Be able to then attack text to hit's and misses
3- Be able to use the creatures/targets name and/or token image in the chat display.
4- As much as possible, have it self contained in the "basic attack" macro, meaning not calling to another macro outside of itself.
5- Keep the option to not select the target and run the macro as normal, with damage being rolled.

OPTION: **Option and separate example** of having to select two targets, for example the rangers Twin Strike. I am sure it is more difficult because it can target one or two targets, no idea how this would be done, and if way more complex, then I will just stick with one targeting for now. Again, if we can pull this one out and be another/additional example.

Thanks.
Last edited by Doc_Waldo on Fri Nov 19, 2010 5:21 pm, edited 1 time in total.
--DOC

User avatar
Doc_Waldo
Giant
Posts: 108
Joined: Wed Sep 08, 2010 11:41 pm
Location: Boise, ID

Re: Step by step simple universal macros - Help from the pro

Post by Doc_Waldo »

NOTE: Tool Tip in Chat

I know that I am not being consistent with the use of "h:" and/or "r:". One reason is laziness, and the other is that I will be utilizing "<SPAN TITLE> and a tool tip for each one that goes down created from html, but very simple, and place in variable, see below:

Code: Select all

Damage Breakdown:
+13  : Weapon damage
+5    : Strength bonus
+2    : Feat bonus
+2    : Weapon enhancement
I have this just be a display when you move over the total damage(s). If there is a better way to do this, please let me know. Right now I use something like this:

Code: Select all

[h:MHWDamage=13]
[h:TextLine1="Weapon Damage"]
[h:StrengthBonus=5]
[h:TextLine2="Strength Bonus"]
My tooltip code is then:

Code: Select all

<HTML>
Damage Breakdown:<BR>
+%{MHWDamage}  : %{TextLine1}<BR>
+%{StrengthBonus}  : %{TextLine2}
</HTML>
Any suggestions or a better way to do this, again simple please (meaning it may take more code, but it's easy to understand), is greatly appreciated.
Last edited by Doc_Waldo on Fri Nov 19, 2010 5:20 pm, edited 1 time in total.
--DOC

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: Step by step simple universal macros - Help from the pro

Post by Rumble »

Let me make one suggestion first - it is helpful to surround your macro code with the

Code: Select all

 tag, so that it sets it off from the rest of the text and makes it easier to read. 

On the topic of the thread - are you looking for assistance in any particular area? Streamlining? Efficiency? Neat tricks? And are all three of these supposed to be one macro in the end, or separate things?

User avatar
Doc_Waldo
Giant
Posts: 108
Joined: Wed Sep 08, 2010 11:41 pm
Location: Boise, ID

Re: Step by step simple universal macros - Help from the pro

Post by Doc_Waldo »

Let me make one suggestion first - it is helpful to surround your macro code with the

Code: Select all

 tag, so that it sets it off from the rest of the text and makes it easier to read.
[/quote]
Thank you for the suggestion, much nicer.
[quote]On the topic of the thread - are you looking for assistance in any particular area? Streamlining? Efficiency? Neat tricks? 
[/quote]
Learning and utilization in one of the campaigns I am in currently.  He has a good framework that allows for us to create our own macros.  There always seems to be little exceptions here and there, such as with the rangers twin strike that I would like to create and tweak my own; furthermore, I can jazzy up my macros the way I want with different text, etc.  I like to customize, and many times for no particular reason except to learn and get something just like I want it.  With this little project, I figure I have access to brilliant people and if I take it small steps at a time I figure things out pretty fast, especially with examples from others. 
[quote]And are all three of these supposed to be one macro in the end, or separate things?[/quote]
Yes eventually yes I would combine them, but instead of throwing all the code into one big macro and then I can't focus on one piece at a time...yes I know from a programming perspective it's crazy and completely inefficient; however, there is a method to my madness.  Eventually by taking these small steps, each almost independent pieces I can see how they work, and they look commonality among them--and also if there is no way to join them at my level.  That is just as important to me, I figure out that I need to wait a little bit before I tackle that next piece.

Hope that helps.  Thanks.
--DOC

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: Step by step simple universal macros - Forum Pros needed

Post by Rumble »

No problem - here's a layout for the first one. I stuck with your variables (as best I could) but I used some tricks I tend to favor (especially for damage calculations and crit calculations). It's lengthy, and I use strformat() in several places, so don't hesitate to ask questions.
Spoiler

Code: Select all

<!--Set all the variables-->
[h:AttackRoll1=1d20]
[h:AttackRoll2=1d20]
[h:AttackBonus1=12]
[h:AttackBonus2=10]
[h:DamageBonus1=12]
[h:DamageBonus2=10]
[h:MHWDamage="1d12"] <!--note that these dice values are strings - that's important for critical value calculation-->
[h:OHWDamage="1d20"]
[h:HQDamage="1d6"]
[h:MHWCritical="2d6"]
[h:OHWCritical="1d10"]
[h:Crit1 = 0]
[h:Crit2 = 0]
[h:Automiss1 = 0]
[h:Automiss2 = 0]
[h:MHW = "Bloody Fury War Axe"]
[h:OHW = "Dwarven War Axe"]
[h:AttackAndDefense = "Strength vs. AC"]

<!--Make the attack rolls-->
[h:AttackTotal1 = AttackRoll1+AttackBonus1]
[h:AttackTotal2 = AttackRoll2+AttackBonus2]

<!--Determine if they crit, or auto-miss. Note that this does not really establish a critical hit, since in DD4E a crit has to roll a 20 AND be higher than the target defense value, but this is close enough-->
[h,if(AttackRoll1 == 20): crit1 = 1]
[h,if(AttackRoll2 == 20): crit2 = 1]
[h,if(AttackRoll1 == 1): Automiss1 = 1]
[h,if(AttackRoll2 == 1): Automiss2 = 1]


<!--here is just putting some text into variables for displaying if there is a crit-->
[h,if(crit1): critLine1 = "***CRITICAL HIT***"; critLine1 = ""]
[h,if(crit2): critLine2 = "***CRITICAL HIT***"; critLine2 = ""]

<!--Handle each attack separately. First, make sure we didn't automiss-->
[h,if(!Automiss1),CODE:
{
  <!--This line replaces the "d" in the main hand damage die with an asterisk, and then evaluates that as if it were macro code, which multiplies the dice size by the number of dice, and gives us the maximized value. Weapon dice codes MUST be strings for this to work right.-->
  [h:MHWCritValue = eval(replace(MHWDamage, "d", "*"))]

  <!--Build a complete "formula" of the damage. strformat() is a godsend here-->
  [h:DamageFormula = strformat("%{MHWDamage}+%{DamageBonus1}")]
  [h:CritFormula = strformat("%{MHWCritValue}+%{DamageBonus1}+%{MHWCritical}")]

  <!--if attack 1 crits, evaluate the CritFormula. Otherwise, evaluate the DamageFormula-->
  [if(crit1): finalDamage1 = eval(CritFormula); finalDamage1 = eval(DamageFormula)]

  <!--Create strings to display the outcome of the attack-->
  [attack1OutputLine = strformat("%{MHW}: %{AttackTotal1} (%{AttackAndDefense}) %{critLine1}<br>")]
  [damage1OutputLine = strformat("%{MHW}: %{finalDamage1}<br>")]
};
{
  [critLine1 = "***Automatic Miss***"] <!--just reusing critline because why not? we missed, so it is not being used otherwise-->
  [attack1OutputLine = strformat("%{MHW}: %{AttackTotal1} (%{AttackAndDefense}) %{critLine1}<br>")]
  [damage1OutputLine = ""]
}]

<!--Same process for this attack, but with the offhand weapon-->
[h,if(!Automiss2),CODE:
{
[h:OHWCritValue = eval(replace(OHWDamage, "d", "*"))]
  [h:DamageFormula = strformat("%{OHWDamage}+%{DamageBonus2}")]
  [h:CritFormula = strformat("%{OHWCritValue}+%{DamageBonus2}+%{OHWCritical}")]
  [if(crit2): finalDamage2 = eval(CritFormula); finalDamage2 = eval(DamageFormula)]
 
  [attack2OutputLine = strformat("%{OHW}: %{AttackTotal2} (%{AttackAndDefense}) %{critLine2}<br>")]
  [damage2OutputLine = strformat("%{OHW}: %{finalDamage2}")]
};
{
  [critLine2 = "***Automatic Miss***"]
  [attack2OutputLine = strformat("%{OHW}: %{AttackTotal2} (%{AttackAndDefense}) %{critLine2}<br>")]
  [damage2OutputLine = ""]
}]

<!--Hunters Quarry. If at least one attack did not auto-miss, then roll the HQ value and make a string to display it-->
[h,if(!Automiss1 || !Automiss2),CODE:
{
  [hqCrit = eval(replace(HQDamage, "d", "*"))]
  [hqDmgActual = eval(HQDamage)] <!--since HQdamage is a string, we need to eval() it to get a number-->
  [hqDamageOutput = strformat("Hunter's Quarry Damage: %{HQDamage} (%{hqCrit} if Critical Hit)")]
}]

<!--Now we output all the data that we generated above-->
<b><i>Ugarth slashes at his enemies with his Twin Strike and rolls:</i></b><br>
[r:attack1OutputLine]
[r:attack2OutputLine]
<b>Damage Breakdown for Twin Strike, including Hunters Quarry</b><br>
[r:damage1OutputLine]
[r:damage2OutputLine]<br>
[r:hqDamageOutput]
I really like the use of strformat() to build output text. It might be overkill in some places, but it's very handy to get formatting right and how you like it. The basic idea is that strformat() inserts variable values into strings, where you tell it to - so for instance, where I say:

Code: Select all

  [hqCrit = eval(replace(HQDamage, "d", "*"))]
  [hqDmgActual = eval(HQDamage)] <!--since HQdamage is a string, we need to eval() it to get a number-->
  [hqDamageOutput = strformat("Hunter's Quarry Damage: %{HQDamage} (%{hqCrit} if Critical Hit)")]
that last line is saying "wherever you see %{HQDamage} or %{hqCrit}, replace that with the actual value of the variable named" - so the value of HQDamage is inserted where I say %{HQDamage}, and so on.

Post Reply

Return to “Macros”