Page 1 of 1

combine 2 macros

Posted: Wed Jun 09, 2021 9:09 am
by raazorfiend
Hey Im currently messing with some fantasy macros, I have a Enemy called Varls, and made a macro to attack players. (with help=)
Spoiler
[h:listOfSelectedTokens = getSelected()]
[h:switchToken(getSelected())]
[foreach(id, listOfSelectedTokens), code:{
<p>
[h:getName(id)]
Varl Attacking [r:token.name]
[h:damage = 3d10+44]
[attackroll = 1d20]
[h:hitMiss = if(attackroll >= 5,1,0)]
[if(hitMiss == 1), code:{
Feral varl Hit
[h:diff = max(0, damage - PD)] <!-- Passive Defence aka Armor -->
[h:HP = max(-10, HP - diff)]
[h:bar.Health = HP / MaxHP]
[r:token.name] takes [r:diff] damage.
};{
Varl Missed
}]
}]
[h: state.Dying = if(HP < 0 && HP > -10, 1, 0)]
[h: state.Dead = if(HP <= -10, 1, 0)]
[h: state.Wounded = if(HP < MaxHP/2 && !state.Dead, 1, 0)]
Now I also have one to check vs player dodge
Spoiler
[h:listOfSelectedTokens = getSelected()]
[h:switchToken(getSelected())]
[foreach(id, listOfSelectedTokens), code:{
<p>
[h:getName(id)]
Attacking [r:token.name]
[damage = 3d10+44]
[h:targetAC = getProperty("Dodge", id)]
[defroll = 1d20]
[h:hitMiss = if(defroll <= Dodge,1,0)]
[if(hitMiss == 1), code:{
Varl Hit
[h:diff = max(0, damage - PD)] <!-- Passive Defence aka Armor -->
[h:HP = max(-10, HP - diff)]
[h:bar.Health = HP / MaxHP]
[r:token.name] takes [r:diff] damage.
};{
You Dodged
}]
}]
[h: state.Dying = if(HP < 0 && HP > -10, 1, 0)]
[h: state.Dead = if(HP <= -10, 1, 0)]
[h: state.Wounded = if(HP < MaxHP/2 && !state.Dead, 1, 0)]
And I was wondering if they could be combined smartly, BUT players can only dodge once pr turn unless they pocess a talent called "dodge twise or trice" ...so how to make a macro that conts dodges(check vs a stat stat maybe?

Right now I simply run the dodge variant, so the first hit is automatic unless the player dodge, and the rest is tested vs Varl attack skill...

Re: combine 2 macros

Posted: Wed Jun 09, 2021 10:55 am
by aliasmask
I would have 3 macros, Attack, Damage and Dodge. Attack would post a link to damage target and the AC they hit. Damage would apply damage to target, no dodge. And dodge would check for dodge, check the init round and set a flag for that init to prevent multiple dodges taking in account the number of dodges based on a property. ie dodges: 1 (2 or 3). If dodge fails, then it applies damage.

Re: combine 2 macros

Posted: Thu Jun 10, 2021 2:29 am
by raazorfiend
thx Alias,

yea I reckoned there was no way to do it, but had to ask the more savvy then myself xD

Re: combine 2 macros

Posted: Thu Jun 10, 2021 3:40 am
by Full Bleed
raazorfiend wrote:
Thu Jun 10, 2021 2:29 am
yea I reckoned there was no way to do it, but had to ask the more savvy then myself xD
There is certainly a way to do it. He's just saying you shouldn't and providing a better method. ;)

Re: combine 2 macros

Posted: Thu Jun 10, 2021 4:28 am
by raazorfiend
True ;P

So another fantasy headache.
Needed funcion, a macro that counts a specific property in tokes - and sums them up.
The plan was to include it in the top of certain "prayer attack macros" where there is a modifyer based on number of "beacons"

Basically a Prayer called "smite" deals 2d8 damage + "number of Beacons nearby"
The beacons represent other clergy anointed in the Light, who therefore buffs the spell passively.

So Im trying to count all tokens beacon property (some tokens carry a relic that adds more then one beacon)
and the counter isnt working at all xD
Spoiler
[H: json = arg(0)]
[H: pcs = getPC("json")]
[H: npcs = getNPC("json")]
[H: selected = getSelected("json")]
[H, foreach(token,pc,npc), code: {
[H: switchToken(token)]
[H: Beacons = getProperty("Beacon")]
[H, if(getProperty("Beacon") =< 1), code: {
[H: json = "sum(%s)", Beacons]
[H: total = eval(strformat("sum(%s)"))]
[R: total]
};{
};{}]
Once I got the sum of all beacon properties they should be added to the damage.
For good meassure the attack macro is below
Spoiler
[h:listOfSelectedTokens = getSelected()]
[h:switchToken(getSelected())]
[h:Beaconsum=8]
[foreach(id, listOfSelectedTokens), code:{
<p>
[h:getName(id)]
Ikibard attempts to smite [r:token.name]
[h:damage = 2d8+Beaconsum]
[h:castroll = 1d20]
[h:hitMiss = if(castroll >= 7,1,0)]
[if(hitMiss == 1), code:{
Smite cast
[h:diff = max(0, damage - PD)]
[h:HP = max(-10, HP - diff)]
[h:bar.Health = HP / MaxHP]
[r:token.name] takes [r:diff] damage.
};{
Ikibards faith falls short
}]
}]
[h: state.Dying = if(HP < 0 && HP > -10, 1, 0)]
[h: state.Dead = if(HP <= -10, 1, 0)]
[h: state.Wounded = if(HP < MaxHP/2 && !state.Dead, 1, 0)]