Two questions

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
Deanethiro
Kobold
Posts: 9
Joined: Thu Feb 03, 2011 8:40 pm

Two questions

Post by Deanethiro »

First question, I just made macro that handles all my attack related stuff and for the game I'm making this framework for, there are "Finesse weapons" where if you use one your damage roll changes depending on your attack roll, if the attack roll (vrs ac or whatever) is even it uses like 1d6 and if its odd it uses 1d8, so what I'm wondering is, would there be any way to check for that in a macro? Thats my first question

The second question is, in the same macro I have it set up to deal damage to the selected token based on what you roll which works fine, but how would I go about updating the health bar on another token? What I have now is at the end of every macro there is [h:bar.Health = HP / MaxHP] which updates the health bars decently, but is there a way that would be able to update it for another token?

User avatar
Azhrei
Site Admin
Posts: 12058
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Two questions

Post by Azhrei »

Check out the wiki. You can start on the [wiki]Main Page[/wiki]. There are numerous tutorials on how to write macros, from the basics up to some pretty advanced stuff. Things like checking for even/odd are in there, as well as updating information on a different token.

(Even/odd can be done in multiple ways, but dividing by 2 and checking for a remainder is a popular technique. Updating information on another token requires either [wroll]token[/wroll] or [wfunc]switchToken[/wfunc].)

Deanethiro
Kobold
Posts: 9
Joined: Thu Feb 03, 2011 8:40 pm

Re: Two questions

Post by Deanethiro »

Ahh! Thank you! I will check this out for sure. I've been loving the wiki for the other stuff I've been doing, really the only thing I'm having trouble with is json stuff lol.

Deanethiro
Kobold
Posts: 9
Joined: Thu Feb 03, 2011 8:40 pm

Re: Two questions

Post by Deanethiro »

Wow! Yeah I just tried it, that was pretty simple! I'll be coming back for more help in the future instead of rigging things up haha.

Is there any elegant way of handling checking if a token is the current initiative? I've been messing around with getInitiativeHold() but have not been having much luck with it :|

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Two questions

Post by CoveredInFish »

Another good method for checking odd/even is using [wfunc]band[/wfunc].

I just mention this since I just recently discovered that this is possible in MT and its more straightforward to use

(and I think this never came up around here before, so i added this to the wiki)

Code: Select all

<!-- Example -->
[r: x = 1d20]
<!-- lets see if x is even or odd -->
[r, if(band(x, 1)): "is odd"; "is even"]

User avatar
patoace
Dragon
Posts: 313
Joined: Mon Sep 24, 2007 6:10 pm
Location: Rancagua - Chile

Re: Two questions

Post by patoace »

Thank you, Covered! Until now I use

Code: Select all

[r, if(x/2!=floor(x/2)): "is odd"; "is even"]


But "band" seems simpler and faster.

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Two questions

Post by CoveredInFish »

It surely is easier, but its actually not faster. I tested using my stopwatch dropin and both methods perform around the same.

Deanethiro
Kobold
Posts: 9
Joined: Thu Feb 03, 2011 8:40 pm

Re: Two questions

Post by Deanethiro »

Oh also another question, here is my block of code that I'm working on...

Code: Select all

[h,if(StandardAction == "0"),CODE:
{[h: abort(isGM())]};{[BLUH= 0]};]
[h:TARGETNAME =  getSelectedNames()]
[h: ATTACKTITLE ="Basic Aggrievement"]
[h: RANGEPRINT = WeaponHandedness+" handed"]
[h: ACTIONTYPE = "Standard"]
[h: TARGETS = 2]
[h: TARGETPRINT = TARGETNAME ]
[h: ATTACKRANGE = WeaponRange]
[h: ATTACKRANGEPRINT =""]
[h:Roll1=1d10][h: Roll2=1d10]

<table border="0"><tr bgcolor="#009900"><table width="100%"><tr><td style="padding:0px 5px;">
<span style="color:white"><b>{ATTACKTITLE}</b></font></td><td style="padding:0px 5px;" align=right>
<span style="color:white">{RANGEPRINT} –  {ACTIONTYPE}</font></td></tr>
</table></tr><tr><td><b>Target:</b><span style="color:red"><b> {TARGETPRINT}</b></span> <b>Range:</b> {ATTACKRANGE}<br>

[MACRO("[email protected]:Functions"):WeaponAttribute][h:SkillAttribute=macro.return]
[MACRO("[email protected]:Functions"):""]

[h,if(Roll1 == Roll2),CODE:
{[Brutal = "<b>: BRUTAL AFFRONT!</b>"]
[BrutalVal = "1"]};{[Brutal = ""][BrutalVal = "0"]};]


<b>Attack:[h: Attack=Roll1+Roll2+(SkillAttribute+level+WeaponPrecision)+ if(state.CombatAdvantage, +2, 0)][r:Attack]</b> vs. <b> [h: target = getSelectedNames()][r: ENEMYAC = getProperty("AC",target)] AC</b> <span style="color:red">
[h,if(Attack < ENEMYAC),CODE:
{[H: ATTACKRESULT="MISS!"]};{[H: ATTACKRESULT=TARGETNAME+" takes "]};]
<b>[r: Brutal]</b></span><br>

[h:BrutalConfirm = "Yes"]

[h,if(BrutalVal == 1),CODE:
{[H: input("BrutalConfirm | Yes , No | BRUTAL AFFRONT! DO YOU WANNA GO FOR IT!? | RADIO | orient=h value=string")]};{[BrutalVal = "No"]};]
[h,if(BrutalConfirm == "Yes"),CODE:
{[h:BrutalCheck = 1d10]};{[BrutalCheck = "0"]};]

[h,if(BrutalCheck >= 5 && FinesseKind == "FALSE"),CODE:
{[h:BrutalFinal = MaxWeaponDamage+SkillAttribute+Level]};{[BrutalFinal = 0]};]
[h,if(BrutalVal == "1" && BrutalConfirm == "Yes" && FinesseKind == "FALSE"),CODE:
{[h:Hit = BrutalFinal]};
{[h:Hit = WeaponDamage+SkillAttribute+Level]};]

[h,if(FinesseKind == "True"),CODE:
{[h:Finesse3 = "(Odd) or (Even)"]};
{[h:Finesse3 = ""][WeaponDamage1 =""][WeaponDamage2 = ""][MaxWeaponDamage1 =""][MaxWeaponDamage2 =""]};]

[h,if(BrutalCheck >= 5 && FinesseKind ==  "True"),CODE:
{[h:BrutalFinal1 = MaxWeaponDamage1+SkillAttribute+Level][h:BrutalFinal2 = MaxWeaponDamage2+SkillAttribute+Level]};{[BrutalFinal1 = 0][BrutalFinal2 = 0]};]
[h,if(BrutalVal == "1" && BrutalConfirm == "Yes" && FinesseKind == "True"),CODE:
{[h:Hit1 = BrutalFinal1][h: Hit2 = BrutalFinal2]};
{[h:Hit1 = WeaponDamage1+SkillAttribute+Level][h:Hit2 = WeaponDamage2+SkillAttribute+Level]};]


<!-- Heir Code -->
[h:Result = ""][h:Result2 =""][h:Result3 = ""]
[h,if(Class == "1" && Level >= 2 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result = "<b>Affront: </b> (Sassa)crusher -The attack deals "][Result2 = 1d10][Result3 = " extra damage and the target or one other enemy within 5 spaces of it is knocked prone."]};
{[h: BLAR = ""]};]
[h,if(Class == "1" && Level >= 2 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result = "<b>Blunder: </b> (Sassa)crusher - you or one other ally within 5 spaces is
knocked prone and "][Result2 = 1d10][Result3 = " damage is applied to yourself."]};
{[h:Bluh = ""]};]


<!-- Seer Code -->
[h,if(Class == "2" && Level >= 2 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result = "<b>Affront: </b> Stinging Snark - The attack deals "][Result2 = 1d8][Result3 = "  extra damage and the target grants combat advantage to you until the end of the encounter."]};
{[h:BLAR = ""]};]
[h,if(Class == "2" && Level >= 2  && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result = "<b>Blunder: </b>Stinging Snark - The attack deals "][Result2 = 1d8][Result3 = " damage to yourself and you grant combat advantage to the target you Blundered against until the end of the encounter. "]};
{[h:Bluh = ""]};]

<!-- Knight Code -->
[h,if(Class == "3" && Level >= 2  && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result = "<b>Affront: </b>Aggressive Demand - The attack deals "][Result2 = 1d10][Result3 = " extra damage and the target suffers a -1 penalty to attack until the end of it's next turn, and a further -1 penalty if it doesn't include you as a target. "]};
{[h:BLAR = ""]};]
[h,if(Class == "3" && Level >= 2  && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result = "<b>Blunder: </b>Aggressive Demand - The attack deals "][Result2 = 1d10][Result3 = " damage to yourself and you suffer -1 to attack until the end of your next turn, and an additional -1 penalty if you don't attack the same target you Blundered against. "]};
{[h:Bluh = ""]};]

<!-- Witch Code -->
[h,if(Class == "4" && Level >= 2  && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result = "<b>Affront: </b>'Don't Hurt My Friends!' - The target and one other enemy of your choice within
5 squares of it is weakened until the end of your next turn."][Result5 = ""][Result6 = ""]};
{[h: BLAR = ""]};]
[h,if(Class == "4" && Level >= 2  && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result = "<b>Blunder: </b>'Don't Hurt My Friends!' - you and one ally of your
choice within 5 squares are weakened."][Result5 = ""][Result6 = ""]};
{[h:Bluh = ""]};]


<!-- Theif Code -->
[h,if(Class == "5" && Level >= 2  && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result = "<b>Affront: </b>Show you my Stabs - The target takes an additional "][Result2 = 1d12+Level][Result3 = "  damage."]};
{[h: BLAR = ""]};]
[h,if(Class == "5" && Level >= 2  && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result = "<b>Blunder: </b>Show you my Stabs - You take "][Result2 = 1d12+Level][Result3 = " damage."]};
{[h:Bluh = ""]};]


<!-- Mage Code -->
[h,if(Class == "6" && Level >= 2 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result = "<b>Affront: </b>Devvastation - The attack deals "][Result2 = 1d10][Result3 = " extra damage and the target loses its next Move action."]};
{[h: BLAR = ""]};]
[h,if(Class == "6" && Level >= 2 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result = "<b>Blunder: </b>Devvastation - "][Result2 = 1d10][Result3 = " damage is applied to yourself and you lose your next Move action. "]};
{[h:Bluh = ""]};]


<!-- Page Code -->
[h,if(Class == "7" && Level >= 2  && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result = "<b>Affront: </b>uH, hIT tHEM! - The attack deals "][Result2 = 1d6][Result3 = " extra damage and an ally of your choice may make a basic attack as a free action."]};
{[h: BLAR = ""]};]
[h,if(Class == "7" && Level >= 2 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result = "<b>Blunder: </b>uH, hIT tHEM! - The attack deals "][Result2 = 1d6][Result3 = " damage to yourself and the target may make a basic attack as a free action."]};
{[h:Bluh = ""]};]

<!-- Slyph Code -->
[h,if(Class == "8" && Level >= 2 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result = "<b>Affront: </b>Razor Wind - You may charge another enemy in range as a free action. Your
movement during the charge does not provoke opportunity attacks. If there is no qualifying target in
charge range, your attack instead deals "][Result2 = 1d8][Result3 = " extra damage to the target."]};
{[h: BLAR = ""]};]
[h,if(Class == "8" && Level >= 2 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result = "<b>Blunder: </b>Razor Wind - The attack deals "][Result2 = 1d8][Result3 = " damage to yourself and the targetThe target may make a melee basic attack against you for free)."]};
{[h:Bluh = ""]};]

<!-- Blood Code -->
[h:Result4 = ""][h:Result5 =""][h:Result6 = ""]
[h,if(Aspect == "1" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>Blood Drain - The target of the attack gains "][Result5 = 10][Result6 = " ongoing damage (save ends)."]};
{[h:BLAR = ""]};]
[h,if(Aspect == "1" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>Blood Drain -  The attack deals "][Result5 = 10][Result6 = " damage to yourself and 5 more damage at the start of your following turn."]};
{[h:Bluh = ""]};]

<!-- Breath Code -->
[h,if(Aspect == "2" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>The attack deals "][Result5 = 1d10][Result6 = " and you can fly your speed as a free action.
You do not trigger Opportunity Attacks for the first square you leave during this movement."]};
{[h:BLAR = ""]};]
[h,if(Aspect == "2" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>You take "][Result5 = 1d10][Result6 = " damage and fall prone in an adjacent space of the target's choosing."]};
{[h:Bluh = ""]};]


<!-- Doom Code -->
[h,if(Aspect == "3" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>Crippling Paranoia - The attack deals "][Result5 = 1d10 ][Result6 = " additional damage and the target of the attack may not make opportunity attacks against its enemies, but is forced to take every Opportunity Attack triggered by its own allies. This effect lasts until the end of your next turn."]};
{[h:BLAR = ""]};]
[h,if(Aspect == "3" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>Crippling Paranoia - The attack deals "][Result5 = 1d10 ][Result6 = " damage to yourself and you may not make opportunity attacks, but are forced to take every Opportunity Attack triggered by your own allies. This effect lasts until the end of your next turn."]};
{[h:Bluh = ""]};]


<!-- Hope Code -->
[h,if(Aspect == "4" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>Momentum Shift - The target gains Vulnerable 5 to all attacks until the end of your next turn. "][Result5 ="" ][Result6 = ""]};
{[h:BLAR = ""]};]
[h,if(Aspect == "4" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>Momentum Shift - You gain Vulnerable 5 to all attacks until the end of your next turn."][Result5 ="" ][Result6 = ""]};
{[h:Bluh = ""]};]

<!-- Keys Code -->
[h,if(Aspect == "5" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>Chains of Woe - The attack deals "][Result5 = 1d8][Result6 = " additional damage and the target of the attack is restrained until the end of your next turn."]};
{[h:BLAR = ""]};]
[h,if(Aspect == "5" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>Chains of Woe - The attack deals "][Result5 = 1d8][Result6 = " damage to yourself and you are restrained until the end of your next turn."]};
{[h:Bluh = ""]};]


<!-- Life Code -->
[h,if(Aspect == "6" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>Vital Surge - One ally within 10 spaces of you regains hit points equal to "][Result5 = Level*2][Result6 = ""]};
{[h:BLAR = ""]};]
[h,if(Aspect == "6" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>Vital Surge - You lose hit points equal to your level, and one ally within 5 spaces gains temporary hit points equal to your level."][Result5 = Level*2][Result6 = ""]};
{[h:Bluh = ""]};]

<!-- Light Code -->
[h,if(Aspect == "7" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>Overwhelming Light - The target takes "][Result5 = 1d6][Result6 = " extra damage and is blinded until the end of its next turn."]};
{[h:BLAR = ""]};]
[h,if(Aspect == "7" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>Overwhelming Light - Every target you attack has total concealment from you until the end  of your next turn.  This penalty bypasses the normal immunities of Vision X-fold."][Result5 = ""][Result6 = ""]};
{[h:Bluh = ""]};]

<!-- Mind Code -->
[h,if(Aspect == "8" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>Confounding Strike - The target is stunned until the end of its next turn."][Result5 = ""][Result6 = ""]};
{[h:BLAR = ""]};]
[h,if(Aspect == "8" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>Confounding Strike - You are stunned until the end of your next turn."][Result5 = ""][Result6 = ""]};
{[h:Bluh = ""]};]

<!-- Space Code -->
[h,if(Aspect == "9" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>The attack deals "][Result5 = 1d10][Result6 = " extra damage, and you can teleport the target 5 spaces into an unoccupied space (you may not teleport them into a hazard or over an empty space)."]};
{[h:BLAR = ""]};]
[h,if(Aspect == "9" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>The attack deals "][Result5 = 1d10][Result6 = " damage to yourself and your target teleports you 5 spaces (you may not teleport them into a hazard or over an empty space)."]};
{[h:Bluh = ""]};]


<!-- Time Code -->
[h,if(Aspect == "10" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>Paradox Strike - The attack deals "][Result5 = 1d8][Result6 = " extra damage and you may create a Time Clone in an unoccupied space within 5 spaces of you as a free action, even if you do not have the Time Clone power."]};
{[h:BLAR = ""]};]
[h,if(Aspect == "10" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>Paradox Strike - The attack deals "][Result5 = 1d8][Result6 = " damage to yourself and are removed from play and unable to take any actions until the end of your next turn. If your space is occupied when you return, you are slid to the nearest unoccupied space of the GM's choice."]};
{[h:Bluh = ""]};]



<!-- Void Code -->
[h,if(Aspect == "11" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>Chaos Strike - The attack deals "][Result5 = 1d8+Level][Result6 = " damage to the target, and the target takes a further 1d8 + your level extra damage at the start of its next turn."]};
{[h:BLAR = ""]};]
[h,if(Aspect == "11" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>Chaos Strike - The attack deals "][Result5 = 1d8+Level][Result6 = " damage to yourself and you take a further 1d8 + your level extra damage at the start of your next turn."]};
{[h:Bluh = ""]};]

<!-- Zen Code -->
[h,if(Aspect == "12" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>Equilibrium Strike - Whenever the target deals damage to you or your allies, it deals half of that damage to itself (save ends)"][Result5 = ""][Result6 = ""]};
{[h:BLAR = ""]};]
[h,if(Aspect == "12" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>Equilibrium Strike - Whenever you deal damage, you also deal half damage to yourself, [Save Ends]"][Result5 = ""][Result6 = ""]};
{[h:Bluh = ""]};]

<!-- Rage Code -->
[h,if(Aspect == "13" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>Subjugglation - The attack deals an additional "][Result5 = 1d12][Result6 = " damage and you add 1d12 + your level damage to the next successful attack that you make before the end of your next turn"]};
{[h:BLAR = ""]};]
[h,if(Aspect == "13" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>Subjugglation - The attack deals "][Result5 = 1d12][Result6 = " damage to yourself, and take your level additional damage on the next successful attack against you"]};
{[h:Bluh = ""]};]

<!-- Heart Code -->
[h,if(Aspect == "14" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck >= 5),CODE:
{[h:Result4 = "<b> -AND- Affront: </b>By Our Powers Combined - You and an ally within 5 spaces of you gain temporary HP equal to "][Result5 = Level][Result6 = ""]};
{[h:BLAR = ""]};]
[h,if(Aspect == "14" && Level >= 6 && BrutalVal == "1" && BrutalConfirm == "Yes" && BrutalCheck < 5),CODE:
{[h:Result4 = "<b> -AND- Blunder: </b>By Our Powers Combined - You take -2 to all defenses until the end of your next turn"][Result5 = ""][Result6 = ""]};
{[h:Bluh = ""]};]

<b>Hit:
[h,if(Hit1 == 0),CODE:
{[h:Blunder = "GRAVE BLUNDER!"]};{[Blunder = ""]};]
[h,if(BrutalFinal1 >= 1 && BrutalVal == 1 ),CODE:
{[h:Affront = "SUCESSFUL AFFRONT!"]};{[Affront = ""]};]

[h,if(Hit == 0),CODE:
{[h:Blunder = "GRAVE BLUNDER!"]};{[Blunder4 = ""]};]
[h,if(BrutalFinal >= 1 && BrutalVal == 1 ),CODE:
{[h:Affront = "SUCESSFUL AFFRONT!"]};{[Affront4 = ""]};]



[h,if(ATTACK >= ENEMYAC ),CODE:
{[HpChange= Hit]};{[HpChange= 0]};]
[h,if(BrutalVal == "1" && BrutalFinal >= 1 ),CODE:
{[HpChange= Hit][ATTACKRESULT = TARGETNAME+" takes "]};{[BLUH= 0]};]


<span style="color:red">[r: Affront][r: Blunder]</span>
[h,if(FinesseKind == "FALSE" ),CODE:
{[h:Hit1=""][r: Hit2=""]};{[Bluh=""]};]
[h,if(FinesseKind == "True" ),CODE:
{[h:Hit=""]};{[Bluh=""]};]
[r:ATTACKRESULT] {HpChange}[h:Hit1][h:Finesse3][h: Hit2][h: Hit]
</b> damage<br>
[r: Result]<b>[r: Result2]</b>[r: Result3][r: Result4]<b>[r: Result5]</b>[r: Result6]
[h,if(BrutalVal == "1"  && BrutalConfirm == "Yes"),CODE:
{[h:BrutalShow="<b>Brutal Affront Confirmation Roll: </b>"+ BrutalCheck]};{[BrutalShow=""]};] [r:BrutalShow]</td>
  </tr>
</table>

[h: ENEMYHP = getProperty("HP",target)]
[setProperty("HP", ENEMYHP-HpChange, target)]</td></td>
[h:bar.Health = HP / MaxHP]
[switchToken(target)]
[h:bar.Health = HP / MaxHP]
[MACRO("Character [email protected]:Functions"):""]



I know its kind of a mess and all, I'm working on cleaning it up and what not, but the important part is the area that asks the user if they want to go through with the brutal affront, I need to be able to display the attack roll so the player has a bit of perspective before they decide if they're going to do the brutal affront, anyone have any idea how to do that?

I also want to move the brutal affront codes out of the macros and have them be retrieved from the token libraries, any guidance on that as well?

And thanks again for the help earlier!

User avatar
aliasmask
Deity
Posts: 8653
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Two questions

Post by aliasmask »

CoveredInFish wrote:Another good method for checking odd/even is using [wfunc]band[/wfunc].

I just mention this since I just recently discovered that this is possible in MT and its more straightforward to use

(and I think this never came up around here before, so i added this to the wiki)

Code: Select all

<!-- Example -->
[r: x = 1d20]
<!-- lets see if x is even or odd -->
[r, if(band(x, 1)): "is odd"; "is even"]

Thanks for the tip. I'll start using this from now on.

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Two questions

Post by CoveredInFish »

Whoooow ... wall of code.

I think for user dialogs the [wfunc]input[/wfunc] function should suffice. Building it dynamically you should go for using [wfunc]strformat[/wfunc]. Using these two functions you can build pretty complex user dialogues. If you wanna go further and run into limits you can read my html forms tutorial.

You already seem to use [wroll]macro[/wroll] to call other macros. You could do this with the "brutal code" as well. You can make use of the special variables macro.args to get data into the other macro and macro.return to retrieve data from there. You might be better off with user defined functions: [url]defineFunction[/url]

Two tips that came to my mind glancing at your code:

Instead of using {stuff} to display results of calculations you should use [r: stuff].

You dont have to use a [wroll]code[/wroll] block if you just have one statement.

Code: Select all

<!-- so instead of -->
[
h,if(ATTACK >= ENEMYAC ),CODE:
{[
HpChange= Hit]};{[HpChange= 0]};]

<!--
 you can write -->
[
h,if(ATTACK >= ENEMYAC ): HpChange= Hit; HpChange= 0]

<!--
 or in this specific case -->
[
h: HpChange = if(ATTACK>=ENEMYAC, Hit, 0)]
<!--
 but note the differences between if()-function and [if:] roll option!!! -->
<!--
 eg using the if() function both branches get executed, so best to use only with literals -->
 

User avatar
aliasmask
Deity
Posts: 8653
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Two questions

Post by aliasmask »

Deanethiro wrote:I know its kind of a mess and all, I'm working on cleaning it up and what not, but the important part is the area that asks the user if they want to go through with the brutal affront, I need to be able to display the attack roll so the player has a bit of perspective before they decide if they're going to do the brutal affront, anyone have any idea how to do that?

I also want to move the brutal affront codes out of the macros and have them be retrieved from the token libraries, any guidance on that as well?

And thanks again for the help earlier!

Code: Select all

<!-- Change this -->
[r:Attack]
<!-- to this -->
[r: Attack + " Roll("+(Roll1+Roll2)+")"]
<!-- or better yet -->
[r: strformat("%{Attack} Roll($s)",Roll1+Roll2)]

As for putting the macro on a lib token, just do it. Create a macro, copy the code there and call the macro from your token or the campaign window with another "macro" call. Just make sure the macro is not editable by the player (checkbox) and to apply the calling macro to selected token (checkbox).

Deanethiro
Kobold
Posts: 9
Joined: Thu Feb 03, 2011 8:40 pm

Re: Two questions

Post by Deanethiro »

Wow thanks so much guys! :DD I'll get to doing that and let you know how it goes! And yeah this code was majorly thrown together just to get something semi functional with the intent of chipping away at it and making it presentable later... :oops: There is a ridiculous amount of redundancy as covered and alias pointed out lol.

I just changed the code a little bit and it was a dumb mistake that was keeping the input thing from working right. BLUH! one misplaced quote!

User avatar
aliasmask
Deity
Posts: 8653
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Two questions

Post by aliasmask »

Deanethiro wrote:Wow thanks so much guys! :DD I'll get to doing that and let you know how it goes! And yeah this code was majorly thrown together just to get something semi functional with the intent of chipping away at it and making it presentable later... :oops: There is a ridiculous amount of redundancy as covered and alias pointed out lol.

I just changed the code a little bit and it was a dumb mistake that was keeping the input thing from working right. BLUH! one misplaced quote!

As far as "wall of code" goes, I've seen worse. Don't be afraid to use line-breaks and indentation :) After all, spaces don't matter when compiling the code and it's easier to read. And CiF had a good point about redundancy, but it's not the end of the world doing that way.

I recommend using notepad++ (in my sig) and the addons I have linked from there to make coding a bit more friendly.

Deanethiro
Kobold
Posts: 9
Joined: Thu Feb 03, 2011 8:40 pm

Re: Two questions

Post by Deanethiro »

Yea I know Notepad++! I used to use it in my programming classes back in highschool! Handy little thing. Yea I've mostly been flying blind, I only found out about the wiki like a couple days ago and the forums are a great help!

All I really need to do is set up multi-targeting capabilities and I'm actually just about done with this macro!

Post Reply

Return to “Macros”